aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
diff options
context:
space:
mode:
authorAlex Deucher <alexander.deucher@amd.com>2018-01-24 17:27:54 -0500
committerAlex Deucher <alexander.deucher@amd.com>2018-02-19 14:18:51 -0500
commit71c9b9adad7ec9c119a4aa0de99543aee716e417 (patch)
tree1fb6cb858a68a89a04b0b7938b0e9eb770a9b3dd /drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
parent2976fc2622b1e77236bea9f88a68f6ac5d2fa6ab (diff)
drm/amdgpu/pm: use read_sensor API to get temperature
Rather than using the amdgpu_dpm_get_temperature. Both provide access to the temperature. Acked-by: Christian König <christian.koenig@amd.com> Reviewed-by: Rex Zhu <Rex.Zhu@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.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index 17f9f3ad9bd1..659467aa9920 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -936,17 +936,23 @@ static ssize_t amdgpu_hwmon_show_temp(struct device *dev,
936{ 936{
937 struct amdgpu_device *adev = dev_get_drvdata(dev); 937 struct amdgpu_device *adev = dev_get_drvdata(dev);
938 struct drm_device *ddev = adev->ddev; 938 struct drm_device *ddev = adev->ddev;
939 int temp; 939 int r, temp, size = sizeof(temp);
940 940
941 /* Can't get temperature when the card is off */ 941 /* Can't get temperature when the card is off */
942 if ((adev->flags & AMD_IS_PX) && 942 if ((adev->flags & AMD_IS_PX) &&
943 (ddev->switch_power_state != DRM_SWITCH_POWER_ON)) 943 (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
944 return -EINVAL; 944 return -EINVAL;
945 945
946 if (!adev->powerplay.pp_funcs->get_temperature) 946 /* sanity check PP is enabled */
947 temp = 0; 947 if (!(adev->powerplay.pp_funcs &&
948 else 948 adev->powerplay.pp_funcs->read_sensor))
949 temp = amdgpu_dpm_get_temperature(adev); 949 return -EINVAL;
950
951 /* get the temperature */
952 r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_GPU_TEMP,
953 (void *)&temp, &size);
954 if (r)
955 return r;
950 956
951 return snprintf(buf, PAGE_SIZE, "%d\n", temp); 957 return snprintf(buf, PAGE_SIZE, "%d\n", temp);
952} 958}
@@ -1306,13 +1312,15 @@ void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
1306 pm.dpm.thermal.work); 1312 pm.dpm.thermal.work);
1307 /* switch to the thermal state */ 1313 /* switch to the thermal state */
1308 enum amd_pm_state_type dpm_state = POWER_STATE_TYPE_INTERNAL_THERMAL; 1314 enum amd_pm_state_type dpm_state = POWER_STATE_TYPE_INTERNAL_THERMAL;
1315 int temp, size = sizeof(temp);
1309 1316
1310 if (!adev->pm.dpm_enabled) 1317 if (!adev->pm.dpm_enabled)
1311 return; 1318 return;
1312 1319
1313 if (adev->powerplay.pp_funcs->get_temperature) { 1320 if (adev->powerplay.pp_funcs &&
1314 int temp = amdgpu_dpm_get_temperature(adev); 1321 adev->powerplay.pp_funcs->read_sensor &&
1315 1322 !amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_GPU_TEMP,
1323 (void *)&temp, &size)) {
1316 if (temp < adev->pm.dpm.thermal.min_temp) 1324 if (temp < adev->pm.dpm.thermal.min_temp)
1317 /* switch back the user state */ 1325 /* switch back the user state */
1318 dpm_state = adev->pm.dpm.user_state; 1326 dpm_state = adev->pm.dpm.user_state;