drm/amd/pm: Free SMUv13.0.6 resources on failure

Free the resources allocated if smu_v13_0_12_tables_init fails.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Fixes: 5bf93e1d6e ("drm/amd/pm: Add caching to SMUv13.0.12 temp metric")
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Lijo Lazar
2025-08-12 13:21:49 +05:30
committed by Alex Deucher
parent 655d6403ad
commit 8a358aaa5d
2 changed files with 13 additions and 3 deletions

View File

@@ -161,8 +161,10 @@ int smu_v13_0_12_tables_init(struct smu_context *smu)
/* Initialize GPU board temperature metrics */
ret = smu_table_cache_init(smu, SMU_TABLE_GPUBOARD_TEMP_METRICS,
sizeof(*gpuboard_temp_metrics), 50);
if (ret)
if (ret) {
smu_table_cache_fini(smu, SMU_TABLE_BASEBOARD_TEMP_METRICS);
return ret;
}
cache = &(tables[SMU_TABLE_GPUBOARD_TEMP_METRICS].cache);
gpuboard_temp_metrics = (struct amdgpu_gpuboard_temp_metrics_v1_0 *)cache->buffer;
smu_cmn_init_gpuboard_temp_metrics(gpuboard_temp_metrics, 1, 0);

View File

@@ -537,6 +537,7 @@ static int smu_v13_0_6_tables_init(struct smu_context *smu)
struct smu_table *tables = smu_table->tables;
struct amdgpu_device *adev = smu->adev;
int gpu_metrcs_size = METRICS_TABLE_SIZE;
int ret;
if (!(adev->flags & AMD_IS_APU))
SMU_TABLE_INIT(tables, SMU_TABLE_PMSTATUSLOG, SMU13_TOOL_SIZE,
@@ -573,8 +574,15 @@ static int smu_v13_0_6_tables_init(struct smu_context *smu)
return -ENOMEM;
}
if (amdgpu_ip_version(smu->adev, MP1_HWIP, 0) == IP_VERSION(13, 0, 12))
return smu_v13_0_12_tables_init(smu);
if (amdgpu_ip_version(smu->adev, MP1_HWIP, 0) ==
IP_VERSION(13, 0, 12)) {
ret = smu_v13_0_12_tables_init(smu);
if (ret) {
kfree(smu_table->metrics_table);
kfree(smu_table->gpu_metrics_table);
return ret;
}
}
return 0;
}