Commit 740dce95 authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher

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

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 2ba38817
...@@ -2090,22 +2090,29 @@ static uint32_t vega20_dpm_get_mclk(struct pp_hwmgr *hwmgr, bool low) ...@@ -2090,22 +2090,29 @@ static uint32_t vega20_dpm_get_mclk(struct pp_hwmgr *hwmgr, bool low)
return (mem_clk * 100); return (mem_clk * 100);
} }
static int vega20_get_metrics_table(struct pp_hwmgr *hwmgr, SmuMetrics_t *metrics_table) static int vega20_get_metrics_table(struct pp_hwmgr *hwmgr,
SmuMetrics_t *metrics_table,
bool bypass_cache)
{ {
struct vega20_hwmgr *data = struct vega20_hwmgr *data =
(struct vega20_hwmgr *)(hwmgr->backend); (struct vega20_hwmgr *)(hwmgr->backend);
int ret = 0; int ret = 0;
if (!data->metrics_time || time_after(jiffies, data->metrics_time + HZ / 2)) { if (bypass_cache ||
ret = smum_smc_table_manager(hwmgr, (uint8_t *)metrics_table, !data->metrics_time ||
TABLE_SMU_METRICS, true); 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) { if (ret) {
pr_info("Failed to export SMU metrics table!\n"); pr_info("Failed to export SMU metrics table!\n");
return ret; return ret;
} }
memcpy(&data->metrics_table, metrics_table, sizeof(SmuMetrics_t));
data->metrics_time = jiffies; data->metrics_time = jiffies;
} else }
if (metrics_table)
memcpy(metrics_table, &data->metrics_table, sizeof(SmuMetrics_t)); memcpy(metrics_table, &data->metrics_table, sizeof(SmuMetrics_t));
return ret; return ret;
...@@ -2117,7 +2124,7 @@ static int vega20_get_gpu_power(struct pp_hwmgr *hwmgr, ...@@ -2117,7 +2124,7 @@ static int vega20_get_gpu_power(struct pp_hwmgr *hwmgr,
int ret = 0; int ret = 0;
SmuMetrics_t metrics_table; SmuMetrics_t metrics_table;
ret = vega20_get_metrics_table(hwmgr, &metrics_table); ret = vega20_get_metrics_table(hwmgr, &metrics_table, false);
if (ret) if (ret)
return ret; return ret;
...@@ -2155,7 +2162,7 @@ static int vega20_get_current_activity_percent(struct pp_hwmgr *hwmgr, ...@@ -2155,7 +2162,7 @@ static int vega20_get_current_activity_percent(struct pp_hwmgr *hwmgr,
int ret = 0; int ret = 0;
SmuMetrics_t metrics_table; SmuMetrics_t metrics_table;
ret = vega20_get_metrics_table(hwmgr, &metrics_table); ret = vega20_get_metrics_table(hwmgr, &metrics_table, false);
if (ret) if (ret)
return ret; return ret;
...@@ -2185,7 +2192,7 @@ static int vega20_read_sensor(struct pp_hwmgr *hwmgr, int idx, ...@@ -2185,7 +2192,7 @@ static int vega20_read_sensor(struct pp_hwmgr *hwmgr, int idx,
switch (idx) { switch (idx) {
case AMDGPU_PP_SENSOR_GFX_SCLK: case AMDGPU_PP_SENSOR_GFX_SCLK:
ret = vega20_get_metrics_table(hwmgr, &metrics_table); ret = vega20_get_metrics_table(hwmgr, &metrics_table, false);
if (ret) if (ret)
return ret; return ret;
...@@ -2210,7 +2217,7 @@ static int vega20_read_sensor(struct pp_hwmgr *hwmgr, int idx, ...@@ -2210,7 +2217,7 @@ static int vega20_read_sensor(struct pp_hwmgr *hwmgr, int idx,
*size = 4; *size = 4;
break; break;
case AMDGPU_PP_SENSOR_EDGE_TEMP: case AMDGPU_PP_SENSOR_EDGE_TEMP:
ret = vega20_get_metrics_table(hwmgr, &metrics_table); ret = vega20_get_metrics_table(hwmgr, &metrics_table, false);
if (ret) if (ret)
return ret; return ret;
...@@ -2219,7 +2226,7 @@ static int vega20_read_sensor(struct pp_hwmgr *hwmgr, int idx, ...@@ -2219,7 +2226,7 @@ static int vega20_read_sensor(struct pp_hwmgr *hwmgr, int idx,
*size = 4; *size = 4;
break; break;
case AMDGPU_PP_SENSOR_MEM_TEMP: case AMDGPU_PP_SENSOR_MEM_TEMP:
ret = vega20_get_metrics_table(hwmgr, &metrics_table); ret = vega20_get_metrics_table(hwmgr, &metrics_table, false);
if (ret) if (ret)
return ret; return ret;
...@@ -4283,7 +4290,7 @@ static ssize_t vega20_get_gpu_metrics(struct pp_hwmgr *hwmgr, ...@@ -4283,7 +4290,7 @@ static ssize_t vega20_get_gpu_metrics(struct pp_hwmgr *hwmgr,
uint32_t fan_speed_rpm; uint32_t fan_speed_rpm;
int ret; int ret;
ret = vega20_get_metrics_table(hwmgr, &metrics); ret = vega20_get_metrics_table(hwmgr, &metrics, true);
if (ret) if (ret)
return 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