Commit 60d06906 authored by Alex Deucher's avatar Alex Deucher

drm/amdgpu/powerplay/smu10: add support for gpu busy query (v2)

Was added in newer versions of the firmware.  Add support
for it.

v2: return an error in SMU error, drop needless break.
Reviewed-by: default avatarEvan Quan <evan.quan@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 1a31474c
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
#define PPSMC_MSG_PowerGateMmHub 0x35 #define PPSMC_MSG_PowerGateMmHub 0x35
#define PPSMC_MSG_SetRccPfcPmeRestoreRegister 0x36 #define PPSMC_MSG_SetRccPfcPmeRestoreRegister 0x36
#define PPSMC_MSG_GpuChangeState 0x37 #define PPSMC_MSG_GpuChangeState 0x37
#define PPSMC_MSG_GetGfxBusy 0x3D
#define PPSMC_Message_Count 0x42 #define PPSMC_Message_Count 0x42
typedef uint16_t PPSMC_Result; typedef uint16_t PPSMC_Result;
......
...@@ -1261,9 +1261,21 @@ static int smu10_read_sensor(struct pp_hwmgr *hwmgr, int idx, ...@@ -1261,9 +1261,21 @@ static int smu10_read_sensor(struct pp_hwmgr *hwmgr, int idx,
void *value, int *size) void *value, int *size)
{ {
struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend); struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
uint32_t sclk, mclk; struct amdgpu_device *adev = hwmgr->adev;
uint32_t sclk, mclk, activity_percent;
bool has_gfx_busy;
int ret = 0; int ret = 0;
/* GetGfxBusy support was added on RV SMU FW 30.85.00 and PCO 4.30.59 */
if ((adev->apu_flags & AMD_APU_IS_PICASSO) &&
(hwmgr->smu_version >= 0x41e3b))
has_gfx_busy = true;
else if ((adev->apu_flags & AMD_APU_IS_RAVEN) &&
(hwmgr->smu_version >= 0x1e5500))
has_gfx_busy = true;
else
has_gfx_busy = false;
switch (idx) { switch (idx) {
case AMDGPU_PP_SENSOR_GFX_SCLK: case AMDGPU_PP_SENSOR_GFX_SCLK:
smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetGfxclkFrequency, &sclk); smum_send_msg_to_smc(hwmgr, PPSMC_MSG_GetGfxclkFrequency, &sclk);
...@@ -1284,6 +1296,20 @@ static int smu10_read_sensor(struct pp_hwmgr *hwmgr, int idx, ...@@ -1284,6 +1296,20 @@ static int smu10_read_sensor(struct pp_hwmgr *hwmgr, int idx,
*(uint32_t *)value = smu10_data->vcn_power_gated ? 0 : 1; *(uint32_t *)value = smu10_data->vcn_power_gated ? 0 : 1;
*size = 4; *size = 4;
break; break;
case AMDGPU_PP_SENSOR_GPU_LOAD:
if (has_gfx_busy) {
ret = smum_send_msg_to_smc(hwmgr,
PPSMC_MSG_GetGfxBusy,
&activity_percent);
if (!ret)
activity_percent = activity_percent > 100 ? 100 : activity_percent;
else
return -EIO;
*((uint32_t *)value) = activity_percent;
return 0;
} else {
return -EOPNOTSUPP;
}
default: default:
ret = -EOPNOTSUPP; ret = -EOPNOTSUPP;
break; break;
......
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