<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<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">Hi Christian,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">You can reproduce this issue by allocate CSA buffer in baremetal and map them to reserved VM address.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Please see the attached patch.</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> Christian König <ckoenig.leichtzumerken@gmail.com><br>
<b>Sent:</b> Tuesday, October 23, 2018 5:01 PM<br>
<b>To:</b> Zhu, Rex; Zhang, Jerry; amd-gfx@lists.freedesktop.org; Deucher, Alexander; Koenig, Christian<br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: Fix amdgpu_vm_alloc_pts failed</font>
<div> </div>
</div>
<meta content="text/html; charset=Windows-1252">
<div style="background-color:#FFFFFF">
<div class="x_moz-cite-prefix">Hi guys,<br>
<br>
yeah the root PD doesn't necessarily have a power of two entries.<br>
<br>
But what exactly was the problem with the original code? Why does 0xffffffff doesn't work?<br>
<br>
The only possible explanation I can see is that somebody tried to use an address which is above max_pfn, or how did that trigger?<br>
<br>
Thanks,<br>
Christian.<br>
<br>
Am 23.10.18 um 07:42 schrieb Zhu, Rex:<br>
</div>
<blockquote type="cite">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0">No, if the vm size is small, there may only on root pd entry.</p>
<p style="margin-top:0; margin-bottom:0">we need to make sure the mask >= 0;</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Maybe this change revert Christian's commit:</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<div>commit 72af632549b97ead9251bb155f08fefd1fb6f5c3<br>
Author: Christian König <a class="x_moz-txt-link-rfc2396E OWAAutoLink" href="mailto:christian.koenig@amd.com" id="LPlnk32464" previewremoved="true">
<christian.koenig@amd.com></a><br>
Date:   Sat Sep 15 10:02:13 2018 +0200<br>
<br>
    drm/amdgpu: add amdgpu_vm_entries_mask v2<br>
    <br>
    We can't get the mask for the root directory from the number of entries.<br>
    <br>
    So add a new function to avoid that problem.</div>
<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>
<br>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block; width:98%" tabindex="-1">
<div id="x_divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>From:</b> amd-gfx
<a class="x_moz-txt-link-rfc2396E OWAAutoLink" href="mailto:amd-gfx-bounces@lists.freedesktop.org" id="LPlnk298439" previewremoved="true">
<amd-gfx-bounces@lists.freedesktop.org></a> on behalf of Zhang, Jerry(Junwei) <a class="x_moz-txt-link-rfc2396E OWAAutoLink" href="mailto:Jerry.Zhang@amd.com" id="LPlnk595359" previewremoved="true">
<Jerry.Zhang@amd.com></a><br>
<b>Sent:</b> Tuesday, October 23, 2018 1:12 PM<br>
<b>To:</b> Zhu, Rex; <a class="x_moz-txt-link-abbreviated OWAAutoLink" href="mailto:amd-gfx@lists.freedesktop.org" id="LPlnk144243" previewremoved="true">
amd-gfx@lists.freedesktop.org</a>; Deucher, Alexander; Koenig, Christian<br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: Fix amdgpu_vm_alloc_pts failed</font>
<div> </div>
</div>
<div class="x_BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="x_PlainText">On 10/23/2018 11:29 AM, Rex Zhu wrote:<br>
> when the VA address located in the last PD entries,<br>
> the alloc_pts will faile.<br>
><br>
> Use the right PD mask instand of hardcode, suggested<br>
> by jerry.zhang.<br>
><br>
> Signed-off-by: Rex Zhu <a class="x_moz-txt-link-rfc2396E OWAAutoLink" href="mailto:Rex.Zhu@amd.com" id="LPlnk300100" previewremoved="true">
<Rex.Zhu@amd.com></a><br>
<br>
Thanks to verify that.<br>
Feel free to add<br>
Reviewed-by: Junwei Zhang <a class="x_moz-txt-link-rfc2396E OWAAutoLink" href="mailto:Jerry.Zhang@amd.com" id="LPlnk163240" previewremoved="true">
<Jerry.Zhang@amd.com></a><br>
<br>
Also like to get to know some background about these two functions from <br>
Christian.<br>
Perhaps we may make it more simple, e.g. merging them together.<br>
<br>
Regards,<br>
Jerry<br>
<br>
> ---<br>
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++++-<br>
>   1 file changed, 4 insertions(+), 1 deletion(-)<br>
><br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
> index 054633b..3939013 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
> @@ -202,8 +202,11 @@ static unsigned amdgpu_vm_num_entries(struct amdgpu_device *adev,<br>
>   static uint32_t amdgpu_vm_entries_mask(struct amdgpu_device *adev,<br>
>                                       unsigned int level)<br>
>   {<br>
> +     unsigned shift = amdgpu_vm_level_shift(adev,<br>
> +                                            adev->vm_manager.root_level);<br>
> +<br>
>        if (level <= adev->vm_manager.root_level)<br>
> -             return 0xffffffff;<br>
> +             return (round_up(adev->vm_manager.max_pfn, 1 << shift) >> shift) - 1;<br>
>        else if (level != AMDGPU_VM_PTB)<br>
>                return 0x1ff;<br>
>        else<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a class="x_moz-txt-link-abbreviated OWAAutoLink" href="mailto:amd-gfx@lists.freedesktop.org" id="LPlnk365121" previewremoved="true">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" id="LPlnk206689" class="x_OWAAutoLink" previewremoved="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
<div id="LPBorder_GT_15402730099220.06989990489403342" style="margin-bottom:20px; overflow:auto; width:100%; text-indent:0px" contenteditable="false">
<table id="LPContainer_15402730099180.16758172594804666" style="width:90%; background-color:rgb(255,255,255); 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)" cellspacing="0">
<tbody>
<tr style="border-spacing:0px" valign="top">
<td id="x_TextCell_15402730099180.9196994567727107" colspan="2" style="vertical-align:top; padding:0px; display:table-cell">
<div id="LPTitle_15402730099180.46519874882455503" style=""><a id="LPUrlAnchor_15402730099200.5625533175983499" 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_15402730099200.935286511114562" style="">lists.freedesktop.org</div>
<div id="LPDescription_15402730099200.10363074579177611" style="">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 class="x_moz-txt-link-abbreviated OWAAutoLink" href="mailto:amd-gfx@lists.freedesktop.org" id="LPlnk610386" previewremoved="true">
amd-gfx@lists.freedesktop.org</a>. You can subscribe to the list, or change your existing subscription, in the sections below.</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
</div>
</span></font></div>
</div>
</div>
<br>
<fieldset class="x_mimeAttachmentHeader"></fieldset>
<pre class="x_moz-quote-pre">_______________________________________________
amd-gfx mailing list
<a class="x_moz-txt-link-abbreviated OWAAutoLink" href="mailto:amd-gfx@lists.freedesktop.org" id="LPlnk840136" previewremoved="true">amd-gfx@lists.freedesktop.org</a>
<a class="x_moz-txt-link-freetext OWAAutoLink" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" id="LPlnk97345" previewremoved="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
</pre>
</blockquote>
<br>
</div>
</div>
</div>
</body>
</html>