<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p><br>
</p>
<div style="color: rgb(0, 0, 0);">
<div>
<div id="x_divRplyFwdMsg" dir="ltr">
<div></div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Signed-off-by: Rex Zhu <Rex.Zhu@amd.com><br>
<br>
Change-Id: I72d61851630e5d4ff5b3236ca33abac6f5b200c6<br>
---<br>
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 35 ++++++++++++----------<br>
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c | 9 +++---<br>
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h | 2 +-<br>
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 1 +<br>
4 files changed, 27 insertions(+), 20 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c<br>
index b3d4285..a74a3db 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c<br>
@@ -4334,26 +4334,31 @@ static int smu7_print_clock_levels(struct pp_hwmgr *hwmgr,<br>
<br>
static int smu7_set_fan_control_mode(struct pp_hwmgr *hwmgr, uint32_t mode)<br>
{<br>
- if (mode) {<br>
- /* stop auto-manage */<br>
- if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,<br>
- PHM_PlatformCaps_MicrocodeFanControl))<br>
- smu7_fan_ctrl_stop_smc_fan_control(hwmgr);<br>
- smu7_fan_ctrl_set_static_mode(hwmgr, mode);<br>
- } else<br>
- /* restart auto-manage */<br>
- smu7_fan_ctrl_reset_fan_speed_to_default(hwmgr);<br>
+ int result = 0;<br>
<br>
- return 0;<br>
+ switch (mode) {<br>
+ case AMD_FAN_CTRL_NONE:<br>
+ result = smu7_fan_ctrl_set_fan_speed_percent(hwmgr, 100);<br>
+ break;<br>
+ case AMD_FAN_CTRL_MANUAL:<br>
+ if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,<br>
+ PHM_PlatformCaps_MicrocodeFanControl))<br>
+ result = smu7_fan_ctrl_stop_smc_fan_control(hwmgr);<br>
+ break;<br>
+ case AMD_FAN_CTRL_AUTO:<br>
+ result = smu7_fan_ctrl_set_static_mode(hwmgr, mode);<br>
+ if (!result)<br>
+ result = smu7_fan_ctrl_start_smc_fan_control(hwmgr);<br>
+ break;<br>
+ default:<br>
+ break;<br>
+ }<br>
+ return result;<br>
}<br>
<br>
static int smu7_get_fan_control_mode(struct pp_hwmgr *hwmgr)<br>
{<br>
- if (hwmgr->fan_ctrl_is_in_default_mode)<br>
- return hwmgr->fan_ctrl_default_mode;<br>
- else<br>
- return PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,<br>
- CG_FDO_CTRL2, FDO_PWM_MODE);<br>
+ return hwmgr->fan_ctrl_enabled ? AMD_FAN_CTRL_AUTO : AMD_FAN_CTRL_MANUAL;<br>
}<br>
<br>
static int smu7_get_sclk_od(struct pp_hwmgr *hwmgr)<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c<br>
index 436ca5c..baddb56 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c<br>
@@ -112,10 +112,9 @@ int smu7_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t *speed)<br>
*/<br>
int smu7_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode)<br>
{<br>
-<br>
if (hwmgr->fan_ctrl_is_in_default_mode) {<br>
hwmgr->fan_ctrl_default_mode =<br>
- PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,<br>
+ PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,<br>
CG_FDO_CTRL2, FDO_PWM_MODE);<br>
hwmgr->tmin =<br>
PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,<br>
@@ -149,7 +148,7 @@ int smu7_fan_ctrl_set_default_mode(struct pp_hwmgr *hwmgr)<br>
return 0;<br>
}<br>
<br>
-static int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr)<br>
+int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr)<br>
{<br>
int result;<br>
<br>
@@ -179,6 +178,7 @@ static int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr)<br>
PPSMC_MSG_SetFanTemperatureTarget,<br>
hwmgr->thermal_controller.<br>
advanceFanControlParameters.ucTargetTemperature);<br>
+ hwmgr->fan_ctrl_enabled = true;<br>
<br>
return result;<br>
}<br>
@@ -186,6 +186,7 @@ static int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr)<br>
<br>
int smu7_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr)<br>
{<br>
+ hwmgr->fan_ctrl_enabled = false;<br>
return smum_send_msg_to_smc(hwmgr->smumgr, PPSMC_StopFanControl);<br>
}<br>
<br>
@@ -280,7 +281,7 @@ int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)<br>
PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,<br>
CG_TACH_STATUS, TACH_PERIOD, tach_period);<br>
<br>
- return smu7_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC);<br>
+ return smu7_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC_RPM);<br>
}<br>
<br>
/**<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h<br>
index 2ed774d..ba71b60 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.h<br>
@@ -54,6 +54,6 @@<br>
extern int smu7_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr);<br>
extern int smu7_thermal_enable_alert(struct pp_hwmgr *hwmgr);<br>
extern int smu7_thermal_disable_alert(struct pp_hwmgr *hwmgr);<br>
-<br>
+extern int smu7_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr);<br>
#endif<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h<br>
index e4574c2..805b9df 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h<br>
@@ -764,6 +764,7 @@ struct pp_hwmgr {<br>
struct pp_thermal_controller_info thermal_controller;<br>
bool fan_ctrl_is_in_default_mode;<br>
uint32_t fan_ctrl_default_mode;<br>
+ bool fan_ctrl_enabled;<br>
uint32_t tmin;<br>
struct phm_microcode_version_info microcode_version_info;<br>
uint32_t ps_size;<br>
-- <br>
1.9.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>