diff options
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_pm.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_pm.c | 55 |
1 files changed, 14 insertions, 41 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c index d1385ccc672c..984097b907ef 100644 --- a/drivers/gpu/drm/radeon/radeon_pm.c +++ b/drivers/gpu/drm/radeon/radeon_pm.c | |||
@@ -537,8 +537,7 @@ static ssize_t radeon_hwmon_show_temp(struct device *dev, | |||
537 | struct device_attribute *attr, | 537 | struct device_attribute *attr, |
538 | char *buf) | 538 | char *buf) |
539 | { | 539 | { |
540 | struct drm_device *ddev = dev_get_drvdata(dev); | 540 | struct radeon_device *rdev = dev_get_drvdata(dev); |
541 | struct radeon_device *rdev = ddev->dev_private; | ||
542 | int temp; | 541 | int temp; |
543 | 542 | ||
544 | if (rdev->asic->pm.get_temperature) | 543 | if (rdev->asic->pm.get_temperature) |
@@ -553,8 +552,7 @@ static ssize_t radeon_hwmon_show_temp_thresh(struct device *dev, | |||
553 | struct device_attribute *attr, | 552 | struct device_attribute *attr, |
554 | char *buf) | 553 | char *buf) |
555 | { | 554 | { |
556 | struct drm_device *ddev = dev_get_drvdata(dev); | 555 | struct radeon_device *rdev = dev_get_drvdata(dev); |
557 | struct radeon_device *rdev = ddev->dev_private; | ||
558 | int hyst = to_sensor_dev_attr(attr)->index; | 556 | int hyst = to_sensor_dev_attr(attr)->index; |
559 | int temp; | 557 | int temp; |
560 | 558 | ||
@@ -566,23 +564,14 @@ static ssize_t radeon_hwmon_show_temp_thresh(struct device *dev, | |||
566 | return snprintf(buf, PAGE_SIZE, "%d\n", temp); | 564 | return snprintf(buf, PAGE_SIZE, "%d\n", temp); |
567 | } | 565 | } |
568 | 566 | ||
569 | static ssize_t radeon_hwmon_show_name(struct device *dev, | ||
570 | struct device_attribute *attr, | ||
571 | char *buf) | ||
572 | { | ||
573 | return sprintf(buf, "radeon\n"); | ||
574 | } | ||
575 | |||
576 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0); | 567 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0); |
577 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0); | 568 | static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0); |
578 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1); | 569 | static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1); |
579 | static SENSOR_DEVICE_ATTR(name, S_IRUGO, radeon_hwmon_show_name, NULL, 0); | ||
580 | 570 | ||
581 | static struct attribute *hwmon_attributes[] = { | 571 | static struct attribute *hwmon_attributes[] = { |
582 | &sensor_dev_attr_temp1_input.dev_attr.attr, | 572 | &sensor_dev_attr_temp1_input.dev_attr.attr, |
583 | &sensor_dev_attr_temp1_crit.dev_attr.attr, | 573 | &sensor_dev_attr_temp1_crit.dev_attr.attr, |
584 | &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, | 574 | &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, |
585 | &sensor_dev_attr_name.dev_attr.attr, | ||
586 | NULL | 575 | NULL |
587 | }; | 576 | }; |
588 | 577 | ||
@@ -590,8 +579,7 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, | |||
590 | struct attribute *attr, int index) | 579 | struct attribute *attr, int index) |
591 | { | 580 | { |
592 | struct device *dev = container_of(kobj, struct device, kobj); | 581 | struct device *dev = container_of(kobj, struct device, kobj); |
593 | struct drm_device *ddev = dev_get_drvdata(dev); | 582 | struct radeon_device *rdev = dev_get_drvdata(dev); |
594 | struct radeon_device *rdev = ddev->dev_private; | ||
595 | 583 | ||
596 | /* Skip limit attributes if DPM is not enabled */ | 584 | /* Skip limit attributes if DPM is not enabled */ |
597 | if (rdev->pm.pm_method != PM_METHOD_DPM && | 585 | if (rdev->pm.pm_method != PM_METHOD_DPM && |
@@ -607,11 +595,15 @@ static const struct attribute_group hwmon_attrgroup = { | |||
607 | .is_visible = hwmon_attributes_visible, | 595 | .is_visible = hwmon_attributes_visible, |
608 | }; | 596 | }; |
609 | 597 | ||
598 | static const struct attribute_group *hwmon_groups[] = { | ||
599 | &hwmon_attrgroup, | ||
600 | NULL | ||
601 | }; | ||
602 | |||
610 | static int radeon_hwmon_init(struct radeon_device *rdev) | 603 | static int radeon_hwmon_init(struct radeon_device *rdev) |
611 | { | 604 | { |
612 | int err = 0; | 605 | int err = 0; |
613 | 606 | struct device *hwmon_dev; | |
614 | rdev->pm.int_hwmon_dev = NULL; | ||
615 | 607 | ||
616 | switch (rdev->pm.int_thermal_type) { | 608 | switch (rdev->pm.int_thermal_type) { |
617 | case THERMAL_TYPE_RV6XX: | 609 | case THERMAL_TYPE_RV6XX: |
@@ -624,20 +616,13 @@ static int radeon_hwmon_init(struct radeon_device *rdev) | |||
624 | case THERMAL_TYPE_KV: | 616 | case THERMAL_TYPE_KV: |
625 | if (rdev->asic->pm.get_temperature == NULL) | 617 | if (rdev->asic->pm.get_temperature == NULL) |
626 | return err; | 618 | return err; |
627 | rdev->pm.int_hwmon_dev = hwmon_device_register(rdev->dev); | 619 | hwmon_dev = hwmon_device_register_with_groups(rdev->dev, |
628 | if (IS_ERR(rdev->pm.int_hwmon_dev)) { | 620 | "radeon", rdev, |
629 | err = PTR_ERR(rdev->pm.int_hwmon_dev); | 621 | hwmon_groups); |
622 | if (IS_ERR(hwmon_dev)) { | ||
623 | err = PTR_ERR(hwmon_dev); | ||
630 | dev_err(rdev->dev, | 624 | dev_err(rdev->dev, |
631 | "Unable to register hwmon device: %d\n", err); | 625 | "Unable to register hwmon device: %d\n", err); |
632 | break; | ||
633 | } | ||
634 | dev_set_drvdata(rdev->pm.int_hwmon_dev, rdev->ddev); | ||
635 | err = sysfs_create_group(&rdev->pm.int_hwmon_dev->kobj, | ||
636 | &hwmon_attrgroup); | ||
637 | if (err) { | ||
638 | dev_err(rdev->dev, | ||
639 | "Unable to create hwmon sysfs file: %d\n", err); | ||
640 | hwmon_device_unregister(rdev->dev); | ||
641 | } | 626 | } |
642 | break; | 627 | break; |
643 | default: | 628 | default: |
@@ -647,14 +632,6 @@ static int radeon_hwmon_init(struct radeon_device *rdev) | |||
647 | return err; | 632 | return err; |
648 | } | 633 | } |
649 | 634 | ||
650 | static void radeon_hwmon_fini(struct radeon_device *rdev) | ||
651 | { | ||
652 | if (rdev->pm.int_hwmon_dev) { | ||
653 | sysfs_remove_group(&rdev->pm.int_hwmon_dev->kobj, &hwmon_attrgroup); | ||
654 | hwmon_device_unregister(rdev->pm.int_hwmon_dev); | ||
655 | } | ||
656 | } | ||
657 | |||
658 | static void radeon_dpm_thermal_work_handler(struct work_struct *work) | 635 | static void radeon_dpm_thermal_work_handler(struct work_struct *work) |
659 | { | 636 | { |
660 | struct radeon_device *rdev = | 637 | struct radeon_device *rdev = |
@@ -1337,8 +1314,6 @@ static void radeon_pm_fini_old(struct radeon_device *rdev) | |||
1337 | 1314 | ||
1338 | if (rdev->pm.power_state) | 1315 | if (rdev->pm.power_state) |
1339 | kfree(rdev->pm.power_state); | 1316 | kfree(rdev->pm.power_state); |
1340 | |||
1341 | radeon_hwmon_fini(rdev); | ||
1342 | } | 1317 | } |
1343 | 1318 | ||
1344 | static void radeon_pm_fini_dpm(struct radeon_device *rdev) | 1319 | static void radeon_pm_fini_dpm(struct radeon_device *rdev) |
@@ -1358,8 +1333,6 @@ static void radeon_pm_fini_dpm(struct radeon_device *rdev) | |||
1358 | 1333 | ||
1359 | if (rdev->pm.power_state) | 1334 | if (rdev->pm.power_state) |
1360 | kfree(rdev->pm.power_state); | 1335 | kfree(rdev->pm.power_state); |
1361 | |||
1362 | radeon_hwmon_fini(rdev); | ||
1363 | } | 1336 | } |
1364 | 1337 | ||
1365 | void radeon_pm_fini(struct radeon_device *rdev) | 1338 | void radeon_pm_fini(struct radeon_device *rdev) |