Skip to content

Commit

Permalink
drm/amdgpu: Revert "drm/amdgpu: getting fan speed pwm for vega10 prop…
Browse files Browse the repository at this point in the history
…erly"

[ Upstream commit e5b781c ]

This reverts commit 16fb4dc.

Unfortunately, that commit causes fan monitors can't be read and written
properly.

Fixes: 16fb4dc ("drm/amdgpu: getting fan speed pwm for vega10 properly")
Signed-off-by: Asher Song <Asher.Song@amd.com>
Reviewed-by: Guchun Chen <guchun.chen@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Asher Song authored and gregkh committed Dec 31, 2022
1 parent 3265e0f commit 9ccd117
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,22 @@ int vega10_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr,
int vega10_fan_ctrl_get_fan_speed_pwm(struct pp_hwmgr *hwmgr,
uint32_t *speed)
{
struct amdgpu_device *adev = hwmgr->adev;
uint32_t duty100, duty;
uint64_t tmp64;
uint32_t current_rpm;
uint32_t percent = 0;

duty100 = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_FDO_CTRL1),
CG_FDO_CTRL1, FMAX_DUTY100);
duty = REG_GET_FIELD(RREG32_SOC15(THM, 0, mmCG_THERMAL_STATUS),
CG_THERMAL_STATUS, FDO_PWM_DUTY);
if (hwmgr->thermal_controller.fanInfo.bNoFan)
return 0;

if (!duty100)
return -EINVAL;
if (vega10_get_current_rpm(hwmgr, &current_rpm))
return -1;

if (hwmgr->thermal_controller.
advanceFanControlParameters.usMaxFanRPM != 0)
percent = current_rpm * 255 /
hwmgr->thermal_controller.
advanceFanControlParameters.usMaxFanRPM;

tmp64 = (uint64_t)duty * 255;
do_div(tmp64, duty100);
*speed = MIN((uint32_t)tmp64, 255);
*speed = MIN(percent, 255);

return 0;
}
Expand Down

0 comments on commit 9ccd117

Please sign in to comment.