Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5f40e80 authored by Brian Norris's avatar Brian Norris Committed by Bjorn Helgaas
Browse files

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: default avatarBjorn Helgaas <helgaas@kernel.org>
Signed-off-by: default avatarBrian Norris <briannorris@chromium.org>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent ef1b5dad
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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,
+1 −0
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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);
+1 −0
Original line number Diff line number Diff line
@@ -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,
};
Loading