<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-2022-jp">
<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,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">I think when user set max/min fan speed, the fan control mode will switch to</p>
<p style="margin-top:0;margin-bottom:0">manual mode.</p>
<p style="margin-top:0;margin-bottom:0">so if user need to exit the max/min fan speed, user need to reset to auto mode.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Do we need to let user enter manual mode first before set max/min fan speed?<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Best Regards</p>
<p style="margin-top:0;margin-bottom:0">Rex<br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<br>
<br>
<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" color="#000000" face="Calibri, sans-serif"><b>From:</b> Quan, Evan<br>
<b>Sent:</b> Wednesday, October 24, 2018 4:47 PM<br>
<b>To:</b> Zhu, Rex; 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</font>
<div> </div>
</div>
<meta content="text/html; charset=gb2312">
<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">This can be performed under auto mode. </p>
<p class="x_MsoNormal">The settings are always effective unless user resets them back.</p>
<p class="x_MsoNormal"> </p>
<p class="x_MsoNormal">Regards,</p>
<p class="x_MsoNormal">Evan</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="x_MsoNormal"><b>From:</b> Zhu, Rex <br>
<b>Sent:</b> 2018<span style="font-family:"$BHy(B软$B2m|n(B",sans-serif" lang="ZH-CN">$BG/(B</span>10<span style="font-family:"$BHy(B软$B2m|n(B",sans-serif" lang="ZH-CN">$B7n(B</span>24<span style="font-family:"$BHy(B软$B2m|n(B",sans-serif" lang="ZH-CN">$BF|(B</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</p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<div id="x_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?</span></p>
<p><span style="font-size:12.0pt; color:black"> </span></p>
<p><span style="font-size:12.0pt; color:black">Best Regards</span></p>
<p><span style="font-size:12.0pt; color:black">Rex</span></p>
<p><span style="font-size:12.0pt; color:black"> </span></p>
<p class="x_MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:12.0pt; color:black"> </span></p>
<div>
<div class="x_MsoNormal" style="text-align:center" align="center"><span style="font-size:12.0pt; color:black">
<hr width="98%" size="2" align="center">
</span></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="LPlnk669449" class="OWAAutoLink" previewremoved="true">amd-gfx-bounces@lists.freedesktop.org</a>>
on behalf of Evan Quan <<a href="mailto:evan.quan@amd.com" id="LPlnk588882" class="OWAAutoLink" previewremoved="true">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" id="LPlnk746317" class="OWAAutoLink" previewremoved="true">
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">
</span></p>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
</div>
<div>
<div>
<p class="x_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" id="LPlnk457844" class="OWAAutoLink" previewremoved="true">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" id="LPlnk218458" class="OWAAutoLink" previewremoved="true">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" id="LPlnk474610" class="OWAAutoLink" previewremoved="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
</span></p>
<div id="LPBorder_GT_15403698863000.14269909928300328" style="margin-bottom:15.0pt; overflow:auto">
<table class="x_MsoNormalTable" style="width:90.0%; background:white; border-top:dotted #C8C8C8 1.0pt; border-left:none; border-bottom:dotted #C8C8C8 1.0pt; border-right:none" width="90%" cellspacing="0" cellpadding="0" border="1">
<tbody>
<tr>
<td style="border:none; padding:0cm 0cm 0cm 0cm" valign="top">
<div id="LPTitle_15403698863000.9916224528545828">
<p class="x_MsoNormal" style="margin-top:15.0pt"><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" id="LPlnk74812" class="OWAAutoLink" previewremoved="true"><span style="text-decoration:none">amd-gfx
Info Page - freedesktop.org</span></a></span></p>
</div>
<div id="LPMetadata_15403698863000.39120505537129757" style="margin-top:7.5pt; margin-bottom:12.0pt">
<p class="x_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</span></p>
</div>
<div id="LPDescription_15403698863000.17702711523041492">
<p class="x_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" id="LPlnk253702" class="OWAAutoLink" previewremoved="true">
amd-gfx@lists.freedesktop.org</a>. You can subscribe to the list, or change your existing subscription, in the sections below.</span></p>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<p class="x_MsoNormal"><span style="color:black"> </span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>