diff mbox series

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

Message ID cc0497c9e86db09e04240aacc8cb2f54ecc65e92.1547168645.git-series.andrew.donnellan@au1.ibm.com
State Changes Requested
Headers show
Series Support OpenCAPI and NVLink devices on same NPU on Witherspoon | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning master/apply_patch Patch failed to apply
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Andrew Donnellan Jan. 11, 2019, 1:09 a.m. UTC
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@au1.ibm.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
 hw/npu2.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Alexey Kardashevskiy Jan. 22, 2019, 12:49 a.m. UTC | #1
On 11/01/2019 12:09, Andrew Donnellan wrote:
> 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@au1.ibm.com>
> Reviewed-by: Frederic Barrat <fbarrat@linux.ibm.com>

Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>

> ---
>  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
>
diff mbox series

Patch

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