diff mbox series

[2/3] npu2: Read slot label from the link node

Message ID 20170920094602.4838-2-oohall@gmail.com
State Accepted
Headers show
Series [1/3] npu2: Copy link speed from the npu node | expand

Commit Message

Oliver O'Halloran Sept. 20, 2017, 9:46 a.m. UTC
Binding GPU to emulated NPU PCI devices is done using the slot labels
since the NPU devices do not have a patching slot node we need to
copy the label in here.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 hw/npu2.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/hw/npu2.c b/hw/npu2.c
index 1176d3c0a9b7..0b85a5dae26b 100644
--- a/hw/npu2.c
+++ b/hw/npu2.c
@@ -710,6 +710,7 @@  static int npu2_dn_fixup(struct phb *phb,
 	struct npu2 *p = phb_to_npu2(phb);
 	struct npu2_dev *dev;
 	uint32_t speed;
+	const char *label;
 
 	dev = npu2_bdf_to_dev(p, pd->bdfn);
 	assert(dev);
@@ -730,9 +731,20 @@  static int npu2_dn_fixup(struct phb *phb,
 	if (speed != 0xff)
 		dt_add_property_cells(pd->dn, "ibm,nvlink-speed", speed);
 
-	/* NPU2 devices require a slot location to associate with GPUs */
-	dev->slot_label = dt_prop_get_def(pd->dn, "ibm,slot-label", NULL);
-	if (!dev->slot_label) {
+	/*
+	 * NPU2 devices require a slot location to associate with GPUs.
+	 * This can be added via the slot table matching, otherwise we
+	 * read it from the link node.
+	 */
+	label = dt_prop_get_def(pd->dn, "ibm,slot-label", NULL);
+
+	if (!label) {
+		label = dt_prop_get_def(dev->dt_node, "ibm,slot-label", NULL);
+		if (label)
+			dt_add_property_string(pd->dn, "ibm,slot-label", label);
+	}
+
+	if (!label) {
 		/**
 		 * @fwts-label NPUNoPHBSlotLabel
 		 * @fwts-advice No GPU/NPU2 slot information was found.
@@ -742,6 +754,8 @@  static int npu2_dn_fixup(struct phb *phb,
 		return 0;
 	}
 
+	dev->slot_label = label;
+
 	/*
 	 * Bind the emulated PCI device with the real one, which can't
 	 * be done until the PCI devices are populated. Once the real