Commit bf110287 authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher

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

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 740dce95
......@@ -1262,22 +1262,29 @@ static uint32_t vega12_dpm_get_mclk(struct pp_hwmgr *hwmgr, bool low)
return (mem_clk * 100);
}
static int vega12_get_metrics_table(struct pp_hwmgr *hwmgr, SmuMetrics_t *metrics_table)
static int vega12_get_metrics_table(struct pp_hwmgr *hwmgr,
SmuMetrics_t *metrics_table,
bool bypass_cache)
{
struct vega12_hwmgr *data =
(struct vega12_hwmgr *)(hwmgr->backend);
int ret = 0;
if (!data->metrics_time || time_after(jiffies, data->metrics_time + HZ / 2)) {
ret = smum_smc_table_manager(hwmgr, (uint8_t *)metrics_table,
TABLE_SMU_METRICS, true);
if (bypass_cache ||
!data->metrics_time ||
time_after(jiffies, data->metrics_time + HZ / 2)) {
ret = smum_smc_table_manager(hwmgr,
(uint8_t *)(&data->metrics_table),
TABLE_SMU_METRICS,
true);
if (ret) {
pr_info("Failed to export SMU metrics table!\n");
return ret;
}
memcpy(&data->metrics_table, metrics_table, sizeof(SmuMetrics_t));
data->metrics_time = jiffies;
} else
}
if (metrics_table)
memcpy(metrics_table, &data->metrics_table, sizeof(SmuMetrics_t));
return ret;
......@@ -1288,7 +1295,7 @@ static int vega12_get_gpu_power(struct pp_hwmgr *hwmgr, uint32_t *query)
SmuMetrics_t metrics_table;
int ret = 0;
ret = vega12_get_metrics_table(hwmgr, &metrics_table);
ret = vega12_get_metrics_table(hwmgr, &metrics_table, false);
if (ret)
return ret;
......@@ -1339,7 +1346,7 @@ static int vega12_get_current_activity_percent(
SmuMetrics_t metrics_table;
int ret = 0;
ret = vega12_get_metrics_table(hwmgr, &metrics_table);
ret = vega12_get_metrics_table(hwmgr, &metrics_table, false);
if (ret)
return ret;
......@@ -1387,7 +1394,7 @@ static int vega12_read_sensor(struct pp_hwmgr *hwmgr, int idx,
*size = 4;
break;
case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:
ret = vega12_get_metrics_table(hwmgr, &metrics_table);
ret = vega12_get_metrics_table(hwmgr, &metrics_table, false);
if (ret)
return ret;
......@@ -1396,7 +1403,7 @@ static int vega12_read_sensor(struct pp_hwmgr *hwmgr, int idx,
*size = 4;
break;
case AMDGPU_PP_SENSOR_MEM_TEMP:
ret = vega12_get_metrics_table(hwmgr, &metrics_table);
ret = vega12_get_metrics_table(hwmgr, &metrics_table, false);
if (ret)
return ret;
......@@ -2752,7 +2759,7 @@ static ssize_t vega12_get_gpu_metrics(struct pp_hwmgr *hwmgr,
uint32_t fan_speed_rpm;
int ret;
ret = vega12_get_metrics_table(hwmgr, &metrics);
ret = vega12_get_metrics_table(hwmgr, &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