From 768403ebcdf94d7667a47ba85d12debf0cb733dd Mon Sep 17 00:00:00 2001 From: Oliver O'Halloran Date: Wed, 20 Sep 2017 19:46:01 +1000 Subject: npu2: Read slot label from the link node 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 Signed-off-by: Stewart Smith --- hw/npu2.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/hw/npu2.c b/hw/npu2.c index 1176d3c..0b85a5d 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 -- cgit v1.1