Skip to contentSkip to conversation

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

PATCH In review Mario Limonciello 2 participants 2 messages Mar 10 – Mar 11

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 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 and skip the unnecessary cleanup path.

---
v3:
* Skip cleanup path for early discovery failure

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
index 5c24369821e47..c1949070a2969 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;
 	}
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
index 77e2133de5cf9..7f19554b9ad11 100644
@@ -83,7 +83,7 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)
 {
 	struct amdgpu_device *adev = drm_to_adev(dev);
 
-	if (adev == NULL)
+	if (adev == NULL || !adev->num_ip_blocks)
 		return;
 
 	amdgpu_unregister_gpu_instance(adev);
Signature · 1 line
2.53.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 9 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 and skip the unnecessary cleanup path.

Thanks,
Lijo

Quoted 37 lines

---
v3:
* Skip cleanup path for early discovery failure

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 +++-
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c    | 2 +-
  2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
index 5c24369821e47..c1949070a2969 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;
  	}
 
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
index 77e2133de5cf9..7f19554b9ad11 100644
@@ -83,7 +83,7 @@ void amdgpu_driver_unload_kms(struct drm_device *dev)
  {
  	struct amdgpu_device *adev = drm_to_adev(dev);
 
-	if (adev == NULL)
+	if (adev == NULL || !adev->num_ip_blocks)
  		return;
 
  	amdgpu_unregister_gpu_instance(adev);