summaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
authorLucas Stach <dev@lynxeye.de>2014-10-04 19:40:12 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-10-08 08:39:01 +0200
commitb8a1bb1dd215770670108fe5b0de0e5e137bf8fd (patch)
tree05137d719dfbda1846d933675d0063bbdc2eafda /drivers/pci/pci.c
parent687ceb77162df447f909cc587133417723828f9e (diff)
downloadbarebox-b8a1bb1dd215770670108fe5b0de0e5e137bf8fd.tar.gz
barebox-b8a1bb1dd215770670108fe5b0de0e5e137bf8fd.tar.xz
pci: defer device registration until after bridge setup
Otherwise the drivers for a device may probe before the devices parent bridge is fully configured, which leads to errors when accessing the BARs. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 59f942d51..943d0e8eb 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -208,7 +208,6 @@ static void setup_device(struct pci_dev *dev, int max_bar)
pci_write_config_byte(dev, PCI_COMMAND, cmd);
list_add_tail(&dev->bus_list, &dev->bus->devices);
- pci_register_device(dev);
}
static void prescan_setup_bridge(struct pci_dev *dev)
@@ -362,6 +361,11 @@ unsigned int pci_scan_bus(struct pci_bus *bus)
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);
+ list_for_each_entry(dev, &child_bus->devices, bus_list)
+ if (!dev->subordinate)
+ pci_register_device(dev);
break;
default:
bad: