summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
diff options
context:
space:
mode:
authorEvan Quan <evan.quan@amd.com>2020-08-06 16:49:19 +0800
committerAlex Deucher <alexander.deucher@amd.com>2020-08-14 16:22:40 -0400
commitfceafc9b7b393698ac9aadb5c3b64b1ba1f61e1e (patch)
treea846e3dd57c49a650dd73a061a5fa62cdd3f0161 /drivers/gpu/drm/amd/powerplay/navi10_ppt.c
parenta9c75edcbe7cca5c2edb87fa765efac7558523c0 (diff)
drm/amd/powerplay: maximum the code sharing around metrics table retrieving
Instead of having one copy in each ASIC. Signed-off-by: Evan Quan <evan.quan@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@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.c41
1 files changed, 7 insertions, 34 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
index 82659b781f05..42a60769c52f 100644
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
@@ -504,34 +504,6 @@ err0_out:
return -ENOMEM;
}
-static int navi10_get_metrics_table_locked(struct smu_context *smu,
- SmuMetrics_t *metrics_table,
- bool bypass_cache)
-{
- struct smu_table_context *smu_table= &smu->smu_table;
- int ret = 0;
-
- if (bypass_cache ||
- !smu_table->metrics_time ||
- time_after(jiffies, smu_table->metrics_time + msecs_to_jiffies(1))) {
- ret = smu_cmn_update_table(smu,
- SMU_TABLE_SMU_METRICS,
- 0,
- smu_table->metrics_table,
- false);
- if (ret) {
- dev_info(smu->adev->dev, "Failed to export SMU metrics table!\n");
- return ret;
- }
- smu_table->metrics_time = jiffies;
- }
-
- if (metrics_table)
- memcpy(metrics_table, smu_table->metrics_table, sizeof(SmuMetrics_t));
-
- return 0;
-}
-
static int navi10_get_smu_metrics_data(struct smu_context *smu,
MetricsMember_t member,
uint32_t *value)
@@ -547,9 +519,9 @@ static int navi10_get_smu_metrics_data(struct smu_context *smu,
mutex_lock(&smu->metrics_lock);
- ret = navi10_get_metrics_table_locked(smu,
- NULL,
- false);
+ ret = smu_cmn_get_metrics_table_locked(smu,
+ NULL,
+ false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
return ret;
@@ -2526,14 +2498,15 @@ static ssize_t navi10_get_gpu_metrics(struct smu_context *smu,
mutex_lock(&smu->metrics_lock);
- ret = navi10_get_metrics_table_locked(smu,
- &metrics,
- true);
+ ret = smu_cmn_get_metrics_table_locked(smu,
+ NULL,
+ true);
if (ret) {
mutex_unlock(&smu->metrics_lock);
return ret;
}
+ memcpy(&metrics, smu_table->metrics_table, sizeof(SmuMetrics_t));
if (adev->asic_type == CHIP_NAVI12)
memcpy(&nv12_metrics, smu_table->metrics_table, sizeof(SmuMetrics_NV12_t));