linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] PCI: Fix BUG on device attach failure
@ 2016-04-20 14:44 Lukas Wunner
  2016-04-20 14:44 ` [PATCH v2 2/2] PCI: Do not treat EPROBE_DEFER as " Lukas Wunner
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Lukas Wunner @ 2016-04-20 14:44 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-pm, Bjorn Helgaas

Previously when pci_bus_add_device() called device_attach() and it
returned a negative value, we emitted a WARN but carried on.

Commit ab1a187bba5c ("PCI: Check device_attach() return value always"),
introduced in Linux 4.6-rc1, changed this to unwind all steps preceding
device_attach() and to not set dev->is_added = 1.

The latter leads to a BUG if pci_bus_add_device() was called from
pci_bus_add_devices(). Fix by not recursing to a child bus if
device_attach() failed for the bridge leading to it.

This can be triggered by plugging in a PCI device (e.g. Thunderbolt)
while the system is asleep. The system locks up when woken because
device_attach() returns -EPROBE_DEFER.

Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
v2: Split commit in two (Bjorn Helgaas).

 drivers/pci/bus.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 6c9f546..23a39fd 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -324,7 +324,9 @@ void pci_bus_add_devices(const struct pci_bus *bus)
 	}
 
 	list_for_each_entry(dev, &bus->devices, bus_list) {
-		BUG_ON(!dev->is_added);
+		/* Skip if device attach failed */
+		if (!dev->is_added)
+			continue;
 		child = dev->subordinate;
 		if (child)
 			pci_bus_add_devices(child);
-- 
2.8.0.rc3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-05-02 20:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-20 14:44 [PATCH v2 1/2] PCI: Fix BUG on device attach failure Lukas Wunner
2016-04-20 14:44 ` [PATCH v2 2/2] PCI: Do not treat EPROBE_DEFER as " Lukas Wunner
2016-04-26  1:00   ` Rafael J. Wysocki
2016-04-26  1:00 ` [PATCH v2 1/2] PCI: Fix BUG on " Rafael J. Wysocki
2016-05-02 19:01 ` Bjorn Helgaas
2016-05-02 20:23   ` Lukas Wunner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).