Skip to contentSkip to conversation

drm/amdgpu: Avoid to release the FW twice in the validated error

PATCH In review Prike Liang 2 participants 3 messages Dec 2, 2024

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

PATCH 1/1 drm/amdgpu: Avoid to release the FW twice in the validated error

There will to release the FW twice when the FW validated error. Even if the release_firmware() will further validate the FW whether is empty, but that will be redundant and inefficient.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +1 -4
index 4c7b53648a50..e7f50415926c 100644
@@ -1461,11 +1461,8 @@ int amdgpu_ucode_request(struct amdgpu_device *adev, const struct firmware **fw,
 		return -ENODEV;
 
 	r = amdgpu_ucode_validate(*fw);
-	if (r) {
+	if (r)
 		dev_dbg(adev->dev, "\"%s\" failed to validate\n", fname);
-		release_firmware(*fw);
-		*fw = NULL;
-	}
 
 	return r;
 }
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Prike Liang

There will to release the FW twice when the FW validated error. Even if the release_firmware() will further validate the FW whether is empty, but that will be redundant and inefficient.

Better to add a remark that amdgpu_ucode_request should be paired with amdgpu_ucode_release regardless of success/failure. amdgpu_ucode_release takes care of firmware release, avoiding redundant operation here.

Thanks,
Lijo

Quoted 23 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +1 -4
index 4c7b53648a50..e7f50415926c 100644
@@ -1461,11 +1461,8 @@ int amdgpu_ucode_request(struct amdgpu_device *adev, const struct firmware **fw,
 		return -ENODEV;
 
 	r = amdgpu_ucode_validate(*fw);
-	if (r) {
+	if (r)
 		dev_dbg(adev->dev, "\"%s\" failed to validate\n", fname);
-		release_firmware(*fw);
-		*fw = NULL;
-	}
 
 	return r;
 }
#2 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Thanks for the input, as offline syncing will add this remark in the function amdgpu_ucode_request() description part.

Regards,
Prike

Quoted 50 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, December 2, 2024 3:46 PM
To: Liang, Prike <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: Avoid to release the FW twice in the validated error

Quoted 3 lines · Prike Liang

There will to release the FW twice when the FW validated error. Even if the release_firmware() will further validate the FW whether is empty, but that will be redundant and inefficient.

Better to add a remark that amdgpu_ucode_request should be paired with amdgpu_ucode_release regardless of success/failure. amdgpu_ucode_release takes care of firmware release, avoiding redundant operation here.

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c int amdgpu_ucode_request(struct amdgpu_device

Quoted 12 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +0 -0
index 4c7b53648a50..e7f50415926c 100644
@@ -1461,11 +1461,8 @@ int amdgpu_ucode_request(struct amdgpu_device

*adev, const struct firmware **fw,

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +1 -4
            return -ENODEV;
 
    r = amdgpu_ucode_validate(*fw);
-   if (r) {
+   if (r)
            dev_dbg(adev->dev, "\"%s\" failed to validate\n", fname);
-           release_firmware(*fw);
-           *fw = NULL;
-   }
 
    return r;
 }