alistair23-linux/drivers/pci
Alex Williamson 61cf16d8bd PCI: Add pci_try_reset_function(), pci_try_reset_slot(), pci_try_reset_bus()
When doing a function/slot/bus reset PCI grabs the device_lock for each
device to block things like suspend and driver probes, but call paths exist
where this lock may already be held.  This creates an opportunity for
deadlock.  For instance, vfio allows userspace to issue resets so long as
it owns the device(s).  If a driver unbind .remove callback races with
userspace issuing a reset, we have a deadlock as userspace gets stuck
waiting on device_lock while another thread has device_lock and waits for
.remove to complete.  To resolve this, we can make a version of the reset
interfaces which use trylock.  With this, we can safely attempt a reset and
return error to userspace if there is contention.

[bhelgaas: the deadlock happens when A (userspace) has a file descriptor for
the device, and B waits in this path:

  driver_detach
    device_lock                     # take device_lock
    __device_release_driver
      pci_device_remove             # pci_bus_type.remove
        vfio_pci_remove             # pci_driver .remove
          vfio_del_group_dev
            wait_event(vfio.release_q, !vfio_dev_present)   # wait (holding device_lock)

Now B is stuck until A gives up the file descriptor.  If A tries to acquire
device_lock for any reason, we deadlock because A is waiting for B to release
the lock, and B is waiting for A to release the file descriptor.]

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2014-01-14 16:34:44 -07:00
..
host Merge branch 'pci/host-mvebu' into next 2014-01-07 17:34:14 -07:00
hotplug Merge branch 'pci/dead-code' into next 2014-01-13 16:47:08 -07:00
pcie Merge branch 'pci/dead-code' into next 2014-01-13 16:47:08 -07:00
access.c PCI: Remove unused pci_vpd_truncate() 2014-01-13 11:14:43 -07:00
ats.c PCI: Removed unused parts of Page Request Interface support 2014-01-10 14:00:47 -07:00
bus.c Merge branch 'pci/resource' into next 2014-01-10 14:23:15 -07:00
host-bridge.c PCI: Convert pcibios_resource_to_bus() to take a pci_bus, not a pci_dev 2013-12-21 10:06:10 -07:00
hotplug-pci.c
htirq.c
ioapic.c PCI: Convert ioapic to be builtin only, not modular 2014-01-03 14:31:38 -07:00
iov.c PCI: Clear NumVFs when disabling SR-IOV in sriov_init() 2013-11-22 14:53:27 -07:00
irq.c PCI: Fix whitespace, capitalization, and spelling errors 2013-11-14 11:28:18 -07:00
Kconfig PCI: Convert ioapic to be builtin only, not modular 2014-01-03 14:31:38 -07:00
Makefile PCI: Add Virtual Channel to save/restore support 2013-12-17 17:39:08 -07:00
msi.c Merge branch 'pci/msi' into next 2014-01-07 17:34:39 -07:00
of.c
pci-acpi.c PCI: Use dev_is_pci() to identify PCI devices 2013-12-09 16:42:53 -07:00
pci-driver.c PCI: Disable Bus Master only on kexec reboot 2013-12-07 14:20:28 -07:00
pci-label.c PCI: Reorder so actual code comes before stubs 2014-01-13 17:01:11 -07:00
pci-stub.c PCI: Fix whitespace, capitalization, and spelling errors 2013-11-14 11:28:18 -07:00
pci-sysfs.c PCI: Fix whitespace, capitalization, and spelling errors 2013-11-14 11:28:18 -07:00
pci.c PCI: Add pci_try_reset_function(), pci_try_reset_slot(), pci_try_reset_bus() 2014-01-14 16:34:44 -07:00
pci.h PCI: Make local functions static 2014-01-13 11:57:29 -07:00
probe.c Merge branch 'pci/dead-code' into next 2014-01-13 16:47:08 -07:00
proc.c PCI: Fix whitespace, capitalization, and spelling errors 2013-11-14 11:28:18 -07:00
quirks.c PCI: Convert pcibios_resource_to_bus() to take a pci_bus, not a pci_dev 2013-12-21 10:06:10 -07:00
remove.c PCI: Remove from bus_list and release resources in pci_release_dev() 2013-12-18 13:53:40 -07:00
rom.c PCI: Convert pcibios_resource_to_bus() to take a pci_bus, not a pci_dev 2013-12-21 10:06:10 -07:00
search.c PCI: Fix whitespace, capitalization, and spelling errors 2013-11-14 11:28:18 -07:00
setup-bus.c Merge branch 'pci/resource' into next 2014-01-10 14:23:15 -07:00
setup-irq.c
setup-res.c PCI: Convert pcibios_resource_to_bus() to take a pci_bus, not a pci_dev 2013-12-21 10:06:10 -07:00
slot.c PCI: Remove unused pci_renumber_slot() 2014-01-13 11:14:44 -07:00
syscall.c PCI: Fix whitespace, capitalization, and spelling errors 2013-11-14 11:28:18 -07:00
vc.c PCI: Rename PCI_VC_PORT_REG1/2 to PCI_VC_PORT_CAP1/2 2013-12-17 17:49:39 -07:00
vpd.c
xen-pcifront.c