drm/amd/powerplay: export a function to read fan rpm
Subsystems (2)
PATCH 1/2 drm/amd/powerplay: export a function to read fan rpm
Powerplay hwmgr already has an implementation, all we need to do is to call it.
--- drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 18 ++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h | 1 + 2 files changed, 19 insertions(+)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +18 -0
@@ -582,6 +582,23 @@ static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed)return hwmgr->hwmgr_func->get_fan_speed_percent (hwmgr, speed); } +static int pp_dpm_get_fan_speed_rpm (void *handle,uint32_t *rpm) +{ +struct pp_hwmgr *hwmgr; + +if (handle ==NULL ) +return -EINVAL ; + + hwmgr = ((struct pp_instance *)handle)->hwmgr; + +PP_CHECK_HW (hwmgr); + +if (hwmgr->hwmgr_func->get_fan_speed_rpm ==NULL ) +return -EINVAL ; + +return hwmgr->hwmgr_func->get_fan_speed_rpm (hwmgr, rpm); +} +static int pp_dpm_get_temperature (void *handle) {struct pp_hwmgr *hwmgr;
@@ -852,6 +869,7 @@ const struct amd_powerplay_funcs pp_dpm_funcs = { .get_fan_control_mode = pp_dpm_get_fan_control_mode, .set_fan_speed_percent = pp_dpm_set_fan_speed_percent, .get_fan_speed_percent = pp_dpm_get_fan_speed_percent, + .get_fan_speed_rpm = pp_dpm_get_fan_speed_rpm, .get_pp_num_states = pp_dpm_get_pp_num_states, .get_pp_table = pp_dpm_get_pp_table, .set_pp_table = pp_dpm_set_pp_table,
drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +1 -0
@@ -349,6 +349,7 @@ struct amd_powerplay_funcs {int (*get_fan_control_mode)(void *handle);int (*set_fan_speed_percent)(void *handle,uint32_t percent);int (*get_fan_speed_percent)(void *handle,uint32_t *speed); +int (*get_fan_speed_rpm)(void *handle,uint32_t *rpm);int (*get_pp_num_states)(void *handle,struct pp_states_info *data);int (*get_pp_table)(void *handle,char **table);int (*set_pp_table)(void *handle,const char *buf,size_t size);
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1477772939-23619-1-git-send-email-notasas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 2/2 drm/amd/amdgpu: expose fan rpm though hwmon
Only for cards that are supported by powerplay.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +5 -0
@@ -317,6 +317,11 @@ struct amdgpu_dpm_funcs { (adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \ (adev)->pm.funcs->get_fan_speed_percent((adev), (s))) +#define amdgpu_dpm_get_fan_speed_rpm (adev, s) \ + ((adev)->pp_enabled ? \ + (adev)->powerplay.pp_funcs->get_fan_speed_rpm((adev)->powerplay.pp_handle, (s)) : \ + -EINVAL) +#define amdgpu_dpm_get_sclk (adev, l) \ ((adev)->pp_enabled ? \ (adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)) : \
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +21 -0
@@ -737,6 +737,21 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,return sprintf (buf,"%i\n" , speed); } +static ssize_t amdgpu_hwmon_get_fan1_input (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct amdgpu_device *adev =dev_get_drvdata (dev); +int err; +u32 speed; + + err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed); +if (err) +return err; + +return sprintf (buf,"%i\n" , speed); +} + static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, amdgpu_hwmon_show_temp, NULL, 0); static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 0); static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 1);
@@ -744,6 +759,7 @@ static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1, amdgpu static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1_enable, amdgpu_hwmon_set_pwm1_enable, 0); static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0); static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, amdgpu_hwmon_get_pwm1_max, NULL, 0); +static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, amdgpu_hwmon_get_fan1_input, NULL, 0);static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_temp1_input.dev_attr.attr,
@@ -753,6 +769,7 @@ static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_pwm1_enable.dev_attr.attr, &sensor_dev_attr_pwm1_min.dev_attr.attr, &sensor_dev_attr_pwm1_max.dev_attr.attr, + &sensor_dev_attr_fan1_input.dev_attr.attr, NULL };
@@ -804,6 +821,10 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; +/* requires powerplay */ +if (attr == &sensor_dev_attr_fan1_input.dev_attr.attr) +return 0 ; +return effective_mode; }
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1477772939-23619-2-git-send-email-notasas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Alex Deucher
AppliedRe: [PATCH 2/2] drm/amd/amdgpu: expose fan rpm though hwmon
Quoted 3 lines · Grazvydas Ignotas
Only for cards that are supported by powerplay.
Signed-off-by Grazvydas Ignotas <[email protected]>
Applied the series. Thanks!
Alex
Quoted 77 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +5
-0@@ -317,6 +317,11 @@ struct amdgpu_dpm_funcs { (adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \ (adev)->pm.funcs->get_fan_speed_percent((adev), (s))) +#define amdgpu_dpm_get_fan_speed_rpm (adev, s) \ + ((adev)->pp_enabled ? \ + (adev)->powerplay.pp_funcs->get_fan_speed_rpm((adev)->powerplay.pp_handle, (s)) : \ + -EINVAL) +#define amdgpu_dpm_get_sclk (adev, l) \ ((adev)->pp_enabled ? \ (adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)) : \drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +21
-1@@ -737,6 +737,21 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,return sprintf (buf,"%i\n" , speed); } +static ssize_t amdgpu_hwmon_get_fan1_input (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct amdgpu_device *adev =dev_get_drvdata (dev); +int err; +u32 speed; + + err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed); +if (err) +return err; + +return sprintf (buf,"%i\n" , speed); +} + static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, amdgpu_hwmon_show_temp, NULL, 0); static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 0); static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 1);@@ -744,6 +759,7 @@ static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1, amdgpu static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1_enable, amdgpu_hwmon_set_pwm1_enable, 0); static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0); static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, amdgpu_hwmon_get_pwm1_max, NULL, 0); +static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, amdgpu_hwmon_get_fan1_input, NULL, 0);static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_temp1_input.dev_attr.attr,@@ -753,6 +769,7 @@ static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_pwm1_enable.dev_attr.attr, &sensor_dev_attr_pwm1_min.dev_attr.attr, &sensor_dev_attr_pwm1_max.dev_attr.attr, + &sensor_dev_attr_fan1_input.dev_attr.attr, NULL };@@ -804,6 +821,10 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))return 0 ; +/* requires powerplay */ +if (attr == &sensor_dev_attr_fan1_input.dev_attr.attr) +return 0 ; +return effective_mode; } --2.7.4
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
Howdy,
Quoted 13 lines · Grazvydas Ignotas
Powerplay hwmgr already has an implementation, all we need to do is to call it.
Signed-off-by Grazvydas Ignotas <[email protected]>--- drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 18 ++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h | 1 + 2 files changed, 19 insertions(+)drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-0
drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed) · line 585
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +1
-0@@ -582,6 +582,23 @@ static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed)return hwmgr->hwmgr_func->get_fan_speed_percent (hwmgr, speed); } +static int pp_dpm_get_fan_speed_rpm (void *handle,uint32_t *rpm)
why not type the handle rather than have 'void *' and a coercion (I didn't check the call site yet..)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed) · line 589
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +4
-0+{ +struct pp_hwmgr *hwmgr; + +if (handle ==NULL )
if (!handle)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed) · line 596
Quoted 7 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +7
-0+return -EINVAL ; + + hwmgr = ((struct pp_instance *)handle)->hwmgr; + +PP_CHECK_HW (hwmgr); + +if (hwmgr->hwmgr_func->get_fan_speed_rpm ==NULL )
if (!hwmgr->hwmgr_func->get_fan_speed_rpm)
Quoted 22 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +6
-0+return -EINVAL ; + +return hwmgr->hwmgr_func->get_fan_speed_rpm (hwmgr, rpm); +} +static int pp_dpm_get_temperature (void *handle) {struct pp_hwmgr *hwmgr;@@ -852,6 +869,7 @@ const struct amd_powerplay_funcs pp_dpm_funcs = { .get_fan_control_mode = pp_dpm_get_fan_control_mode, .set_fan_speed_percent = pp_dpm_set_fan_speed_percent, .get_fan_speed_percent = pp_dpm_get_fan_speed_percent, + .get_fan_speed_rpm = pp_dpm_get_fan_speed_rpm, .get_pp_num_states = pp_dpm_get_pp_num_states, .get_pp_table = pp_dpm_get_pp_table, .set_pp_table = pp_dpm_set_pp_table,drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +0
-0
drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h struct amd_powerplay_funcs { · line 355
Quoted 7 lines
drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +1
-0@@ -349,6 +349,7 @@ struct amd_powerplay_funcs {int (*get_fan_control_mode)(void *handle);int (*set_fan_speed_percent)(void *handle,uint32_t percent);int (*get_fan_speed_percent)(void *handle,uint32_t *speed); +int (*get_fan_speed_rpm)(void *handle,uint32_t *rpm);int (*get_pp_num_states)(void *handle,struct pp_states_info *data);int (*get_pp_table)(void *handle,char **table);int (*set_pp_table)(void *handle,const char *buf,size_t size);
_______________________________________________
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): 85ab550e-ccff-6f0c-9a1e-4a9aa2feaf34-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org
Hi,
Quoted 19 lines · Edward O'Callaghan
Howdy,
Quoted 16 lines · Grazvydas Ignotas
Powerplay hwmgr already has an implementation, all we need to do is to call it.
Signed-off-by Grazvydas Ignotas <[email protected]>--- drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 18 ++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h | 1 + 2 files changed, 19 insertions(+)drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-0@@ -582,6 +582,23 @@ static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed)return hwmgr->hwmgr_func->get_fan_speed_percent (hwmgr, speed); }
Quoted 4 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed) · line 585
Quoted 1 line
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +1
-0+static int pp_dpm_get_fan_speed_rpm (void *handle,uint32_t *rpm)why not type the handle rather than have 'void *' and a coercion (I didn't check the call site yet..)
Well the rest of this file is written in such a style, as well as all the other function pointers having void * handles in the powerplay table, so it would be an odd one standing out from the others. Same thing for the NULL checks.
Quoted 39 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed) · line 589
Quoted 5 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +4
-0+{ +struct pp_hwmgr *hwmgr; + +if (handle ==NULL )if (!handle)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_dpm_get_fan_speed_percent(void *handle, uint32_t *speed) · line 596
Quoted 7 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +7
-0+return -EINVAL ; + + hwmgr = ((struct pp_instance *)handle)->hwmgr; + +PP_CHECK_HW (hwmgr); + +if (hwmgr->hwmgr_func->get_fan_speed_rpm ==NULL )if (!hwmgr->hwmgr_func->get_fan_speed_rpm)
Quoted 21 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +6
-0+return -EINVAL ; + +return hwmgr->hwmgr_func->get_fan_speed_rpm (hwmgr, rpm); +} +static int pp_dpm_get_temperature (void *handle) {struct pp_hwmgr *hwmgr;@@ -852,6 +869,7 @@ const struct amd_powerplay_funcs pp_dpm_funcs = { .get_fan_control_mode = pp_dpm_get_fan_control_mode, .set_fan_speed_percent = pp_dpm_set_fan_speed_percent, .get_fan_speed_percent = pp_dpm_get_fan_speed_percent, + .get_fan_speed_rpm = pp_dpm_get_fan_speed_rpm, .get_pp_num_states = pp_dpm_get_pp_num_states, .get_pp_table = pp_dpm_get_pp_table, .set_pp_table = pp_dpm_set_pp_table,drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +0
-0@@ -349,6 +349,7 @@ struct amd_powerplay_funcs {
Quoted 9 lines
drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h struct amd_powerplay_funcs { · line 355
Quoted 8 lines
drivers/gpu/drm/amd/powerplay/inc/amd_powerplay.h +1
-0int (*get_fan_control_mode)(void *handle);int (*set_fan_speed_percent)(void *handle,uint32_t percent);int (*get_fan_speed_percent)(void *handle,uint32_t *speed); +int (*get_fan_speed_rpm)(void *handle,uint32_t *rpm);int (*get_pp_num_states)(void *handle,struct pp_states_info *data);int (*get_pp_table)(void *handle,char **table);int (*set_pp_table)(void *handle,const char *buf,size_t size);
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx