Fw: [PATCH 4/5] drm/amd/powerplay: refine pwm1_enable callback functions on vi.

Zhu, Rex Rex.Zhu at amd.com
Fri May 5 12:43:39 UTC 2017


Signed-off-by: Rex Zhu <Rex.Zhu at amd.com>

Change-Id: I72d61851630e5d4ff5b3236ca33abac6f5b200c6
---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c   | 35 ++++++++++++----------
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c |  9 +++---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h |  2 +-
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          |  1 +
 4 files changed, 27 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index b3d4285..a74a3db 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -4334,26 +4334,31 @@ static int smu7_print_clock_levels(struct pp_hwmgr *hwmgr,

 static int smu7_set_fan_control_mode(struct pp_hwmgr *hwmgr, uint32_t mode)
 {
-       if (mode) {
-               /* stop auto-manage */
-               if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
-                               PHM_PlatformCaps_MicrocodeFanControl))
-                       smu7_fan_ctrl_stop_smc_fan_control(hwmgr);
-               smu7_fan_ctrl_set_static_mode(hwmgr, mode);
-       } else
-               /* restart auto-manage */
-               smu7_fan_ctrl_reset_fan_speed_to_default(hwmgr);
+       int result = 0;

-       return 0;
+       switch (mode) {
+       case AMD_FAN_CTRL_NONE:
+               result = smu7_fan_ctrl_set_fan_speed_percent(hwmgr, 100);
+               break;
+       case AMD_FAN_CTRL_MANUAL:
+               if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
+                       PHM_PlatformCaps_MicrocodeFanControl))
+                       result = smu7_fan_ctrl_stop_smc_fan_control(hwmgr);
+               break;
+       case AMD_FAN_CTRL_AUTO:
+               result = smu7_fan_ctrl_set_static_mode(hwmgr, mode);
+               if (!result)
+                       result = smu7_fan_ctrl_start_smc_fan_control(hwmgr);
+               break;
+       default:
+               break;
+       }
+       return result;
 }

 static int smu7_get_fan_control_mode(struct pp_hwmgr *hwmgr)
 {
-       if (hwmgr->fan_ctrl_is_in_default_mode)
-               return hwmgr->fan_ctrl_default_mode;
-       else
-               return PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
-                               CG_FDO_CTRL2, FDO_PWM_MODE);
+       return hwmgr->fan_ctrl_enabled ? AMD_FAN_CTRL_AUTO : AMD_FAN_CTRL_MANUAL;
 }

 static int smu7_get_sclk_od(struct pp_hwmgr *hwmgr)
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c
index 436ca5c..baddb56 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c
@@ -112,10 +112,9 @@ int smu7_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t *speed)
 */
 int smu7_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode)
 {
-
         if (hwmgr->fan_ctrl_is_in_default_mode) {
                 hwmgr->fan_ctrl_default_mode =
-                               PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device,     CGS_IND_REG__SMC,
+                               PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
                                                 CG_FDO_CTRL2, FDO_PWM_MODE);
                 hwmgr->tmin =
                                 PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
@@ -149,7 +148,7 @@ int smu7_fan_ctrl_set_default_mode(struct pp_hwmgr *hwmgr)
         return 0;
 }

-static int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr)
+int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr)
 {
         int result;

@@ -179,6 +178,7 @@ static int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr)
                                 PPSMC_MSG_SetFanTemperatureTarget,
                                 hwmgr->thermal_controller.
                                 advanceFanControlParameters.ucTargetTemperature);
+       hwmgr->fan_ctrl_enabled = true;

         return result;
 }
@@ -186,6 +186,7 @@ static int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr)

 int smu7_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr)
 {
+       hwmgr->fan_ctrl_enabled = false;
         return smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_StopFanControl);
 }

@@ -280,7 +281,7 @@ int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)
         PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
                                 CG_TACH_STATUS, TACH_PERIOD, tach_period);

-       return smu7_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC);
+       return smu7_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC_RPM);
 }

 /**
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h
index 2ed774d..ba71b60 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h
@@ -54,6 +54,6 @@
 extern int smu7_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr);
 extern int smu7_thermal_enable_alert(struct pp_hwmgr *hwmgr);
 extern int smu7_thermal_disable_alert(struct pp_hwmgr *hwmgr);
-
+extern int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr);
 #endif

diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index e4574c2..805b9df 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -764,6 +764,7 @@ struct pp_hwmgr {
         struct pp_thermal_controller_info thermal_controller;
         bool fan_ctrl_is_in_default_mode;
         uint32_t fan_ctrl_default_mode;
+       bool fan_ctrl_enabled;
         uint32_t tmin;
         struct phm_microcode_version_info microcode_version_info;
         uint32_t ps_size;
--
1.9.1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20170505/21c3d07c/attachment-0001.html>


More information about the amd-gfx mailing list