diff options
author | Evan Quan <evan.quan@amd.com> | 2019-07-11 14:36:44 +0800 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2019-07-18 14:18:07 -0500 |
commit | c06403045aad6ae2edd935f6309e0c72e118c6de (patch) | |
tree | 38d42c132773b848505c4c80ff2edfc30a4ac18a /drivers/gpu/drm/amd/powerplay/vega20_ppt.c | |
parent | 7e01a2ec96bf8a149c5e83d0352cf6ea286275cf (diff) |
drm/amd/powerplay: input check for unsupported message/clock index
This can avoid them to be handled in a wrong way without notice.
Since not all SMU messages/clocks are supported on every SMU11 ASIC.
Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Feifei Xu <Feifei.Xu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/powerplay/vega20_ppt.c')
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c index af54fee0aed2..080956ea0570 100644 --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c @@ -231,8 +231,10 @@ static int vega20_get_smu_table_index(struct smu_context *smc, uint32_t index) return -EINVAL; mapping = vega20_table_map[index]; - if (!(mapping.valid_mapping)) + if (!(mapping.valid_mapping)) { + pr_warn("Unsupported SMU table: %d\n", index); return -EINVAL; + } return mapping.map_to; } @@ -245,8 +247,10 @@ static int vega20_get_pwr_src_index(struct smu_context *smc, uint32_t index) return -EINVAL; mapping = vega20_pwr_src_map[index]; - if (!(mapping.valid_mapping)) + if (!(mapping.valid_mapping)) { + pr_warn("Unsupported power source: %d\n", index); return -EINVAL; + } return mapping.map_to; } @@ -259,8 +263,10 @@ static int vega20_get_smu_feature_index(struct smu_context *smc, uint32_t index) return -EINVAL; mapping = vega20_feature_mask_map[index]; - if (!(mapping.valid_mapping)) + if (!(mapping.valid_mapping)) { + pr_warn("Unsupported SMU feature: %d\n", index); return -EINVAL; + } return mapping.map_to; } @@ -273,8 +279,10 @@ static int vega20_get_smu_clk_index(struct smu_context *smc, uint32_t index) return -EINVAL; mapping = vega20_clk_map[index]; - if (!(mapping.valid_mapping)) + if (!(mapping.valid_mapping)) { + pr_warn("Unsupported SMU clock: %d\n", index); return -EINVAL; + } return mapping.map_to; } @@ -287,8 +295,10 @@ static int vega20_get_smu_msg_index(struct smu_context *smc, uint32_t index) return -EINVAL; mapping = vega20_message_map[index]; - if (!(mapping.valid_mapping)) + if (!(mapping.valid_mapping)) { + pr_warn("Unsupported SMU message: %d\n", index); return -EINVAL; + } return mapping.map_to; } @@ -301,8 +311,10 @@ static int vega20_get_workload_type(struct smu_context *smu, enum PP_SMC_POWER_P return -EINVAL; mapping = vega20_workload_map[profile]; - if (!(mapping.valid_mapping)) + if (!(mapping.valid_mapping)) { + pr_warn("Unsupported SMU workload: %d\n", (int)profile); return -EINVAL; + } return mapping.map_to; } @@ -1778,7 +1790,7 @@ static int vega20_get_power_profile_mode(struct smu_context *smu, char *buf) { DpmActivityMonitorCoeffInt_t activity_monitor; uint32_t i, size = 0; - uint16_t workload_type = 0; + int16_t workload_type = 0; static const char *profile_name[] = { "BOOTUP_DEFAULT", "3D_FULL_SCREEN", @@ -1811,6 +1823,9 @@ static int vega20_get_power_profile_mode(struct smu_context *smu, char *buf) for (i = 0; i <= PP_SMC_POWER_PROFILE_CUSTOM; i++) { /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ workload_type = smu_workload_get_type(smu, i); + if (workload_type < 0) + return -EINVAL; + result = smu_update_table(smu, SMU_TABLE_ACTIVITY_MONITOR_COEFF, workload_type, (void *)(&activity_monitor), false); @@ -1963,6 +1978,8 @@ static int vega20_set_power_profile_mode(struct smu_context *smu, long *input, u /* conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT */ workload_type = smu_workload_get_type(smu, smu->power_profile_mode); + if (workload_type < 0) + return -EINVAL; smu_send_smc_msg_with_param(smu, SMU_MSG_SetWorkloadMask, 1 << workload_type); |