summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/amd/pm/legacy-dpm
diff options
context:
space:
mode:
authorEvan Quan <evan.quan@amd.com>2022-01-11 15:02:19 +0800
committerAlex Deucher <alexander.deucher@amd.com>2022-01-14 17:51:15 -0500
commit685fae24d94fd615b7058832fcb437eb588f4860 (patch)
tree4228a37a53ab54831d7f6c88238ab12a11ec9753 /drivers/gpu/drm/amd/pm/legacy-dpm
parent54c73b51df2958f564b144ce86f15a85e227db90 (diff)
drm/amd/pm: correct the checks for fan attributes support
On functionality unsupported, -EOPNOTSUPP will be returned. And we rely on that to determine the fan attributes support. Fixes: 79c65f3fcbb128 ("drm/amd/pm: do not expose power implementation details to amdgpu_pm.c") Signed-off-by: Evan Quan <evan.quan@amd.com> Reviewed-by: Lijo Lazar <lijo.lazar@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/pm/legacy-dpm')
-rw-r--r--drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
index 92b987fb31d4..23ff0d812e4b 100644
--- a/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
+++ b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
@@ -6619,6 +6619,9 @@ static int si_dpm_get_fan_speed_pwm(void *handle,
u64 tmp64;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+ if (!speed)
+ return -EINVAL;
+
if (adev->pm.no_fan)
return -ENOENT;
@@ -6669,10 +6672,13 @@ static int si_dpm_set_fan_speed_pwm(void *handle,
return 0;
}
-static void si_dpm_set_fan_control_mode(void *handle, u32 mode)
+static int si_dpm_set_fan_control_mode(void *handle, u32 mode)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+ if (mode == U32_MAX)
+ return -EINVAL;
+
if (mode) {
/* stop auto-manage */
if (adev->pm.dpm.fan.ucode_fan_control)
@@ -6685,19 +6691,26 @@ static void si_dpm_set_fan_control_mode(void *handle, u32 mode)
else
si_fan_ctrl_set_default_mode(adev);
}
+
+ return 0;
}
-static u32 si_dpm_get_fan_control_mode(void *handle)
+static int si_dpm_get_fan_control_mode(void *handle, u32 *fan_mode)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
struct si_power_info *si_pi = si_get_pi(adev);
u32 tmp;
+ if (!fan_mode)
+ return -EINVAL;
+
if (si_pi->fan_is_controlled_by_smc)
return 0;
tmp = RREG32(CG_FDO_CTRL2) & FDO_PWM_MODE_MASK;
- return (tmp >> FDO_PWM_MODE_SHIFT);
+ *fan_mode = (tmp >> FDO_PWM_MODE_SHIFT);
+
+ return 0;
}
#if 0