]> git.baikalelectronics.ru Git - kernel.git/commit
PCI/P2PDMA: Avoid pci_get_slot(), which may sleep
authorLogan Gunthorpe <logang@deltatee.com>
Thu, 10 Jun 2021 16:06:09 +0000 (10:06 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 10 Jun 2021 23:01:55 +0000 (18:01 -0500)
commit34b9190160a75746edfa19e8013f70bba8f2ffa4
treeabb619a1489102d96b3a4222e0f73b7205818821
parentfaba2a7166eca08559e4f8e6af50293d20ebf28a
PCI/P2PDMA: Avoid pci_get_slot(), which may sleep

In order to use upstream_bridge_distance_warn() from a dma_map function, it
must not sleep. However, pci_get_slot() takes the pci_bus_sem so it might
sleep.

In order to avoid this, try to get the host bridge's device from the first
element in the device list. It should be impossible for the host bridge's
device to go away while references are held on child devices, so the first
element should not be able to change and, thus, this should be safe.

Introduce a static function called pci_host_bridge_dev() to obtain the host
bridge's root device.

Link: https://lore.kernel.org/r/20210610160609.28447-7-logang@deltatee.com
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/p2pdma.c