<html>
<head>
<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>
</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'm not sure what you mean by the 3 scenarios.  Generally userspace selects what domains it wants a buffer to be in, vram, gtt, or both (don't care).  I'd rather not have the kernel second guess the UMDs if we can help
 it.  I'd rather leave the kernel for cases where we have to force things due to hw bugs, or hw restrictions, etc.  If we force all display buffers to be in gtt in the kernel, we have not excluded the possibility of ever setting displays anywhere else without
 a kernel update.  E.g., to my earlier point, there may be cases where it is advantageous to put display buffers in vram even if s/g display is supported.  That was the point I was trying to make about user mode selecting the domain (vram of gtt or vram|gtt). 
 Say you have a board with 2 GB of ram and 1 GB is carved out for "vram".  In that case, it would make sense to put the buffer in vram because otherwise you are wasting a comparatively scarce resource.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Alex<br>
</p>
</div>
<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> Li, Samuel<br>
<b>Sent:</b> Monday, March 19, 2018 3:58:52 PM<br>
<b>To:</b> Deucher, Alexander; Koenig, Christian; Marek Olšák<br>
<b>Cc:</b> Alex Deucher; Michel Dänzer; amd-gfx list<br>
<b>Subject:</b> RE: [PATCH 1/2] drm/amdgpu: Enable scatter gather display support</font>
<div> </div>
</div>
<style>
<!--
@font-face
        {font-family:SimSun}
@font-face
        {font-family:SimSun}
@font-face
        {font-family:Calibri}
@font-face
        {font-family:Consolas}
@font-face
        {}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif}
a:x_link, span.x_MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:x_visited, span.x_MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
p
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif}
pre
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black}
span.x_HTMLPreformattedChar
        {font-family:Consolas}
p.x_xmsonormal, li.x_xmsonormal, div.x_xmsonormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black}
p.x_xmsochpdefault, li.x_xmsochpdefault, div.x_xmsochpdefault
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Times New Roman",serif}
span.x_xhtmlpreformattedchar
        {font-family:Consolas;
        color:black}
span.x_xemailstyle19
        {font-family:"Calibri",sans-serif;
        color:#2F5496}
span.x_xemailstyle20
        {font-family:"Calibri",sans-serif;
        color:#2F5496}
span.x_EmailStyle25
        {font-family:"Calibri",sans-serif;
        color:#2F5496}
.x_MsoChpDefault
        {font-size:10.0pt}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
div.x_WordSection1
        {}
-->
</style>
<div lang="EN-US" link="blue" vlink="purple">
<div class="x_WordSection1">
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">Alex,</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">I assume you are talking the three scenarios here,
</span><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">1)VRAM, 2)GTT, 3)VRAM/GTT.</span><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496"></span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">But kernel will need the decision too(amdgpufb). I think it shall be better to do it in kernel, instead of different clients(mesa, ddx, kernel …)</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">Regards,</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">Samuel Li</span></p>
<p class="x_MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496"> </span></p>
<div style="border:none; border-left:solid blue 1.5pt; padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_MsoNormal"><b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> Deucher, Alexander
<br>
<b>Sent:</b> Monday, March 19, 2018 3:54 PM<br>
<b>To:</b> Li, Samuel <Samuel.Li@amd.com>; Koenig, Christian <Christian.Koenig@amd.com>; Marek Olšák <maraeo@gmail.com><br>
<b>Cc:</b> Alex Deucher <alexdeucher@gmail.com>; Michel Dänzer <michel@daenzer.net>; amd-gfx list <amd-gfx@lists.freedesktop.org><br>
<b>Subject:</b> Re: [PATCH 1/2] drm/amdgpu: Enable scatter gather display support</span></p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<div id="x_divtagdefaultwrapper">
<p><span style="font-family:"Calibri",sans-serif; color:black">My personal preference is still to plumb this through to mesa rather than forcing it in the kernel.</span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black"> </span></p>
<p><span style="font-family:"Calibri",sans-serif; color:black">Alex</span></p>
</div>
<div class="x_MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal"><b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:black">From:</span></b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:black"> amd-gfx <<a href="mailto:amd-gfx-bounces@lists.freedesktop.org">amd-gfx-bounces@lists.freedesktop.org</a>>
 on behalf of Li, Samuel <<a href="mailto:Samuel.Li@amd.com">Samuel.Li@amd.com</a>><br>
<b>Sent:</b> Monday, March 19, 2018 3:50:34 PM<br>
<b>To:</b> Koenig, Christian; Marek Olšák<br>
<b>Cc:</b> Alex Deucher; Michel Dänzer; amd-gfx list<br>
<b>Subject:</b> RE: [PATCH 1/2] drm/amdgpu: Enable scatter gather display support</span>
</p>
<div>
<p class="x_MsoNormal"> </p>
</div>
</div>
<div>
<div>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">Christian,</span></p>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496"> </span></p>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">You misunderstood Alex’s comments,</span></p>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496"> </span></p>
<pre style="background:white">>Regardless of which scenarios we need to support, I think we also need</pre>
<pre style="background:white">>to really plumb this through to mesa however since user space is who</pre>
<pre style="background:white">>ultimately requests the location.  Overriding it in the kernel gets</pre>
<pre style="background:white">>tricky and can lead to ping-ponging as others have noted.  Better to</pre>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496"> </span></p>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">Here Alex mentioned the scenarios is 1)VRAM, 2)GTT, 3)VRAM/GTT.</span></p>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">His concern is this might cause ping-pong, not about preferred domain. Since preferred domain can solve the ping-pong issue, it
 shall address his concern here.</span></p>
<div>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496"> </span></p>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">Regards,</span></p>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">Samuel Li</span></p>
</div>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496"> </span></p>
<div style="border:none; border-left:solid blue 1.5pt; padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_xmsonormal" style="background:white"><b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:windowtext">From:</span></b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:windowtext"> Christian König [<a href="mailto:ckoenig.leichtzumerken@gmail.com">mailto:ckoenig.leichtzumerken@gmail.com</a>]
<br>
<b>Sent:</b> Monday, March 19, 2018 3:45 PM<br>
<b>To:</b> Li, Samuel <<a href="mailto:Samuel.Li@amd.com">Samuel.Li@amd.com</a>>; Marek Olšák <<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>>; Koenig, Christian <<a href="mailto:Christian.Koenig@amd.com">Christian.Koenig@amd.com</a>><br>
<b>Cc:</b> Alex Deucher <<a href="mailto:alexdeucher@gmail.com">alexdeucher@gmail.com</a>>; Michel Dänzer <<a href="mailto:michel@daenzer.net">michel@daenzer.net</a>>; amd-gfx list <<a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a>><br>
<b>Subject:</b> Re: [PATCH 1/2] drm/amdgpu: Enable scatter gather display support</span></p>
</div>
</div>
<p class="x_xmsonormal" style="background:white"> </p>
<div>
<p class="x_xmsonormal" style="margin-bottom:12.0pt; background:white">Quoting Alex:</p>
<blockquote style="margin-top:5.0pt; margin-bottom:5.0pt">
<pre style="background:white">Regardless of which scenarios we need to support, I think we also need</pre>
<pre style="background:white">to really plumb this through to mesa however since user space is who</pre>
<pre style="background:white">ultimately requests the location.  Overriding it in the kernel gets</pre>
<pre style="background:white">tricky and can lead to ping-ponging as others have noted.  Better to</pre>
<pre style="background:white">have user space know what chips support it or not and request display</pre>
<pre style="background:white">buffers in GTT or VRAM from the start.</pre>
</blockquote>
<p class="x_xmsonormal" style="background:white">And I completely agree with Alex here. So overriding the domain in the kernel is a serious NAK from my side as well.<br>
<br>
Please implement the necessary bits in Mesa, shouldn't be more than a few lines of code anyway.<br>
<br>
Regards,<br>
Christian.<br>
<br>
Am 19.03.2018 um 20:42 schrieb Li, Samuel:</p>
</div>
<blockquote style="margin-top:5.0pt; margin-bottom:5.0pt">
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">Agreed.</span></p>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496"> </span></p>
<p class="x_xmsonormal" style="margin-bottom:12.0pt; background:white">>I think that the consensus with Alex and me is that we should avoid exactly that.<br>
Christian, Alex’s concern is about ping-pong, not about the preferred domain. <br>
<br>
</p>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">Regards,</span></p>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496">Samuel Li</span></p>
<p class="x_xmsonormal" style="background:white"><span style="font-size:11.0pt; font-family:"Calibri",sans-serif; color:#2F5496"> </span></p>
<div style="border:none; border-left:solid blue 1.5pt; padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">
<p class="x_xmsonormal" style="background:white"><b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt; font-family:"Calibri",sans-serif"> Marek Olšák [<a href="mailto:maraeo@gmail.com">mailto:maraeo@gmail.com</a>]
<br>
<b>Sent:</b> Monday, March 19, 2018 3:39 PM<br>
<b>To:</b> Koenig, Christian <a href="mailto:Christian.Koenig@amd.com"><Christian.Koenig@amd.com></a><br>
<b>Cc:</b> Li, Samuel <a href="mailto:Samuel.Li@amd.com"><Samuel.Li@amd.com></a>; Michel Dänzer
<a href="mailto:michel@daenzer.net"><michel@daenzer.net></a>; Alex Deucher <a href="mailto:alexdeucher@gmail.com">
<alexdeucher@gmail.com></a>; amd-gfx list <a href="mailto:amd-gfx@lists.freedesktop.org">
<amd-gfx@lists.freedesktop.org></a><br>
<b>Subject:</b> Re: [PATCH 1/2] drm/amdgpu: Enable scatter gather display support</span></p>
</div>
</div>
<p class="x_xmsonormal" style="background:white"> </p>
<div>
<div>
<div>
<p class="x_xmsonormal" style="background:white">On Mon, Mar 19, 2018 at 3:27 PM, Christian König <<a href="mailto:christian.koenig@amd.com" target="_blank">christian.koenig@amd.com</a>> wrote:</p>
<blockquote style="border:none; border-left:solid #CCCCCC 1.0pt; padding:0in 0in 0in 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt">
<p class="x_xmsonormal" style="background:white">I think that the consensus with Alex and me is that we should avoid exactly that.<br>
<br>
Overriding the preferred domain in the kernel is a no-go for that patch set, so please implement the discussed changes in Mesa.</p>
</blockquote>
<div>
<p class="x_xmsonormal" style="background:white"> </p>
</div>
<div>
<p class="x_xmsonormal" style="background:white">I don't see how Mesa can make a smarter decision than the kernel. If you overwrite the preferred domain of the buffer in the kernel, there will be no ping-ponging between domains. Mesa never changes the initial
 preferred domain.</p>
</div>
<div>
<p class="x_xmsonormal" style="background:white"> </p>
</div>
<div>
<p class="x_xmsonormal" style="background:white">Marek</p>
</div>
<div>
<p class="x_xmsonormal" style="background:white"> </p>
</div>
<div>
<p class="x_xmsonormal" style="background:white"> </p>
</div>
<blockquote style="border:none; border-left:solid #CCCCCC 1.0pt; padding:0in 0in 0in 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt">
<p class="x_xmsonormal" style="background:white"><br>
Regards,<br>
Christian.</p>
<div>
<div>
<p class="x_xmsonormal" style="background:white"><br>
<br>
Am 19.03.2018 um 20:22 schrieb Li, Samuel:</p>
<blockquote style="border:none; border-left:solid #CCCCCC 1.0pt; padding:0in 0in 0in 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt">
<p class="x_xmsonormal" style="margin-bottom:12.0pt; background:white">I agree with Marek/Michel: since kernel sets the domain before scanning out, it shall update the preferred domain here too.<br>
<br>
Regards,<br>
Samuel Li<br>
<br>
</p>
<blockquote style="border:none; border-left:solid #CCCCCC 1.0pt; padding:0in 0in 0in 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt">
<p class="x_xmsonormal" style="background:white">-----Original Message-----<br>
From: Koenig, Christian<br>
Sent: Thursday, March 08, 2018 4:07 AM<br>
To: Michel Dänzer <<a href="mailto:michel@daenzer.net" target="_blank">michel@daenzer.net</a>>; Li, Samuel<br>
<<a href="mailto:Samuel.Li@amd.com" target="_blank">Samuel.Li@amd.com</a>>; Alex Deucher <<a href="mailto:alexdeucher@gmail.com" target="_blank">alexdeucher@gmail.com</a>><br>
Cc: amd-gfx list <<a href="mailto:amd-gfx@lists.freedesktop.org" target="_blank">amd-gfx@lists.freedesktop.org</a>><br>
Subject: Re: [PATCH 1/2] drm/amdgpu: Enable scatter gather display support<br>
<br>
Am 08.03.2018 um 09:35 schrieb Michel Dänzer:</p>
<blockquote style="border:none; border-left:solid #CCCCCC 1.0pt; padding:0in 0in 0in 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt">
<p class="x_xmsonormal" style="background:white">On 2018-03-07 10:47 AM, Christian König wrote:</p>
<blockquote style="border:none; border-left:solid #CCCCCC 1.0pt; padding:0in 0in 0in 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt">
<p class="x_xmsonormal" style="background:white">Am 07.03.2018 um 09:42 schrieb Michel Dänzer:</p>
<blockquote style="border:none; border-left:solid #CCCCCC 1.0pt; padding:0in 0in 0in 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt">
<p class="x_xmsonormal" style="margin-bottom:12.0pt; background:white">On 2018-03-06 07:23 PM, Christian König wrote:</p>
<blockquote style="border:none; border-left:solid #CCCCCC 1.0pt; padding:0in 0in 0in 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt">
<p class="x_xmsonormal" style="background:white">E.g. the last time I tested it placing things into GTT still<br>
resulted in quite a performance penalty for rendering.</p>
</blockquote>
<p class="x_xmsonormal" style="background:white">FWIW, I think the penalty is most likely IOMMU related. Last time I<br>
tested, I couldn't measure a big difference with IOMMU disabled.</p>
</blockquote>
<p class="x_xmsonormal" style="background:white">No, the penalty I'm talking about came from the ping/pong we did with<br>
the scanout buffers.<br>
<br>
See when I tested this the DDX and Mesa where unmodified, so both<br>
still assumed VRAM as placement for scanout BOs, but the kernel<br>
forced scanout BOs into GTT for testing.<br>
<br>
So what happened was that on scanout we moved the VRAM BO to GTT</p>
</blockquote>
</blockquote>
<p class="x_xmsonormal" style="background:white">and</p>
<blockquote style="border:none; border-left:solid #CCCCCC 1.0pt; padding:0in 0in 0in 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt">
<blockquote style="border:none; border-left:solid #CCCCCC 1.0pt; padding:0in 0in 0in 6.0pt; margin-left:4.8pt; margin-top:5.0pt; margin-right:0in; margin-bottom:5.0pt">
<p class="x_xmsonormal" style="background:white">after unpinning it on the first command submission which used the BO<br>
we moved it back to VRAM again.</p>
</blockquote>
<p class="x_xmsonormal" style="background:white">In the meantime, I've had the same idea as Marek: Can't the kernel<br>
driver simply change the BO's preferred domain to GTT when scanning<br>
out from it? Then it won't move back to VRAM.</p>
</blockquote>
<p class="x_xmsonormal" style="background:white">Yes, I've considered this as well.<br>
<br>
But I think making the decision in Mesa is the cleaner approach.<br>
<br>
E.g. so far we only override the placement decision of userspace for two<br>
reasons:<br>
1. We where running out of memory in VRAM.<br>
2. We have a hardware restriction which makes VRAM usage mandatory.<br>
<br>
And even then we never adjust the placement permanently, we just<br>
temporary moved the buffer where it was needed and moved it back after<br>
the operation completed.<br>
<br>
Additional to that Mesa might want to set even more flags and/or changes<br>
it's behavior. E.g. use a tilling mode which both importer and export in an<br>
A+A laptop understands etc...<br>
<br>
Regards,<br>
Christian.</p>
</blockquote>
</blockquote>
<p class="x_xmsonormal" style="background:white"><br>
_______________________________________________<br>
amd-gfx mailing list<br>
<a href="mailto:amd-gfx@lists.freedesktop.org" target="_blank">amd-gfx@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" target="_blank">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></p>
</div>
</div>
</blockquote>
</div>
<p class="x_xmsonormal" style="background:white"> </p>
</div>
</div>
</div>
<p class="x_xmsonormal" style="margin-bottom:12.0pt; background:white"><br>
<br>
</p>
<pre style="background:white">_______________________________________________</pre>
<pre style="background:white">amd-gfx mailing list</pre>
<pre style="background:white"><a href="mailto:amd-gfx@lists.freedesktop.org">amd-gfx@lists.freedesktop.org</a></pre>
<pre style="background:white"><a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></pre>
</blockquote>
<p class="x_xmsonormal" style="background:white"> </p>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>