Commit 60ae4d67 authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher

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

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 62d35163
......@@ -407,17 +407,16 @@ static int sienna_cichlid_tables_init(struct smu_context *smu)
return -ENOMEM;
}
static int sienna_cichlid_get_smu_metrics_data(struct smu_context *smu,
MetricsMember_t member,
uint32_t *value)
static int sienna_cichlid_get_metrics_table_locked(struct smu_context *smu,
SmuMetrics_t *metrics_table,
bool bypass_cache)
{
struct smu_table_context *smu_table= &smu->smu_table;
SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
if (!smu_table->metrics_time ||
time_after(jiffies, smu_table->metrics_time + msecs_to_jiffies(1))) {
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,
......@@ -425,12 +424,50 @@ static int sienna_cichlid_get_smu_metrics_data(struct smu_context *smu,
false);
if (ret) {
dev_info(smu->adev->dev, "Failed to export SMU metrics table!\n");
mutex_unlock(&smu->metrics_lock);
return ret;
}
smu_table->metrics_time = jiffies;
}
if (metrics_table)
memcpy(metrics_table, smu_table->metrics_table, sizeof(SmuMetrics_t));
return 0;
}
static int sienna_cichlid_get_metrics_table(struct smu_context *smu,
SmuMetrics_t *metrics_table,
bool bypass_cache)
{
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = sienna_cichlid_get_metrics_table_locked(smu,
metrics_table,
bypass_cache);
mutex_unlock(&smu->metrics_lock);
return ret;
}
static int sienna_cichlid_get_smu_metrics_data(struct smu_context *smu,
MetricsMember_t member,
uint32_t *value)
{
struct smu_table_context *smu_table= &smu->smu_table;
SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = sienna_cichlid_get_metrics_table_locked(smu,
NULL,
false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
return ret;
}
switch (member) {
case METRICS_CURR_GFXCLK:
*value = metrics->CurrClock[PPCLK_GFXCLK];
......@@ -2670,23 +2707,11 @@ static ssize_t sienna_cichlid_get_gpu_metrics(struct smu_context *smu,
SmuMetrics_t metrics;
int ret = 0;
mutex_lock(&smu->metrics_lock);
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");
mutex_unlock(&smu->metrics_lock);
ret = sienna_cichlid_get_metrics_table(smu,
&metrics,
true);
if (ret)
return ret;
}
smu_table->metrics_time = jiffies;
memcpy(&metrics, smu_table->metrics_table, sizeof(SmuMetrics_t));
mutex_unlock(&smu->metrics_lock);
smu_v11_0_init_gpu_metrics_v1_0(gpu_metrics);
......
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