diff mbox

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

Message ID 1446087612-7255-1-git-send-email-alistair@popple.id.au
State Accepted
Headers show

Commit Message

Alistair Popple Oct. 29, 2015, 3 a.m. UTC
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@popple.id.au>
---
 core/pci.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

Comments

Stewart Smith Nov. 12, 2015, 6:12 a.m. UTC | #1
Alistair Popple <alistair@popple.id.au> writes:
> 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@popple.id.au>
> ---
>  core/pci.c | 23 +++++++++++++++++++----
>  1 file changed, 19 insertions(+), 4 deletions(-)

Thanks, merged as of 03c6c2d.

Should we bump the skiboot rev we're building for garisson in op-build?
Alistair Popple Nov. 12, 2015, 10:47 p.m. UTC | #2
Stewart,

It would be a good idea as nvlink may not work without this fix. That said it 
won't work anyway at the moment as we're waiting for a Hostboot update. 
Hopefully they will be pushing that out in the next week or so.

- Alistair

On Thu, 12 Nov 2015 17:12:46 Stewart Smith wrote:
> Alistair Popple <alistair@popple.id.au> writes:
> > 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@popple.id.au>
> > ---
> >  core/pci.c | 23 +++++++++++++++++++----
> >  1 file changed, 19 insertions(+), 4 deletions(-)
> 
> Thanks, merged as of 03c6c2d.
> 
> Should we bump the skiboot rev we're building for garisson in op-build?
>
diff mbox

Patch

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]);
+	}
 }
 
 /*