]> asedeno.scripts.mit.edu Git - linux.git/commit
PCI: Detach driver before procfs & sysfs teardown on device remove
authorAlex Williamson <alex.williamson@redhat.com>
Wed, 11 Oct 2017 21:35:56 +0000 (15:35 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 25 Oct 2017 13:47:10 +0000 (08:47 -0500)
commit16b6c8bb687cc3bec914de09061fcb8411951fda
treedab98fb9152382a882f634dce90afde894b6657f
parentf2ddaf8dfd4a5071ad09074d2f95ab85d35c8a1e
PCI: Detach driver before procfs & sysfs teardown on device remove

When removing a device, for example a VF being removed due to SR-IOV
teardown, a "soft" hot-unplug via 'echo 1 > remove' in sysfs, or an actual
hot-unplug, we first remove the procfs and sysfs attributes for the device
before attempting to release the device from any driver bound to it.
Unbinding the driver from the device can take time.  The device might need
to write out data or it might be actively in use.  If it's in use by
userspace through a vfio driver, the unbind might block until the user
releases the device.  This leads to a potentially non-trivial amount of
time where the device exists, but we've torn down the interfaces that
userspace uses to examine devices, for instance lspci might generate this
sort of error:

  pcilib: Cannot open /sys/bus/pci/devices/0000:01:0a.3/config
  lspci: Unable to read the standard configuration space header of device 0000:01:0a.3

We don't seem to have any dependence on this teardown ordering in the
kernel, so let's unbind the driver first, which is also more symmetric with
the instantiation of the device in pci_bus_add_device().

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/remove.c