From: jsg Date: Thu, 4 Apr 2024 07:39:57 +0000 (+0000) Subject: drm/amdgpu/pm: Fix the error of pwm1_enable setting X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=971a55aa2fc3e7f1a33db072b7648f0673f88a4f;p=openbsd drm/amdgpu/pm: Fix the error of pwm1_enable setting From Ma Jun 6f3c1dabe8d014ad95b72fc56276d82a6f5e6ab3 in linux-6.6.y/6.6.24 0dafaf659cc463f2db0af92003313a8bc46781cd in mainline linux --- diff --git a/sys/dev/pci/drm/amd/pm/amdgpu_pm.c b/sys/dev/pci/drm/amd/pm/amdgpu_pm.c index 2d03a047318..842a5929766 100644 --- a/sys/dev/pci/drm/amd/pm/amdgpu_pm.c +++ b/sys/dev/pci/drm/amd/pm/amdgpu_pm.c @@ -2397,6 +2397,7 @@ static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev, { struct amdgpu_device *adev = dev_get_drvdata(dev); int err, ret; + u32 pwm_mode; int value; if (amdgpu_in_reset(adev)) @@ -2408,13 +2409,22 @@ static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev, if (err) return err; + if (value == 0) + pwm_mode = AMD_FAN_CTRL_NONE; + else if (value == 1) + pwm_mode = AMD_FAN_CTRL_MANUAL; + else if (value == 2) + pwm_mode = AMD_FAN_CTRL_AUTO; + else + return -EINVAL; + ret = pm_runtime_get_sync(adev_to_drm(adev)->dev); if (ret < 0) { pm_runtime_put_autosuspend(adev_to_drm(adev)->dev); return ret; } - ret = amdgpu_dpm_set_fan_control_mode(adev, value); + ret = amdgpu_dpm_set_fan_control_mode(adev, pwm_mode); pm_runtime_mark_last_busy(adev_to_drm(adev)->dev); pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);