drm/amdgpu: Avoid to release the FW twice in the validated error
authorPrike Liang <Prike.Liang@amd.com>
Mon, 2 Dec 2024 06:13:02 +0000 (14:13 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 10 Dec 2024 15:26:50 +0000 (10:26 -0500)
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.

Signed-off-by: Prike Liang <Prike.Liang@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c

index 4c7b53648a507afcb49bff8ddba487fa026bc4fa..d3cd76c6dab3b7ce92d7a4416148dd6d4dfbb3fe 100644 (file)
@@ -1461,11 +1461,13 @@ int amdgpu_ucode_request(struct amdgpu_device *adev, const struct firmware **fw,
                return -ENODEV;
 
        r = amdgpu_ucode_validate(*fw);
-       if (r) {
+       if (r)
+               /*
+                * The amdgpu_ucode_request() should be paired with amdgpu_ucode_release()
+                * regardless of success/failure, and the amdgpu_ucode_release() takes care of
+                * firmware release and need to avoid redundant release FW operation here.
+                */
                dev_dbg(adev->dev, "\"%s\" failed to validate\n", fname);
-               release_firmware(*fw);
-               *fw = NULL;
-       }
 
        return r;
 }