[08/26] drm/amd/powerplay: implement fan1_enable hwmon interface for SMU11 (v2)

Submitted by Huang, Ray on Feb. 25, 2019, 12:12 p.m.

Details

Message ID 1551096752-18205-9-git-send-email-ray.huang@amd.com
State New
Headers show
Series "Updates for SW SMU driver" ( rev: 1 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Huang, Ray Feb. 25, 2019, 12:12 p.m.
From: Chengming Gui <Jack.Gui@amd.com>

set the fan1_enable hwmon interface to call
smu_get_fan_control_mode and smu_set_fan_control_mode.

v2: fix print value.

Signed-off-by: Chengming Gui <Jack.Gui@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c    | 23 +++++++++++++++--------
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c |  2 +-
 2 files changed, 16 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index ac991f9..9413c39 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -1635,12 +1635,15 @@  static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,
 	struct amdgpu_device *adev = dev_get_drvdata(dev);
 	u32 pwm_mode = 0;
 
-	if (!adev->powerplay.pp_funcs->get_fan_control_mode)
-		return -EINVAL;
-
-	pwm_mode = amdgpu_dpm_get_fan_control_mode(adev);
+	if (is_support_sw_smu(adev)) {
+		pwm_mode = smu_get_fan_control_mode(&adev->smu);
+	} else {
+		if (!adev->powerplay.pp_funcs->get_fan_control_mode)
+			return -EINVAL;
 
-	return sprintf(buf, "%i\n", pwm_mode == AMD_FAN_CTRL_AUTO ? 0 : 1);
+		pwm_mode = amdgpu_dpm_get_fan_control_mode(adev);
+	}
+		return sprintf(buf, "%i\n", pwm_mode == AMD_FAN_CTRL_AUTO ? 0 : 1);
 }
 
 static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev,
@@ -1658,8 +1661,6 @@  static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev,
 	     (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON))
 		return -EINVAL;
 
-	if (!adev->powerplay.pp_funcs->set_fan_control_mode)
-		return -EINVAL;
 
 	err = kstrtoint(buf, 10, &value);
 	if (err)
@@ -1672,7 +1673,13 @@  static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev,
 	else
 		return -EINVAL;
 
-	amdgpu_dpm_set_fan_control_mode(adev, pwm_mode);
+	if (is_support_sw_smu(adev)) {
+		smu_set_fan_control_mode(&adev->smu, pwm_mode);
+	} else {
+		if (!adev->powerplay.pp_funcs->set_fan_control_mode)
+			return -EINVAL;
+		amdgpu_dpm_set_fan_control_mode(adev, pwm_mode);
+	}
 
 	return count;
 }
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index aaa1bd8..c0bc4f4 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -1856,7 +1856,7 @@  smu_v11_0_set_fan_control_mode(struct smu_context *smu,
 	}
 
 	if (ret) {
-		pr_err("[%s]Set fan control mode failed!");
+		pr_err("[%s]Set fan control mode failed!", __func__);
 		return -EINVAL;
 	}
 

Comments

On Mon, Feb 25, 2019 at 7:13 AM Huang Rui <ray.huang@amd.com> wrote:
>
> From: Chengming Gui <Jack.Gui@amd.com>
>
> set the fan1_enable hwmon interface to call
> smu_get_fan_control_mode and smu_set_fan_control_mode.
>
> v2: fix print value.
>
> Signed-off-by: Chengming Gui <Jack.Gui@amd.com>
> Reviewed-by: Huang Rui <ray.huang@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c    | 23 +++++++++++++++--------
>  drivers/gpu/drm/amd/powerplay/smu_v11_0.c |  2 +-
>  2 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> index ac991f9..9413c39 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
> @@ -1635,12 +1635,15 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,
>         struct amdgpu_device *adev = dev_get_drvdata(dev);
>         u32 pwm_mode = 0;
>
> -       if (!adev->powerplay.pp_funcs->get_fan_control_mode)
> -               return -EINVAL;
> -
> -       pwm_mode = amdgpu_dpm_get_fan_control_mode(adev);
> +       if (is_support_sw_smu(adev)) {
> +               pwm_mode = smu_get_fan_control_mode(&adev->smu);
> +       } else {
> +               if (!adev->powerplay.pp_funcs->get_fan_control_mode)
> +                       return -EINVAL;
>
> -       return sprintf(buf, "%i\n", pwm_mode == AMD_FAN_CTRL_AUTO ? 0 : 1);
> +               pwm_mode = amdgpu_dpm_get_fan_control_mode(adev);
> +       }
> +               return sprintf(buf, "%i\n", pwm_mode == AMD_FAN_CTRL_AUTO ? 0 : 1);

indentation looks wrong here.
With that fixed:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>


>  }
>
>  static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev,
> @@ -1658,8 +1661,6 @@ static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev,
>              (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON))
>                 return -EINVAL;
>
> -       if (!adev->powerplay.pp_funcs->set_fan_control_mode)
> -               return -EINVAL;
>
>         err = kstrtoint(buf, 10, &value);
>         if (err)
> @@ -1672,7 +1673,13 @@ static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev,
>         else
>                 return -EINVAL;
>
> -       amdgpu_dpm_set_fan_control_mode(adev, pwm_mode);
> +       if (is_support_sw_smu(adev)) {
> +               smu_set_fan_control_mode(&adev->smu, pwm_mode);
> +       } else {
> +               if (!adev->powerplay.pp_funcs->set_fan_control_mode)
> +                       return -EINVAL;
> +               amdgpu_dpm_set_fan_control_mode(adev, pwm_mode);
> +       }
>
>         return count;
>  }
> diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> index aaa1bd8..c0bc4f4 100644
> --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> @@ -1856,7 +1856,7 @@ smu_v11_0_set_fan_control_mode(struct smu_context *smu,
>         }
>
>         if (ret) {
> -               pr_err("[%s]Set fan control mode failed!");
> +               pr_err("[%s]Set fan control mode failed!", __func__);
>                 return -EINVAL;
>         }
>
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx