On 02/13/2017 05:13 PM, Deucher, Alexander wrote: >> -----Original Message----- >> From: amd-gfx [mailto:amd-gfx-bounces at lists.freedesktop.org] On Behalf >> Of Samuel Pitoiset >> Sent: Monday, February 13, 2017 5:02 PM >> To: amd-gfx at lists.freedesktop.org >> Cc: Samuel Pitoiset >> Subject: [PATCH 1/2] drm/amdgpu: implement read_sensor() for pre- >> powerplay chips >> >> Currently, only the GPU temperature, the shader clock and >> eventually the memory clock are implemented. The main goal >> is to expose this info to the userspace like Radeon. >> >> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com> >> --- >> drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 4 +++- >> drivers/gpu/drm/amd/amdgpu/ci_dpm.c | 26 +++++++++++++++++++++ >> drivers/gpu/drm/amd/amdgpu/kv_dpm.c | 34 >> +++++++++++++++++++++++++++ >> drivers/gpu/drm/amd/amdgpu/si_dpm.c | 41 >> +++++++++++++++++++++++++++++++++ >> 4 files changed, 104 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h >> b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h >> index 98698dcf15c7..f1876808ff58 100644 >> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h >> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h >> @@ -270,6 +270,8 @@ struct amdgpu_dpm_funcs { >> struct amdgpu_ps *cps, >> struct amdgpu_ps *rps, >> bool *equal); >> + int (*read_sensor)(struct amdgpu_device *adev, int idx, void *value, >> + int *size); >> >> struct amd_vce_state* (*get_vce_clock_state)(struct >> amdgpu_device *adev, unsigned idx); >> int (*reset_power_profile_state)(struct amdgpu_device *adev, >> @@ -293,7 +295,7 @@ struct amdgpu_dpm_funcs { >> #define amdgpu_dpm_read_sensor(adev, idx, value, size) \ >> ((adev)->pp_enabled ? \ >> (adev)->powerplay.pp_funcs->read_sensor(adev- >>> powerplay.pp_handle, (idx), (value), (size)) : \ >> - -EINVAL) >> + (adev)->pm.funcs->read_sensor((adev), (idx), (value), >> (size))) >> >> #define amdgpu_dpm_get_temperature(adev) \ >> ((adev)->pp_enabled ? \ >> diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c >> b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c >> index 578878d1d4c0..e3a06d6d9e99 100644 >> --- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c >> +++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c >> @@ -6936,6 +6936,31 @@ static int ci_dpm_switch_power_profile(struct >> amdgpu_device *adev, >> return 0; >> } >> >> +static int ci_dpm_read_sensor(struct amdgpu_device *adev, int idx, >> + void *value, int *size) >> +{ >> + /* size must be at least 4 bytes for all sensors */ >> + if (*size < 4) >> + return -EINVAL; >> + >> + switch (idx) { >> + case AMDGPU_PP_SENSOR_GFX_SCLK: >> + *((uint32_t *)value) = ci_get_average_sclk_freq(adev); >> + *size = 4; >> + return 0; >> + case AMDGPU_PP_SENSOR_GFX_MCLK: >> + *((uint32_t *)value) = ci_get_average_mclk_freq(adev); >> + *size = 4; >> + return 0; >> + case AMDGPU_PP_SENSOR_GPU_TEMP: >> + *((uint32_t *)value) = ci_dpm_get_temp(adev); >> + *size = 4; >> + return 0; > > While you are here you could add AMDGPU_PP_SENSOR_GPU_LOAD. See ci_dpm_debugfs_print_current_performance_level() for the activity percent calculations. > > Either way: > Reviewed-by: Alex Deucher <alexander.deucher at amd.com> Once these land I can submit a patch to extend umr to read them. Right now I only track sensors from ST/CZ and VI hardware. Tom