Commit 448b8ef0 authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher
Browse files

drm/amd/pm: drop the unnecessary intermediate percent-based transition



Currently, the readout of fan speed pwm is transited into percent-based
and then pwm-based. However, the transition into percent-based is totally
unnecessary and make the final output less accurate.
Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 93cb1f37
......@@ -2622,8 +2622,6 @@ static ssize_t amdgpu_hwmon_set_pwm1(struct device *dev,
return err;
}
value = (value * 100) / 255;
  • Instead of removing, maybe:

           if (!is_support_sw_smu(adev))
                   value = (value * 100) / 255;

    That way it won't brake pre SWSMU fan control

    Edited by Dobromir Dobrev
Please register or sign in to reply
if (is_support_sw_smu(adev))
err = smu_set_fan_speed_percent(&adev->smu, value);
else if (adev->powerplay.pp_funcs->set_fan_speed_percent)
......@@ -2670,8 +2668,6 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,
if (err)
return err;
speed = (speed * 255) / 100;
Please register or sign in to reply
return sprintf(buf, "%i\n", speed);
}
......
......@@ -2310,23 +2310,17 @@ int smu_set_fan_control_mode(struct smu_context *smu, int value)
int smu_get_fan_speed_percent(struct smu_context *smu, uint32_t *speed)
{
int ret = 0;
uint32_t percent;
if (!smu->pm_enabled || !smu->adev->pm.dpm_enabled)
return -EOPNOTSUPP;
mutex_lock(&smu->mutex);
if (smu->ppt_funcs->get_fan_speed_percent) {
ret = smu->ppt_funcs->get_fan_speed_percent(smu, &percent);
if (!ret) {
*speed = percent > 100 ? 100 : percent;
}
}
if (smu->ppt_funcs->get_fan_speed_percent)
ret = smu->ppt_funcs->get_fan_speed_percent(smu, speed);
mutex_unlock(&smu->mutex);
return ret;
}
......@@ -2340,8 +2334,6 @@ int smu_set_fan_speed_percent(struct smu_context *smu, uint32_t speed)
mutex_lock(&smu->mutex);
if (smu->ppt_funcs->set_fan_speed_percent) {
if (speed > 100)
speed = 100;
ret = smu->ppt_funcs->set_fan_speed_percent(smu, speed);
if (!ret && smu->user_dpm_profile.flags != SMU_DPM_USER_PROFILE_RESTORE) {
smu->user_dpm_profile.custom_fan_speed |= SMU_CUSTOM_FAN_SPEED_PWM;
......
......@@ -1183,8 +1183,8 @@ smu_v11_0_set_fan_speed_percent(struct smu_context *smu, uint32_t speed)
uint32_t duty100, duty;
uint64_t tmp64;
if (speed > 100)
speed = 100;
if (speed > 255)
speed = 255;
if (smu_v11_0_auto_fan_control(smu, 0))
return -EINVAL;
......@@ -1195,7 +1195,7 @@ smu_v11_0_set_fan_speed_percent(struct smu_context *smu, uint32_t speed)
return -EINVAL;
tmp64 = (uint64_t)speed * duty100;
do_div(tmp64, 100);
do_div(tmp64, 255);
duty = (uint32_t)tmp64;
WREG32_SOC15(THM, 0, mmCG_FDO_CTRL0,
......@@ -1258,12 +1258,12 @@ int smu_v11_0_get_fan_speed_percent(struct smu_context *smu,
if (!duty100)
return -EINVAL;
tmp64 = (uint64_t)duty * 100;
tmp64 = (uint64_t)duty * 255;
do_div(tmp64, duty100);
*speed = (uint32_t)tmp64;
if (*speed > 100)
*speed = 100;
if (*speed > 255)
*speed = 255;
return 0;
}
......@@ -1304,7 +1304,7 @@ smu_v11_0_set_fan_control_mode(struct smu_context *smu,
switch (mode) {
case AMD_FAN_CTRL_NONE:
ret = smu_v11_0_set_fan_speed_percent(smu, 100);
ret = smu_v11_0_set_fan_speed_percent(smu, 255);
break;
case AMD_FAN_CTRL_MANUAL:
ret = smu_v11_0_auto_fan_control(smu, 0);
......
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