[PATCH 25/30] drm/amd/powerplay: fix arcturus real-time clock frequency retrieval
Alex Deucher
alexdeucher at gmail.com
Mon Jul 29 20:15:03 UTC 2019
From: Evan Quan <evan.quan at amd.com>
Make sure we can still get the accurate gfxclk/uclk/socclk frequency
even on dpm disabled.
Signed-off-by: Evan Quan <evan.quan at amd.com>
Reviewed-by: Kenneth Feng <kenneth.feng at amd.com>
Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
---
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c | 30 +++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
index 30317cf9dc9a..1b6d41c2462f 100644
--- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
@@ -1053,7 +1053,35 @@ static int arcturus_get_current_clk_freq_by_table(struct smu_context *smu,
if (ret)
return ret;
- *value = metrics.CurrClock[clk_id];
+ switch (clk_id) {
+ case PPCLK_GFXCLK:
+ /*
+ * CurrClock[clk_id] can provide accurate
+ * output only when the dpm feature is enabled.
+ * We can use Average_* for dpm disabled case.
+ * But this is available for gfxclk/uclk/socclk.
+ */
+ if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_GFXCLK_BIT))
+ *value = metrics.CurrClock[PPCLK_GFXCLK];
+ else
+ *value = metrics.AverageGfxclkFrequency;
+ break;
+ case PPCLK_UCLK:
+ if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_UCLK_BIT))
+ *value = metrics.CurrClock[PPCLK_UCLK];
+ else
+ *value = metrics.AverageUclkFrequency;
+ break;
+ case PPCLK_SOCCLK:
+ if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_SOCCLK_BIT))
+ *value = metrics.CurrClock[PPCLK_SOCCLK];
+ else
+ *value = metrics.AverageSocclkFrequency;
+ break;
+ default:
+ *value = metrics.CurrClock[clk_id];
+ break;
+ }
return ret;
}
--
2.20.1
More information about the amd-gfx
mailing list