drm/amd: Set num IP blocks to 0 if discovery fails
Subsystems (2)
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
@@ -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
@@ -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
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_blocksto zero during failure path and skip the unnecessary cleanup path.Suggested-by Lijo Lazar <[email protected]>Signed-off-by Mario Limonciello <[email protected]>
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@@ -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@@ -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);