[coreboot] [PATCH] v3: Fix up PCI device code

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Wed Nov 5 04:01:49 CET 2008

The current PCI device code calls pci_scan_bus with a PCI domain instead
of a PCI bus as parameter. That causes all sorts of havoc, including
double initialization of hardware and ignoring devices in the dts.

This patch attempts to fix these bugs, but it has other side effects.
Somehow, resource allocation is now skipped.

I'd appreciate logs with and without this patch for every target,
especially K8.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

Index: corebootv3-pci_scan_bus_nexttry_minimal_fixup/device/pci_device.c
--- corebootv3-pci_scan_bus_nexttry_minimal_fixup/device/pci_device.c	(Revision 980)
+++ corebootv3-pci_scan_bus_nexttry_minimal_fixup/device/pci_device.c	(Arbeitskopie)
@@ -1234,8 +1234,24 @@
 unsigned int pci_domain_scan_bus(struct device *dev, unsigned int curr_bus)
 	printk(BIOS_SPEW, "pci_domain_scan_bus: calling pci_scan_bus\n");
-	/* There is only one link on this device, and it is always link 0. */
-	return pci_scan_bus(&dev->link[0], PCI_DEVFN(0, 0), 0xff, curr_bus);
+	/* There is only one link on a bus, and it is always link 0.
+	 * dev->link[0] for a PCI domain is the domain link.
+	 * The child of the domain link is the PCI bus device.
+	 * We want to scan the bus link of the PCI bus device.
+	 * dev->link[0].children->link[0] is that PCI bus link.
+	 * If there can be multiple PCI buses directly below a PCI domain,
+	 * we have to iterate over the PCI buses in a loop.
+	 */
+#if 1
+	return pci_scan_bus(&dev->link[0].children->link[0],
+				   PCI_DEVFN(0, 0), 0xff, curr_bus);
+	struct device *list;
+	for (list = dev->link[0].children; list; list = list->sibling)
+		curr_bus = pci_scan_bus(&list->link[0],
+				   PCI_DEVFN(0, 0), 0xff, curr_bus);
+	return curr_bus;


More information about the coreboot mailing list