summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd
diff options
context:
space:
mode:
authorEvan Quan <evan.quan@amd.com>2019-07-23 20:28:14 +0800
committerAlex Deucher <alexander.deucher@amd.com>2019-07-30 23:48:35 -0500
commit1f23cadbe0775559b3152a4f1fcb566d8cf6f571 (patch)
tree5468a4ada6ab7b1f2c0bbe706e0e17b2a92f6b04 /drivers/gpu/drm/amd
parent60d435b73db607df560f3df04fe5f4ba96e37116 (diff)
drm/amd/powerplay: correct arcturus current clock level calculation
There may be 1Mhz delta between target and actual frequency. That should be taken into consideration for current level check. Signed-off-by: Evan Quan <evan.quan@amd.com> Reviewed-by: Kenneth Feng <kenneth.feng@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd')
-rw-r--r--drivers/gpu/drm/amd/powerplay/arcturus_ppt.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
index fa2845b9330b..c67a9914ce7b 100644
--- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
@@ -51,6 +51,9 @@
#define SMU_FEATURES_HIGH_MASK 0xFFFFFFFF00000000
#define SMU_FEATURES_HIGH_SHIFT 32
+/* possible frequency drift (1Mhz) */
+#define EPSILON 1
+
static struct smu_11_0_cmn2aisc_mapping arcturus_message_map[SMU_MSG_MAX_COUNT] = {
MSG_MAP(TestMessage, PPSMC_MSG_TestMessage),
MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion),
@@ -565,6 +568,12 @@ static int arcturus_get_clk_table(struct smu_context *smu,
return 0;
}
+static int arcturus_freqs_in_same_level(int32_t frequency1,
+ int32_t frequency2)
+{
+ return (abs(frequency1 - frequency2) <= EPSILON);
+}
+
static int arcturus_print_clk_levels(struct smu_context *smu,
enum smu_clk_type type, char *buf)
{
@@ -595,8 +604,9 @@ static int arcturus_print_clk_levels(struct smu_context *smu,
for (i = 0; i < clocks.num_levels; i++)
size += sprintf(buf + size, "%d: %uMhz %s\n", i,
clocks.data[i].clocks_in_khz / 1000,
- (clocks.data[i].clocks_in_khz == now * 10)
- ? "*" : "");
+ arcturus_freqs_in_same_level(
+ clocks.data[i].clocks_in_khz / 1000,
+ now / 100) ? "*" : "");
break;
case SMU_MCLK:
@@ -616,8 +626,9 @@ static int arcturus_print_clk_levels(struct smu_context *smu,
for (i = 0; i < clocks.num_levels; i++)
size += sprintf(buf + size, "%d: %uMhz %s\n",
i, clocks.data[i].clocks_in_khz / 1000,
- (clocks.data[i].clocks_in_khz == now * 10)
- ? "*" : "");
+ arcturus_freqs_in_same_level(
+ clocks.data[i].clocks_in_khz / 1000,
+ now / 100) ? "*" : "");
break;
case SMU_SOCCLK:
@@ -637,8 +648,9 @@ static int arcturus_print_clk_levels(struct smu_context *smu,
for (i = 0; i < clocks.num_levels; i++)
size += sprintf(buf + size, "%d: %uMhz %s\n",
i, clocks.data[i].clocks_in_khz / 1000,
- (clocks.data[i].clocks_in_khz == now * 10)
- ? "*" : "");
+ arcturus_freqs_in_same_level(
+ clocks.data[i].clocks_in_khz / 1000,
+ now / 100) ? "*" : "");
break;
case SMU_FCLK:
@@ -649,11 +661,18 @@ static int arcturus_print_clk_levels(struct smu_context *smu,
}
single_dpm_table = &(dpm_table->fclk_table);
+ ret = arcturus_get_clk_table(smu, &clocks, single_dpm_table);
+ if (ret) {
+ pr_err("Attempt to get fclk levels Failed!");
+ return ret;
+ }
+
for (i = 0; i < single_dpm_table->count; i++)
size += sprintf(buf + size, "%d: %uMhz %s\n",
i, single_dpm_table->dpm_levels[i].value,
- (single_dpm_table->dpm_levels[i].value == now / 100)
- ? "*" : "");
+ arcturus_freqs_in_same_level(
+ clocks.data[i].clocks_in_khz / 1000,
+ now / 100) ? "*" : "");
break;
default: