drm/amdgpu: expose temp and shader/memory clocks
Subsystems (3)
cover drm/amdgpu: expose temp and shader/memory clocks
Hi,
This series exposes the current GPU temperature and the current shader clock (and eventually the memory clock for non-APUs boards). This adds the same functionality as the Radeon driver. The main goal is to expose the info through the GALLIUM_HUD in Mesa.
Alex Deucher suggested to wire-up the read_sensor() interface for pre-powerplay chips. The rest of the series is quite simple.
This has only been tested on Polaris (RX480).
Please review!
Thanks.
Samuel Pitoiset (2):
drm/amdgpu: implement read_sensor() for pre-powerplay chips drm/amdgpu: expose the current temperature and shader/memory clocks
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 27 ++++++++++++++++++++++ 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 +++++++++++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 8 ++++++- 7 files changed, 140 insertions(+), 3 deletions(-)
Signature · 6 lines
2.11.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170213220132.1033-1-samuel.pitoiset-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
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.
--- 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +3 -1
@@ -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 ? \
drivers/gpu/drm/amd/amdgpu/ci_dpm.c +26 -0
@@ -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 ; +default : +return -EINVAL ; + } +} +const struct amd_ip_funcs ci_dpm_ip_funcs = { .name ="ci_dpm" , .early_init = ci_dpm_early_init,
@@ -6982,6 +7007,7 @@ static const struct amdgpu_dpm_funcs ci_dpm_funcs = { .set_power_profile_state = ci_dpm_set_power_profile_state, .reset_power_profile_state = ci_dpm_reset_power_profile_state, .switch_power_profile = ci_dpm_switch_power_profile, + .read_sensor = ci_dpm_read_sensor, };static void ci_dpm_set_dpm_funcs (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/kv_dpm.c +34 -0
@@ -3260,6 +3260,39 @@ static int kv_check_state_equal(struct amdgpu_device *adev,return 0 ; } +static int kv_dpm_read_sensor (struct amdgpu_device *adev,int idx, +void *value,int *size) +{ +struct kv_power_info *pi =kv_get_pi (adev); +uint32_t sclk; +u32 pl_index = + (RREG32_SMC (ixTARGET_AND_CURRENT_PROFILE_INDEX) & +TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX_MASK ) >> +TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX__SHIFT ; + +/* size must be at least 4 bytes for all sensors */ +if (*size <4 ) +return -EINVAL ; + +switch (idx) { +case AMDGPU_PP_SENSOR_GFX_SCLK : +if (pl_index <SMU__NUM_SCLK_DPM_STATE ) { + sclk =be32_to_cpu ( + pi->graphics_level[pl_index].SclkFrequency); + *((uint32_t *)value) = sclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + *((uint32_t *)value) =kv_dpm_get_temp (adev); + *size =4 ; +return 0 ; +default : +return -EINVAL ; + } +} +const struct amd_ip_funcs kv_dpm_ip_funcs = { .name ="kv_dpm" , .early_init = kv_dpm_early_init,
@@ -3292,6 +3325,7 @@ static const struct amdgpu_dpm_funcs kv_dpm_funcs = { .enable_bapm = &kv_dpm_enable_bapm, .get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, + .read_sensor = &kv_dpm_read_sensor, };static void kv_dpm_set_dpm_funcs (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/si_dpm.c +41 -0
53 lines not on this page · raw message
Signature · 6 lines
2.11.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170213220132.1033-2-samuel.pitoiset-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Deucher, Alexander
Reviewed-by Alex DeucherRE: [PATCH 1/2] drm/amdgpu: implement read_sensor() for pre-powerplay chips
Quoted 69 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Samuel Pitoiset
Sent: Monday, February 13, 2017 5:02 PM
To: [email protected]
Cc: Samuel Pitoiset
Subject: [PATCH 1/2] drm/amdgpu: implementread_sensor()for pre- powerplay chipsCurrently, 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 <[email protected]>--- 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(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +2
-0@@ -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);drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +1
-1int (*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)\drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +0
-0((adev)->pp_enabled ? \drivers/gpu/drm/amd/amdgpu/ci_dpm.c +10
-0@@ -6936,6 +6936,31 @@ static int ci_dpm_switch_power_profile(structamdgpu_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);
drivers/gpu/drm/amd/amdgpu/ci_dpm.c static int ci_dpm_switch_power_profile(struct · line 6959
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/ci_dpm.c +10
-0+ *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:
Quoted 143 lines
drivers/gpu/drm/amd/amdgpu/ci_dpm.c +5
-0+default : +return -EINVAL ; + } +} +const struct amd_ip_funcs ci_dpm_ip_funcs = { .name ="ci_dpm" ,drivers/gpu/drm/amd/amdgpu/ci_dpm.c +1
-0.early_init = ci_dpm_early_init,@@ -6982,6 +7007,7 @@ static const struct amdgpu_dpm_funcs ci_dpm_funcs = { .set_power_profile_state = ci_dpm_set_power_profile_state, .reset_power_profile_state = ci_dpm_reset_power_profile_state, .switch_power_profile = ci_dpm_switch_power_profile, + .read_sensor = ci_dpm_read_sensor, };static void
ci_dpm_set_dpm_funcs(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/kv_dpm.c +7
-0@@ -3260,6 +3260,39 @@ static int kv_check_state_equal(structamdgpu_device *adev, return 0; } +static int kv_dpm_read_sensor (struct amdgpu_device *adev,int idx, +void *value,int *size) +{ +struct kv_power_info *pi =kv_get_pi (adev); +uint32_t sclk; +u32 pl_index = + (RREG32_SMC(ixTARGET_AND_CURRENT_PROFILE_INDEX)&
+
TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX_MA
SK) >>
+
TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX__SH
IFT;drivers/gpu/drm/amd/amdgpu/kv_dpm.c +25
-0+ +/* size must be at least 4 bytes for all sensors */ +if (*size <4 ) +return -EINVAL ; + +switch (idx) { +case AMDGPU_PP_SENSOR_GFX_SCLK : +if (pl_index <SMU__NUM_SCLK_DPM_STATE ) { + sclk =be32_to_cpu ( + pi->graphics_level[pl_index].SclkFrequency); + *((uint32_t *)value) = sclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + *((uint32_t *)value) =kv_dpm_get_temp (adev); + *size =4 ; +return 0 ; +default : +return -EINVAL ; + } +} +const struct amd_ip_funcs kv_dpm_ip_funcs = { .name ="kv_dpm" , .early_init = kv_dpm_early_init,@@ -3292,6 +3325,7 @@ static const struct amdgpu_dpm_funcs kv_dpm_funcs = { .enable_bapm = &kv_dpm_enable_bapm, .get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, + .read_sensor = &kv_dpm_read_sensor, };static void
kv_dpm_set_dpm_funcs(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/si_dpm.c +9
-0@@ -7972,6 +7972,46 @@ static int si_check_state_equal(structamdgpu_device *adev, return 0; } +static int si_dpm_read_sensor (struct amdgpu_device *adev,int idx, +void *value,int *size) +{ +struct evergreen_power_info *eg_pi =evergreen_get_pi (adev); +struct amdgpu_ps *rps = &eg_pi->current_rps; +struct si_ps *ps =si_get_ps (rps); +uint32_t sclk, mclk; + u32 pl_index = + (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) &
CURRENT_STATE_INDEX_MASK) >>drivers/gpu/drm/amd/amdgpu/si_dpm.c +32
-0+CURRENT_STATE_INDEX_SHIFT ; + +/* size must be at least 4 bytes for all sensors */ +if (*size <4 ) +return -EINVAL ; + +switch (idx) { +case AMDGPU_PP_SENSOR_GFX_SCLK : +if (pl_index < ps->performance_level_count) { + sclk = ps->performance_levels[pl_index].sclk; + *((uint32_t *)value) = sclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GFX_MCLK : +if (pl_index < ps->performance_level_count) { + mclk = ps->performance_levels[pl_index].mclk; + *((uint32_t *)value) = mclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + *((uint32_t *)value) =si_dpm_get_temp (adev); + *size =4 ; +return 0 ; +default : +return -EINVAL ; + } +}const struct amd_ip_funcs si_dpm_ip_funcs = { .name ="si_dpm" ,@@ -8008,6 +8048,7 @@ static const struct amdgpu_dpm_funcs si_dpm_funcs = { .get_fan_speed_percent = &si_dpm_get_fan_speed_percent, .check_state_equal = &si_check_state_equal, .get_vce_clock_state = amdgpu_get_vce_clock_state, + .read_sensor = &si_dpm_read_sensor, };static void
si_dpm_set_dpm_funcs(struct amdgpu_device *adev)
--
2.11.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BN6PR12MB1652044A168BA6F29943A2C3F7590-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 1/2] drm/amdgpu: implement read_sensor() for pre-powerplay chips
Quoted 82 lines · Alexander
Quoted 69 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Samuel Pitoiset
Sent: Monday, February 13, 2017 5:02 PM
To: [email protected]
Cc: Samuel Pitoiset
Subject: [PATCH 1/2] drm/amdgpu: implementread_sensor()for pre- powerplay chipsCurrently, 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 <[email protected]>--- 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(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +2
-0@@ -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);drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +1
-1int (*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)\drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +0
-0((adev)->pp_enabled ? \drivers/gpu/drm/amd/amdgpu/ci_dpm.c +10
-0@@ -6936,6 +6936,31 @@ static int ci_dpm_switch_power_profile(structamdgpu_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);drivers/gpu/drm/amd/amdgpu/ci_dpm.c static int ci_dpm_switch_power_profile(struct · line 6959
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/ci_dpm.c +10
-0+ *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. Seeci_dpm_debugfs_print_current_performance_level()for the activity percent calculations.
Quoted 2 lines
Either way:
Reviewed-by Alex Deucher <[email protected]>
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
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 1/2] drm/amdgpu: implement read_sensor() for pre-powerplay chips
In reply to a message not in the archiveHi Samuel,
It would be helpful to modify amdgpu_debugfs_sensor_read() to support dpm based sensors as well. This will let me add it to umr.
If you can swing that in here that would be helpful if not I can submit my own patch when this lands.
Cheers,
Tom
Quoted 183 lines · Samuel Pitoiset
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 <[email protected]>--- 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(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +3
-1@@ -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 ? \drivers/gpu/drm/amd/amdgpu/ci_dpm.c +26
-0@@ -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 ; +default : +return -EINVAL ; + } +} +const struct amd_ip_funcs ci_dpm_ip_funcs = { .name ="ci_dpm" , .early_init = ci_dpm_early_init,@@ -6982,6 +7007,7 @@ static const struct amdgpu_dpm_funcs ci_dpm_funcs = { .set_power_profile_state = ci_dpm_set_power_profile_state, .reset_power_profile_state = ci_dpm_reset_power_profile_state, .switch_power_profile = ci_dpm_switch_power_profile, + .read_sensor = ci_dpm_read_sensor, };static void ci_dpm_set_dpm_funcs (struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/kv_dpm.c +34
-0@@ -3260,6 +3260,39 @@ static int kv_check_state_equal(struct amdgpu_device *adev,return 0 ; } +static int kv_dpm_read_sensor (struct amdgpu_device *adev,int idx, +void *value,int *size) +{ +struct kv_power_info *pi =kv_get_pi (adev); +uint32_t sclk; +u32 pl_index = + (RREG32_SMC (ixTARGET_AND_CURRENT_PROFILE_INDEX) & +TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX_MASK ) >> +TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX__SHIFT ; + +/* size must be at least 4 bytes for all sensors */ +if (*size <4 ) +return -EINVAL ; + +switch (idx) { +case AMDGPU_PP_SENSOR_GFX_SCLK : +if (pl_index <SMU__NUM_SCLK_DPM_STATE ) { + sclk =be32_to_cpu ( + pi->graphics_level[pl_index].SclkFrequency); + *((uint32_t *)value) = sclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + *((uint32_t *)value) =kv_dpm_get_temp (adev); + *size =4 ; +return 0 ; +default : +return -EINVAL ; + } +} +const struct amd_ip_funcs kv_dpm_ip_funcs = { .name ="kv_dpm" , .early_init = kv_dpm_early_init,@@ -3292,6 +3325,7 @@ static const struct amdgpu_dpm_funcs kv_dpm_funcs = { .enable_bapm = &kv_dpm_enable_bapm, .get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, + .read_sensor = &kv_dpm_read_sensor, };static void kv_dpm_set_dpm_funcs (struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/si_dpm.c +40
-0@@ -7972,6 +7972,46 @@ static int si_check_state_equal(struct amdgpu_device *adev,return 0 ; } +static int si_dpm_read_sensor (struct amdgpu_device *adev,int idx, +void *value,int *size) +{ +struct evergreen_power_info *eg_pi =evergreen_get_pi (adev); +struct amdgpu_ps *rps = &eg_pi->current_rps; +struct si_ps *ps =si_get_ps (rps); +uint32_t sclk, mclk; +u32 pl_index = + (RREG32 (TARGET_AND_CURRENT_PROFILE_INDEX ) &CURRENT_STATE_INDEX_MASK ) >> +CURRENT_STATE_INDEX_SHIFT ; + +/* size must be at least 4 bytes for all sensors */ +if (*size <4 ) +return -EINVAL ; + +switch (idx) { +case AMDGPU_PP_SENSOR_GFX_SCLK : +if (pl_index < ps->performance_level_count) { + sclk = ps->performance_levels[pl_index].sclk; + *((uint32_t *)value) = sclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GFX_MCLK : +if (pl_index < ps->performance_level_count) { + mclk = ps->performance_levels[pl_index].mclk; + *((uint32_t *)value) = mclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + *((uint32_t *)value) =si_dpm_get_temp (adev); + *size =4 ; +return 0 ; +default : +return -EINVAL ; + } +}const struct amd_ip_funcs si_dpm_ip_funcs = { .name ="si_dpm" ,
drivers/gpu/drm/amd/amdgpu/si_dpm.c static const struct amdgpu_dpm_funcs si_dpm_funcs = { · line 8054
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/si_dpm.c +1
-0@@ -8008,6 +8048,7 @@ static const struct amdgpu_dpm_funcs si_dpm_funcs = { .get_fan_speed_percent = &si_dpm_get_fan_speed_percent, .check_state_equal = &si_check_state_equal, .get_vce_clock_state = amdgpu_get_vce_clock_state, + .read_sensor = &si_dpm_read_sensor, };static void si_dpm_set_dpm_funcs (struct amdgpu_device *adev)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): f07176a7-6bfe-e98e-7f80-d8f2668d3045-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 1/2] drm/amdgpu: implement read_sensor() for pre-powerplay chips
Quoted 1 line · Tom St Denis
Hi Samuel,
Hi Tom,
Quoted 3 lines
It would be helpful to modify
amdgpu_debugfs_sensor_read()to support dpm based sensors as well. This will let me add it to umr.
You mean removing the sanity check (for powerplay boards)? I can do that in a follow-up patch yes.
Quoted 213 lines
If you can swing that in here that would be helpful if not I can submit my own patch when this lands.
Cheers,
TomQuoted 203 lines · Samuel Pitoiset
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 <[email protected]>--- 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(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +2
-0@@ -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,drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +1
-1@@ -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 ? \drivers/gpu/drm/amd/amdgpu/ci_dpm.c +25
-0@@ -6936,6 +6936,31 @@ static int ci_dpm_switch_power_profile(structamdgpu_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 ; +default : +return -EINVAL ; + } +} +const struct amd_ip_funcs ci_dpm_ip_funcs = { .name ="ci_dpm" ,.early_init =
ci_dpm_early_init,drivers/gpu/drm/amd/amdgpu/ci_dpm.c +1
-0@@ -6982,6 +7007,7 @@ static const struct amdgpu_dpm_funcs ci_dpm_funcs = { .set_power_profile_state = ci_dpm_set_power_profile_state, .reset_power_profile_state = ci_dpm_reset_power_profile_state, .switch_power_profile = ci_dpm_switch_power_profile, + .read_sensor = ci_dpm_read_sensor, };static void
ci_dpm_set_dpm_funcs(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/kv_dpm.c +33
-0@@ -3260,6 +3260,39 @@ static int kv_check_state_equal(structamdgpu_device *adev, return 0; } +static int kv_dpm_read_sensor (struct amdgpu_device *adev,int idx, +void *value,int *size) +{ +struct kv_power_info *pi =kv_get_pi (adev); +uint32_t sclk; +u32 pl_index = + (RREG32_SMC (ixTARGET_AND_CURRENT_PROFILE_INDEX) & +TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX_MASK ) >> +TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX__SHIFT ; + +/* size must be at least 4 bytes for all sensors */ +if (*size <4 ) +return -EINVAL ; + +switch (idx) { +case AMDGPU_PP_SENSOR_GFX_SCLK : +if (pl_index <SMU__NUM_SCLK_DPM_STATE ) { + sclk =be32_to_cpu ( + pi->graphics_level[pl_index].SclkFrequency); + *((uint32_t *)value) = sclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + *((uint32_t *)value) =kv_dpm_get_temp (adev); + *size =4 ; +return 0 ; +default : +return -EINVAL ; + } +} +const struct amd_ip_funcs kv_dpm_ip_funcs = { .name ="kv_dpm" ,.early_init =
kv_dpm_early_init,drivers/gpu/drm/amd/amdgpu/kv_dpm.c +1
-0@@ -3292,6 +3325,7 @@ static const struct amdgpu_dpm_funcs kv_dpm_funcs = { .enable_bapm = &kv_dpm_enable_bapm, .get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, + .read_sensor = &kv_dpm_read_sensor, };static void
kv_dpm_set_dpm_funcs(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/si_dpm.c +9
-0@@ -7972,6 +7972,46 @@ static int si_check_state_equal(structamdgpu_device *adev, return 0; } +static int si_dpm_read_sensor (struct amdgpu_device *adev,int idx, +void *value,int *size) +{ +struct evergreen_power_info *eg_pi =evergreen_get_pi (adev); +struct amdgpu_ps *rps = &eg_pi->current_rps; +struct si_ps *ps =si_get_ps (rps); +uint32_t sclk, mclk; + u32 pl_index = + (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) &
CURRENT_STATE_INDEX_MASK) >>drivers/gpu/drm/amd/amdgpu/si_dpm.c +32
-0+CURRENT_STATE_INDEX_SHIFT ; + +/* size must be at least 4 bytes for all sensors */ +if (*size <4 ) +return -EINVAL ; + +switch (idx) { +case AMDGPU_PP_SENSOR_GFX_SCLK : +if (pl_index < ps->performance_level_count) { + sclk = ps->performance_levels[pl_index].sclk; + *((uint32_t *)value) = sclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GFX_MCLK : +if (pl_index < ps->performance_level_count) { + mclk = ps->performance_levels[pl_index].mclk; + *((uint32_t *)value) = mclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + *((uint32_t *)value) =si_dpm_get_temp (adev); + *size =4 ; +return 0 ; +default : +return -EINVAL ; + } +}const struct amd_ip_funcs si_dpm_ip_funcs = { .name ="si_dpm" ,@@ -8008,6 +8048,7 @@ static const struct amdgpu_dpm_funcs si_dpm_funcs = { .get_fan_speed_percent = &si_dpm_get_fan_speed_percent, .check_state_equal = &si_check_state_equal, .get_vce_clock_state = amdgpu_get_vce_clock_state, + .read_sensor = &si_dpm_read_sensor, };
Quoted 7 lines
Quoted 2 lines
static void
si_dpm_set_dpm_funcs(struct amdgpu_device *adev)_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 924552e4-ed96-af5f-82e9-b1e78b265282-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH 1/2] drm/amdgpu: implement read_sensor() for pre-powerplay chips
Quoted 9 lines · Samuel Pitoiset
Quoted 1 line · Tom St Denis
Hi Samuel,
Hi Tom,
Quoted 1 line
Quoted 5 lines
Quoted 2 lines
It would be helpful to modify
amdgpu_debugfs_sensor_read()to support dpm based sensors as well. This will let me add it to umr.You mean removing the sanity check (for powerplay boards)? I can do that in a follow-up patch yes.
As long as the path to or the pointer for read_sensor is not null.
It's been a while since I looked at the pm code but I wonder if a sanity check is still required even if you use the macro to read the sensor.
Tom
Quoted 216 lines
Quoted 216 lines
If you can swing that in here that would be helpful if not I can submit my own patch when this lands.
Cheers,
TomQuoted 205 lines · Samuel Pitoiset
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 <[email protected]>--- 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(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +2
-0@@ -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)(structamdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +1
-1@@ -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 ? \drivers/gpu/drm/amd/amdgpu/ci_dpm.c +25
-0@@ -6936,6 +6936,31 @@ static int ci_dpm_switch_power_profile(structamdgpu_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 ; +default : +return -EINVAL ; + } +} +const struct amd_ip_funcs ci_dpm_ip_funcs = { .name ="ci_dpm" ,.early_init =
ci_dpm_early_init,drivers/gpu/drm/amd/amdgpu/ci_dpm.c +1
-0@@ -6982,6 +7007,7 @@ static const struct amdgpu_dpm_funcs ci_dpm_funcs = { .set_power_profile_state = ci_dpm_set_power_profile_state, .reset_power_profile_state = ci_dpm_reset_power_profile_state, .switch_power_profile = ci_dpm_switch_power_profile, + .read_sensor = ci_dpm_read_sensor, };static void
ci_dpm_set_dpm_funcs(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/kv_dpm.c +33
-0@@ -3260,6 +3260,39 @@ static int kv_check_state_equal(structamdgpu_device *adev, return 0; } +static int kv_dpm_read_sensor (struct amdgpu_device *adev,int idx, +void *value,int *size) +{ +struct kv_power_info *pi =kv_get_pi (adev); +uint32_t sclk; +u32 pl_index = + (RREG32_SMC (ixTARGET_AND_CURRENT_PROFILE_INDEX) & +TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX_MASK ) >> +TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX__SHIFT ; + +/* size must be at least 4 bytes for all sensors */ +if (*size <4 ) +return -EINVAL ; + +switch (idx) { +case AMDGPU_PP_SENSOR_GFX_SCLK : +if (pl_index <SMU__NUM_SCLK_DPM_STATE ) { + sclk =be32_to_cpu ( + pi->graphics_level[pl_index].SclkFrequency); + *((uint32_t *)value) = sclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + *((uint32_t *)value) =kv_dpm_get_temp (adev); + *size =4 ; +return 0 ; +default : +return -EINVAL ; + } +} +const struct amd_ip_funcs kv_dpm_ip_funcs = { .name ="kv_dpm" ,.early_init =
kv_dpm_early_init,drivers/gpu/drm/amd/amdgpu/kv_dpm.c +1
-0@@ -3292,6 +3325,7 @@ static const struct amdgpu_dpm_funcs kv_dpm_funcs = { .enable_bapm = &kv_dpm_enable_bapm, .get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, + .read_sensor = &kv_dpm_read_sensor, };static void
kv_dpm_set_dpm_funcs(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/si_dpm.c +9
-0@@ -7972,6 +7972,46 @@ static int si_check_state_equal(structamdgpu_device *adev, return 0; } +static int si_dpm_read_sensor (struct amdgpu_device *adev,int idx, +void *value,int *size) +{ +struct evergreen_power_info *eg_pi =evergreen_get_pi (adev); +struct amdgpu_ps *rps = &eg_pi->current_rps; +struct si_ps *ps =si_get_ps (rps); +uint32_t sclk, mclk; + u32 pl_index = + (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) &
CURRENT_STATE_INDEX_MASK) >>drivers/gpu/drm/amd/amdgpu/si_dpm.c +32
-0+CURRENT_STATE_INDEX_SHIFT ; + +/* size must be at least 4 bytes for all sensors */ +if (*size <4 ) +return -EINVAL ; + +switch (idx) { +case AMDGPU_PP_SENSOR_GFX_SCLK : +if (pl_index < ps->performance_level_count) { + sclk = ps->performance_levels[pl_index].sclk; + *((uint32_t *)value) = sclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GFX_MCLK : +if (pl_index < ps->performance_level_count) { + mclk = ps->performance_levels[pl_index].mclk; + *((uint32_t *)value) = mclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + *((uint32_t *)value) =si_dpm_get_temp (adev); + *size =4 ; +return 0 ; +default : +return -EINVAL ; + } +}const struct amd_ip_funcs si_dpm_ip_funcs = { .name ="si_dpm" ,@@ -8008,6 +8048,7 @@ static const struct amdgpu_dpm_funcs si_dpm_funcs = { .get_fan_speed_percent = &si_dpm_get_fan_speed_percent, .check_state_equal = &si_check_state_equal, .get_vce_clock_state = amdgpu_get_vce_clock_state, + .read_sensor = &si_dpm_read_sensor, };
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
static void
si_dpm_set_dpm_funcs(struct amdgpu_device *adev)_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 3ad85db6-0ba2-77c9-6d94-a875efffdabb-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 1/2] drm/amdgpu: implement read_sensor() for pre-powerplay chips
Quoted 13 lines · Tom St Denis
Quoted 12 lines · Samuel Pitoiset
Quoted 1 line · Tom St Denis
Hi Samuel,
Hi Tom,
Quoted 3 lines
It would be helpful to modify
amdgpu_debugfs_sensor_read()to support dpm based sensors as well. This will let me add it to umr.
Quoted 7 lines
Quoted 2 lines
You mean removing the sanity check (for powerplay boards)? I can do that in a follow-up patch yes.
As long as the path to or the pointer for
read_sensoris not null.It's been a while since I looked at the pm code but I wonder if a sanity check is still required even if you use the macro to read the sensor.
Ah yeah, not the function I was thinking of but should be pretty simple I think.
Quoted 228 lines
Tom
Quoted 223 lines
Quoted 223 lines
If you can swing that in here that would be helpful if not I can submit my own patch when this lands.
Cheers,
TomQuoted 205 lines · Samuel Pitoiset
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 <[email protected]>--- 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(-)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +2
-0@@ -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)(structamdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +1
-1@@ -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 ? \drivers/gpu/drm/amd/amdgpu/ci_dpm.c +25
-0@@ -6936,6 +6936,31 @@ static int ci_dpm_switch_power_profile(structamdgpu_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 ; +default : +return -EINVAL ; + } +} +const struct amd_ip_funcs ci_dpm_ip_funcs = { .name ="ci_dpm" ,.early_init =
ci_dpm_early_init,drivers/gpu/drm/amd/amdgpu/ci_dpm.c +1
-0@@ -6982,6 +7007,7 @@ static const struct amdgpu_dpm_funcs ci_dpm_funcs = { .set_power_profile_state = ci_dpm_set_power_profile_state, .reset_power_profile_state = ci_dpm_reset_power_profile_state, .switch_power_profile = ci_dpm_switch_power_profile, + .read_sensor = ci_dpm_read_sensor, };static void
ci_dpm_set_dpm_funcs(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/kv_dpm.c +33
-0@@ -3260,6 +3260,39 @@ static int kv_check_state_equal(structamdgpu_device *adev, return 0; } +static int kv_dpm_read_sensor (struct amdgpu_device *adev,int idx, +void *value,int *size) +{ +struct kv_power_info *pi =kv_get_pi (adev); +uint32_t sclk; +u32 pl_index = + (RREG32_SMC (ixTARGET_AND_CURRENT_PROFILE_INDEX) & +TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX_MASK ) >> +TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX__SHIFT ; + +/* size must be at least 4 bytes for all sensors */ +if (*size <4 ) +return -EINVAL ; + +switch (idx) { +case AMDGPU_PP_SENSOR_GFX_SCLK : +if (pl_index <SMU__NUM_SCLK_DPM_STATE ) { + sclk =be32_to_cpu ( + pi->graphics_level[pl_index].SclkFrequency); + *((uint32_t *)value) = sclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + *((uint32_t *)value) =kv_dpm_get_temp (adev); + *size =4 ; +return 0 ; +default : +return -EINVAL ; + } +} +const struct amd_ip_funcs kv_dpm_ip_funcs = { .name ="kv_dpm" ,.early_init =
kv_dpm_early_init,drivers/gpu/drm/amd/amdgpu/kv_dpm.c +1
-0@@ -3292,6 +3325,7 @@ static const struct amdgpu_dpm_funcs kv_dpm_funcs = { .enable_bapm = &kv_dpm_enable_bapm, .get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, + .read_sensor = &kv_dpm_read_sensor, };static void
kv_dpm_set_dpm_funcs(struct amdgpu_device *adev)drivers/gpu/drm/amd/amdgpu/si_dpm.c +9
-0@@ -7972,6 +7972,46 @@ static int si_check_state_equal(structamdgpu_device *adev, return 0; } +static int si_dpm_read_sensor (struct amdgpu_device *adev,int idx, +void *value,int *size) +{ +struct evergreen_power_info *eg_pi =evergreen_get_pi (adev); +struct amdgpu_ps *rps = &eg_pi->current_rps; +struct si_ps *ps =si_get_ps (rps); +uint32_t sclk, mclk; + u32 pl_index = + (RREG32(TARGET_AND_CURRENT_PROFILE_INDEX) &
CURRENT_STATE_INDEX_MASK) >>drivers/gpu/drm/amd/amdgpu/si_dpm.c +32
-0+CURRENT_STATE_INDEX_SHIFT ; + +/* size must be at least 4 bytes for all sensors */ +if (*size <4 ) +return -EINVAL ; + +switch (idx) { +case AMDGPU_PP_SENSOR_GFX_SCLK : +if (pl_index < ps->performance_level_count) { + sclk = ps->performance_levels[pl_index].sclk; + *((uint32_t *)value) = sclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GFX_MCLK : +if (pl_index < ps->performance_level_count) { + mclk = ps->performance_levels[pl_index].mclk; + *((uint32_t *)value) = mclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + *((uint32_t *)value) =si_dpm_get_temp (adev); + *size =4 ; +return 0 ; +default : +return -EINVAL ; + } +}const struct amd_ip_funcs si_dpm_ip_funcs = { .name ="si_dpm" ,@@ -8008,6 +8048,7 @@ static const struct amdgpu_dpm_funcs si_dpm_funcs = { .get_fan_speed_percent = &si_dpm_get_fan_speed_percent, .check_state_equal = &si_check_state_equal, .get_vce_clock_state = amdgpu_get_vce_clock_state, + .read_sensor = &si_dpm_read_sensor, };Quoted 2 lines
static void
si_dpm_set_dpm_funcs(struct amdgpu_device *adev)_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/amdgpu: expose the current temperature and shader/memory clocks
In reply to a message not in the archiveThe clocks are returned in Mhz and the temperature in millidegrees.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 27 +++++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 8 +++++++- 3 files changed, 36 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -1
@@ -59,9 +59,10 @@* - 3.7.0 - Add support for VCE clock list packet * - 3.8.0 - Add support raster config init in the kernel * - 3.9.0 - Add support for memory query info about VRAM and GTT. +* - 3.10.0 - Add support for clocks/temperature query info. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 9 +#define KMS_DRIVER_MINOR 10#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +27 -0
@@ -241,6 +241,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileuint32_t ui32 =0 ;uint64_t ui64 =0 ;int i, found; +int ui32_size =sizeof (ui32);if (!info->return_size || !info->return_pointer)return -EINVAL ;
@@ -597,6 +598,32 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_filereturn -EINVAL ; } } +case AMDGPU_INFO_CURRENT_GPU_SCLK : +/* get sclk in Mhz */ +if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GFX_SCLK , + (void *)&ui32, &ui32_size)) { + ui32 /=100 ; +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +case AMDGPU_INFO_CURRENT_GPU_MCLK : +/* get mclk in Mhz */ +if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GFX_MCLK , + (void *)&ui32, &ui32_size)) { + ui32 /=100 ; +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +case AMDGPU_INFO_CURRENT_GPU_TEMP : +/* get temperature in millidegrees C */ +if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GPU_TEMP , + (void *)&ui32, &ui32_size)) { +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ;default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->query);return -EINVAL ;
include/uapi/drm/amdgpu_drm.h +7 -1
@@ -532,8 +532,14 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_VBIOS_SIZE 0x1/* Subquery id: Query vbios image */ #define AMDGPU_INFO_VBIOS_IMAGE 0x2 +/* Query the current shader clock */ +#define AMDGPU_INFO_CURRENT_GPU_SCLK 0x1c +/* Query the current memory clock */ +#define AMDGPU_INFO_CURRENT_GPU_MCLK 0x1d +/* Query the current temperature */ +#define AMDGPU_INFO_CURRENT_GPU_TEMP 0x1e/* Query UVD handles */ -#define AMDGPU_INFO_NUM_HANDLES 0x1C +#define AMDGPU_INFO_NUM_HANDLES 0x1f#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
Signature · 6 lines
2.11.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170213220132.1033-3-samuel.pitoiset-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
RE: [PATCH 2/2] drm/amdgpu: expose the current temperature and shader/memory clocks
Quoted 93 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Samuel Pitoiset
Sent: Monday, February 13, 2017 5:02 PM
To: [email protected]
Cc: Samuel Pitoiset
Subject: [PATCH 2/2] drm/amdgpu: expose the current temperature and shader/memory clocksThe clocks are returned in Mhz and the temperature in millidegrees.
Signed-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 27 +++++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 8 +++++++- 3 files changed, 36 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -59,9 +59,10 @@* - 3.7.0 - Add support for VCE clock list packet * - 3.8.0 - Add support raster config init in the kernel * - 3.9.0 - Add support for memory query info about VRAM and GTT. +* - 3.10.0 - Add support for clocks/temperature query info. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 9 +#define KMS_DRIVER_MINOR 10#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0
-0@@ -241,6 +241,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev,void *data, struct
drm_filedrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +22
-0uint32_t ui32 =0 ;uint64_t ui64 =0 ;int i, found; +int ui32_size =sizeof (ui32);if (!info->return_size || !info->return_pointer)return -EINVAL ;@@ -597,6 +598,32 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_filereturn -EINVAL ; } } +case AMDGPU_INFO_CURRENT_GPU_SCLK : +/* get sclk in Mhz */ +if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GFX_SCLK , + (void *)&ui32, &ui32_size)) { + ui32 /=100 ; +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +case AMDGPU_INFO_CURRENT_GPU_MCLK : +/* get mclk in Mhz */ +if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GFX_MCLK , + (void *)&ui32, &ui32_size)) { + ui32 /=100 ; +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +case AMDGPU_INFO_CURRENT_GPU_TEMP : +/* get temperature in millidegrees C */ + if (!amdgpu_dpm_read_sensor(adev,
AMDGPU_PP_SENSOR_GPU_TEMP,drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5
-0+ (void *)&ui32, &ui32_size)) { +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ;default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->query);return -EINVAL ;include/uapi/drm/amdgpu_drm.h +0
-0
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_cs_chunk_data { · line 540
Quoted 9 lines
include/uapi/drm/amdgpu_drm.h +6
-0@@ -532,8 +532,14 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_VBIOS_SIZE 0x1/* Subquery id: Query vbios image */ #define AMDGPU_INFO_VBIOS_IMAGE 0x2 +/* Query the current shader clock */ +#define AMDGPU_INFO_CURRENT_GPU_SCLK 0x1c +/* Query the current memory clock */ +#define AMDGPU_INFO_CURRENT_GPU_MCLK 0x1d +/* Query the current temperature */ +#define AMDGPU_INFO_CURRENT_GPU_TEMP 0x1e
I would suggest adding a single query for power related items. E.g., AMDGPU_INFO_GPU_SENSOR and then add sub-queries for the different things you might want to query (temp, sclk, mclk, gpu load, voltages, etc.). E.g., AMDGPU_INFO_GPU_SENSOR_SCLK, AMDGPU_INFO_GPU_SENSOR_MCLK, etc.
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_cs_chunk_data { · line 542
Quoted 3 lines
include/uapi/drm/amdgpu_drm.h +1
-1/* Query UVD handles */ -#define AMDGPU_INFO_NUM_HANDLES 0x1C +#define AMDGPU_INFO_NUM_HANDLES 0x1f
Can't change an existing query. New ones should be added to the end.
Quoted 10 lines
include/uapi/drm/amdgpu_drm.h +0
-1#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff --2.11.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): BN6PR12MB1652B624BD6BA79E9A7F54F1F7590-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: expose the current temperature and shader/memory clocks
Quoted 96 lines · Alexander
Quoted 96 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Samuel Pitoiset
Sent: Monday, February 13, 2017 5:02 PM
To: [email protected]
Cc: Samuel Pitoiset
Subject: [PATCH 2/2] drm/amdgpu: expose the current temperature and shader/memory clocksThe clocks are returned in Mhz and the temperature in millidegrees.
Signed-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 27 +++++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 8 +++++++- 3 files changed, 36 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -59,9 +59,10 @@* - 3.7.0 - Add support for VCE clock list packet * - 3.8.0 - Add support raster config init in the kernel * - 3.9.0 - Add support for memory query info about VRAM and GTT. +* - 3.10.0 - Add support for clocks/temperature query info. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 9 +#define KMS_DRIVER_MINOR 10#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0
-0@@ -241,6 +241,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev,void *data, struct
drm_filedrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +22
-0uint32_t ui32 =0 ;uint64_t ui64 =0 ;int i, found; +int ui32_size =sizeof (ui32);if (!info->return_size || !info->return_pointer)return -EINVAL ;@@ -597,6 +598,32 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_filereturn -EINVAL ; } } +case AMDGPU_INFO_CURRENT_GPU_SCLK : +/* get sclk in Mhz */ +if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GFX_SCLK , + (void *)&ui32, &ui32_size)) { + ui32 /=100 ; +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +case AMDGPU_INFO_CURRENT_GPU_MCLK : +/* get mclk in Mhz */ +if (!amdgpu_dpm_read_sensor (adev,AMDGPU_PP_SENSOR_GFX_MCLK , + (void *)&ui32, &ui32_size)) { + ui32 /=100 ; +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +case AMDGPU_INFO_CURRENT_GPU_TEMP : +/* get temperature in millidegrees C */ + if (!amdgpu_dpm_read_sensor(adev,
AMDGPU_PP_SENSOR_GPU_TEMP,drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5
-0+ (void *)&ui32, &ui32_size)) { +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ;default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->query);return -EINVAL ;include/uapi/drm/amdgpu_drm.h +0
-0@@ -532,8 +532,14 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_VBIOS_SIZE 0x1/* Subquery id: Query vbios image */ #define AMDGPU_INFO_VBIOS_IMAGE 0x2
Quoted 8 lines
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_cs_chunk_data { · line 540
Quoted 6 lines
include/uapi/drm/amdgpu_drm.h +6
-0+/* Query the current shader clock */ +#define AMDGPU_INFO_CURRENT_GPU_SCLK 0x1c +/* Query the current memory clock */ +#define AMDGPU_INFO_CURRENT_GPU_MCLK 0x1d +/* Query the current temperature */ +#define AMDGPU_INFO_CURRENT_GPU_TEMP 0x1eI would suggest adding a single query for power related items. E.g.,
AMDGPU_INFO_GPU_SENSORand then add sub-queries for the different things you might want to query (temp, sclk, mclk, gpu load, voltages, etc.). E.g.,AMDGPU_INFO_GPU_SENSOR_SCLK,AMDGPU_INFO_GPU_SENSOR_MCLK, etc.
Ok.
Quoted 6 lines
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_cs_chunk_data { · line 542
Quoted 4 lines
include/uapi/drm/amdgpu_drm.h +1
-1/* Query UVD handles */ -#define AMDGPU_INFO_NUM_HANDLES 0x1C +#define AMDGPU_INFO_NUM_HANDLES 0x1fCan't change an existing query. New ones should be added to the end.
I thought this was just the total number of queries... But yeah, I shouldn't break the ABI.
Thanks for reviewing.
Quoted 11 lines
Quoted 11 lines
include/uapi/drm/amdgpu_drm.h +0
-1#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff --2.11.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 1/2 drm/amdgpu: implement read_sensor() for pre-powerplay chips
In reply to a message not in the archiveAdd the GPU temperature, the shader clock and eventually the memory clock (as well as the GPU load on CI). The main goal is to expose this info to the userspace like Radeon.
v2: - add AMDGPU_PP_SENSOR_GPU_LOAD on CI
- update the commit description
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 4 ++- drivers/gpu/drm/amd/amdgpu/ci_dpm.c | 43 +++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/kv_dpm.c | 34 ++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/si_dpm.c | 41 +++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +3 -1
@@ -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 ? \
drivers/gpu/drm/amd/amdgpu/ci_dpm.c +43 -0
55 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/kv_dpm.c +34 -0
@@ -3260,6 +3260,39 @@ static int kv_check_state_equal(struct amdgpu_device *adev,return 0 ; } +static int kv_dpm_read_sensor (struct amdgpu_device *adev,int idx, +void *value,int *size) +{ +struct kv_power_info *pi =kv_get_pi (adev); +uint32_t sclk; +u32 pl_index = + (RREG32_SMC (ixTARGET_AND_CURRENT_PROFILE_INDEX) & +TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX_MASK ) >> +TARGET_AND_CURRENT_PROFILE_INDEX__CURR_SCLK_INDEX__SHIFT ; + +/* size must be at least 4 bytes for all sensors */ +if (*size <4 ) +return -EINVAL ; + +switch (idx) { +case AMDGPU_PP_SENSOR_GFX_SCLK : +if (pl_index <SMU__NUM_SCLK_DPM_STATE ) { + sclk =be32_to_cpu ( + pi->graphics_level[pl_index].SclkFrequency); + *((uint32_t *)value) = sclk; + *size =4 ; +return 0 ; + } +return -EINVAL ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + *((uint32_t *)value) =kv_dpm_get_temp (adev); + *size =4 ; +return 0 ; +default : +return -EINVAL ; + } +} +const struct amd_ip_funcs kv_dpm_ip_funcs = { .name ="kv_dpm" , .early_init = kv_dpm_early_init,
@@ -3292,6 +3325,7 @@ static const struct amdgpu_dpm_funcs kv_dpm_funcs = { .enable_bapm = &kv_dpm_enable_bapm, .get_vce_clock_state = amdgpu_get_vce_clock_state, .check_state_equal = kv_check_state_equal, + .read_sensor = &kv_dpm_read_sensor, };static void kv_dpm_set_dpm_funcs (struct amdgpu_device *adev)
drivers/gpu/drm/amd/amdgpu/si_dpm.c +41 -0
53 lines not on this page · raw message
Signature · 6 lines
2.11.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 2/2 drm/amdgpu: expose the current temperature and shader/memory clocks
In reply to a message not in the archiveThe clocks are returned in Mhz and the temperature in millidegrees.
v2: - add sub-queries for AMDPGU_INFO_GPU_SENSOR_*
- do not break the ABI
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 38 +++++++++++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 12 +++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -1
@@ -59,9 +59,10 @@* - 3.7.0 - Add support for VCE clock list packet * - 3.8.0 - Add support raster config init in the kernel * - 3.9.0 - Add support for memory query info about VRAM and GTT. +* - 3.10.0 - Add support for clocks/temperature query info. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 9 +#define KMS_DRIVER_MINOR 10#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +38 -0
@@ -241,6 +241,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileuint32_t ui32 =0 ;uint64_t ui64 =0 ;int i, found; +int ui32_size =sizeof (ui32);if (!info->return_size || !info->return_pointer)return -EINVAL ;
@@ -597,6 +598,43 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_filereturn -EINVAL ; } } +case AMDGPU_INFO_GPU_SENSOR : { +switch (info->gpu_sensor_info.type) { +case AMDGPU_INFO_GPU_SENSOR_SCLK : +/* get sclk in Mhz */ +if (!amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_GFX_SCLK , + (void *)&ui32, &ui32_size)) { + ui32 /=100 ; +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +case AMDGPU_INFO_GPU_SENSOR_MCLK : +/* get mclk in Mhz */ +if (!amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_GFX_MCLK , + (void *)&ui32, &ui32_size)) { + ui32 /=100 ; +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +case AMDGPU_INFO_GPU_SENSOR_TEMP : +/* get temperature in millidegrees C */ +if (!amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_GPU_TEMP , + (void *)&ui32, &ui32_size)) { +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +default : +DRM_DEBUG_KMS ("Invalid request %d\n" , + info->gpu_sensor_info.type); +return -EINVAL ; + } + }default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->query);return -EINVAL ;
include/uapi/drm/amdgpu_drm.h +12 -0
@@ -534,6 +534,14 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_VBIOS_IMAGE 0x2/* Query UVD handles */ #define AMDGPU_INFO_NUM_HANDLES 0x1C +/* Query GPU sensor related information */ +#define AMDGPU_INFO_GPU_SENSOR 0x1D +/* Query the current shader clock */ +#define AMDGPU_INFO_GPU_SENSOR_SCLK 0x1 +/* Query the current memory clock */ +#define AMDGPU_INFO_GPU_SENSOR_MCLK 0x2 +/* Query the current temperature */ +#define AMDGPU_INFO_GPU_SENSOR_TEMP 0x3#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
@@ -597,6 +605,10 @@ struct drm_amdgpu_info {__u32 type;__u32 offset; } vbios_info; + +struct { +__u32 type; + } gpu_sensor_info; }; };
Signature · 6 lines
2.11.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170214000126.29947-1-samuel.pitoiset-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH v2 2/2] drm/amdgpu: expose the current temperature and shader/memory clocks
Quoted 41 lines · Samuel Pitoiset
The clocks are returned in Mhz and the temperature in millidegrees.
v2: - add sub-queries for AMDPGU_INFO_GPU_SENSOR_*
- do not break the ABISigned-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 38 +++++++++++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 12 +++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -59,9 +59,10 @@* - 3.7.0 - Add support for VCE clock list packet * - 3.8.0 - Add support raster config init in the kernel * - 3.9.0 - Add support for memory query info about VRAM and GTT. +* - 3.10.0 - Add support for clocks/temperature query info. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 9 +#define KMS_DRIVER_MINOR 10#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1
-0@@ -241,6 +241,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileuint32_t ui32 =0 ;uint64_t ui64 =0 ;int i, found; +int ui32_size =sizeof (ui32);if (!info->return_size || !info->return_pointer)return -EINVAL ;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · line 607
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7
-0@@ -597,6 +598,43 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_filereturn -EINVAL ; } } +case AMDGPU_INFO_GPU_SENSOR : { +switch (info->gpu_sensor_info.type) { +case AMDGPU_INFO_GPU_SENSOR_SCLK : +/* get sclk in Mhz */ +if (!amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_GFX_SCLK , + (void *)&ui32, &ui32_size)) {
This will need sanity checks to avoid oops if read_sensor is NULL.
Quoted 54 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +30
-0+ ui32 /=100 ; +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +case AMDGPU_INFO_GPU_SENSOR_MCLK : +/* get mclk in Mhz */ +if (!amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_GFX_MCLK , + (void *)&ui32, &ui32_size)) { + ui32 /=100 ; +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +case AMDGPU_INFO_GPU_SENSOR_TEMP : +/* get temperature in millidegrees C */ +if (!amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_GPU_TEMP , + (void *)&ui32, &ui32_size)) { +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +default : +DRM_DEBUG_KMS ("Invalid request %d\n" , + info->gpu_sensor_info.type); +return -EINVAL ; + } + }default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->query);return -EINVAL ;include/uapi/drm/amdgpu_drm.h +8
-0@@ -534,6 +534,14 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_VBIOS_IMAGE 0x2/* Query UVD handles */ #define AMDGPU_INFO_NUM_HANDLES 0x1C +/* Query GPU sensor related information */ +#define AMDGPU_INFO_GPU_SENSOR 0x1D +/* Query the current shader clock */ +#define AMDGPU_INFO_GPU_SENSOR_SCLK 0x1 +/* Query the current memory clock */ +#define AMDGPU_INFO_GPU_SENSOR_MCLK 0x2 +/* Query the current temperature */ +#define AMDGPU_INFO_GPU_SENSOR_TEMP 0x3#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_info { · line 614
Quoted 10 lines
include/uapi/drm/amdgpu_drm.h +4
-0@@ -597,6 +605,10 @@ struct drm_amdgpu_info {__u32 type;__u32 offset; } vbios_info; + +struct { +__u32 type; + } gpu_sensor_info; }; };
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH v2 2/2] drm/amdgpu: expose the current temperature and shader/memory clocks
In reply to a message not in the archiveQuoted 111 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Samuel Pitoiset
Sent: Monday, February 13, 2017 7:01 PM
To: [email protected]
Cc: Samuel Pitoiset
Subject: [PATCH v2 2/2] drm/amdgpu: expose the current temperature and shader/memory clocksThe clocks are returned in Mhz and the temperature in millidegrees.
v2: - add sub-queries for AMDPGU_INFO_GPU_SENSOR_*
- do not break the ABISigned-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 38 +++++++++++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 12 +++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -59,9 +59,10 @@* - 3.7.0 - Add support for VCE clock list packet * - 3.8.0 - Add support raster config init in the kernel * - 3.9.0 - Add support for memory query info about VRAM and GTT. +* - 3.10.0 - Add support for clocks/temperature query info. */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 9 +#define KMS_DRIVER_MINOR 10#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0
-0@@ -241,6 +241,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev,void *data, struct
drm_filedrivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +17
-0uint32_t ui32 =0 ;uint64_t ui64 =0 ;int i, found; +int ui32_size =sizeof (ui32);if (!info->return_size || !info->return_pointer)return -EINVAL ;@@ -597,6 +598,43 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_filereturn -EINVAL ; } } + case AMDGPU_INFO_GPU_SENSOR: { + switch (info->gpu_sensor_info.type) { + case AMDGPU_INFO_GPU_SENSOR_SCLK: + /* get sclk in Mhz */ + if (!amdgpu_dpm_read_sensor(adev, + AMDGPU_PP_SENSOR_GFX_SCLK, + (void *)&ui32, &ui32_size)) { + ui32 /= 100; + return copy_to_user(out, &ui32, + min(size, 4u)) ? -EFAULT : 0; + } + return -EINVAL; + case AMDGPU_INFO_GPU_SENSOR_MCLK: + /* get mclk in Mhz */ + if (!amdgpu_dpm_read_sensor(adev, +
AMDGPU_PP_SENSOR_GFX_MCLK,drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1
-0+ (void *)&ui32, &ui32_size)){
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +9
-0+ ui32 /=100 ; +return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +case AMDGPU_INFO_GPU_SENSOR_TEMP : +/* get temperature in millidegrees C */ + if (!amdgpu_dpm_read_sensor(adev, +
AMDGPU_PP_SENSOR_GPU_TEMP,drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1
-0+ (void *)&ui32, &ui32_size)){
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +10
-0+return copy_to_user (out, &ui32, +min (size,4u )) ? -EFAULT :0 ; + } +return -EINVAL ; +default : +DRM_DEBUG_KMS ("Invalid request %d\n" , + info->gpu_sensor_info.type); +return -EINVAL ; + } + }default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->query);return -EINVAL ;include/uapi/drm/amdgpu_drm.h +0
-0@@ -534,6 +534,14 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_VBIOS_IMAGE 0x2
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_cs_chunk_data { · line 544
Quoted 10 lines
include/uapi/drm/amdgpu_drm.h +8
-0/* Query UVD handles */ #define AMDGPU_INFO_NUM_HANDLES 0x1C +/* Query GPU sensor related information */ +#define AMDGPU_INFO_GPU_SENSOR 0x1D +/* Query the current shader clock */ +#define AMDGPU_INFO_GPU_SENSOR_SCLK 0x1 +/* Query the current memory clock */ +#define AMDGPU_INFO_GPU_SENSOR_MCLK 0x2 +/* Query the current temperature */ +#define AMDGPU_INFO_GPU_SENSOR_TEMP 0x3
Might as well add the other sensor types as well (VDDGFX, GPU_LOAD, etc.).
Alex
Quoted 17 lines
include/uapi/drm/amdgpu_drm.h +4
-1#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff@@ -597,6 +605,10 @@ struct drm_amdgpu_info {__u32 type;__u32 offset; } vbios_info; + +struct { +__u32 type; + } gpu_sensor_info; }; }; --2.11.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v3 2/2 drm/amdgpu: expose GPU sensor related information
In reply to a message not in the archiveThis includes shader/memory clocks, temperature, GPU load, etc.
v2: - add sub-queries for AMDPGU_INFO_GPU_SENSOR_*
- do not break the ABI
v3: - return -ENOENT when amdgpu_dpm == 0
- expose more sensor queries
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 75 +++++++++++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 20 +++++++++ 3 files changed, 97 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -1
@@ -59,9 +59,10 @@* - 3.7.0 - Add support for VCE clock list packet * - 3.8.0 - Add support raster config init in the kernel * - 3.9.0 - Add support for memory query info about VRAM and GTT. +* - 3.10.0 - Add support for sensor query info (clocks, temp, etc). */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 9 +#define KMS_DRIVER_MINOR 10#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +75 -0
87 lines not on this page · raw message
include/uapi/drm/amdgpu_drm.h +20 -0
@@ -534,6 +534,22 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_VBIOS_IMAGE 0x2/* Query UVD handles */ #define AMDGPU_INFO_NUM_HANDLES 0x1C +/* Query sensor related information */ +#define AMDGPU_INFO_SENSOR 0x1D +/* Subquery id: Query GPU shader clock */ +#define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1 +/* Subquery id: Query GPU memory clock */ +#define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2 +/* Subquery id: Query GPU temperature */ +#define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3 +/* Subquery id: Query GPU load */ +#define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4 +/* Subquery id: Query average GPU power */ +#define AMDGPU_INFO_SENSOR_GPU_POWER 0x5 +/* Subquery id: Query VDDNB */ +#define AMDGPU_INFO_SENSOR_VDDNB 0x6 +/* Subquery id: Query VDDGFX */ +#define AMDGPU_INFO_SENSOR_VDDGFX 0x7#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
@@ -597,6 +613,10 @@ struct drm_amdgpu_info {__u32 type;__u32 offset; } vbios_info; + +struct { +__u32 type; + } sensor_info; }; };
Signature · 6 lines
2.11.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170215191546.27637-1-samuel.pitoiset-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Re: [PATCH v3 2/2] drm/amdgpu: expose GPU sensor related information
Quoted 43 lines · Samuel Pitoiset
This includes shader/memory clocks, temperature, GPU load, etc.
v2: - add sub-queries for AMDPGU_INFO_GPU_SENSOR_*
- do not break the ABI
v3: - return-ENOENTwhenamdgpu_dpm== 0
- expose more sensor queriesSigned-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 75 +++++++++++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 20 +++++++++ 3 files changed, 97 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2
-1@@ -59,9 +59,10 @@* - 3.7.0 - Add support for VCE clock list packet * - 3.8.0 - Add support raster config init in the kernel * - 3.9.0 - Add support for memory query info about VRAM and GTT. +* - 3.10.0 - Add support for sensor query info (clocks, temp, etc). */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 9 +#define KMS_DRIVER_MINOR 10#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1
-0@@ -241,6 +241,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileuint32_t ui32 =0 ;uint64_t ui64 =0 ;int i, found; +int ui32_size =sizeof (ui32);if (!info->return_size || !info->return_pointer)return -EINVAL ;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file · line 605
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +5
-0@@ -597,6 +598,80 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_filereturn -EINVAL ; } } +case AMDGPU_INFO_SENSOR : { +struct pp_gpu_power query = {0 }; +int size =sizeof (query); + +if (amdgpu_dpm !=0 )
if (amdgpu_dpm == 0)
return -ENOENT;
Fixed locally.
Quoted 101 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +69
-0+return -ENOENT ; + +switch (info->sensor_info.type) { +case AMDGPU_INFO_SENSOR_GFX_SCLK : +/* get sclk in Mhz */ +if (amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_GFX_SCLK , + (void *)&ui32, &ui32_size)) { +return -EINVAL ; + } + ui32 /=100 ; +break ; +case AMDGPU_INFO_SENSOR_GFX_MCLK : +/* get mclk in Mhz */ +if (amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_GFX_MCLK , + (void *)&ui32, &ui32_size)) { +return -EINVAL ; + } + ui32 /=100 ; +break ; +case AMDGPU_INFO_SENSOR_GPU_TEMP : +/* get temperature in millidegrees C */ +if (amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_GPU_TEMP , + (void *)&ui32, &ui32_size)) { +return -EINVAL ; + } +break ; +case AMDGPU_INFO_SENSOR_GPU_LOAD : +/* get GPU load */ +if (amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_GPU_LOAD , + (void *)&ui32, &ui32_size)) { +return -EINVAL ; + } +break ; +case AMDGPU_INFO_SENSOR_GPU_POWER : +/* get average GPU power */ +if (amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_GPU_POWER , + (void *)&query, &size)) { +return -EINVAL ; + } + ui32 = query.average_gpu_power >>8 ; +break ; +case AMDGPU_INFO_SENSOR_VDDNB : +/* get VDDNB in millivolts */ +if (amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_VDDNB , + (void *)&ui32, &ui32_size)) { +return -EINVAL ; + } +break ; +case AMDGPU_INFO_SENSOR_VDDGFX : +/* get VDDGFX in millivolts */ +if (amdgpu_dpm_read_sensor (adev, +AMDGPU_PP_SENSOR_VDDGFX , + (void *)&ui32, &ui32_size)) { +return -EINVAL ; + } +break ; +default : +DRM_DEBUG_KMS ("Invalid request %d\n" , + info->sensor_info.type); +return -EINVAL ; + } +return copy_to_user (out, &ui32,min (size,4u )) ? -EFAULT :0 ; + }default :DRM_DEBUG_KMS ("Invalid request %d\n" , info->query);return -EINVAL ;include/uapi/drm/amdgpu_drm.h +16
-0@@ -534,6 +534,22 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_VBIOS_IMAGE 0x2/* Query UVD handles */ #define AMDGPU_INFO_NUM_HANDLES 0x1C +/* Query sensor related information */ +#define AMDGPU_INFO_SENSOR 0x1D +/* Subquery id: Query GPU shader clock */ +#define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1 +/* Subquery id: Query GPU memory clock */ +#define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2 +/* Subquery id: Query GPU temperature */ +#define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3 +/* Subquery id: Query GPU load */ +#define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4 +/* Subquery id: Query average GPU power */ +#define AMDGPU_INFO_SENSOR_GPU_POWER 0x5 +/* Subquery id: Query VDDNB */ +#define AMDGPU_INFO_SENSOR_VDDNB 0x6 +/* Subquery id: Query VDDGFX */ +#define AMDGPU_INFO_SENSOR_VDDGFX 0x7#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
include/uapi/drm/amdgpu_drm.h struct drm_amdgpu_info { · line 622
Quoted 10 lines
include/uapi/drm/amdgpu_drm.h +4
-0@@ -597,6 +613,10 @@ struct drm_amdgpu_info {__u32 type;__u32 offset; } vbios_info; + +struct { +__u32 type; + } sensor_info; }; };
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v4 2/2 drm/amdgpu: expose GPU sensor related information
In reply to a message not in the archiveThis includes shader/memory clocks, temperature, GPU load, etc.
v2: - add sub-queries for AMDPGU_INFO_GPU_SENSOR_*
- do not break the ABI
v3: - return -ENOENT when amdgpu_dpm == 0
- expose more sensor queries
v4: - s/GPU_POWER/GPU_AVG_POWER/
- improve VDDNB/VDDGFX query description
- fix amdgpu_dpm check
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 3 +- drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 75 +++++++++++++++++++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 20 +++++++++ 3 files changed, 97 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -1
@@ -59,9 +59,10 @@* - 3.7.0 - Add support for VCE clock list packet * - 3.8.0 - Add support raster config init in the kernel * - 3.9.0 - Add support for memory query info about VRAM and GTT. +* - 3.10.0 - Add support for sensor query info (clocks, temp, etc). */ #define KMS_DRIVER_MAJOR 3 -#define KMS_DRIVER_MINOR 9 +#define KMS_DRIVER_MINOR 10#define KMS_DRIVER_PATCHLEVEL 0int amdgpu_vram_limit =0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +75 -0
87 lines not on this page · raw message
include/uapi/drm/amdgpu_drm.h +20 -0
@@ -534,6 +534,22 @@ struct drm_amdgpu_cs_chunk_data {#define AMDGPU_INFO_VBIOS_IMAGE 0x2/* Query UVD handles */ #define AMDGPU_INFO_NUM_HANDLES 0x1C +/* Query sensor related information */ +#define AMDGPU_INFO_SENSOR 0x1D +/* Subquery id: Query GPU shader clock */ +#define AMDGPU_INFO_SENSOR_GFX_SCLK 0x1 +/* Subquery id: Query GPU memory clock */ +#define AMDGPU_INFO_SENSOR_GFX_MCLK 0x2 +/* Subquery id: Query GPU temperature */ +#define AMDGPU_INFO_SENSOR_GPU_TEMP 0x3 +/* Subquery id: Query GPU load */ +#define AMDGPU_INFO_SENSOR_GPU_LOAD 0x4 +/* Subquery id: Query average GPU power */ +#define AMDGPU_INFO_SENSOR_GPU_AVG_POWER 0x5 +/* Subquery id: Query northbridge voltage */ +#define AMDGPU_INFO_SENSOR_VDDNB 0x6 +/* Subquery id: Query graphics voltage */ +#define AMDGPU_INFO_SENSOR_VDDGFX 0x7#define AMDGPU_INFO_MMR_SE_INDEX_SHIFT 0#define AMDGPU_INFO_MMR_SE_INDEX_MASK 0xff
@@ -597,6 +613,10 @@ struct drm_amdgpu_info {__u32 type;__u32 offset; } vbios_info; + +struct { +__u32 type; + } sensor_info; }; };
Signature · 6 lines
2.11.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx