<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<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: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;" dir="ltr">
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Zhu, Rex<br>
<b>Sent:</b> Thursday, September 20, 2018 10:43 AM<br>
<b>To:</b> Deucher, Alexander; amd-gfx@lists.freedesktop.org; Quan, Evan<br>
<b>Subject:</b> RE: [PATCH 1/3] drm/amd/pp: Avoid divide-by-zero in smu7_fan_ctrl_set_fan_speed_rpm</font>
<div> </div>
</div>
<meta content="text/html; charset=us-ascii">
<meta name="x_Generator" content="Microsoft Word 15 (filtered medium)">
<div link="blue" vlink="purple" lang="EN-US">
<div class="x_WordSection1">
<p class="x_MsoNormal">Hi Alex and Evan,</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">For the fan control via sysfs, I think we need to clarify the use case.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">We support manual/auto fan control mode.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">User can set the mode through pwm_enable. 1 mean manual. 2 mean auto</p>
<p class="x_MsoNormal">User can set fan speed via pwm1 and fan1_input.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">For pwm1, user set the percentage value (0% - 100%)</p>
<p class="x_MsoNormal">And can get the pwm1’s range via sysfs: pwm1_min, pwm1_max. the range is [0, 255]. In driver, we transfer to [0% - 100%]</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">For fan1_input, user set the fan’s resolution per minute</p>
<p class="x_MsoNormal">No way for user to get the range. On Tonga, the range is (0, 6000]. Not support zero-rpm on tonga.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Do we need to add new sysfs to expose the RPM range or just print the range in dmesg if user’s setting is out of range?</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"><span style="color: rgb(75, 165, 36);">Yes, expose the rpm limits via fan1_min and max. See:</span></p>
<p class="x_MsoNormal"><a href="https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface" class="OWAAutoLink" id="LPlnk700456" previewremoved="true"><span style="color: rgb(75, 165, 36);">https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface</span></a></p>
<p class="x_MsoNormal"><span style="color: rgb(75, 165, 36);">for more info on standard
</span><span style="color: rgb(75, 165, 36);">sysfs interfaces for hwmon.</span><br>
</p>
<p class="x_MsoNormal"><br>
</p>
<p class="x_MsoNormal">Another question is:</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Currently, the default fan control mode is auto.</p>
<p class="x_MsoNormal">When user change the fan speed via pwm1 or fan1_input, we switch to manual mode automatically.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">So if user want to change back to auto fan control mode, they need to echo 2 to pwm_enable.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"><span style="color: rgb(75, 165, 36);">I think we should reject any changes unless the user selects manual (1) first.</span><br>
</p>
<p class="x_MsoNormal"><br>
</p>
<p class="x_MsoNormal">Best Regards</p>
<p class="x_MsoNormal">Rex</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal"> </p>
<div style="border:none; border-left:solid blue 1.5pt; padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal"><b>From:</b> Deucher, Alexander <br>
<b>Sent:</b> Thursday, September 20, 2018 9:52 PM<br>
<b>To:</b> Zhu, Rex <Rex.Zhu@amd.com>; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH 1/3] drm/amd/pp: Avoid divide-by-zero in smu7_fan_ctrl_set_fan_speed_rpm</p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<div id="x_divtagdefaultwrapper">
<p><span style="font-size:12.0pt; color:black">Series is:</span></p>
<p><span style="font-size:12.0pt; color:black">Reviewed-by: Alex Deucher <<a href="mailto:alexander.deucher@amd.com" id="LPlnk816393" class="OWAAutoLink" previewremoved="true">alexander.deucher@amd.com</a>></span></p>
</div>
<div class="x_MsoNormal" style="text-align:center" align="center">
<hr width="98%" size="3" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> amd-gfx <<a href="mailto:amd-gfx-bounces@lists.freedesktop.org" id="LPlnk94004" class="OWAAutoLink" previewremoved="true">amd-gfx-bounces@lists.freedesktop.org</a>>
on behalf of Rex Zhu <<a href="mailto:Rex.Zhu@amd.com" id="LPlnk312175" class="OWAAutoLink" previewremoved="true">Rex.Zhu@amd.com</a>><br>
<b>Sent:</b> Thursday, September 20, 2018 3:14:25 AM<br>
<b>To:</b> <a href="mailto:amd-gfx@lists.freedesktop.org" id="LPlnk914609" class="OWAAutoLink" previewremoved="true">
amd-gfx@lists.freedesktop.org</a><br>
<b>Cc:</b> Zhu, Rex<br>
<b>Subject:</b> [PATCH 1/3] drm/amd/pp: Avoid divide-by-zero in smu7_fan_ctrl_set_fan_speed_rpm</span>
</p>
<div>
<p class="x_MsoNormal"> </p>
</div>
</div>
<div>
<div>
<p class="x_MsoNormal">The minRPM speed maybe equal to zero. so need to check<br>
input RPM not equal to 0, otherwise cause divide-by-zero driver crash.<br>
<br>
Signed-off-by: Rex Zhu <<a href="mailto:Rex.Zhu@amd.com" id="LPlnk857205" class="OWAAutoLink" previewremoved="true">Rex.Zhu@amd.com</a>><br>
---<br>
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c | 1 +<br>
1 file changed, 1 insertion(+)<br>
<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 44527755..d61a9b4 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_thermal.c<br>
@@ -260,6 +260,7 @@ int smu7_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed)<br>
if (hwmgr->thermal_controller.fanInfo.bNoFan ||<br>
(hwmgr->thermal_controller.fanInfo.<br>
ucTachometerPulsesPerRevolution == 0) ||<br>
+ speed == 0 ||<br>
(speed < hwmgr->thermal_controller.fanInfo.ulMinRPM) ||<br>
(speed > hwmgr->thermal_controller.fanInfo.ulMaxRPM))<br>
return 0;<br>
-- <br>
1.9.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org" id="LPlnk288979" class="OWAAutoLink" previewremoved="true">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" id="LPlnk994164" class="OWAAutoLink" previewremoved="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>