drm/amdgpu/pm: Check input value for power profile setting on smu11, smu13 and smu14
BugLink: https://bugs.launchpad.net/bugs/2084941 [ Upstream commit adb9de4dd207fb1264ea70b9eacab9f70ee4707a ] Check the input value for CUSTOM profile mode setting on smu 11, smu13 and smu14. Otherwise we use uninitialized value of input[] Signed-off-by: Ma Jun <Jun.Ma2@amd.com> Reviewed-by: Yang Wang <kevinyang.wang@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
This commit is contained in:
@@ -1439,6 +1439,9 @@ static int arcturus_set_power_profile_mode(struct smu_context *smu,
|
||||
|
||||
if ((profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) &&
|
||||
(smu->smc_fw_version >= 0x360d00)) {
|
||||
if (size != 10)
|
||||
return -EINVAL;
|
||||
|
||||
ret = smu_cmn_update_table(smu,
|
||||
SMU_TABLE_ACTIVITY_MONITOR_COEFF,
|
||||
WORKLOAD_PPLIB_CUSTOM_BIT,
|
||||
@@ -1472,6 +1475,8 @@ static int arcturus_set_power_profile_mode(struct smu_context *smu,
|
||||
activity_monitor.Mem_PD_Data_error_coeff = input[8];
|
||||
activity_monitor.Mem_PD_Data_error_rate_coeff = input[9];
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = smu_cmn_update_table(smu,
|
||||
|
||||
@@ -2021,6 +2021,8 @@ static int navi10_set_power_profile_mode(struct smu_context *smu, long *input, u
|
||||
}
|
||||
|
||||
if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) {
|
||||
if (size != 10)
|
||||
return -EINVAL;
|
||||
|
||||
ret = smu_cmn_update_table(smu,
|
||||
SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT,
|
||||
@@ -2064,6 +2066,8 @@ static int navi10_set_power_profile_mode(struct smu_context *smu, long *input, u
|
||||
activity_monitor.Mem_PD_Data_error_coeff = input[8];
|
||||
activity_monitor.Mem_PD_Data_error_rate_coeff = input[9];
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = smu_cmn_update_table(smu,
|
||||
|
||||
@@ -1722,6 +1722,8 @@ static int sienna_cichlid_set_power_profile_mode(struct smu_context *smu, long *
|
||||
}
|
||||
|
||||
if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) {
|
||||
if (size != 10)
|
||||
return -EINVAL;
|
||||
|
||||
ret = smu_cmn_update_table(smu,
|
||||
SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT,
|
||||
@@ -1765,6 +1767,8 @@ static int sienna_cichlid_set_power_profile_mode(struct smu_context *smu, long *
|
||||
activity_monitor->Mem_PD_Data_error_coeff = input[8];
|
||||
activity_monitor->Mem_PD_Data_error_rate_coeff = input[9];
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = smu_cmn_update_table(smu,
|
||||
|
||||
@@ -2495,6 +2495,9 @@ static int smu_v13_0_0_set_power_profile_mode(struct smu_context *smu,
|
||||
}
|
||||
|
||||
if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) {
|
||||
if (size != 9)
|
||||
return -EINVAL;
|
||||
|
||||
ret = smu_cmn_update_table(smu,
|
||||
SMU_TABLE_ACTIVITY_MONITOR_COEFF,
|
||||
WORKLOAD_PPLIB_CUSTOM_BIT,
|
||||
@@ -2526,6 +2529,8 @@ static int smu_v13_0_0_set_power_profile_mode(struct smu_context *smu,
|
||||
activity_monitor->Fclk_PD_Data_error_coeff = input[7];
|
||||
activity_monitor->Fclk_PD_Data_error_rate_coeff = input[8];
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = smu_cmn_update_table(smu,
|
||||
|
||||
@@ -2450,6 +2450,8 @@ static int smu_v13_0_7_set_power_profile_mode(struct smu_context *smu, long *inp
|
||||
}
|
||||
|
||||
if (smu->power_profile_mode == PP_SMC_POWER_PROFILE_CUSTOM) {
|
||||
if (size != 8)
|
||||
return -EINVAL;
|
||||
|
||||
ret = smu_cmn_update_table(smu,
|
||||
SMU_TABLE_ACTIVITY_MONITOR_COEFF, WORKLOAD_PPLIB_CUSTOM_BIT,
|
||||
@@ -2478,6 +2480,8 @@ static int smu_v13_0_7_set_power_profile_mode(struct smu_context *smu, long *inp
|
||||
activity_monitor->Fclk_MinActiveFreq = input[6];
|
||||
activity_monitor->Fclk_BoosterFreq = input[7];
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = smu_cmn_update_table(smu,
|
||||
|
||||
Reference in New Issue
Block a user