<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">This can be performed under auto mode. <o:p></o:p></p>
<p class="MsoNormal">The settings are always effective unless user resets them back.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal">Evan<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:36<br>
<b>To:</b> Quan, Evan <Evan.Quan@amd.com>; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH 2/3] drm/amd/powerplay: added hwmon interfaces for setting max/min fan speed<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div id="divtagdefaultwrapper">
<p><span style="font-size:12.0pt;color:black">One question: how to exit the max/min fan speed and return to auto mode?<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>
<p><span style="font-size:12.0pt;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:12.0pt;color:black"><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 2/3] drm/amd/powerplay: added hwmon interfaces for setting max/min fan speed</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">New hwmon interfaces for maximum and minimum fan speed setting.<br>
<br>
Change-Id: Ic9ec9f2427c6d3425e1c7e7b765d7d01a92f9a26<br>
Signed-off-by: Evan Quan <<a href="mailto:evan.quan@amd.com">evan.quan@amd.com</a>><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 6 ++<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 56 ++++++++++++++++++-<br>
.../gpu/drm/amd/include/kgd_pp_interface.h | 2 +<br>
drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 46 +++++++++++++++<br>
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 2 +<br>
5 files changed, 110 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h<br>
index f972cd156795..12c4e461a7bc 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h<br>
@@ -364,6 +364,12 @@ enum amdgpu_pcie_gen {<br>
((adev)->powerplay.pp_funcs->enable_mgpu_fan_boost(\<br>
(adev)->powerplay.pp_handle))<br>
<br>
+#define amdgpu_dpm_set_fan_speed_max_rpm(adev, s) \<br>
+ ((adev)->powerplay.pp_funcs->set_fan_speed_max_rpm)((adev)->powerplay.pp_handle, (s))<br>
+<br>
+#define amdgpu_dpm_set_fan_speed_min_rpm(adev, s) \<br>
+ ((adev)->powerplay.pp_funcs->set_fan_speed_min_rpm)((adev)->powerplay.pp_handle, (s))<br>
+<br>
struct amdgpu_dpm {<br>
struct amdgpu_ps *ps;<br>
/* number of valid power states */<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
index 8e94255654ed..92da37bb51ba 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
@@ -1265,6 +1265,32 @@ static ssize_t amdgpu_hwmon_get_fan1_min(struct device *dev,<br>
return snprintf(buf, PAGE_SIZE, "%d\n", min_rpm);<br>
}<br>
<br>
+static ssize_t amdgpu_hwmon_set_fan1_min(struct device *dev,<br>
+ struct device_attribute *attr,<br>
+ const char *buf, size_t count)<br>
+{<br>
+ struct amdgpu_device *adev = dev_get_drvdata(dev);<br>
+ int err;<br>
+ u32 value;<br>
+<br>
+ /* Can't adjust fan when the card is off */<br>
+ if ((adev->flags & AMD_IS_PX) &&<br>
+ (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON))<br>
+ return -EINVAL;<br>
+<br>
+ err = kstrtou32(buf, 10, &value);<br>
+ if (err)<br>
+ return err;<br>
+<br>
+ if (adev->powerplay.pp_funcs->set_fan_speed_min_rpm) {<br>
+ err = amdgpu_dpm_set_fan_speed_min_rpm(adev, value);<br>
+ if (err)<br>
+ return err;<br>
+ }<br>
+<br>
+ return count;<br>
+}<br>
+<br>
static ssize_t amdgpu_hwmon_get_fan1_max(struct device *dev,<br>
struct device_attribute *attr,<br>
char *buf)<br>
@@ -1285,6 +1311,32 @@ static ssize_t amdgpu_hwmon_get_fan1_max(struct device *dev,<br>
return snprintf(buf, PAGE_SIZE, "%d\n", max_rpm);<br>
}<br>
<br>
+static ssize_t amdgpu_hwmon_set_fan1_max(struct device *dev,<br>
+ struct device_attribute *attr,<br>
+ const char *buf, size_t count)<br>
+{<br>
+ struct amdgpu_device *adev = dev_get_drvdata(dev);<br>
+ int err;<br>
+ u32 value;<br>
+<br>
+ /* Can't adjust fan when the card is off */<br>
+ if ((adev->flags & AMD_IS_PX) &&<br>
+ (adev->ddev->switch_power_state != DRM_SWITCH_POWER_ON))<br>
+ return -EINVAL;<br>
+<br>
+ err = kstrtou32(buf, 10, &value);<br>
+ if (err)<br>
+ return err;<br>
+<br>
+ if (adev->powerplay.pp_funcs->set_fan_speed_max_rpm) {<br>
+ err = amdgpu_dpm_set_fan_speed_max_rpm(adev, value);<br>
+ if (err)<br>
+ return err;<br>
+ }<br>
+<br>
+ return count;<br>
+}<br>
+<br>
static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,<br>
struct device_attribute *attr,<br>
char *buf)<br>
@@ -1628,8 +1680,8 @@ static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1_<br>
static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0);<br>
static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, amdgpu_hwmon_get_pwm1_max, NULL, 0);<br>
static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, amdgpu_hwmon_get_fan1_input, NULL, 0);<br>
-static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO, amdgpu_hwmon_get_fan1_min, NULL, 0);<br>
-static SENSOR_DEVICE_ATTR(fan1_max, S_IRUGO, amdgpu_hwmon_get_fan1_max, NULL, 0);<br>
+static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_fan1_min, amdgpu_hwmon_set_fan1_min, 0);<br>
+static SENSOR_DEVICE_ATTR(fan1_max, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_fan1_max, amdgpu_hwmon_set_fan1_max, 0);<br>
static SENSOR_DEVICE_ATTR(fan1_target, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_fan1_target, amdgpu_hwmon_set_fan1_target, 0);<br>
static SENSOR_DEVICE_ATTR(fan1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_fan1_enable, amdgpu_hwmon_set_fan1_enable, 0);<br>
static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, amdgpu_hwmon_show_vddgfx, NULL, 0);<br>
diff --git a/drivers/gpu/drm/amd/include/kgd_pp_interface.h b/drivers/gpu/drm/amd/include/kgd_pp_interface.h<br>
index 980e696989b1..1af55997bdb9 100644<br>
--- a/drivers/gpu/drm/amd/include/kgd_pp_interface.h<br>
+++ b/drivers/gpu/drm/amd/include/kgd_pp_interface.h<br>
@@ -276,6 +276,8 @@ struct amd_pm_funcs {<br>
struct amd_pp_simple_clock_info *clocks);<br>
int (*notify_smu_enable_pwe)(void *handle);<br>
int (*enable_mgpu_fan_boost)(void *handle);<br>
+ int (*set_fan_speed_max_rpm)(void *handle, uint32_t rpm);<br>
+ int (*set_fan_speed_min_rpm)(void *handle, uint32_t rpm);<br>
};<br>
<br>
#endif<br>
diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c<br>
index 586f1ff9f73e..f10237b4d057 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c<br>
@@ -603,6 +603,50 @@ static int pp_dpm_set_fan_speed_rpm(void *handle, uint32_t rpm)<br>
return ret;<br>
}<br>
<br>
+static int pp_dpm_set_fan_speed_max_rpm(void *handle, uint32_t rpm)<br>
+{<br>
+ struct pp_hwmgr *hwmgr = handle;<br>
+ int ret = 0;<br>
+<br>
+ if (!hwmgr || !hwmgr->pm_en)<br>
+ return -EINVAL;<br>
+<br>
+ if (hwmgr->hwmgr_func->set_fan_speed_max_rpm == NULL) {<br>
+ pr_info("%s was not implemented.\n", __func__);<br>
+ return -EOPNOTSUPP;<br>
+ }<br>
+ mutex_lock(&hwmgr->smu_lock);<br>
+ ret = hwmgr->hwmgr_func->set_fan_speed_max_rpm(hwmgr, rpm);<br>
+ mutex_unlock(&hwmgr->smu_lock);<br>
+<br>
+ if (!ret)<br>
+ hwmgr->thermal_controller.fanInfo.ulMaxRPM = rpm;<br>
+<br>
+ return ret;<br>
+}<br>
+<br>
+static int pp_dpm_set_fan_speed_min_rpm(void *handle, uint32_t rpm)<br>
+{<br>
+ struct pp_hwmgr *hwmgr = handle;<br>
+ int ret = 0;<br>
+<br>
+ if (!hwmgr || !hwmgr->pm_en)<br>
+ return -EINVAL;<br>
+<br>
+ if (hwmgr->hwmgr_func->set_fan_speed_min_rpm == NULL) {<br>
+ pr_info("%s was not implemented.\n", __func__);<br>
+ return -EOPNOTSUPP;<br>
+ }<br>
+ mutex_lock(&hwmgr->smu_lock);<br>
+ ret = hwmgr->hwmgr_func->set_fan_speed_min_rpm(hwmgr, rpm);<br>
+ mutex_unlock(&hwmgr->smu_lock);<br>
+<br>
+ if (!ret)<br>
+ hwmgr->thermal_controller.fanInfo.ulMinRPM = rpm;<br>
+<br>
+ return ret;<br>
+}<br>
+<br>
static int pp_dpm_get_pp_num_states(void *handle,<br>
struct pp_states_info *data)<br>
{<br>
@@ -1342,6 +1386,8 @@ static const struct amd_pm_funcs pp_dpm_funcs = {<br>
.get_fan_speed_percent = pp_dpm_get_fan_speed_percent,<br>
.get_fan_speed_rpm = pp_dpm_get_fan_speed_rpm,<br>
.set_fan_speed_rpm = pp_dpm_set_fan_speed_rpm,<br>
+ .set_fan_speed_max_rpm = pp_dpm_set_fan_speed_max_rpm,<br>
+ .set_fan_speed_min_rpm = pp_dpm_set_fan_speed_min_rpm,<br>
.get_pp_num_states = pp_dpm_get_pp_num_states,<br>
.get_pp_table = pp_dpm_get_pp_table,<br>
.set_pp_table = pp_dpm_set_pp_table,<br>
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h<br>
index 687f73fe4cf5..0242bc039a48 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h<br>
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h<br>
@@ -269,6 +269,8 @@ struct pp_hwmgr_func {<br>
int (*get_fan_speed_percent)(struct pp_hwmgr *hwmgr, uint32_t *speed);<br>
int (*set_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t percent);<br>
int (*get_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t *speed);<br>
+ int (*set_fan_speed_max_rpm)(struct pp_hwmgr *hwmgr, uint32_t max_rpm);<br>
+ int (*set_fan_speed_min_rpm)(struct pp_hwmgr *hwmgr, uint32_t min_rpm);<br>
int (*reset_fan_speed_to_default)(struct pp_hwmgr *hwmgr);<br>
int (*uninitialize_thermal_controller)(struct pp_hwmgr *hwmgr);<br>
int (*register_irq_handlers)(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_15403698863000.14269909928300328">
<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_15403698863000.9916224528545828">
<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_15403698863000.39120505537129757">
<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_15403698863000.17702711523041492">
<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>