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/navi10_ppt.c | |
parent | drm/amd/powerplay: correct SW SMU valid mapping check (diff) | |
download | linux-dev-c06403045aad6ae2edd935f6309e0c72e118c6de.tar.xz linux-dev-c06403045aad6ae2edd935f6309e0c72e118c6de.zip |
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/navi10_ppt.c')
-rw-r--r-- | drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c index f6b1c8b2b2d6..7061ff14333f 100644 --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c @@ -216,8 +216,10 @@ static int navi10_get_smu_msg_index(struct smu_context *smc, uint32_t index) return -EINVAL; mapping = navi10_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; } @@ -230,8 +232,10 @@ static int navi10_get_smu_clk_index(struct smu_context *smc, uint32_t index) return -EINVAL; mapping = navi10_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; } @@ -244,8 +248,10 @@ static int navi10_get_smu_feature_index(struct smu_context *smc, uint32_t index) return -EINVAL; mapping = navi10_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; } @@ -258,8 +264,10 @@ static int navi10_get_smu_table_index(struct smu_context *smc, uint32_t index) return -EINVAL; mapping = navi10_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; } @@ -272,8 +280,10 @@ static int navi10_get_pwr_src_index(struct smu_context *smc, uint32_t index) return -EINVAL; mapping = navi10_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; } @@ -287,8 +297,10 @@ static int navi10_get_workload_type(struct smu_context *smu, enum PP_SMC_POWER_P return -EINVAL; mapping = navi10_workload_map[profile]; - if (!(mapping.valid_mapping)) + if (!(mapping.valid_mapping)) { + pr_warn("Unsupported workload: %d\n", (int)profile); return -EINVAL; + } return mapping.map_to; } @@ -969,7 +981,7 @@ static int navi10_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", @@ -1002,6 +1014,9 @@ static int navi10_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); @@ -1130,6 +1145,8 @@ static int navi10_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); |