<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:DengXian;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Microsoft YaHei";
        panose-1:2 11 5 3 2 2 4 2 2 4;}
@font-face
        {font-family:"Microsoft YaHei";}
@font-face
        {font-family:"Segoe UI";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
@font-face
        {font-family:"Segoe UI Light";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Sure<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Zhu, Rex <br>
<b>Sent:</b> 2018<span lang="ZH-CN" style="font-family:"΢ÈíÑźÚ",sans-serif">Äê</span>10<span lang="ZH-CN" style="font-family:"΢ÈíÑźÚ",sans-serif">ÔÂ</span>24<span lang="ZH-CN" style="font-family:"΢ÈíÑźÚ",sans-serif">ÈÕ</span> 16:37<br>
<b>To:</b> Quan, Evan <Evan.Quan@amd.com>; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH 3/3] drm/amd/powerplay: support hwmon max/min fan speed setting on Vega20<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div id="divtagdefaultwrapper">
<p><span style="color:black">-       percent = current_rpm * 100 / pp_table->FanMaximumRpm;<br>
+       percent = (current_rpm * 100) /<br>
+               hwmgr->thermal_controller.fanInfo.ulMaxRPM;</span><span style="font-size:12.0pt;color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
<p><span style="font-size:12.0pt;color:black">Better check </span><span style="color:black">hwmgr->thermal_controller.fanInfo.ulMaxRPM</span><span style="font-size:12.0pt;color:black"> not equal to 0.<o:p></o:p></span></p>
<p><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
<p><span style="font-size:12.0pt;color:black">Best Regards<o:p></o:p></span></p>
<p><span style="font-size:12.0pt;color:black">Rex<o:p></o:p></span></p>
<div>
<div class="MsoNormal" align="center" style="text-align:center"><span style="font-size:12.0pt;color:black">
<hr size="2" width="98%" align="center">
</span></div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> amd-gfx <<a href="mailto:amd-gfx-bounces@lists.freedesktop.org">amd-gfx-bounces@lists.freedesktop.org</a>> on behalf of Evan Quan <<a href="mailto:evan.quan@amd.com">evan.quan@amd.com</a>><br>
<b>Sent:</b> Wednesday, October 24, 2018 4:11 PM<br>
<b>To:</b> <a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<b>Cc:</b> Quan, Evan<br>
<b>Subject:</b> [PATCH 3/3] drm/amd/powerplay: support hwmon max/min fan speed setting on Vega20</span><span style="font-size:12.0pt;color:black">
<o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt;color:black"> <o:p></o:p></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="color:black">Added support for hwmon max/min fan speed setting on Vega20.<br>
<br>
Change-Id: Ieab42c744d6c54f8b85a71be80f7c6832ae7352b<br>
Signed-off-by: Evan Quan <<a href="mailto:evan.quan@amd.com">evan.quan@amd.com</a>><br>
---<br>
 .../drm/amd/powerplay/hwmgr/vega20_hwmgr.c    |  4 ++<br>
 .../drm/amd/powerplay/hwmgr/vega20_thermal.c  | 56 ++++++++++++++++++-<br>
 .../drm/amd/powerplay/hwmgr/vega20_thermal.h  |  4 ++<br>
 3 files changed, 62 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c<br>
index 57143d51e3ee..2513e6be3219 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c<br>
@@ -3539,6 +3539,10 @@ static const struct pp_hwmgr_func vega20_hwmgr_funcs = {<br>
                 vega20_get_fan_control_mode,<br>
         .set_fan_control_mode =<br>
                 vega20_set_fan_control_mode,<br>
+       .set_fan_speed_max_rpm =<br>
+               vega20_fan_ctrl_set_fan_speed_max_rpm,<br>
+       .set_fan_speed_min_rpm =<br>
+               vega20_fan_ctrl_set_fan_speed_min_rpm,<br>
         /* smu memory related */<br>
         .notify_cac_buffer_info =<br>
                 vega20_notify_cac_buffer_info,<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c<br>
index ede54e87e287..da9fd2168dcb 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.c<br>
@@ -118,7 +118,6 @@ int vega20_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr,<br>
                 uint32_t *speed)<br>
 {<br>
         struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend);<br>
-       PPTable_t *pp_table = &(data->smc_state_table.pp_table);<br>
         uint32_t current_rpm, percent = 0;<br>
         int ret = 0;<br>
 <br>
@@ -126,7 +125,8 @@ int vega20_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr,<br>
         if (ret)<br>
                 return ret;<br>
 <br>
-       percent = current_rpm * 100 / pp_table->FanMaximumRpm;<br>
+       percent = (current_rpm * 100) /<br>
+               hwmgr->thermal_controller.fanInfo.ulMaxRPM;<br>
 <br>
         *speed = percent > 100 ? 100 : percent;<br>
 <br>
@@ -208,6 +208,58 @@ int vega20_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)<br>
         return vega20_fan_ctrl_set_static_mode(hwmgr, FDO_PWM_MODE_STATIC_RPM);<br>
 }<br>
 <br>
+int vega20_fan_ctrl_set_fan_speed_max_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)<br>
+{<br>
+       struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend);<br>
+       struct vega20_od8_settings *od8_settings = &(data->od8_settings);<br>
+       int ret = 0;<br>
+<br>
+       if ((od8_settings->overdrive8_capabilities & OD8_ACOUSTIC_LIMIT_SCLK) &&<br>
+           (speed > od8_settings->od8_settings_array[OD8_SETTING_FAN_ACOUSTIC_LIMIT].max_value ||<br>
+            speed < od8_settings->od8_settings_array[OD8_SETTING_FAN_ACOUSTIC_LIMIT].min_value))<br>
+               return -EINVAL;<br>
+<br>
+       ret = smum_send_msg_to_smc_with_parameter(hwmgr,<br>
+                       PPSMC_MSG_SetFanMaxRpm,<br>
+                       speed);<br>
+       PP_ASSERT_WITH_CODE(!ret,<br>
+                       "Set FanMaxRpm Failed!",<br>
+                       return ret);<br>
+<br>
+       hwmgr->thermal_controller.fanInfo.ulMinRPM =<br>
+               (speed * hwmgr->thermal_controller.fanInfo.ulMinPWM) / 255;<br>
+<br>
+       return ret;<br>
+}<br>
+<br>
+int vega20_fan_ctrl_set_fan_speed_min_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)<br>
+{<br>
+       struct vega20_hwmgr *data = (struct vega20_hwmgr *)(hwmgr->backend);<br>
+       struct vega20_od8_settings *od8_settings = &(data->od8_settings);<br>
+       int ret = 0;<br>
+       uint32_t pwm = 0;<br>
+<br>
+       if ((od8_settings->overdrive8_capabilities & OD8_FAN_SPEED_MIN) &&<br>
+           (speed > od8_settings->od8_settings_array[OD8_FAN_SPEED_MIN].max_value ||<br>
+            speed < od8_settings->od8_settings_array[OD8_FAN_SPEED_MIN].min_value))<br>
+               return -EINVAL;<br>
+<br>
+       if (speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM)<br>
+               return -EINVAL;<br>
+<br>
+       pwm = (speed * 255) / hwmgr->thermal_controller.fanInfo.ulMaxRPM;<br>
+       ret = smum_send_msg_to_smc_with_parameter(hwmgr,<br>
+                       PPSMC_MSG_SetFanMinPwm,<br>
+                       pwm);<br>
+       PP_ASSERT_WITH_CODE(!ret,<br>
+                       "Set FanMinPwm Failed!",<br>
+                       return ret);<br>
+<br>
+       hwmgr->thermal_controller.fanInfo.ulMinPWM = pwm;<br>
+<br>
+       return ret;<br>
+}<br>
+<br>
 /**<br>
 * Reads the remote temperature from the SIslands thermal controller.<br>
 *<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.h<br>
index 2d1769bbd24e..ddfc950e90ca 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_thermal.h<br>
@@ -56,6 +56,10 @@ extern int vega20_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr,<br>
                 uint32_t *speed);<br>
 extern int vega20_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr,<br>
                 uint32_t speed);<br>
+extern int vega20_fan_ctrl_set_fan_speed_max_rpm(struct pp_hwmgr *hwmgr,<br>
+               uint32_t speed);<br>
+extern int vega20_fan_ctrl_set_fan_speed_min_rpm(struct pp_hwmgr *hwmgr,<br>
+               uint32_t speed);<br>
 extern int vega20_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr,<br>
                 uint32_t *speed);<br>
 extern int vega20_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr,<br>
-- <br>
2.19.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
<o:p></o:p></span></p>
<div style="margin-bottom:15.0pt;overflow:auto" id="LPBorder_GT_15403701438120.35346562924862934">
<table class="MsoNormalTable" border="1" cellspacing="0" cellpadding="0" width="90%" style="width:90.0%;background:white;border-top:dotted #C8C8C8 1.0pt;border-left:none;border-bottom:dotted #C8C8C8 1.0pt;border-right:none">
<tbody>
<tr>
<td valign="top" style="border:none;padding:0cm 0cm 0cm 0cm">
<div id="LPTitle_15403701438100.6054106554689949">
<p class="MsoNormal" style="margin-top:15.0pt;mso-line-height-alt:15.75pt"><span style="font-size:16.0pt;font-family:"Segoe UI Light",sans-serif;color:#0078D7"><a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" target="_blank"><span style="text-decoration:none">amd-gfx
 Info Page - freedesktop.org</span></a><o:p></o:p></span></p>
</div>
<div style="margin-top:7.5pt;margin-bottom:12.0pt" id="LPMetadata_15403701438120.035970050768817985">
<p class="MsoNormal" style="margin-top:15.0pt;line-height:10.5pt"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#666666">lists.freedesktop.org<o:p></o:p></span></p>
</div>
<div id="LPDescription_15403701438120.9681582559548375">
<p class="MsoNormal" style="margin-top:15.0pt;line-height:15.0pt"><span style="font-size:10.5pt;font-family:"Segoe UI",sans-serif;color:#666666">To see the collection of prior postings to the list, visit the amd-gfx Archives.. Using amd-gfx: To post a message
 to all the list members, send email to <a href="mailto:amd-gfx@lists.freedesktop.org">
amd-gfx@lists.freedesktop.org</a>. You can subscribe to the list, or change your existing subscription, in the sections below.<o:p></o:p></span></p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<p class="MsoNormal"><span style="color:black"><o:p> </o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>