[Skiboot] [PATCH] pci: Try harder to add meaningful ibm,loc-code

Stewart Smith stewart at linux.ibm.com
Fri May 3 16:36:21 AEST 2019

We keep the existing logic of looking to the parent for the slot-label or
slot-location-code, but we add logic to (if all that fails) we look
directly for the slot-location-code (as this should give us the correct
loc code for things directly under the PHB), and otherwise we just look
for a loc-code.

The applicable bit of PAPR here is:

  R1–12.1–1. Each instance of a hardware entity (FRU) has a platform
  unique location code and any node in the OF
  device tree that describes a part of a hardware entity must include the
  “ibm,loc-code” property with a
  value that represents the location code for that hardware entity.

which we weren't really fully obeying at any recent (ever?) point in
time. Now we should do okay, at least for PCI.

Signed-off-by: Stewart Smith <stewart at linux.ibm.com>
 core/pci.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/core/pci.c b/core/pci.c
index 85f3f722bf38..4a83c718beb4 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -1437,6 +1437,21 @@ static void pci_add_loc_code(struct dt_node *np, struct pci_device *pd)
 		p = p->parent;
+	if (!blcode)
+		blcode = dt_prop_get_def(np, "ibm,slot-location-code", NULL);
+	if (!blcode) {
+		/* Fall back to finding a ibm,loc-code */
+		p = np->parent;
+		while (p) {
+			blcode = dt_prop_get_def(p, "ibm,loc-code", NULL);
+			if (blcode)
+				break;
+			p = p->parent;
+		}
+	}
 	if (!blcode)

More information about the Skiboot mailing list