drm/amd: Use `amdgpu_ucode_*` helpers for SMU
authorMario Limonciello <mario.limonciello@amd.com>
Tue, 3 Jan 2023 21:40:19 +0000 (15:40 -0600)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 10 Jan 2023 19:32:57 +0000 (14:32 -0500)
The `amdgpu_ucode_request` helper will ensure that the return code for
missing firmware is -ENODEV so that early_init can fail.

The `amdgpu_ucode_release` helper is for symmetry on unloading.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c

index d4756bd..6492d69 100644 (file)
@@ -109,10 +109,7 @@ int smu_v11_0_init_microcode(struct smu_context *smu)
 
        snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
 
-       err = request_firmware(&adev->pm.fw, fw_name, adev->dev);
-       if (err)
-               goto out;
-       err = amdgpu_ucode_validate(adev->pm.fw);
+       err = amdgpu_ucode_request(adev, &adev->pm.fw, fw_name);
        if (err)
                goto out;
 
@@ -130,12 +127,8 @@ int smu_v11_0_init_microcode(struct smu_context *smu)
        }
 
 out:
-       if (err) {
-               DRM_ERROR("smu_v11_0: Failed to load firmware \"%s\"\n",
-                         fw_name);
-               release_firmware(adev->pm.fw);
-               adev->pm.fw = NULL;
-       }
+       if (err)
+               amdgpu_ucode_release(&adev->pm.fw);
        return err;
 }
 
@@ -143,8 +136,7 @@ void smu_v11_0_fini_microcode(struct smu_context *smu)
 {
        struct amdgpu_device *adev = smu->adev;
 
-       release_firmware(adev->pm.fw);
-       adev->pm.fw = NULL;
+       amdgpu_ucode_release(&adev->pm.fw);
        adev->pm.fw_version = 0;
 }
 
index f986c7b..ccaedfc 100644 (file)
@@ -103,10 +103,7 @@ int smu_v13_0_init_microcode(struct smu_context *smu)
 
        snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
 
-       err = request_firmware(&adev->pm.fw, fw_name, adev->dev);
-       if (err)
-               goto out;
-       err = amdgpu_ucode_validate(adev->pm.fw);
+       err = amdgpu_ucode_request(adev, &adev->pm.fw, fw_name);
        if (err)
                goto out;
 
@@ -124,12 +121,8 @@ int smu_v13_0_init_microcode(struct smu_context *smu)
        }
 
 out:
-       if (err) {
-               DRM_ERROR("smu_v13_0: Failed to load firmware \"%s\"\n",
-                         fw_name);
-               release_firmware(adev->pm.fw);
-               adev->pm.fw = NULL;
-       }
+       if (err)
+               amdgpu_ucode_release(&adev->pm.fw);
        return err;
 }
 
@@ -137,8 +130,7 @@ void smu_v13_0_fini_microcode(struct smu_context *smu)
 {
        struct amdgpu_device *adev = smu->adev;
 
-       release_firmware(adev->pm.fw);
-       adev->pm.fw = NULL;
+       amdgpu_ucode_release(&adev->pm.fw);
        adev->pm.fw_version = 0;
 }