mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] PCI: register and active bridge device before proceeding to scan
@ 2015-04-29 19:59 Lucas Stach
  2015-04-29 19:59 ` [PATCH 2/3] PCI: fill in bus primary field Lucas Stach
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lucas Stach @ 2015-04-29 19:59 UTC (permalink / raw)
  To: barebox

The bridge device needs to be registered and activated before
the scanning can proceed, as the bridge is the parent for other
devices.

This fixes a NULL ptr derefernce when scanning PCI hierarchies
with bridges behind bridges.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
---
Please apply to master, as this fixes a crash when activating
PCI support on the GW54xx board.
---
 drivers/pci/pci.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 40e0fe7..470ea66 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -371,11 +371,15 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
 			list_add_tail(&child_bus->node, &bus->children);
 			dev->subordinate = child_bus;
 
+			/* activate bridge device */
+			pci_register_device(dev);
+
+			/* scan pci hierarchy behind bridge */
 			prescan_setup_bridge(dev);
 			pci_scan_bus(child_bus);
 			postscan_setup_bridge(dev);
-			/* first activate bridge then all devices on it's bus */
-			pci_register_device(dev);
+
+			/* finally active all devices behind the bridge */
 			list_for_each_entry(dev, &child_bus->devices, bus_list)
 				if (!dev->subordinate)
 					pci_register_device(dev);
-- 
2.1.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2015-05-01  6:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-29 19:59 [PATCH 1/3] PCI: register and active bridge device before proceeding to scan Lucas Stach
2015-04-29 19:59 ` [PATCH 2/3] PCI: fill in bus primary field Lucas Stach
2015-04-29 19:59 ` [PATCH 3/3] PCI: imx6: simplify config access code Lucas Stach
2015-05-01  6:38 ` [PATCH 1/3] PCI: register and active bridge device before proceeding to scan Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox