PCI: Don't allow unbinding host controllers that aren't prepared
authorBrian Norris <briannorris@chromium.org>
Thu, 20 Apr 2017 20:36:25 +0000 (15:36 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 28 Apr 2017 15:38:00 +0000 (10:38 -0500)
commita5f40e8098fe6d983fdb3beb7b50a8067c136141
treea98617d22761b5b620ac2af829e15f9afe6d00ea
parentef1b5dad5a386885998d11eb45ca7fd183079965
PCI: Don't allow unbinding host controllers that aren't prepared

Many PCI host controller drivers aren't prepared to have their devices
unbound from them forcefully (e.g., through /sys/.../<driver>/unbind), as
they don't provide any driver .remove callback, where they'd detach the
root bus, release resources, etc. Keeping the driver built in (i.e., not a
loadable module) is not enough; and providing no .remove callback just
means we don't do any teardown.

To rule out the possibility of unbinding a device via sysfs, we need to set
the ".suppress_bind_attrs" field.

I found the suspect drivers via the following search:

  git grep -l platform_driver $(git grep -L -e '\.remove' -e suppress_bind_attrs drivers/pci/)

Then I inspected them to ensure that
(a) they set up a PCI bus in their probe() and
(b) they don't have a remove() callback for undoing the setup

Suggested-by: Bjorn Helgaas <helgaas@kernel.org>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
13 files changed:
drivers/pci/dwc/pci-imx6.c
drivers/pci/dwc/pci-layerscape.c
drivers/pci/dwc/pcie-armada8k.c
drivers/pci/dwc/pcie-artpec6.c
drivers/pci/dwc/pcie-designware-plat.c
drivers/pci/dwc/pcie-hisi.c
drivers/pci/dwc/pcie-spear13xx.c
drivers/pci/host/pci-ftpci100.c
drivers/pci/host/pci-host-generic.c
drivers/pci/host/pci-thunder-ecam.c
drivers/pci/host/pci-thunder-pem.c
drivers/pci/host/pci-versatile.c
drivers/pci/host/pci-xgene.c