Skip to contentSkip to conversation

drm/amdgpu/pm: Fix the error of pwm1_enable setting

PATCH In review Ma Jun 3 participants 3 messages Mar 1, 2024 – Mar 4, 2024

Subsystems (3)
lore
Share & tools
lore

Ma Jun

author
#0 lore raw

PATCH 1/1 drm/amdgpu/pm: Fix the error of pwm1_enable setting

Fix the pwm_mode value error which used for
pwm1_enable setting

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +11 -1
index 9e70c41ad98f..7cc5cd7616b1 100644
@@ -2582,6 +2582,7 @@ static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev,
 	struct amdgpu_device *adev = dev_get_drvdata(dev);
 	int err, ret;
 	int value;
+	u32 pwm_mode;
 
 	if (amdgpu_in_reset(adev))
 		return -EPERM;
@@ -2592,13 +2593,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);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Ma Jun

Fix the pwm_mode value error which used for
pwm1_enable setting

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -0
index 9e70c41ad98f..7cc5cd7616b1 100644

drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev, · line 2586

Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
@@ -2582,6 +2582,7 @@ static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev,
 	struct amdgpu_device *adev = dev_get_drvdata(dev);
 	int err, ret;
 	int value;
+	u32 pwm_mode;
 

You may move this declaration up to follow reverse Christmas tree order.

Thanks,
Lijo

Quoted 26 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +10 -1
 	if (amdgpu_in_reset(adev))
 		return -EPERM;
@@ -2592,13 +2593,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);
#2 lore raw
Quoted 11 lines · Lijo
Quoted 8 lines · Ma Jun

Fix the pwm_mode value error which used for
pwm1_enable setting

---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
Quoted 12 lines

drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev, · line 2586

Quoted 10 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +1 -0
index 9e70c41ad98f..7cc5cd7616b1 100644
@@ -2582,6 +2582,7 @@ static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev,
 	struct amdgpu_device *adev = dev_get_drvdata(dev);
 	int err, ret;
 	int value;
+	u32 pwm_mode;
 

You may move this declaration up to follow reverse Christmas tree order.

Thanks, will fix it when submit.

Regards,
Ma Jun

Quoted 31 lines

Thanks,
Lijo

Quoted 26 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +10 -1
 	if (amdgpu_in_reset(adev))
 		return -EPERM;
@@ -2592,13 +2593,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);