aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
diff options
context:
space:
mode:
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, 34 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index eaf91d0e831e..17f9f3ad9bd1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -1170,6 +1170,38 @@ static ssize_t amdgpu_hwmon_show_vddnb_label(struct device *dev,
1170 return snprintf(buf, PAGE_SIZE, "vddnb\n"); 1170 return snprintf(buf, PAGE_SIZE, "vddnb\n");
1171} 1171}
1172 1172
1173static ssize_t amdgpu_hwmon_show_power_avg(struct device *dev,
1174 struct device_attribute *attr,
1175 char *buf)
1176{
1177 struct amdgpu_device *adev = dev_get_drvdata(dev);
1178 struct drm_device *ddev = adev->ddev;
1179 struct pp_gpu_power query = {0};
1180 int r, size = sizeof(query);
1181 unsigned uw;
1182
1183 /* Can't get power when the card is off */
1184 if ((adev->flags & AMD_IS_PX) &&
1185 (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
1186 return -EINVAL;
1187
1188 /* sanity check PP is enabled */
1189 if (!(adev->powerplay.pp_funcs &&
1190 adev->powerplay.pp_funcs->read_sensor))
1191 return -EINVAL;
1192
1193 /* get the voltage */
1194 r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_GPU_POWER,
1195 (void *)&query, &size);
1196 if (r)
1197 return r;
1198
1199 /* convert to microwatts */
1200 uw = (query.average_gpu_power >> 8) * 1000000;
1201
1202 return snprintf(buf, PAGE_SIZE, "%u\n", uw);
1203}
1204
1173static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, amdgpu_hwmon_show_temp, NULL, 0); 1205static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, amdgpu_hwmon_show_temp, NULL, 0);
1174static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 0); 1206static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 0);
1175static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 1); 1207static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 1);
@@ -1182,6 +1214,7 @@ static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, amdgpu_hwmon_show_vddgfx, NULL, 0)
1182static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, amdgpu_hwmon_show_vddgfx_label, NULL, 0); 1214static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, amdgpu_hwmon_show_vddgfx_label, NULL, 0);
1183static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, amdgpu_hwmon_show_vddnb, NULL, 0); 1215static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, amdgpu_hwmon_show_vddnb, NULL, 0);
1184static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, amdgpu_hwmon_show_vddnb_label, NULL, 0); 1216static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, amdgpu_hwmon_show_vddnb_label, NULL, 0);
1217static SENSOR_DEVICE_ATTR(power1_average, S_IRUGO, amdgpu_hwmon_show_power_avg, NULL, 0);
1185 1218
1186static struct attribute *hwmon_attributes[] = { 1219static struct attribute *hwmon_attributes[] = {
1187 &sensor_dev_attr_temp1_input.dev_attr.attr, 1220 &sensor_dev_attr_temp1_input.dev_attr.attr,
@@ -1196,6 +1229,7 @@ static struct attribute *hwmon_attributes[] = {
1196 &sensor_dev_attr_in0_label.dev_attr.attr, 1229 &sensor_dev_attr_in0_label.dev_attr.attr,
1197 &sensor_dev_attr_in1_input.dev_attr.attr, 1230 &sensor_dev_attr_in1_input.dev_attr.attr,
1198 &sensor_dev_attr_in1_label.dev_attr.attr, 1231 &sensor_dev_attr_in1_label.dev_attr.attr,
1232 &sensor_dev_attr_power1_average.dev_attr.attr,
1199 NULL 1233 NULL
1200}; 1234};
1201 1235