[Skiboot] [PATCH] core/pci.c: Move device node fixups to happen after all devices are added to the DT

Alistair Popple alistair at popple.id.au
Thu Oct 29 14:00:12 AEDT 2015


Commit 75e9440 (PCI: Trace device node from PCI device) introduced the
ability for PCI devices to do fixups based on information added to the
device tree as part of device initialisation.

However that patch called the fixups during device initialisation
meaning not all devices present in the system had been added to the
device tree. Depending on device initialisation order this means some
devices were not detected by the fixup code.

This patch moves the calls to the fixup code until after all PCI
devices have been added to the device tree.

Signed-off-by: Alistair Popple <alistair at popple.id.au>
---
 core/pci.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/core/pci.c b/core/pci.c
index 22d38b5..e584da8 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -1386,10 +1386,6 @@ static void pci_add_one_node(struct phb *phb, struct pci_device *pd,
 	reg[1] = reg[2] = reg[3] = reg[4] = 0;
 	dt_add_property(np, "reg", reg, sizeof(reg));
 
-	/* Device node fixup */
-	if (phb->ops->device_node_fixup)
-		phb->ops->device_node_fixup(phb, pd);
-
 	/* Print summary info about the device */
 	pci_print_summary_line(phb, pd, np, rev_class, cname);
 	if (!pd->is_bridge)
@@ -1443,6 +1439,17 @@ static void pci_add_nodes(struct phb *phb)
 		pci_add_one_node(phb, pd, phb->dt_node, lstate, 0);
 }
 
+static void pci_fixup_nodes(struct phb *phb)
+{
+	struct pci_device *pd;
+
+	if (!phb->ops->device_node_fixup)
+		return;
+
+	list_for_each(&phb->devices, pd, link)
+		phb->ops->device_node_fixup(phb, pd);
+}
+
 static void __pci_reset(struct list_head *list)
 {
 	struct pci_device *pd;
@@ -1523,6 +1530,14 @@ void pci_init_slots(void)
 			continue;
 		pci_add_nodes(phbs[i]);
 	}
+
+	/* Do device node fixups now that all the devices have been
+	 * added to the device tree. */
+	for (i = 0; i < ARRAY_SIZE(phbs); i++) {
+		if (!phbs[i])
+			continue;
+		pci_fixup_nodes(phbs[i]);
+	}
 }
 
 /*
-- 
2.1.4



More information about the Skiboot mailing list