Skip to contentSkip to conversation

drm/amd: Set num IP blocks to 0 if discovery fails

PATCH Superseded Mario Limonciello 2 participants 2 messages Mar 10

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amd: Set num IP blocks to 0 if discovery fails

If discovery has failed for any reason (such as no support for a block) then there is no need to unwind all the IP blocks in fini. In this condition there can actually be failures during the unwind too.

Reset num_ip_blocks to zero during failure path.

---
v2:
* Stop chasing NULL pointers (Lijo)

 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
index bc6f714e8763a..042f24a0e10fb 100644
@@ -2701,8 +2701,10 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)
 		break;
 	default:
 		r = amdgpu_discovery_set_ip_blocks(adev);
-		if (r)
+		if (r) {
+			adev->num_ip_blocks = 0;
 			return r;
+		}
 		break;
 	}
 
Signature · 1 line
2.53.0
#1 lore raw
Quoted 8 lines · Mario Limonciello

If discovery has failed for any reason (such as no support for a block) then there is no need to unwind all the IP blocks in fini. In this condition there can actually be failures during the unwind too.

Reset num_ip_blocks to zero during failure path.

This will do specifically for the ip block checks.

Wondering whether amdgpu_driver_unload_kms() also should be modified. For ex: calling amdgpu_unregister_gpu_instance and amdgpu_device_fini_hw() don't seem to be relevant if discovery fails.

Thanks,
Lijo

Quoted 22 lines

---
v2:
* Stop chasing NULL pointers (Lijo)

  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
index bc6f714e8763a..042f24a0e10fb 100644
@@ -2701,8 +2701,10 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)
  		break;
  	default:
  		r = amdgpu_discovery_set_ip_blocks(adev);
-		if (r)
+		if (r) {
+			adev->num_ip_blocks = 0;
  			return r;
+		}
  		break;
  	}