<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">
<blockquote type="cite"><font size="2"><span
style="font-size:11pt;">Who's tree should this go through?</span></font></blockquote>
To answer the question: When Rex is ok with that he pushes it to
our internal amd-staging-drm-next tree.<br>
<br>
Alex then pushes that tree to a public server and at some point
sends a pull request for inclusion in drm-next.<br>
<br>
Regards,<br>
Christian.<br>
<br>
Am 17.07.2018 um 08:23 schrieb Zhu, Rex:<br>
</div>
<blockquote type="cite"
cite="mid:CY4PR12MB16874F4DB841A96E065E94EEFB5C0@CY4PR12MB1687.namprd12.prod.outlook.com">
<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>
<div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;"
dir="ltr">
<div dir="auto" style="direction: ltr; margin: 0px; padding:
0px; font-family: sans-serif, serif, "EmojiFont";
font-size: 11pt; color: black;">
Patch is:<br>
Reviewed-by: Rex Zhu<<a href="mailto:rezhu@amd.com"
target="_blank" rel="noopener noreferrer"
data-auth="NotApplicable" id="LPlnk600685"
class="OWAAutoLink" previewremoved="true"
moz-do-not-send="true">rezhu@amd.com</a>> <br>
<br>
<br>
<br>
</div>
<div align="left">
<div dir="auto" style="direction: ltr; margin: 0px; padding:
0px; font-family: sans-serif, serif, "EmojiFont";
font-size: 11pt; color: black;">
<font color="#000000">Best Regards</font><br>
</div>
</div>
<font color="#000000">Rex</font><br>
<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>
<a class="moz-txt-link-abbreviated" href="mailto:keescook@google.com">keescook@google.com</a> <a class="moz-txt-link-rfc2396E" href="mailto:keescook@google.com"><keescook@google.com></a> on behalf
of Kees Cook <a class="moz-txt-link-rfc2396E" href="mailto:keescook@chromium.org"><keescook@chromium.org></a><br>
<b>Sent:</b> Tuesday, July 17, 2018 11:59 AM<br>
<b>To:</b> Deucher, Alexander<br>
<b>Cc:</b> LKML; Koenig, Christian; Zhou, David(ChunMing);
David Airlie; Zhu, Rex; Huang, Ray; Kuehling, Felix;
amd-gfx list; Maling list - DRI developers<br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu/pm: Remove VLA
usage</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span
style="font-size:11pt;">
<div class="PlainText">On Wed, Jun 20, 2018 at 11:26 AM,
Kees Cook <a class="moz-txt-link-rfc2396E" href="mailto:keescook@chromium.org"><keescook@chromium.org></a> wrote:<br>
> In the quest to remove all stack VLA usage from
the kernel[1], this<br>
> uses the maximum sane buffer size and removes
copy/paste code.<br>
><br>
> [1] <a
href="https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com"
id="LPlnk141741" class="OWAAutoLink"
previewremoved="true" moz-do-not-send="true">
https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com</a><br>
><br>
> Signed-off-by: Kees Cook
<a class="moz-txt-link-rfc2396E" href="mailto:keescook@chromium.org"><keescook@chromium.org></a><br>
<br>
Friendly ping! Who's tree should this go through?<br>
<br>
Thanks!<br>
<br>
-Kees<br>
<br>
> ---<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 100
+++++++++++--------------<br>
> 1 file changed, 42 insertions(+), 58
deletions(-)<br>
><br>
> diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
> index b455da487782..5eb98cde22ed 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c<br>
> @@ -593,40 +593,59 @@ static ssize_t
amdgpu_get_pp_dpm_sclk(struct device *dev,<br>
> return snprintf(buf, PAGE_SIZE,
"\n");<br>
> }<br>
><br>
> -static ssize_t amdgpu_set_pp_dpm_sclk(struct
device *dev,<br>
> - struct device_attribute *attr,<br>
> - const char *buf,<br>
> - size_t count)<br>
> +/*<br>
> + * Worst case: 32 bits individually specified,
in octal at 12 characters<br>
> + * per line (+1 for \n).<br>
> + */<br>
> +#define AMDGPU_MASK_BUF_MAX (32 * 13)<br>
> +<br>
> +static ssize_t amdgpu_read_mask(const char *buf,
size_t count, uint32_t *mask)<br>
> {<br>
> - struct drm_device *ddev =
dev_get_drvdata(dev);<br>
> - struct amdgpu_device *adev =
ddev->dev_private;<br>
> int ret;<br>
> long level;<br>
> - uint32_t mask = 0;<br>
> char *sub_str = NULL;<br>
> char *tmp;<br>
> - char buf_cpy[count];<br>
> + char buf_cpy[AMDGPU_MASK_BUF_MAX + 1];<br>
> const char delimiter[3] = {' ', '\n',
'\0'};<br>
> + size_t bytes;<br>
><br>
> - memcpy(buf_cpy, buf, count+1);<br>
> + *mask = 0;<br>
> +<br>
> + bytes = min(count, sizeof(buf_cpy) - 1);<br>
> + memcpy(buf_cpy, buf, bytes);<br>
> + buf_cpy[bytes] = '\0';<br>
> tmp = buf_cpy;<br>
> while (tmp[0]) {<br>
> - sub_str = strsep(&tmp,
delimiter);<br>
> + sub_str = strsep(&tmp,
delimiter);<br>
> if (strlen(sub_str)) {<br>
> ret = kstrtol(sub_str, 0,
&level);<br>
> -<br>
> - if (ret) {<br>
> - count = -EINVAL;<br>
> - goto fail;<br>
> - }<br>
> - mask |= 1 << level;<br>
> + if (ret)<br>
> + return -EINVAL;<br>
> + *mask |= 1 <<
level;<br>
> } else<br>
> break;<br>
> }<br>
> +<br>
> + return 0;<br>
> +}<br>
> +<br>
> +static ssize_t amdgpu_set_pp_dpm_sclk(struct
device *dev,<br>
> + struct device_attribute *attr,<br>
> + const char *buf,<br>
> + size_t count)<br>
> +{<br>
> + struct drm_device *ddev =
dev_get_drvdata(dev);<br>
> + struct amdgpu_device *adev =
ddev->dev_private;<br>
> + int ret;<br>
> + uint32_t mask = 0;<br>
> +<br>
> + ret = amdgpu_read_mask(buf, count,
&mask);<br>
> + if (ret)<br>
> + return ret;<br>
> +<br>
> if
(adev->powerplay.pp_funcs->force_clock_level)<br>
>
amdgpu_dpm_force_clock_level(adev, PP_SCLK, mask);<br>
><br>
> -fail:<br>
> return count;<br>
> }<br>
><br>
> @@ -651,32 +670,15 @@ static ssize_t
amdgpu_set_pp_dpm_mclk(struct device *dev,<br>
> struct drm_device *ddev =
dev_get_drvdata(dev);<br>
> struct amdgpu_device *adev =
ddev->dev_private;<br>
> int ret;<br>
> - long level;<br>
> uint32_t mask = 0;<br>
> - char *sub_str = NULL;<br>
> - char *tmp;<br>
> - char buf_cpy[count];<br>
> - const char delimiter[3] = {' ', '\n',
'\0'};<br>
><br>
> - memcpy(buf_cpy, buf, count+1);<br>
> - tmp = buf_cpy;<br>
> - while (tmp[0]) {<br>
> - sub_str = strsep(&tmp,
delimiter);<br>
> - if (strlen(sub_str)) {<br>
> - ret = kstrtol(sub_str, 0,
&level);<br>
> + ret = amdgpu_read_mask(buf, count,
&mask);<br>
> + if (ret)<br>
> + return ret;<br>
><br>
> - if (ret) {<br>
> - count = -EINVAL;<br>
> - goto fail;<br>
> - }<br>
> - mask |= 1 << level;<br>
> - } else<br>
> - break;<br>
> - }<br>
> if
(adev->powerplay.pp_funcs->force_clock_level)<br>
>
amdgpu_dpm_force_clock_level(adev, PP_MCLK, mask);<br>
><br>
> -fail:<br>
> return count;<br>
> }<br>
><br>
> @@ -701,33 +703,15 @@ static ssize_t
amdgpu_set_pp_dpm_pcie(struct device *dev,<br>
> struct drm_device *ddev =
dev_get_drvdata(dev);<br>
> struct amdgpu_device *adev =
ddev->dev_private;<br>
> int ret;<br>
> - long level;<br>
> uint32_t mask = 0;<br>
> - char *sub_str = NULL;<br>
> - char *tmp;<br>
> - char buf_cpy[count];<br>
> - const char delimiter[3] = {' ', '\n',
'\0'};<br>
> -<br>
> - memcpy(buf_cpy, buf, count+1);<br>
> - tmp = buf_cpy;<br>
><br>
> - while (tmp[0]) {<br>
> - sub_str = strsep(&tmp,
delimiter);<br>
> - if (strlen(sub_str)) {<br>
> - ret = kstrtol(sub_str, 0,
&level);<br>
> + ret = amdgpu_read_mask(buf, count,
&mask);<br>
> + if (ret)<br>
> + return ret;<br>
><br>
> - if (ret) {<br>
> - count = -EINVAL;<br>
> - goto fail;<br>
> - }<br>
> - mask |= 1 << level;<br>
> - } else<br>
> - break;<br>
> - }<br>
> if
(adev->powerplay.pp_funcs->force_clock_level)<br>
>
amdgpu_dpm_force_clock_level(adev, PP_PCIE, mask);<br>
><br>
> -fail:<br>
> return count;<br>
> }<br>
><br>
> --<br>
> 2.17.1<br>
><br>
><br>
> --<br>
> Kees Cook<br>
> Pixel Security<br>
<br>
<br>
<br>
-- <br>
Kees Cook<br>
Pixel Security<br>
</div>
</span></font></div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
amd-gfx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
</pre>
</blockquote>
<br>
</body>
</html>