Skip to content

Commit

Permalink
drm/powerplay: Fix Vega20 Average Power value v4
Browse files Browse the repository at this point in the history
The SMU changed reading from CurrSocketPower to AverageSocketPower, so
reflect this accordingly. This fixes the issue where Average Power
Consumption was being reported as 0 from SMU 40.46-onward

v2: Fixed headline prefix
v3: Add check for SMU version for proper compatibility
v4: Style fix

Signed-off-by: Kent Russell <kent.russell@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
kentrussell authored and alexdeucher committed Aug 26, 2019
1 parent 42068e1 commit 21649c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2101,7 +2101,10 @@ static int vega20_get_gpu_power(struct pp_hwmgr *hwmgr,
if (ret)
return ret;

*query = metrics_table.CurrSocketPower << 8;
if (hwmgr->smu_version < 0x282e00)
*query = metrics_table.CurrSocketPower << 8;
else
*query = metrics_table.AverageSocketPower << 8;

return ret;
}
Expand Down
10 changes: 9 additions & 1 deletion drivers/gpu/drm/amd/powerplay/vega20_ppt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3050,6 +3050,7 @@ static int vega20_get_fan_speed_percent(struct smu_context *smu,

static int vega20_get_gpu_power(struct smu_context *smu, uint32_t *value)
{
uint32_t smu_version;
int ret = 0;
SmuMetrics_t metrics;

Expand All @@ -3060,7 +3061,14 @@ static int vega20_get_gpu_power(struct smu_context *smu, uint32_t *value)
if (ret)
return ret;

*value = metrics.CurrSocketPower << 8;
ret = smu_get_smc_version(smu, NULL, &smu_version);
if (ret)
return ret;

if (smu_version < 0x282e00)
*value = metrics.CurrSocketPower << 8;
else
*value = metrics.AverageSocketPower << 8;

return 0;
}
Expand Down

0 comments on commit 21649c0

Please sign in to comment.