diff options
| author | Jean Delvare <jdelvare@suse.de> | 2013-09-10 04:32:41 -0400 |
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2013-09-11 11:44:36 -0400 |
| commit | 6ea4e84d209c1b49c90b52efff2ab0b1824619a6 (patch) | |
| tree | 57e39043de3112efa98da0902371ea9394ddc556 | |
| parent | 3e4e21292d0089d4c87b933ab05c67824e940b9e (diff) | |
drm/radeon: expose DPM thermal thresholds through sysfs
The hwmon sysfs interface allows exposing temperature limits. The "max"
and "min" thresholds will be exposed as a critical high limit and its
hysteresis value, respectively. This gives the user a better idea of how
well cooling is doing and whether it is sufficient.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_pm.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c index dea7dcbb3507..33c88c4038cf 100644 --- a/drivers/gpu/drm/radeon/radeon_pm.c +++ b/drivers/gpu/drm/radeon/radeon_pm.c | |||
| @@ -536,6 +536,23 @@ static ssize_t radeon_hwmon_show_temp(struct device *dev, | |||
| 536 | return snprintf(buf, PAGE_SIZE, "%d\n", temp); | 536 | return snprintf(buf, PAGE_SIZE, "%d\n", temp); |
| 537 | } | 537 | } |
| 538 | 538 | ||
| 539 | static ssize_t radeon_hwmon_show_temp_thresh(struct device *dev, | ||
| 540 | struct device_attribute *attr, | ||
| 541 | char *buf) | ||
| 542 | { | ||
| 543 | struct drm_device *ddev = dev_get_drvdata(dev); | ||
| 544 | struct radeon_device *rdev = ddev->dev_private; | ||
| 545 | int hyst = to_sensor_dev_attr(attr)->index; | ||
| 546 | int temp; | ||
| 547 | |||
| 548 | if (hyst) | ||
| 549 | temp = rdev->pm.dpm.thermal.min_temp; | ||
| 550 | else | ||
| 551 | temp = rdev->pm.dpm.thermal.max_temp; | ||
| 552 | |||
| 553 | return snprintf(buf, PAGE_SIZE, "%d\n", temp); | ||
| 554 | } | ||
| 555 | |||
| 539 | static ssize_t radeon_hwmon_show_name(struct device *dev, | 556 | static ssize_t radeon_hwmon_show_name(struct device *dev, |
| 540 | struct device_attribute *attr, | 557 | struct device_attribute *attr, |
| 541 | char *buf) | 558 | char *buf) |
| @@ -544,16 +561,37 @@ static ssize_t radeon_hwmon_show_name(struct device *dev, | |||
| 544 | } | 561 | } |
| 545 | 562 | ||
| 546 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0); | 563 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0); |
| 564 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0); | ||
| 565 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1); | ||
| 547 | static SENSOR_DEVICE_ATTR(name, S_IRUGO, radeon_hwmon_show_name, NULL, 0); | 566 | static SENSOR_DEVICE_ATTR(name, S_IRUGO, radeon_hwmon_show_name, NULL, 0); |
| 548 | 567 | ||
| 549 | static struct attribute *hwmon_attributes[] = { | 568 | static struct attribute *hwmon_attributes[] = { |
| 550 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 569 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
| 570 | &sensor_dev_attr_temp1_crit.dev_attr.attr, | ||
| 571 | &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, | ||
| 551 | &sensor_dev_attr_name.dev_attr.attr, | 572 | &sensor_dev_attr_name.dev_attr.attr, |
| 552 | NULL | 573 | NULL |
| 553 | }; | 574 | }; |
| 554 | 575 | ||
| 576 | static umode_t hwmon_attributes_visible(struct kobject *kobj, | ||
| 577 | struct attribute *attr, int index) | ||
| 578 | { | ||
| 579 | struct device *dev = container_of(kobj, struct device, kobj); | ||
| 580 | struct drm_device *ddev = dev_get_drvdata(dev); | ||
| 581 | struct radeon_device *rdev = ddev->dev_private; | ||
| 582 | |||
| 583 | /* Skip limit attributes if DPM is not enabled */ | ||
| 584 | if (rdev->pm.pm_method != PM_METHOD_DPM && | ||
| 585 | (attr == &sensor_dev_attr_temp1_crit.dev_attr.attr || | ||
| 586 | attr == &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr)) | ||
| 587 | return 0; | ||
| 588 | |||
| 589 | return attr->mode; | ||
| 590 | } | ||
| 591 | |||
| 555 | static const struct attribute_group hwmon_attrgroup = { | 592 | static const struct attribute_group hwmon_attrgroup = { |
| 556 | .attrs = hwmon_attributes, | 593 | .attrs = hwmon_attributes, |
| 594 | .is_visible = hwmon_attributes_visible, | ||
| 557 | }; | 595 | }; |
| 558 | 596 | ||
| 559 | static int radeon_hwmon_init(struct radeon_device *rdev) | 597 | static int radeon_hwmon_init(struct radeon_device *rdev) |
