aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon_pm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_pm.c')
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c49
1 files changed, 12 insertions, 37 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index d1385ccc672c..dc75bb603ea5 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)
@@ -566,23 +565,14 @@ static ssize_t radeon_hwmon_show_temp_thresh(struct device *dev,
566 return snprintf(buf, PAGE_SIZE, "%d\n", temp); 565 return snprintf(buf, PAGE_SIZE, "%d\n", temp);
567} 566}
568 567
569static 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
576static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0); 568static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0);
577static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0); 569static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0);
578static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1); 570static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1);
579static SENSOR_DEVICE_ATTR(name, S_IRUGO, radeon_hwmon_show_name, NULL, 0);
580 571
581static struct attribute *hwmon_attributes[] = { 572static struct attribute *hwmon_attributes[] = {
582 &sensor_dev_attr_temp1_input.dev_attr.attr, 573 &sensor_dev_attr_temp1_input.dev_attr.attr,
583 &sensor_dev_attr_temp1_crit.dev_attr.attr, 574 &sensor_dev_attr_temp1_crit.dev_attr.attr,
584 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, 575 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
585 &sensor_dev_attr_name.dev_attr.attr,
586 NULL 576 NULL
587}; 577};
588 578
@@ -607,11 +597,15 @@ static const struct attribute_group hwmon_attrgroup = {
607 .is_visible = hwmon_attributes_visible, 597 .is_visible = hwmon_attributes_visible,
608}; 598};
609 599
600static const struct attribute_group *hwmon_groups[] = {
601 &hwmon_attrgroup,
602 NULL
603};
604
610static int radeon_hwmon_init(struct radeon_device *rdev) 605static int radeon_hwmon_init(struct radeon_device *rdev)
611{ 606{
612 int err = 0; 607 int err = 0;
613 608 struct device *hwmon_dev;
614 rdev->pm.int_hwmon_dev = NULL;
615 609
616 switch (rdev->pm.int_thermal_type) { 610 switch (rdev->pm.int_thermal_type) {
617 case THERMAL_TYPE_RV6XX: 611 case THERMAL_TYPE_RV6XX:
@@ -624,20 +618,13 @@ static int radeon_hwmon_init(struct radeon_device *rdev)
624 case THERMAL_TYPE_KV: 618 case THERMAL_TYPE_KV:
625 if (rdev->asic->pm.get_temperature == NULL) 619 if (rdev->asic->pm.get_temperature == NULL)
626 return err; 620 return err;
627 rdev->pm.int_hwmon_dev = hwmon_device_register(rdev->dev); 621 hwmon_dev = hwmon_device_register_with_groups(rdev->dev,
628 if (IS_ERR(rdev->pm.int_hwmon_dev)) { 622 "radeon", rdev,
629 err = PTR_ERR(rdev->pm.int_hwmon_dev); 623 hwmon_groups);
624 if (IS_ERR(hwmon_dev)) {
625 err = PTR_ERR(hwmon_dev);
630 dev_err(rdev->dev, 626 dev_err(rdev->dev,
631 "Unable to register hwmon device: %d\n", err); 627 "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 } 628 }
642 break; 629 break;
643 default: 630 default:
@@ -647,14 +634,6 @@ static int radeon_hwmon_init(struct radeon_device *rdev)
647 return err; 634 return err;
648} 635}
649 636
650static 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
658static void radeon_dpm_thermal_work_handler(struct work_struct *work) 637static void radeon_dpm_thermal_work_handler(struct work_struct *work)
659{ 638{
660 struct radeon_device *rdev = 639 struct radeon_device *rdev =
@@ -1337,8 +1316,6 @@ static void radeon_pm_fini_old(struct radeon_device *rdev)
1337 1316
1338 if (rdev->pm.power_state) 1317 if (rdev->pm.power_state)
1339 kfree(rdev->pm.power_state); 1318 kfree(rdev->pm.power_state);
1340
1341 radeon_hwmon_fini(rdev);
1342} 1319}
1343 1320
1344static void radeon_pm_fini_dpm(struct radeon_device *rdev) 1321static void radeon_pm_fini_dpm(struct radeon_device *rdev)
@@ -1358,8 +1335,6 @@ static void radeon_pm_fini_dpm(struct radeon_device *rdev)
1358 1335
1359 if (rdev->pm.power_state) 1336 if (rdev->pm.power_state)
1360 kfree(rdev->pm.power_state); 1337 kfree(rdev->pm.power_state);
1361
1362 radeon_hwmon_fini(rdev);
1363} 1338}
1364 1339
1365void radeon_pm_fini(struct radeon_device *rdev) 1340void radeon_pm_fini(struct radeon_device *rdev)