<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"><span style="color: rgb(33, 33, 33); font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif, serif, EmojiFont; font-size: 14.6667px;">>Isn't the power limit only multiplied by 256 on smu7? </span><br>
</p>
<div><br>
</div>
Yes,I will fix it and convert the output to mw.
<div><br>
</div>
<div>Best Regards</div>
<div>Rex<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Alex Deucher <alexdeucher@gmail.com><br>
<b>Sent:</b> Tuesday, January 30, 2018 4:00 AM<br>
<b>To:</b> Zhu, Rex<br>
<b>Cc:</b> amd-gfx list<br>
<b>Subject:</b> Re: [PATCH 2/2] drm/amdgpu/pm: get/set dgpu power cap via hwmon API</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On Mon, Jan 29, 2018 at 5:14 AM, Rex Zhu <Rex.Zhu@amd.com> wrote:<br>
> Adust power limit through power1_cap<br>
> Get min/max power limit through power1_cap_min/power1_cap_max<br>
><br>
> Signed-off-by: Rex Zhu <Rex.Zhu@amd.com><br>
><br>
> Change-Id: Idca81ae12dc9fa4e4dd6c89fe47e0318df2859d3<br>
> ---<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 75 ++++++++++++++++++++++++++++++++++<br>
> 1 file changed, 75 insertions(+)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
> index b0cdb14..db6e2ba 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
> @@ -1207,6 +1207,69 @@ static ssize_t amdgpu_hwmon_show_power_avg(struct device *dev,<br>
> return snprintf(buf, PAGE_SIZE, "%u\n", uw);<br>
> }<br>
><br>
> +static ssize_t amdgpu_hwmon_show_power_cap_min(struct device *dev,<br>
> + struct device_attribute *attr,<br>
> + char *buf)<br>
> +{<br>
> + return sprintf(buf, "%i\n", 0);<br>
> +}<br>
> +<br>
> +static ssize_t amdgpu_hwmon_show_power_cap_max(struct device *dev,<br>
> + struct device_attribute *attr,<br>
> + char *buf)<br>
> +{<br>
> + struct amdgpu_device *adev = dev_get_drvdata(dev);<br>
> + uint32_t limit = 0;<br>
> +<br>
> + if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->get_power_limit) {<br>
> + adev->powerplay.pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit, true);<br>
> + return snprintf(buf, PAGE_SIZE, "%d w\n", limit / 256);<br>
<br>
Isn't the power limit only multiplied by 256 on smu7? Please<br>
normalize the internal interface. Also the hwmon API takes the uses<br>
microWatt units, please expose those and convert to normalized<br>
internal units as necessary.<br>
<a href="https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface" id="LPlnk37477" previewremoved="true">https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface</a><br>
<br>
<br>
> + } else {<br>
> + return snprintf(buf, PAGE_SIZE, "\n");<br>
> + }<br>
> +}<br>
> +<br>
> +static ssize_t amdgpu_hwmon_show_power_cap(struct device *dev,<br>
> + struct device_attribute *attr,<br>
> + char *buf)<br>
> +{<br>
> + struct amdgpu_device *adev = dev_get_drvdata(dev);<br>
> + uint32_t limit = 0;<br>
> +<br>
> + if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->get_power_limit) {<br>
> + adev->powerplay.pp_funcs->get_power_limit(adev->powerplay.pp_handle, &limit, false);<br>
> + return snprintf(buf, PAGE_SIZE, "%d w\n", limit / 256);<br>
> + } else {<br>
> + return snprintf(buf, PAGE_SIZE, "\n");<br>
> + }<br>
> +}<br>
> +<br>
> +<br>
> +static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev,<br>
> + struct device_attribute *attr,<br>
> + const char *buf,<br>
> + size_t count)<br>
> +{<br>
> + struct amdgpu_device *adev = dev_get_drvdata(dev);<br>
> + int err;<br>
> + u32 value;<br>
> +<br>
> + err = kstrtou32(buf, 10, &value);<br>
> + if (err)<br>
> + return err;<br>
> +<br>
> + value = value * 256;<br>
<br>
Same comment here.<br>
<br>
Alex<br>
<br>
> + if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->set_power_limit) {<br>
> + err = adev->powerplay.pp_funcs->set_power_limit(adev->powerplay.pp_handle, value);<br>
> + if (err)<br>
> + return err;<br>
> + } else {<br>
> + return -EINVAL;<br>
> + }<br>
> +<br>
> + return count;<br>
> +}<br>
> +<br>
> static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, amdgpu_hwmon_show_temp, NULL, 0);<br>
> static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 0);<br>
> static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 1);<br>
> @@ -1220,6 +1283,9 @@ static ssize_t amdgpu_hwmon_show_power_avg(struct device *dev,<br>
> static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, amdgpu_hwmon_show_vddnb, NULL, 0);<br>
> static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, amdgpu_hwmon_show_vddnb_label, NULL, 0);<br>
> static SENSOR_DEVICE_ATTR(power1_average, S_IRUGO, amdgpu_hwmon_show_power_avg, NULL, 0);<br>
> +static SENSOR_DEVICE_ATTR(power1_cap_max, S_IRUGO, amdgpu_hwmon_show_power_cap_max, NULL, 0);<br>
> +static SENSOR_DEVICE_ATTR(power1_cap_min, S_IRUGO, amdgpu_hwmon_show_power_cap_min, NULL, 0);<br>
> +static SENSOR_DEVICE_ATTR(power1_cap, S_IRUGO | S_IWUSR, amdgpu_hwmon_show_power_cap, amdgpu_hwmon_set_power_cap, 0);<br>
><br>
> static struct attribute *hwmon_attributes[] = {<br>
> &sensor_dev_attr_temp1_input.dev_attr.attr,<br>
> @@ -1235,6 +1301,9 @@ static ssize_t amdgpu_hwmon_show_power_avg(struct device *dev,<br>
> &sensor_dev_attr_in1_input.dev_attr.attr,<br>
> &sensor_dev_attr_in1_label.dev_attr.attr,<br>
> &sensor_dev_attr_power1_average.dev_attr.attr,<br>
> + &sensor_dev_attr_power1_cap_max.dev_attr.attr,<br>
> + &sensor_dev_attr_power1_cap_min.dev_attr.attr,<br>
> + &sensor_dev_attr_power1_cap.dev_attr.attr,<br>
> NULL<br>
> };<br>
><br>
> @@ -1282,6 +1351,12 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,<br>
> attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr)) /* can't manage state */<br>
> effective_mode &= ~S_IWUSR;<br>
><br>
> + if ((adev->flags & AMD_IS_APU) &&<br>
> + (attr == &sensor_dev_attr_power1_cap_max.dev_attr.attr ||<br>
> + attr == &sensor_dev_attr_power1_cap_min.dev_attr.attr||<br>
> + attr == &sensor_dev_attr_power1_cap.dev_attr.attr))<br>
> + return 0;<br>
> +<br>
> /* hide max/min values if we can't both query and manage the fan */<br>
> if ((!adev->powerplay.pp_funcs->set_fan_speed_percent &&<br>
> !adev->powerplay.pp_funcs->get_fan_speed_percent) &&<br>
> --<br>
> 1.9.1<br>
><br>
> _______________________________________________<br>
> amd-gfx mailing list<br>
> amd-gfx@lists.freedesktop.org<br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" id="LPlnk32052" previewremoved="true">
https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
<div id="LPBorder_GT_15172635569800.8063216739451147" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_15172635569770.4522080127564547" role="presentation" cellspacing="0" style="width: 90%; background-color: rgb(255, 255, 255); position: relative; overflow: auto; padding-top: 20px; padding-bottom: 20px; margin-top: 20px; border-top: 1px dotted rgb(200, 200, 200); border-bottom: 1px dotted rgb(200, 200, 200);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td id="TextCell_15172635569780.7714998563208677" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_15172635569790.8900824754268704"></div>
<div id="LPTitle_15172635569790.2954400542439797" style="top: 0px; color: rgb(0, 120, 215); font-weight: normal; font-size: 21px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_15172635569790.2935921932351151" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" target="_blank" style="text-decoration: none;">amd-gfx Info Page - freedesktop.org</a></div>
<div id="LPMetadata_15172635569790.030739303613855462" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 14px;">
lists.freedesktop.org</div>
<div id="LPDescription_15172635569800.3105988911815125" style="display: block; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 20px; max-height: 100px; overflow: hidden;">
Subscribing to amd-gfx: Subscribe to amd-gfx by filling out the following form. Use of all freedesktop.org lists is subject to our Code of ...</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</div>
</span></font></div>
</div>
</div>
</div>
</body>
</html>