-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathradeon_extratemps-5.0.patch
177 lines (172 loc) · 7.01 KB
/
radeon_extratemps-5.0.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
diff -rau linux-5.0-orig/drivers/gpu/drm/radeon/cik.c linux-5.0/drivers/gpu/drm/radeon/cik.c
--- linux-5.0-orig/drivers/gpu/drm/radeon/cik.c 2019-03-04 00:21:29.000000000 +0100
+++ linux-5.0/drivers/gpu/drm/radeon/cik.c 2019-03-17 12:04:37.168970159 +0100
@@ -223,6 +223,26 @@
}
/* get temperature in millidegrees */
+int ci_get_temp_asic_max(struct radeon_device *rdev)
+{
+ u32 temp;
+ int actual_temp = 0;
+
+ temp = (RREG32_SMC(CG_MULT_THERMAL_STATUS) & ASIC_MAX_TEMP_MASK) >>
+ ASIC_MAX_TEMP_SHIFT;
+
+ if (temp & 0x200)
+ actual_temp = 255;
+ else
+ actual_temp = temp & 0x1ff;
+
+ actual_temp = actual_temp * 1000;
+
+ return actual_temp;
+}
+
+
+/* get temperature in millidegrees */
int kv_get_temp(struct radeon_device *rdev)
{
u32 temp;
diff -rau linux-5.0-orig/drivers/gpu/drm/radeon/radeon_asic.c linux-5.0/drivers/gpu/drm/radeon/radeon_asic.c
--- linux-5.0-orig/drivers/gpu/drm/radeon/radeon_asic.c 2019-03-04 00:21:29.000000000 +0100
+++ linux-5.0/drivers/gpu/drm/radeon/radeon_asic.c 2019-03-17 12:04:37.168970159 +0100
@@ -1992,6 +1992,7 @@
.set_uvd_clocks = &si_set_uvd_clocks,
.set_vce_clocks = &si_set_vce_clocks,
.get_temperature = &si_get_temp,
+ .get_temperature_asic_max = &si_get_temp_asic_max,
},
.dpm = {
.init = &si_dpm_init,
@@ -2162,6 +2163,7 @@
.set_uvd_clocks = &cik_set_uvd_clocks,
.set_vce_clocks = &cik_set_vce_clocks,
.get_temperature = &ci_get_temp,
+ .get_temperature_asic_max = &ci_get_temp_asic_max,
},
.dpm = {
.init = &ci_dpm_init,
diff -rau linux-5.0-orig/drivers/gpu/drm/radeon/radeon_asic.h linux-5.0/drivers/gpu/drm/radeon/radeon_asic.h
--- linux-5.0-orig/drivers/gpu/drm/radeon/radeon_asic.h 2019-03-04 00:21:29.000000000 +0100
+++ linux-5.0/drivers/gpu/drm/radeon/radeon_asic.h 2019-03-17 12:04:37.168970159 +0100
@@ -749,6 +749,7 @@
int si_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk);
int si_set_vce_clocks(struct radeon_device *rdev, u32 evclk, u32 ecclk);
int si_get_temp(struct radeon_device *rdev);
+int si_get_temp_asic_max(struct radeon_device *rdev);
int si_get_allowed_info_register(struct radeon_device *rdev,
u32 reg, u32 *val);
int si_dpm_init(struct radeon_device *rdev);
@@ -867,6 +868,7 @@
void cik_sdma_set_wptr(struct radeon_device *rdev,
struct radeon_ring *ring);
int ci_get_temp(struct radeon_device *rdev);
+int ci_get_temp_asic_max(struct radeon_device *rdev);
int kv_get_temp(struct radeon_device *rdev);
int cik_get_allowed_info_register(struct radeon_device *rdev,
u32 reg, u32 *val);
diff -rau linux-5.0-orig/drivers/gpu/drm/radeon/radeon.h linux-5.0/drivers/gpu/drm/radeon/radeon.h
--- linux-5.0-orig/drivers/gpu/drm/radeon/radeon.h 2019-03-04 00:21:29.000000000 +0100
+++ linux-5.0/drivers/gpu/drm/radeon/radeon.h 2019-03-17 12:04:37.168970159 +0100
@@ -1961,6 +1961,8 @@
int (*set_uvd_clocks)(struct radeon_device *rdev, u32 vclk, u32 dclk);
int (*set_vce_clocks)(struct radeon_device *rdev, u32 evclk, u32 ecclk);
int (*get_temperature)(struct radeon_device *rdev);
+ // my ASIC_MAX
+ int (*get_temperature_asic_max)(struct radeon_device *rdev);
} pm;
/* dynamic power management */
struct {
@@ -2752,6 +2754,7 @@
#define radeon_set_uvd_clocks(rdev, v, d) (rdev)->asic->pm.set_uvd_clocks((rdev), (v), (d))
#define radeon_set_vce_clocks(rdev, ev, ec) (rdev)->asic->pm.set_vce_clocks((rdev), (ev), (ec))
#define radeon_get_temperature(rdev) (rdev)->asic->pm.get_temperature((rdev))
+#define radeon_get_temperature_asic_max(rdev) (rdev)->asic->pm.get_temperature_asic_max((rdev))
#define radeon_set_surface_reg(rdev, r, f, p, o, s) ((rdev)->asic->surface.set_reg((rdev), (r), (f), (p), (o), (s)))
#define radeon_clear_surface_reg(rdev, r) ((rdev)->asic->surface.clear_reg((rdev), (r)))
#define radeon_bandwidth_update(rdev) (rdev)->asic->display.bandwidth_update((rdev))
diff -rau linux-5.0-orig/drivers/gpu/drm/radeon/radeon_pm.c linux-5.0/drivers/gpu/drm/radeon/radeon_pm.c
--- linux-5.0-orig/drivers/gpu/drm/radeon/radeon_pm.c 2019-03-04 00:21:29.000000000 +0100
+++ linux-5.0/drivers/gpu/drm/radeon/radeon_pm.c 2019-03-17 12:04:37.172303515 +0100
@@ -683,6 +683,28 @@
return snprintf(buf, PAGE_SIZE, "%d\n", temp);
}
+static ssize_t radeon_hwmon_show_temp_asic_max(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct radeon_device *rdev = dev_get_drvdata(dev);
+ struct drm_device *ddev = rdev->ddev;
+ int temp;
+
+ /* Can't get temperature when the card is off */
+ if ((rdev->flags & RADEON_IS_PX) &&
+ (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
+ return -EINVAL;
+
+ if (rdev->asic->pm.get_temperature_asic_max)
+ temp = radeon_get_temperature_asic_max(rdev);
+ else
+ temp = 0;
+
+ return snprintf(buf, PAGE_SIZE, "%d\n", temp);
+}
+
+
static ssize_t radeon_hwmon_show_temp_thresh(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -702,6 +724,7 @@
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0);
static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0);
static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1);
+static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, radeon_hwmon_show_temp_asic_max, NULL, 0);
static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, radeon_hwmon_get_pwm1, radeon_hwmon_set_pwm1, 0);
static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, radeon_hwmon_get_pwm1_enable, radeon_hwmon_set_pwm1_enable, 0);
static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, radeon_hwmon_get_pwm1_min, NULL, 0);
@@ -712,6 +735,7 @@
&sensor_dev_attr_temp1_input.dev_attr.attr,
&sensor_dev_attr_temp1_crit.dev_attr.attr,
&sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
+ &sensor_dev_attr_temp2_input.dev_attr.attr,
&sensor_dev_attr_pwm1.dev_attr.attr,
&sensor_dev_attr_pwm1_enable.dev_attr.attr,
&sensor_dev_attr_pwm1_min.dev_attr.attr,
@@ -726,6 +750,11 @@
struct radeon_device *rdev = dev_get_drvdata(dev);
umode_t effective_mode = attr->mode;
+ /* Skip attributes if no ASIC_MAX temperature */
+ if (!rdev->asic->pm.get_temperature_asic_max &&
+ attr == &sensor_dev_attr_temp2_input.dev_attr.attr)
+ return 0;
+
/* Skip attributes if DPM is not enabled */
if (rdev->pm.pm_method != PM_METHOD_DPM &&
(attr == &sensor_dev_attr_temp1_crit.dev_attr.attr ||
diff -rau linux-5.0-orig/drivers/gpu/drm/radeon/si.c linux-5.0/drivers/gpu/drm/radeon/si.c
--- linux-5.0-orig/drivers/gpu/drm/radeon/si.c 2019-03-04 00:21:29.000000000 +0100
+++ linux-5.0/drivers/gpu/drm/radeon/si.c 2019-03-17 12:04:37.172303515 +0100
@@ -1371,6 +1371,25 @@
return actual_temp;
}
+/* get temperature in millidegrees */
+int si_get_temp_asic_max(struct radeon_device *rdev)
+{
+ u32 temp;
+ int actual_temp = 0;
+
+ temp = (RREG32(CG_MULT_THERMAL_STATUS) & ASIC_MAX_TEMP_MASK) >>
+ ASIC_MAX_TEMP_SHIFT;
+
+ if (temp & 0x200)
+ actual_temp = 255;
+ else
+ actual_temp = temp & 0x1ff;
+
+ actual_temp = (actual_temp * 1000);
+
+ return actual_temp;
+}
+
#define TAHITI_IO_MC_REGS_SIZE 36
static const u32 tahiti_io_mc_regs[TAHITI_IO_MC_REGS_SIZE][2] = {