aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
diff options
context:
space:
mode:
authorEvan Quan <evan.quan@amd.com>2019-04-17 03:45:08 -0400
committerAlex Deucher <alexander.deucher@amd.com>2019-05-24 13:20:47 -0400
commit2adc11564c42b63827eaf1cf9d61da2f79b9c978 (patch)
tree90cdcd5570f71dddd365da32e661696ae4f9e058 /drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
parenta34d1166b47c8497cffda4da7c14182cb3420362 (diff)
drm/amd/powerplay: support hwmon temperature channel labels V2
Expose temp[1-3]_label hwmon interfaces. While temp2_label and temp3_label are visible for SOC15 dGPUs only. - V2: correct temp1_label as "edge" Signed-off-by: Evan Quan <evan.quan@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 00ca8ec9845f..6d2995fcfd33 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -67,6 +67,15 @@ static const struct cg_flag_name clocks[] = {
67 {0, NULL}, 67 {0, NULL},
68}; 68};
69 69
70static const struct hwmon_temp_label {
71 enum PP_HWMON_TEMP channel;
72 const char *label;
73} temp_label[] = {
74 {PP_TEMP_EDGE, "edge"},
75 {PP_TEMP_JUNCTION, "junction"},
76 {PP_TEMP_MEM, "mem"},
77};
78
70void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev) 79void amdgpu_pm_acpi_event_handler(struct amdgpu_device *adev)
71{ 80{
72 if (adev->pm.dpm_enabled) { 81 if (adev->pm.dpm_enabled) {
@@ -1468,6 +1477,18 @@ static ssize_t amdgpu_hwmon_show_mem_temp_thresh(struct device *dev,
1468 return snprintf(buf, PAGE_SIZE, "%d\n", temp); 1477 return snprintf(buf, PAGE_SIZE, "%d\n", temp);
1469} 1478}
1470 1479
1480static ssize_t amdgpu_hwmon_show_temp_label(struct device *dev,
1481 struct device_attribute *attr,
1482 char *buf)
1483{
1484 int channel = to_sensor_dev_attr(attr)->index;
1485
1486 if (channel >= PP_TEMP_MAX)
1487 return -EINVAL;
1488
1489 return snprintf(buf, PAGE_SIZE, "%s\n", temp_label[channel].label);
1490}
1491
1471static ssize_t amdgpu_hwmon_show_temp_emergency(struct device *dev, 1492static ssize_t amdgpu_hwmon_show_temp_emergency(struct device *dev,
1472 struct device_attribute *attr, 1493 struct device_attribute *attr,
1473 char *buf) 1494 char *buf)
@@ -2066,6 +2087,9 @@ static ssize_t amdgpu_hwmon_show_mclk_label(struct device *dev,
2066 * - temp[1-3]_input: the on die GPU temperature in millidegrees Celsius 2087 * - temp[1-3]_input: the on die GPU temperature in millidegrees Celsius
2067 * - temp2_input and temp3_input are supported on SOC15 dGPUs only 2088 * - temp2_input and temp3_input are supported on SOC15 dGPUs only
2068 * 2089 *
2090 * - temp[1-3]_label: temperature channel label
2091 * - temp2_label and temp3_label are supported on SOC15 dGPUs only
2092 *
2069 * - temp[1-3]_crit: temperature critical max value in millidegrees Celsius 2093 * - temp[1-3]_crit: temperature critical max value in millidegrees Celsius
2070 * - temp2_crit and temp3_crit are supported on SOC15 dGPUs only 2094 * - temp2_crit and temp3_crit are supported on SOC15 dGPUs only
2071 * 2095 *
@@ -2133,6 +2157,9 @@ static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, amdgpu_hwmon_show_temp, NULL, PP
2133static SENSOR_DEVICE_ATTR(temp3_crit, S_IRUGO, amdgpu_hwmon_show_mem_temp_thresh, NULL, 0); 2157static SENSOR_DEVICE_ATTR(temp3_crit, S_IRUGO, amdgpu_hwmon_show_mem_temp_thresh, NULL, 0);
2134static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, amdgpu_hwmon_show_mem_temp_thresh, NULL, 1); 2158static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO, amdgpu_hwmon_show_mem_temp_thresh, NULL, 1);
2135static SENSOR_DEVICE_ATTR(temp3_emergency, S_IRUGO, amdgpu_hwmon_show_temp_emergency, NULL, PP_TEMP_MEM); 2159static SENSOR_DEVICE_ATTR(temp3_emergency, S_IRUGO, amdgpu_hwmon_show_temp_emergency, NULL, PP_TEMP_MEM);
2160static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, amdgpu_hwmon_show_temp_label, NULL, PP_TEMP_EDGE);
2161static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, amdgpu_hwmon_show_temp_label, NULL, PP_TEMP_JUNCTION);
2162static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, amdgpu_hwmon_show_temp_label, NULL, PP_TEMP_MEM);
2136static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1, amdgpu_hwmon_set_pwm1, 0); 2163static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1, amdgpu_hwmon_set_pwm1, 0);
2137static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1_enable, amdgpu_hwmon_set_pwm1_enable, 0); 2164static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1_enable, amdgpu_hwmon_set_pwm1_enable, 0);
2138static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0); 2165static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0);
@@ -2168,6 +2195,9 @@ static struct attribute *hwmon_attributes[] = {
2168 &sensor_dev_attr_temp1_emergency.dev_attr.attr, 2195 &sensor_dev_attr_temp1_emergency.dev_attr.attr,
2169 &sensor_dev_attr_temp2_emergency.dev_attr.attr, 2196 &sensor_dev_attr_temp2_emergency.dev_attr.attr,
2170 &sensor_dev_attr_temp3_emergency.dev_attr.attr, 2197 &sensor_dev_attr_temp3_emergency.dev_attr.attr,
2198 &sensor_dev_attr_temp1_label.dev_attr.attr,
2199 &sensor_dev_attr_temp2_label.dev_attr.attr,
2200 &sensor_dev_attr_temp3_label.dev_attr.attr,
2171 &sensor_dev_attr_pwm1.dev_attr.attr, 2201 &sensor_dev_attr_pwm1.dev_attr.attr,
2172 &sensor_dev_attr_pwm1_enable.dev_attr.attr, 2202 &sensor_dev_attr_pwm1_enable.dev_attr.attr,
2173 &sensor_dev_attr_pwm1_min.dev_attr.attr, 2203 &sensor_dev_attr_pwm1_min.dev_attr.attr,
@@ -2301,7 +2331,9 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
2301 attr == &sensor_dev_attr_temp2_emergency.dev_attr.attr || 2331 attr == &sensor_dev_attr_temp2_emergency.dev_attr.attr ||
2302 attr == &sensor_dev_attr_temp3_emergency.dev_attr.attr || 2332 attr == &sensor_dev_attr_temp3_emergency.dev_attr.attr ||
2303 attr == &sensor_dev_attr_temp2_input.dev_attr.attr || 2333 attr == &sensor_dev_attr_temp2_input.dev_attr.attr ||
2304 attr == &sensor_dev_attr_temp3_input.dev_attr.attr)) 2334 attr == &sensor_dev_attr_temp3_input.dev_attr.attr ||
2335 attr == &sensor_dev_attr_temp2_label.dev_attr.attr ||
2336 attr == &sensor_dev_attr_temp3_label.dev_attr.attr))
2305 return 0; 2337 return 0;
2306 2338
2307 return effective_mode; 2339 return effective_mode;