Merge tag 'drm-misc-next-fixes-2021-09-09' of git://anongit.freedesktop.org/drm/drm...
[linux-2.6-microblaze.git] / drivers / gpu / drm / amd / pm / powerplay / si_dpm.c
index 15c0b8a..bdbbeb9 100644 (file)
@@ -6539,7 +6539,7 @@ static int si_fan_ctrl_stop_smc_fan_control(struct amdgpu_device *adev)
        }
 }
 
-static int si_dpm_get_fan_speed_percent(void *handle,
+static int si_dpm_get_fan_speed_pwm(void *handle,
                                      u32 *speed)
 {
        u32 duty, duty100;
@@ -6555,17 +6555,14 @@ static int si_dpm_get_fan_speed_percent(void *handle,
        if (duty100 == 0)
                return -EINVAL;
 
-       tmp64 = (u64)duty * 100;
+       tmp64 = (u64)duty * 255;
        do_div(tmp64, duty100);
-       *speed = (u32)tmp64;
-
-       if (*speed > 100)
-               *speed = 100;
+       *speed = MIN((u32)tmp64, 255);
 
        return 0;
 }
 
-static int si_dpm_set_fan_speed_percent(void *handle,
+static int si_dpm_set_fan_speed_pwm(void *handle,
                                      u32 speed)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -6580,7 +6577,7 @@ static int si_dpm_set_fan_speed_percent(void *handle,
        if (si_pi->fan_is_controlled_by_smc)
                return -EINVAL;
 
-       if (speed > 100)
+       if (speed > 255)
                return -EINVAL;
 
        duty100 = (RREG32(CG_FDO_CTRL1) & FMAX_DUTY100_MASK) >> FMAX_DUTY100_SHIFT;
@@ -6589,7 +6586,7 @@ static int si_dpm_set_fan_speed_percent(void *handle,
                return -EINVAL;
 
        tmp64 = (u64)speed * duty100;
-       do_div(tmp64, 100);
+       do_div(tmp64, 255);
        duty = (u32)tmp64;
 
        tmp = RREG32(CG_FDO_CTRL0) & ~FDO_STATIC_DUTY_MASK;
@@ -8059,8 +8056,8 @@ static const struct amd_pm_funcs si_dpm_funcs = {
        .vblank_too_short = &si_dpm_vblank_too_short,
        .set_fan_control_mode = &si_dpm_set_fan_control_mode,
        .get_fan_control_mode = &si_dpm_get_fan_control_mode,
-       .set_fan_speed_percent = &si_dpm_set_fan_speed_percent,
-       .get_fan_speed_percent = &si_dpm_get_fan_speed_percent,
+       .set_fan_speed_pwm = &si_dpm_set_fan_speed_pwm,
+       .get_fan_speed_pwm = &si_dpm_get_fan_speed_pwm,
        .check_state_equal = &si_check_state_equal,
        .get_vce_clock_state = amdgpu_get_vce_clock_state,
        .read_sensor = &si_dpm_read_sensor,