drm/radeon: Add sclk frequency as hwmon sensor
Subsystems (2)
PATCH 1/2 drm/radeon: Add sclk frequency as hwmon sensor
This patch series adds support for reporting sclk and vddc values for Radeon GPUs, where supported.
--- drivers/gpu/drm/radeon/radeon_pm.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_pm.c +28 -1
@@ -712,6 +712,31 @@ static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, radeon_hwmon_get_pwm1_ static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, radeon_hwmon_get_pwm1_min, NULL, 0); static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, radeon_hwmon_get_pwm1_max, NULL, 0); +static ssize_t radeon_hwmon_show_sclk (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct radeon_device *rdev =dev_get_drvdata (dev); +struct drm_device *ddev = rdev->ddev; +u32 sclk =0 ; + +/* Can't get clock frequency 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_sclk) + sclk =radeon_dpm_get_current_sclk (rdev); + +/* Value returned by dpm is in 10 KHz units, need to convert it into Hz +for hwmon */ + sclk *=10000 ; + +return snprintf (buf,PAGE_SIZE ,"%u\n" , sclk); +} + +static SENSOR_DEVICE_ATTR(freq1_input, S_IRUGO, radeon_hwmon_show_sclk, NULL, + 0); +static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_temp1_input.dev_attr.attr,
@@ -721,6 +746,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_freq1_input.dev_attr.attr, NULL };
@@ -738,7 +764,8 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, attr == &sensor_dev_attr_pwm1.dev_attr.attr || attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || - attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) + attr == &sensor_dev_attr_pwm1_min.dev_attr.attr || + attr == &sensor_dev_attr_freq1_input.dev_attr.attr)) return 0;/* Skip fan attributes if fan is not present */
--
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 2 lines · Sandeep Raghuraman
This patch series adds support for reporting sclk and vddc values for Radeon GPUs, where supported.
This commit message should be specific to this particular patch rather than the series. You could probably expose mclk as well.
Alex
Quoted 61 lines
Signed-off-by Sandeep Raghuraman <[email protected]>--- drivers/gpu/drm/radeon/radeon_pm.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)drivers/gpu/drm/radeon/radeon_pm.c +28
-2@@ -712,6 +712,31 @@ static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, radeon_hwmon_get_pwm1_ static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, radeon_hwmon_get_pwm1_min, NULL, 0); static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, radeon_hwmon_get_pwm1_max, NULL, 0); +static ssize_t radeon_hwmon_show_sclk (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct radeon_device *rdev =dev_get_drvdata (dev); +struct drm_device *ddev = rdev->ddev; +u32 sclk =0 ; + +/* Can't get clock frequency 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_sclk) + sclk =radeon_dpm_get_current_sclk (rdev); + +/* Value returned by dpm is in 10 KHz units, need to convert it into Hz +for hwmon */ + sclk *=10000 ; + +return snprintf (buf,PAGE_SIZE ,"%u\n" , sclk); +} + +static SENSOR_DEVICE_ATTR(freq1_input, S_IRUGO, radeon_hwmon_show_sclk, NULL, + 0); +static struct attribute *hwmon_attributes[] = { &sensor_dev_attr_temp1_input.dev_attr.attr,@@ -721,6 +746,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_freq1_input.dev_attr.attr, NULL };@@ -738,7 +764,8 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, attr == &sensor_dev_attr_pwm1.dev_attr.attr || attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr || attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || - attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) + attr == &sensor_dev_attr_pwm1_min.dev_attr.attr || + attr == &sensor_dev_attr_freq1_input.dev_attr.attr)) return 0;/* Skip fan attributes if fan is not present */ --
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
Quoted 10 lines · Alex Deucher
Quoted 2 lines · Sandeep Raghuraman
This patch series adds support for reporting sclk and vddc values for Radeon GPUs, where supported.
This commit message should be specific to this particular patch rather than the series. You could probably expose mclk as well.
Alex
I only have a Radeon iGPU, and don't have a Radeon dGPU to test with, so that's why I didn't wire up mclk.
Yours sincerely,
Sandeep
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 8 lines · Sandeep Raghuraman
Quoted 4 lines · Alex Deucher
Quoted 2 lines · Sandeep Raghuraman
This patch series adds support for reporting sclk and vddc values for Radeon GPUs, where supported.
Quoted 8 lines
Quoted 6 lines
This commit message should be specific to this particular patch rather than the series. You could probably expose mclk as well.
Alex
I only have a Radeon iGPU, and don't have a Radeon dGPU to test with, so that's why I didn't wire up mclk.
Well, there is still an mclk, it's just the speed of your memory.
Alex
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel