drm/radeon: Add vddc hwmon sensor
Subsystems (2)
PATCH 2/2 drm/radeon: Add vddc hwmon sensor
--- drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_asic.c | 1 + drivers/gpu/drm/radeon/radeon_asic.h | 1 + drivers/gpu/drm/radeon/radeon_pm.c | 21 +++++++++++++++++++++ drivers/gpu/drm/radeon/sumo_dpm.c | 20 ++++++++++++++++++++ 5 files changed, 44 insertions(+)
drivers/gpu/drm/radeon/radeon.h +1 -0
@@ -1992,6 +1992,7 @@ struct radeon_asic {int (*get_fan_speed_percent)(struct radeon_device *rdev,u32 *speed);u32 (*get_current_sclk)(struct radeon_device *rdev);u32 (*get_current_mclk)(struct radeon_device *rdev); +u16 (*get_current_vddc)(struct radeon_device *rdev); } dpm;/* pageflipping */ struct {
drivers/gpu/drm/radeon/radeon_asic.c +1 -0
@@ -1513,6 +1513,7 @@ static struct radeon_asic sumo_asic = { .force_performance_level = &sumo_dpm_force_performance_level, .get_current_sclk = &sumo_dpm_get_current_sclk, .get_current_mclk = &sumo_dpm_get_current_mclk, + .get_current_vddc = &sumo_dpm_get_current_vddc, }, .pflip = { .page_flip = &evergreen_page_flip,
drivers/gpu/drm/radeon/radeon_asic.h +1 -0
@@ -596,6 +596,7 @@ int sumo_dpm_force_performance_level(struct radeon_device *rdev, enum radeon_dpm_forced_level level);u32 sumo_dpm_get_current_sclk (struct radeon_device *rdev);u32 sumo_dpm_get_current_mclk (struct radeon_device *rdev); +u16 sumo_dpm_get_current_vddc (struct radeon_device *rdev);/* * cayman
drivers/gpu/drm/radeon/radeon_pm.c +21 -0
@@ -737,6 +737,26 @@ static ssize_t radeon_hwmon_show_sclk(struct device *dev, static SENSOR_DEVICE_ATTR(freq1_input, S_IRUGO, radeon_hwmon_show_sclk, NULL, 0); +static ssize_t radeon_hwmon_show_vddc (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct radeon_device *rdev =dev_get_drvdata (dev); +struct drm_device *ddev = rdev->ddev; +u16 vddc =0 ; + +/* Can't get vddc when the card is off */ +if ((rdev->flags &RADEON_IS_PX ) && + (ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; + +if (rdev->asic->dpm.get_current_vddc) + vddc = rdev->asic->dpm.get_current_vddc (rdev); + +return snprintf (buf,PAGE_SIZE ,"%u\n" , vddc); +} + +static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, radeon_hwmon_show_vddc, NULL, + 0);static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_temp1_input.dev_attr.attr,
@@ -747,6 +767,7 @@ static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_pwm1_min.dev_attr.attr, &sensor_dev_attr_pwm1_max.dev_attr.attr, &sensor_dev_attr_freq1_input.dev_attr.attr, + &sensor_dev_attr_in0_input.dev_attr.attr, NULL };
drivers/gpu/drm/radeon/sumo_dpm.c +20 -0
@@ -1865,6 +1865,26 @@ u32 sumo_dpm_get_current_mclk(struct radeon_device *rdev)return pi->sys_info.bootup_uma_clk; } +u16 sumo_dpm_get_current_vddc (struct radeon_device *rdev) +{ +struct sumo_power_info *pi =sumo_get_pi (rdev); +struct radeon_ps *rps = &pi->current_rps; +struct sumo_ps *ps =sumo_get_ps (rps); +struct sumo_pl *pl; +u32 current_index = + (RREG32 (TARGET_AND_CURRENT_PROFILE_INDEX ) &CURR_INDEX_MASK ) >> +CURR_INDEX_SHIFT ; + +if (current_index ==BOOST_DPM_LEVEL ) { + pl = &pi->boost_pl; + }else if (current_index >= ps->num_levels) { +return 0 ; + }else { + pl = &ps->levels[current_index]; + } +return sumo_convert_voltage_index_to_value (rdev, pl->vddc_index); +} +void sumo_dpm_fini (struct radeon_device *rdev) {int i;
--
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 1 line · Sandeep Raghuraman
Please add a commit message. Also, split this into 2-3 patches:
1. add the new dpm callback
2. add the sumo implementation of the new callback (could be combined with 1)
3. expose the voltage via hwmon
For the last patch, you probably also want to adjust hwmon_attributes_visible() to hide the voltage on asics which don't have the callback.
Thanks!
Alex
Quoted 116 lines
Signed-off-by Sandeep Raghuraman <[email protected]>--- drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_asic.c | 1 + drivers/gpu/drm/radeon/radeon_asic.h | 1 + drivers/gpu/drm/radeon/radeon_pm.c | 21 +++++++++++++++++++++ drivers/gpu/drm/radeon/sumo_dpm.c | 20 ++++++++++++++++++++ 5 files changed, 44 insertions(+)drivers/gpu/drm/radeon/radeon.h +1
-0@@ -1992,6 +1992,7 @@ struct radeon_asic {int (*get_fan_speed_percent)(struct radeon_device *rdev,u32 *speed);u32 (*get_current_sclk)(struct radeon_device *rdev);u32 (*get_current_mclk)(struct radeon_device *rdev); +u16 (*get_current_vddc)(struct radeon_device *rdev); } dpm;/* pageflipping */ struct {drivers/gpu/drm/radeon/radeon_asic.c +1
-0@@ -1513,6 +1513,7 @@ static struct radeon_asic sumo_asic = { .force_performance_level = &sumo_dpm_force_performance_level, .get_current_sclk = &sumo_dpm_get_current_sclk, .get_current_mclk = &sumo_dpm_get_current_mclk, + .get_current_vddc = &sumo_dpm_get_current_vddc, }, .pflip = { .page_flip = &evergreen_page_flip,drivers/gpu/drm/radeon/radeon_asic.h +1
-0@@ -596,6 +596,7 @@ int sumo_dpm_force_performance_level(struct radeon_device *rdev, enum radeon_dpm_forced_level level);u32 sumo_dpm_get_current_sclk (struct radeon_device *rdev);u32 sumo_dpm_get_current_mclk (struct radeon_device *rdev); +u16 sumo_dpm_get_current_vddc (struct radeon_device *rdev);/* * cayman drivers/gpu/drm/radeon/radeon_pm.c +21
-0@@ -737,6 +737,26 @@ static ssize_t radeon_hwmon_show_sclk(struct device *dev, static SENSOR_DEVICE_ATTR(freq1_input, S_IRUGO, radeon_hwmon_show_sclk, NULL, 0); +static ssize_t radeon_hwmon_show_vddc (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct radeon_device *rdev =dev_get_drvdata (dev); +struct drm_device *ddev = rdev->ddev; +u16 vddc =0 ; + +/* Can't get vddc when the card is off */ +if ((rdev->flags &RADEON_IS_PX ) && + (ddev->switch_power_state !=DRM_SWITCH_POWER_ON )) +return -EINVAL ; + +if (rdev->asic->dpm.get_current_vddc) + vddc = rdev->asic->dpm.get_current_vddc (rdev); + +return snprintf (buf,PAGE_SIZE ,"%u\n" , vddc); +} + +static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, radeon_hwmon_show_vddc, NULL, + 0);static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_temp1_input.dev_attr.attr,@@ -747,6 +767,7 @@ static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_pwm1_min.dev_attr.attr, &sensor_dev_attr_pwm1_max.dev_attr.attr, &sensor_dev_attr_freq1_input.dev_attr.attr, + &sensor_dev_attr_in0_input.dev_attr.attr, NULL };drivers/gpu/drm/radeon/sumo_dpm.c +20
-1@@ -1865,6 +1865,26 @@ u32 sumo_dpm_get_current_mclk(struct radeon_device *rdev)return pi->sys_info.bootup_uma_clk; } +u16 sumo_dpm_get_current_vddc (struct radeon_device *rdev) +{ +struct sumo_power_info *pi =sumo_get_pi (rdev); +struct radeon_ps *rps = &pi->current_rps; +struct sumo_ps *ps =sumo_get_ps (rps); +struct sumo_pl *pl; +u32 current_index = + (RREG32 (TARGET_AND_CURRENT_PROFILE_INDEX ) &CURR_INDEX_MASK ) >> +CURR_INDEX_SHIFT ; + +if (current_index ==BOOST_DPM_LEVEL ) { + pl = &pi->boost_pl; + }else if (current_index >= ps->num_levels) { +return 0 ; + }else { + pl = &ps->levels[current_index]; + } +return sumo_convert_voltage_index_to_value (rdev, pl->vddc_index); +} +void sumo_dpm_fini (struct radeon_device *rdev) {int i; --
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel