<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" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Arial, Helvetica, sans-serif, EmojiFont, 'Apple Color Emoji', 'Segoe UI Emoji', NotoColorEmoji, 'Segoe UI Symbol', 'Android Emoji', EmojiSymbols;">
<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">Change-Id: Ib8681558cabab99da804d1d10987aca63435b1e5<br>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com><br>
---<br>
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 43 ++++++++++++----------<br>
 .../gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h   |  1 +<br>
 2 files changed, 25 insertions(+), 19 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c<br>
index 625ee9d..9fef840 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c<br>
@@ -3962,32 +3962,37 @@ static int vega10_dpm_force_dpm_level(struct pp_hwmgr *hwmgr,<br>
 <br>
 static int vega10_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>
-                       vega10_fan_ctrl_stop_smc_fan_control(hwmgr);<br>
-               vega10_fan_ctrl_set_static_mode(hwmgr, mode);<br>
-       } else<br>
-               /* restart auto-manage */<br>
-               vega10_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 = vega10_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 = vega10_fan_ctrl_stop_smc_fan_control(hwmgr);<br>
+               break;<br>
+       case AMD_FAN_CTRL_AUTO:<br>
+               result = vega10_fan_ctrl_set_static_mode(hwmgr, mode);<br>
+               if (!result)<br>
+                       result = vega10_fan_ctrl_start_smc_fan_control(hwmgr);<br>
+               break;<br>
+       default:<br>
+               break;<br>
+       }<br>
+       return result;<br>
 }<br>
 <br>
 static int vega10_get_fan_control_mode(struct pp_hwmgr *hwmgr)<br>
 {<br>
         uint32_t reg;<br>
+       struct vega10_hwmgr *data = (struct vega10_hwmgr *)(hwmgr->backend);<br>
 <br>
-       if (hwmgr->fan_ctrl_is_in_default_mode) {<br>
-               return hwmgr->fan_ctrl_default_mode;<br>
-       } else {<br>
-               reg = soc15_get_register_offset(THM_HWID, 0,<br>
-                       mmCG_FDO_CTRL2_BASE_IDX, mmCG_FDO_CTRL2);<br>
-               return (cgs_read_register(hwmgr->device, reg) &<br>
-                               CG_FDO_CTRL2__FDO_PWM_MODE_MASK) >><br>
-                               CG_FDO_CTRL2__FDO_PWM_MODE__SHIFT;<br>
-       }<br>
+       if (data->smu_features[GNLD_FAN_CONTROL].enabled == false)<br>
+               return AMD_FAN_CTRL_MANUAL;<br>
+       else<br>
+               return AMD_FAN_CTRL_AUTO;<br>
 }<br>
 <br>
 static int vega10_get_dal_power_level(struct pp_hwmgr *hwmgr,<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h<br>
index 70c1d22..776f3a2 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_thermal.h<br>
@@ -79,6 +79,7 @@ extern int vega10_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr,<br>
 extern int vega10_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr);<br>
 extern uint32_t smu7_get_xclk(struct pp_hwmgr *hwmgr);<br>
 extern int vega10_thermal_disable_alert(struct pp_hwmgr *hwmgr);<br>
+int vega10_fan_ctrl_start_smc_fan_control(struct pp_hwmgr *hwmgr);<br>
 <br>
 #endif<br>
 <br>
-- <br>
1.9.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>