hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/gpu/drm/radeon/radeon_pm.c
....@@ -20,14 +20,19 @@
2020 * Authors: Rafał Miłecki <zajec5@gmail.com>
2121 * Alex Deucher <alexdeucher@gmail.com>
2222 */
23
-#include <drm/drmP.h>
24
-#include "radeon.h"
25
-#include "avivod.h"
26
-#include "atom.h"
27
-#include "r600_dpm.h"
28
-#include <linux/power_supply.h>
29
-#include <linux/hwmon.h>
23
+
3024 #include <linux/hwmon-sysfs.h>
25
+#include <linux/hwmon.h>
26
+#include <linux/pci.h>
27
+#include <linux/power_supply.h>
28
+
29
+#include <drm/drm_debugfs.h>
30
+#include <drm/drm_vblank.h>
31
+
32
+#include "atom.h"
33
+#include "avivod.h"
34
+#include "r600_dpm.h"
35
+#include "radeon.h"
3136
3237 #define RADEON_IDLE_LOOP_MS 100
3338 #define RADEON_RECLOCK_DELAY_MS 200
....@@ -707,6 +712,31 @@
707712 static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, radeon_hwmon_get_pwm1_min, NULL, 0);
708713 static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, radeon_hwmon_get_pwm1_max, NULL, 0);
709714
715
+static ssize_t radeon_hwmon_show_sclk(struct device *dev,
716
+ struct device_attribute *attr, char *buf)
717
+{
718
+ struct radeon_device *rdev = dev_get_drvdata(dev);
719
+ struct drm_device *ddev = rdev->ddev;
720
+ u32 sclk = 0;
721
+
722
+ /* Can't get clock frequency when the card is off */
723
+ if ((rdev->flags & RADEON_IS_PX) &&
724
+ (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
725
+ return -EINVAL;
726
+
727
+ if (rdev->asic->dpm.get_current_sclk)
728
+ sclk = radeon_dpm_get_current_sclk(rdev);
729
+
730
+ /* Value returned by dpm is in 10 KHz units, need to convert it into Hz
731
+ for hwmon */
732
+ sclk *= 10000;
733
+
734
+ return snprintf(buf, PAGE_SIZE, "%u\n", sclk);
735
+}
736
+
737
+static SENSOR_DEVICE_ATTR(freq1_input, S_IRUGO, radeon_hwmon_show_sclk, NULL,
738
+ 0);
739
+
710740
711741 static struct attribute *hwmon_attributes[] = {
712742 &sensor_dev_attr_temp1_input.dev_attr.attr,
....@@ -716,6 +746,7 @@
716746 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
717747 &sensor_dev_attr_pwm1_min.dev_attr.attr,
718748 &sensor_dev_attr_pwm1_max.dev_attr.attr,
749
+ &sensor_dev_attr_freq1_input.dev_attr.attr,
719750 NULL
720751 };
721752
....@@ -733,7 +764,8 @@
733764 attr == &sensor_dev_attr_pwm1.dev_attr.attr ||
734765 attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr ||
735766 attr == &sensor_dev_attr_pwm1_max.dev_attr.attr ||
736
- attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))
767
+ attr == &sensor_dev_attr_pwm1_min.dev_attr.attr ||
768
+ attr == &sensor_dev_attr_freq1_input.dev_attr.attr))
737769 return 0;
738770
739771 /* Skip fan attributes if fan is not present */
....@@ -1792,7 +1824,7 @@
17921824 u32 stat_crtc = 0;
17931825 bool in_vbl = radeon_pm_in_vbl(rdev);
17941826
1795
- if (in_vbl == false)
1827
+ if (!in_vbl)
17961828 DRM_DEBUG_DRIVER("not in vbl for pm change %08x at %s\n", stat_crtc,
17971829 finish ? "exit" : "entry");
17981830 return in_vbl;