Commit 62d35163 authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher

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

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 345fcb02
...@@ -504,22 +504,16 @@ static int navi10_tables_init(struct smu_context *smu) ...@@ -504,22 +504,16 @@ static int navi10_tables_init(struct smu_context *smu)
return -ENOMEM; return -ENOMEM;
} }
static int navi10_get_smu_metrics_data(struct smu_context *smu, static int navi10_get_metrics_table_locked(struct smu_context *smu,
MetricsMember_t member, SmuMetrics_t *metrics_table,
uint32_t *value) bool bypass_cache)
{ {
struct smu_table_context *smu_table= &smu->smu_table; struct smu_table_context *smu_table= &smu->smu_table;
/*
* This works for NV12 also. As although NV12 uses a different
* SmuMetrics structure from other NV1X ASICs, they share the
* same offsets for the heading parts(those members used here).
*/
SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
int ret = 0; int ret = 0;
mutex_lock(&smu->metrics_lock); if (bypass_cache ||
if (!smu_table->metrics_time || !smu_table->metrics_time ||
time_after(jiffies, smu_table->metrics_time + msecs_to_jiffies(1))) { time_after(jiffies, smu_table->metrics_time + msecs_to_jiffies(1))) {
ret = smu_cmn_update_table(smu, ret = smu_cmn_update_table(smu,
SMU_TABLE_SMU_METRICS, SMU_TABLE_SMU_METRICS,
0, 0,
...@@ -527,12 +521,40 @@ static int navi10_get_smu_metrics_data(struct smu_context *smu, ...@@ -527,12 +521,40 @@ static int navi10_get_smu_metrics_data(struct smu_context *smu,
false); false);
if (ret) { if (ret) {
dev_info(smu->adev->dev, "Failed to export SMU metrics table!\n"); dev_info(smu->adev->dev, "Failed to export SMU metrics table!\n");
mutex_unlock(&smu->metrics_lock);
return ret; return ret;
} }
smu_table->metrics_time = jiffies; 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)
{
struct smu_table_context *smu_table= &smu->smu_table;
/*
* This works for NV12 also. As although NV12 uses a different
* SmuMetrics structure from other NV1X ASICs, they share the
* same offsets for the heading parts(those members used here).
*/
SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = navi10_get_metrics_table_locked(smu,
NULL,
false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
return ret;
}
switch (member) { switch (member) {
case METRICS_CURR_GFXCLK: case METRICS_CURR_GFXCLK:
*value = metrics->CurrClock[PPCLK_GFXCLK]; *value = metrics->CurrClock[PPCLK_GFXCLK];
...@@ -2512,19 +2534,13 @@ static ssize_t navi10_get_gpu_metrics(struct smu_context *smu, ...@@ -2512,19 +2534,13 @@ static ssize_t navi10_get_gpu_metrics(struct smu_context *smu,
mutex_lock(&smu->metrics_lock); mutex_lock(&smu->metrics_lock);
ret = smu_cmn_update_table(smu, ret = navi10_get_metrics_table_locked(smu,
SMU_TABLE_SMU_METRICS, &metrics,
0, true);
smu_table->metrics_table,
false);
if (ret) { if (ret) {
dev_info(smu->adev->dev, "Failed to export SMU metrics table!\n");
mutex_unlock(&smu->metrics_lock); mutex_unlock(&smu->metrics_lock);
return ret; return ret;
} }
smu_table->metrics_time = jiffies;
memcpy(&metrics, smu_table->metrics_table, sizeof(SmuMetrics_t));
if (adev->asic_type == CHIP_NAVI12) if (adev->asic_type == CHIP_NAVI12)
memcpy(&nv12_metrics, smu_table->metrics_table, sizeof(SmuMetrics_NV12_t)); memcpy(&nv12_metrics, smu_table->metrics_table, sizeof(SmuMetrics_NV12_t));
......
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