[Skiboot] [PATCH v2 13/15] hw/npu2: Always check device type when looping through NPU devices

Andrew Donnellan andrew.donnellan at au1.ibm.com
Fri Jan 11 12:09:33 AEDT 2019


Fix all the remaining places in the NVLink code where we loop through all
the devices on an NPU and don't check whether it's an NVLink device -
triggering NTL resets, setting up relaxed ordering, and setting up LPAR
mapping.

Signed-off-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat at linux.ibm.com>
---
 hw/npu2.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/hw/npu2.c b/hw/npu2.c
index a8744f4af7f7..411028189975 100644
--- a/hw/npu2.c
+++ b/hw/npu2.c
@@ -1120,7 +1120,7 @@ static int64_t npu2_hreset(struct pci_slot *slot __unused)
 
 	for (i = 0; i < p->total_devices; i++) {
 		ndev = &p->devices[i];
-		if (ndev) {
+		if (ndev && ndev->type == NPU2_DEV_TYPE_NVLINK) {
 			NPU2DEVINF(ndev, "Resetting device\n");
 			reset_ntl(ndev);
 		}
@@ -1144,7 +1144,7 @@ static int64_t npu2_creset(struct pci_slot *slot)
 
 	for (i = 0; i < p->total_devices; i++) {
 		ndev = &p->devices[i];
-		if (ndev) {
+		if (ndev && ndev->type == NPU2_DEV_TYPE_NVLINK) {
 			NPU2DEVINF(ndev, "Resetting device\n");
 			reset_ntl(ndev);
 		}
@@ -1972,7 +1972,8 @@ static int opal_npu_map_lpar(uint64_t phb_id, uint64_t bdf, uint64_t lparid,
 
 	/* Need to find an NVLink to send the ATSDs for this device over */
 	for (i = 0; i < p->total_devices; i++) {
-		if (p->devices[i].nvlink.gpu_bdfn == bdf) {
+		if (p->devices[i].type == NPU2_DEV_TYPE_NVLINK &&
+		    p->devices[i].nvlink.gpu_bdfn == bdf) {
 			ndev = &p->devices[i];
 			break;
 		}
@@ -2156,6 +2157,9 @@ static int npu2_set_relaxed_ordering(uint32_t gcid, int pec, bool enable)
 		npu = phb_to_npu2_nvlink(phb);
 		for (int i = 0; i < npu->total_devices; i++) {
 			ndev = &npu->devices[i];
+			if (ndev->type != NPU2_DEV_TYPE_NVLINK)
+				continue;
+
 			if (enable)
 				rc = npu2_enable_relaxed_ordering(ndev, gcid, pec);
 			else
-- 
git-series 0.9.1



More information about the Skiboot mailing list