Commit 71c9b9ad authored by Alex Deucher's avatar Alex Deucher

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: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarRex Zhu <Rex.Zhu@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 2976fc26
...@@ -936,17 +936,23 @@ static ssize_t amdgpu_hwmon_show_temp(struct device *dev, ...@@ -936,17 +936,23 @@ static ssize_t amdgpu_hwmon_show_temp(struct device *dev,
{ {
struct amdgpu_device *adev = dev_get_drvdata(dev); struct amdgpu_device *adev = dev_get_drvdata(dev);
struct drm_device *ddev = adev->ddev; struct drm_device *ddev = adev->ddev;
int temp; int r, temp, size = sizeof(temp);
/* Can't get temperature when the card is off */ /* Can't get temperature when the card is off */
if ((adev->flags & AMD_IS_PX) && if ((adev->flags & AMD_IS_PX) &&
(ddev->switch_power_state != DRM_SWITCH_POWER_ON)) (ddev->switch_power_state != DRM_SWITCH_POWER_ON))
return -EINVAL; return -EINVAL;
if (!adev->powerplay.pp_funcs->get_temperature) /* sanity check PP is enabled */
temp = 0; if (!(adev->powerplay.pp_funcs &&
else adev->powerplay.pp_funcs->read_sensor))
temp = amdgpu_dpm_get_temperature(adev); return -EINVAL;
/* get the temperature */
r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_GPU_TEMP,
(void *)&temp, &size);
if (r)
return r;
return snprintf(buf, PAGE_SIZE, "%d\n", temp); return snprintf(buf, PAGE_SIZE, "%d\n", temp);
} }
...@@ -1306,13 +1312,15 @@ void amdgpu_dpm_thermal_work_handler(struct work_struct *work) ...@@ -1306,13 +1312,15 @@ void amdgpu_dpm_thermal_work_handler(struct work_struct *work)
pm.dpm.thermal.work); pm.dpm.thermal.work);
/* switch to the thermal state */ /* switch to the thermal state */
enum amd_pm_state_type dpm_state = POWER_STATE_TYPE_INTERNAL_THERMAL; enum amd_pm_state_type dpm_state = POWER_STATE_TYPE_INTERNAL_THERMAL;
int temp, size = sizeof(temp);
if (!adev->pm.dpm_enabled) if (!adev->pm.dpm_enabled)
return; return;
if (adev->powerplay.pp_funcs->get_temperature) { if (adev->powerplay.pp_funcs &&
int temp = amdgpu_dpm_get_temperature(adev); adev->powerplay.pp_funcs->read_sensor &&
!amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_GPU_TEMP,
(void *)&temp, &size)) {
if (temp < adev->pm.dpm.thermal.min_temp) if (temp < adev->pm.dpm.thermal.min_temp)
/* switch back the user state */ /* switch back the user state */
dpm_state = adev->pm.dpm.user_state; dpm_state = adev->pm.dpm.user_state;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment