Commit 2ba38817 authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher

drm/amd/powerplay: add control method to bypass metrics cache on Renoir

As for the gpu metric export, metrics cache makes no sense. It's up to
user to decide how often the metrics should be retrieved.
Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 60ae4d67
......@@ -129,13 +129,17 @@ static struct cmn2asic_mapping renoir_workload_map[PP_SMC_POWER_PROFILE_COUNT] =
};
static int renoir_get_metrics_table(struct smu_context *smu,
SmuMetrics_t *metrics_table)
SmuMetrics_t *metrics_table,
bool bypass_cache)
{
struct smu_table_context *smu_table= &smu->smu_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
if (!smu_table->metrics_time || time_after(jiffies, smu_table->metrics_time + msecs_to_jiffies(100))) {
if (bypass_cache ||
!smu_table->metrics_time ||
time_after(jiffies, smu_table->metrics_time + msecs_to_jiffies(100))) {
ret = smu_cmn_update_table(smu, SMU_TABLE_SMU_METRICS, 0,
(void *)smu_table->metrics_table, false);
if (ret) {
......@@ -146,7 +150,9 @@ static int renoir_get_metrics_table(struct smu_context *smu,
smu_table->metrics_time = jiffies;
}
memcpy(metrics_table, smu_table->metrics_table, sizeof(SmuMetrics_t));
if (metrics_table)
memcpy(metrics_table, smu_table->metrics_table, sizeof(SmuMetrics_t));
mutex_unlock(&smu->metrics_lock);
return ret;
......@@ -375,7 +381,7 @@ static int renoir_print_clk_levels(struct smu_context *smu,
memset(&metrics, 0, sizeof(metrics));
ret = renoir_get_metrics_table(smu, &metrics);
ret = renoir_get_metrics_table(smu, &metrics, false);
if (ret)
return ret;
......@@ -529,7 +535,7 @@ static int renoir_get_current_clk_freq_by_table(struct smu_context *smu,
int ret = 0, clk_id = 0;
SmuMetrics_t metrics;
ret = renoir_get_metrics_table(smu, &metrics);
ret = renoir_get_metrics_table(smu, &metrics, false);
if (ret)
return ret;
......@@ -612,7 +618,7 @@ static int renoir_get_gpu_temperature(struct smu_context *smu, uint32_t *value)
if (!value)
return -EINVAL;
ret = renoir_get_metrics_table(smu, &metrics);
ret = renoir_get_metrics_table(smu, &metrics, false);
if (ret)
return ret;
......@@ -632,7 +638,7 @@ static int renoir_get_current_activity_percent(struct smu_context *smu,
if (!value)
return -EINVAL;
ret = renoir_get_metrics_table(smu, &metrics);
ret = renoir_get_metrics_table(smu, &metrics, false);
if (ret)
return ret;
......@@ -1018,7 +1024,7 @@ static ssize_t renoir_get_gpu_metrics(struct smu_context *smu,
SmuMetrics_t metrics;
int ret = 0;
ret = renoir_get_metrics_table(smu, &metrics);
ret = renoir_get_metrics_table(smu, &metrics, true);
if (ret)
return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment