From e36182490dec3d2947dbf3c3d979051b8706845c Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Wed, 8 May 2019 14:37:08 +0800 Subject: [PATCH] drm/amd/powerplay: fix dpm freq unit error (10KHz -> Mhz) the interface smu_v11_0_get_current_clk_freq should be return 10Khz not Mhz unit to adapt vega20 and navi10 asic at the same time. Signed-off-by: Kevin Wang Acked-by: Huang Rui Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 2 ++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c index e705067b4dd2..7df9d3c15094 100644 --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c @@ -581,6 +581,8 @@ static int navi10_print_clk_levels(struct smu_context *smu, ret = smu_get_current_clk_freq(smu, clk_type, &cur_value); if (ret) return size; + /* 10KHz -> MHz */ + cur_value = cur_value / 100; size += sprintf(buf, "current clk: %uMhz\n", cur_value); diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c index ec7862ea299d..29f868f0ef3c 100644 --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c @@ -1098,16 +1098,17 @@ static int smu_v11_0_get_current_clk_freq(struct smu_context *smu, /* if don't has GetDpmClockFreq Message, try get current clock by SmuMetrics_t */ if (smu_msg_get_index(smu, SMU_MSG_GetDpmClockFreq) == 0) - return smu_get_current_clk_freq_by_table(smu, clk_id, value); - - ret = smu_send_smc_msg_with_param(smu, SMU_MSG_GetDpmClockFreq, - (smu_clk_get_index(smu, clk_id) << 16)); - if (ret) - return ret; + ret = smu_get_current_clk_freq_by_table(smu, clk_id, &freq); + else { + ret = smu_send_smc_msg_with_param(smu, SMU_MSG_GetDpmClockFreq, + (smu_clk_get_index(smu, clk_id) << 16)); + if (ret) + return ret; - ret = smu_read_smc_arg(smu, &freq); - if (ret) - return ret; + ret = smu_read_smc_arg(smu, &freq); + if (ret) + return ret; + } freq *= 100; *value = freq; -- 2.30.2