Commit 9e75f709 authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher

drm/amd/powerplay: avoid frequent metrics table export

That's unnecessary. Also it makes more sense to show all the clocks
on one metrics table export.
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 28e732dc
...@@ -1958,16 +1958,36 @@ static uint32_t vega20_dpm_get_mclk(struct pp_hwmgr *hwmgr, bool low) ...@@ -1958,16 +1958,36 @@ 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)
{
struct vega20_hwmgr *data =
(struct vega20_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 (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
memcpy(metrics_table, &data->metrics_table, sizeof(SmuMetrics_t));
return ret;
}
static int vega20_get_gpu_power(struct pp_hwmgr *hwmgr, static int vega20_get_gpu_power(struct pp_hwmgr *hwmgr,
uint32_t *query) uint32_t *query)
{ {
int ret = 0; int ret = 0;
SmuMetrics_t metrics_table; SmuMetrics_t metrics_table;
ret = smum_smc_table_manager(hwmgr, (uint8_t *)&metrics_table, TABLE_SMU_METRICS, true); ret = vega20_get_metrics_table(hwmgr, &metrics_table);
PP_ASSERT_WITH_CODE(!ret, if (ret)
"Failed to export SMU METRICS table!", return ret;
return ret);
*query = metrics_table.CurrSocketPower << 8; *query = metrics_table.CurrSocketPower << 8;
...@@ -1998,10 +2018,9 @@ static int vega20_get_current_activity_percent(struct pp_hwmgr *hwmgr, ...@@ -1998,10 +2018,9 @@ 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 = smum_smc_table_manager(hwmgr, (uint8_t *)&metrics_table, TABLE_SMU_METRICS, true); ret = vega20_get_metrics_table(hwmgr, &metrics_table);
PP_ASSERT_WITH_CODE(!ret, if (ret)
"Failed to export SMU METRICS table!", return ret;
return ret);
*activity_percent = metrics_table.AverageGfxActivity; *activity_percent = metrics_table.AverageGfxActivity;
...@@ -2019,11 +2038,9 @@ static int vega20_read_sensor(struct pp_hwmgr *hwmgr, int idx, ...@@ -2019,11 +2038,9 @@ 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 = smum_smc_table_manager(hwmgr, (uint8_t *)&metrics_table, ret = vega20_get_metrics_table(hwmgr, &metrics_table);
TABLE_SMU_METRICS, true); if (ret)
PP_ASSERT_WITH_CODE(!ret, return ret;
"Failed to export SMU METRICS table!",
return ret);
*((uint32_t *)value) = metrics_table.AverageGfxclkFrequency * 100; *((uint32_t *)value) = metrics_table.AverageGfxclkFrequency * 100;
*size = 4; *size = 4;
......
...@@ -520,6 +520,9 @@ struct vega20_hwmgr { ...@@ -520,6 +520,9 @@ struct vega20_hwmgr {
/* ---- Gfxoff ---- */ /* ---- Gfxoff ---- */
bool gfxoff_allowed; bool gfxoff_allowed;
uint32_t counter_gfxoff; uint32_t counter_gfxoff;
unsigned long metrics_time;
SmuMetrics_t metrics_table;
}; };
#define VEGA20_DPM2_NEAR_TDP_DEC 10 #define VEGA20_DPM2_NEAR_TDP_DEC 10
......
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