Skip to content

Commit 765bbbe

Browse files
superm1alexdeucher
authored andcommitted
drm/amd: Show both power attributes for vega20
Vega20 can offer average power in some versions of the PMFW and current power in others. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 4c64f2e commit 765bbbe

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_hwmgr.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,7 +2129,7 @@ static int vega20_get_metrics_table(struct pp_hwmgr *hwmgr,
21292129
return ret;
21302130
}
21312131

2132-
static int vega20_get_gpu_power(struct pp_hwmgr *hwmgr,
2132+
static int vega20_get_gpu_power(struct pp_hwmgr *hwmgr, int idx,
21332133
uint32_t *query)
21342134
{
21352135
int ret = 0;
@@ -2140,10 +2140,17 @@ static int vega20_get_gpu_power(struct pp_hwmgr *hwmgr,
21402140
return ret;
21412141

21422142
/* For the 40.46 release, they changed the value name */
2143-
if (hwmgr->smu_version == 0x282e00)
2144-
*query = metrics_table.AverageSocketPower << 8;
2145-
else
2143+
switch (idx) {
2144+
case AMDGPU_PP_SENSOR_GPU_POWER:
2145+
if (hwmgr->smu_version == 0x282e00)
2146+
*query = metrics_table.AverageSocketPower << 8;
2147+
else
2148+
ret = -EOPNOTSUPP;
2149+
break;
2150+
case AMDGPU_PP_SENSOR_GPU_INPUT_POWER:
21462151
*query = metrics_table.CurrSocketPower << 8;
2152+
break;
2153+
}
21472154

21482155
return ret;
21492156
}
@@ -2253,9 +2260,10 @@ static int vega20_read_sensor(struct pp_hwmgr *hwmgr, int idx,
22532260
*((uint32_t *)value) = data->vce_power_gated ? 0 : 1;
22542261
*size = 4;
22552262
break;
2263+
case AMDGPU_PP_SENSOR_GPU_POWER:
22562264
case AMDGPU_PP_SENSOR_GPU_INPUT_POWER:
22572265
*size = 16;
2258-
ret = vega20_get_gpu_power(hwmgr, (uint32_t *)value);
2266+
ret = vega20_get_gpu_power(hwmgr, idx, (uint32_t *)value);
22592267
break;
22602268
case AMDGPU_PP_SENSOR_VDDGFX:
22612269
val_vid = (RREG32_SOC15(SMUIO, 0, mmSMUSVI0_TEL_PLANE0) &

0 commit comments

Comments
 (0)