]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
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)
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

index 129717ae50225e3712bb8aea57686812b2b1105e..a98cba55c7f02e670436787c011a85a8772f5109 100644 (file)
@@ -804,6 +804,7 @@ static struct platform_driver imx6_pcie_driver = {
        .driver = {
                .name   = "imx6q-pcie",
                .of_match_table = imx6_pcie_of_match,
+               .suppress_bind_attrs = true,
        },
        .probe    = imx6_pcie_probe,
        .shutdown = imx6_pcie_shutdown,
index 8f0ee0d8129c8f5e44381a406ad68356ca662ebb..27d638c4e134316676f9984a4596b6275c23f133 100644 (file)
@@ -305,6 +305,7 @@ static struct platform_driver ls_pcie_driver = {
        .driver = {
                .name = "layerscape-pcie",
                .of_match_table = ls_pcie_of_match,
+               .suppress_bind_attrs = true,
        },
 };
 builtin_platform_driver_probe(ls_pcie_driver, ls_pcie_probe);
index 3ff31301323b0d877739c1048f9d8d3d0735d021..495b023042b3ac2b861515aea4245be91ecaefeb 100644 (file)
@@ -262,6 +262,7 @@ static struct platform_driver armada8k_pcie_driver = {
        .driver = {
                .name   = "armada8k-pcie",
                .of_match_table = of_match_ptr(armada8k_pcie_of_match),
+               .suppress_bind_attrs = true,
        },
 };
 builtin_platform_driver(armada8k_pcie_driver);
index 5b3b3afc0edbdd4c196e114585bed277f0f2c6c4..82a04acc42fdc228e8e500efd4fa082494b7930c 100644 (file)
@@ -295,6 +295,7 @@ static struct platform_driver artpec6_pcie_driver = {
        .driver = {
                .name   = "artpec6-pcie",
                .of_match_table = artpec6_pcie_of_match,
+               .suppress_bind_attrs = true,
        },
 };
 builtin_platform_driver(artpec6_pcie_driver);
index f20d494922ab890badd99dd96af9bcad866f2ca2..32091b32f6e1e43b52ecec7f40a4d5e26105e891 100644 (file)
@@ -133,6 +133,7 @@ static struct platform_driver dw_plat_pcie_driver = {
        .driver = {
                .name   = "dw-pcie",
                .of_match_table = dw_plat_pcie_of_match,
+               .suppress_bind_attrs = true,
        },
        .probe = dw_plat_pcie_probe,
 };
index 1606de5bf7574e9849732f13e8886b44384d74ec..18af8057cdc44eb94ef2c7a5af3e3ac85527dc24 100644 (file)
@@ -333,6 +333,7 @@ static struct platform_driver hisi_pcie_driver = {
        .driver = {
                   .name = "hisi-pcie",
                   .of_match_table = hisi_pcie_of_match,
+                  .suppress_bind_attrs = true,
        },
 };
 builtin_platform_driver(hisi_pcie_driver);
@@ -390,6 +391,7 @@ static struct platform_driver hisi_pcie_almost_ecam_driver = {
        .driver = {
                   .name = "hisi-pcie-almost-ecam",
                   .of_match_table = hisi_pcie_almost_ecam_of_match,
+                  .suppress_bind_attrs = true,
        },
 };
 builtin_platform_driver(hisi_pcie_almost_ecam_driver);
index 3ae59de5c043f1e74f2bede957813cedb7de0bd2..8ff36b3dbbdf7ebdb8f06fdaea334033467bf31d 100644 (file)
@@ -308,6 +308,7 @@ static struct platform_driver spear13xx_pcie_driver = {
        .driver = {
                .name   = "spear-pcie",
                .of_match_table = of_match_ptr(spear13xx_pcie_of_match),
+               .suppress_bind_attrs = true,
        },
 };
 
index c0f29d1de341bca88627877ac76e27dcee292cd4..d26501c4145afca4553c20f90c5e4321a8222460 100644 (file)
@@ -556,6 +556,7 @@ static struct platform_driver faraday_pci_driver = {
        .driver = {
                .name = "ftpci100",
                .of_match_table = of_match_ptr(faraday_pci_of_match),
+               .suppress_bind_attrs = true,
        },
        .probe  = faraday_pci_probe,
 };
index c05ea9d72f693f38203e98ae92c4c95df4dab661..7d709a7e0aa8a7cf2e0bc55de059f1731d8adb27 100644 (file)
@@ -60,6 +60,7 @@ static struct platform_driver gen_pci_driver = {
        .driver = {
                .name = "pci-host-generic",
                .of_match_table = gen_pci_of_match,
+               .suppress_bind_attrs = true,
        },
        .probe = gen_pci_probe,
 };
index 3f54a43bbbea50740045592790377d4b009e5d76..fc0ca03f280ead292d26d67d15ece79bd8e0f558 100644 (file)
@@ -373,6 +373,7 @@ static struct platform_driver thunder_ecam_driver = {
        .driver = {
                .name = KBUILD_MODNAME,
                .of_match_table = thunder_ecam_of_match,
+               .suppress_bind_attrs = true,
        },
        .probe = thunder_ecam_probe,
 };
index 6e031b522529daec0240022cf5221e92be3ea29b..6e066f8b74dfda865a6b9b4ad5c145861d255415 100644 (file)
@@ -474,6 +474,7 @@ static struct platform_driver thunder_pem_driver = {
        .driver = {
                .name = KBUILD_MODNAME,
                .of_match_table = thunder_pem_of_match,
+               .suppress_bind_attrs = true,
        },
        .probe = thunder_pem_probe,
 };
index 85e773661bc813c395e9584e8eded1f5b059a3fb..9281eee2d00088eaea0a74adeed4bd9430f55f92 100644 (file)
@@ -222,6 +222,7 @@ static struct platform_driver versatile_pci_driver = {
        .driver = {
                .name = "versatile-pci",
                .of_match_table = versatile_pci_of_match,
+               .suppress_bind_attrs = true,
        },
        .probe = versatile_pci_probe,
 };
index de198980432e0b661ddf84eacd18b5273ce82c45..8cae013e7188dfcf1c6d78a8316c4dcc7d21663b 100644 (file)
@@ -697,6 +697,7 @@ static struct platform_driver xgene_pcie_driver = {
        .driver = {
                   .name = "xgene-pcie",
                   .of_match_table = of_match_ptr(xgene_pcie_match_table),
+                  .suppress_bind_attrs = true,
        },
        .probe = xgene_pcie_probe_bridge,
 };