Commit 315d1716 authored by Mario Limonciello's avatar Mario Limonciello Committed by Alex Deucher

drm/amd: Use `amdgpu_ucode_*` helpers for SMU

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: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 51526637
...@@ -109,10 +109,7 @@ int smu_v11_0_init_microcode(struct smu_context *smu) ...@@ -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); snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
err = request_firmware(&adev->pm.fw, fw_name, adev->dev); err = amdgpu_ucode_request(adev, &adev->pm.fw, fw_name);
if (err)
goto out;
err = amdgpu_ucode_validate(adev->pm.fw);
if (err) if (err)
goto out; goto out;
...@@ -130,12 +127,8 @@ int smu_v11_0_init_microcode(struct smu_context *smu) ...@@ -130,12 +127,8 @@ int smu_v11_0_init_microcode(struct smu_context *smu)
} }
out: out:
if (err) { if (err)
DRM_ERROR("smu_v11_0: Failed to load firmware \"%s\"\n", amdgpu_ucode_release(&adev->pm.fw);
fw_name);
release_firmware(adev->pm.fw);
adev->pm.fw = NULL;
}
return err; return err;
} }
...@@ -143,8 +136,7 @@ void smu_v11_0_fini_microcode(struct smu_context *smu) ...@@ -143,8 +136,7 @@ void smu_v11_0_fini_microcode(struct smu_context *smu)
{ {
struct amdgpu_device *adev = smu->adev; struct amdgpu_device *adev = smu->adev;
release_firmware(adev->pm.fw); amdgpu_ucode_release(&adev->pm.fw);
adev->pm.fw = NULL;
adev->pm.fw_version = 0; adev->pm.fw_version = 0;
} }
......
...@@ -103,10 +103,7 @@ int smu_v13_0_init_microcode(struct smu_context *smu) ...@@ -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); snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix);
err = request_firmware(&adev->pm.fw, fw_name, adev->dev); err = amdgpu_ucode_request(adev, &adev->pm.fw, fw_name);
if (err)
goto out;
err = amdgpu_ucode_validate(adev->pm.fw);
if (err) if (err)
goto out; goto out;
...@@ -124,12 +121,8 @@ int smu_v13_0_init_microcode(struct smu_context *smu) ...@@ -124,12 +121,8 @@ int smu_v13_0_init_microcode(struct smu_context *smu)
} }
out: out:
if (err) { if (err)
DRM_ERROR("smu_v13_0: Failed to load firmware \"%s\"\n", amdgpu_ucode_release(&adev->pm.fw);
fw_name);
release_firmware(adev->pm.fw);
adev->pm.fw = NULL;
}
return err; return err;
} }
...@@ -137,8 +130,7 @@ void smu_v13_0_fini_microcode(struct smu_context *smu) ...@@ -137,8 +130,7 @@ void smu_v13_0_fini_microcode(struct smu_context *smu)
{ {
struct amdgpu_device *adev = smu->adev; struct amdgpu_device *adev = smu->adev;
release_firmware(adev->pm.fw); amdgpu_ucode_release(&adev->pm.fw);
adev->pm.fw = NULL;
adev->pm.fw_version = 0; adev->pm.fw_version = 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment