Skip to contentSkip to conversation

drm/amdgpu/ucode: Remove firmware load type check in amdgpu_ucode_free_bo

PATCH In review Alice Wong 2 participants 2 messages Apr 29, 2022

Subsystems (2)
lore
Share & tools
lore

Alice Wong

author
#0 lore raw

PATCH 1/1 drm/amdgpu/ucode: Remove firmware load type check in amdgpu_ucode_free_bo

When psp_hw_init failed, it will set the load_type to AMDGPU_FW_LOAD_DIRECT. During amdgpu_device_ip_fini, amdgpu_ucode_free_bo checks that load_type is AMDGPU_FW_LOAD_DIRECT and skips deallocating fw_buf causing memory leak. Remove load_type check in amdgpu_ucode_free_bo.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +1 -2
index ca3350502618..aebafbc327fb 100644
@@ -714,8 +714,7 @@ int amdgpu_ucode_create_bo(struct amdgpu_device *adev)
 
 void amdgpu_ucode_free_bo(struct amdgpu_device *adev)
 {
-	if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT)
-		amdgpu_bo_free_kernel(&adev->firmware.fw_buf,
+	amdgpu_bo_free_kernel(&adev->firmware.fw_buf,
 		&adev->firmware.fw_buf_mc,
 		&adev->firmware.fw_buf_ptr);
 }
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Alice Wong

When psp_hw_init failed, it will set the load_type to AMDGPU_FW_LOAD_DIRECT. During amdgpu_device_ip_fini, amdgpu_ucode_free_bo checks that load_type is AMDGPU_FW_LOAD_DIRECT and skips deallocating fw_buf causing memory leak. Remove load_type check in amdgpu_ucode_free_bo.

Quoted 21 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +1 -3
index ca3350502618..aebafbc327fb 100644
@@ -714,8 +714,7 @@ int amdgpu_ucode_create_bo(struct amdgpu_device *adev)
 
 void amdgpu_ucode_free_bo(struct amdgpu_device *adev)
 {
-       if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT)
-               amdgpu_bo_free_kernel(&adev->firmware.fw_buf,
+       amdgpu_bo_free_kernel(&adev->firmware.fw_buf,
                &adev->firmware.fw_buf_mc,
                &adev->firmware.fw_buf_ptr);
 }
--

2.25.1