<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@SimSun";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Plain Text Char";
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-priority:99;
mso-style-link:"Plain Text";
font-family:"Calibri",sans-serif;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoPlainText">Christian, <o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">I'm not going to argue with you about policy or interface protocol , cuz those things would block us from implementing new features, instead they should be changed if they are not fit to new requirement, isn't it ?<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">See my answers in lines, thanks !<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">-----Original Message-----<br>
From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf Of Christian K?nig<br>
Sent: Wednesday, August 24, 2016 4:56 PM<br>
To: Liu, Monk <Monk.Liu@amd.com>; amd-gfx@lists.freedesktop.org<br>
Cc: Wang, Daniel(Xiaowei) <Daniel.Wang2@amd.com>; Jiang, Jerry (SW) <Jerry.Jiang@amd.com><br>
Subject: Re: [PATCH] drm/amdgpu:fix DMAframe for GFX8</p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Am 24.08.2016 um 10:29 schrieb Liu, Monk:<o:p></o:p></p>
<p class="MsoPlainText">> Christian,<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> 1,umd should insert always three IB each job, this is guaranteed in windows and catalyst driver, and this is a must for virtualization,<o:p></o:p></p>
<p class="MsoPlainText">> Besides, how to implement virtualization is not lead by driver, instead we should follow CP logic, and you don't have any choice of how to impl it ...<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">No, that is totally nonsense. The kernel driver can *NEVER* rely on that the UMD does something in a certain way.<o:p></o:p></p>
<p class="MsoPlainText"><span style="color:black"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:red">[ML] please stick to my patch, my patch only *not* skip the preamble CE ib, it actually doesn't make any harm, and umd can do whatever it want,
<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:red">but please remember that if the system want to support world switch, UMD *must* always insert preamble CE_IB, CE_IB, and DE_IB for *each* DMAframe/job.
<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:red">Because CP will rely on the offset of preamble CE IB to calculate the meta data filling package offset within the ring buffer, and CP will change those meta data for world switch.
<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:red">NOTE: the meta data filling package patch is not ready in staging-4.6, I will provide more patches later, and the meta data records some snapshot of the timing CPG get preempted.<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:red"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:red">>>Briefly speaking: ring buffer should be fixed at some certain pattern so that CP hw can rely on this pattern to get/set data *in ring buffer directly* for the purpose of world switch!<o:p></o:p></span></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Mesa for example does uses the IBs this way and since that is the open source implementation it is also the only one that matters for us.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">See Daniels recent mail about that<o:p></o:p></p>
<p class="MsoPlainText">(<a href="http://www.spinics.net/lists/dri-devel/msg116196.html"><span style="color:windowtext;text-decoration:none">http://www.spinics.net/lists/dri-devel/msg116196.html</span></a>).<o:p></o:p></p>
<p class="MsoPlainText">"<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">+- The Linux kernel's "no regression" policy holds in practice only for<o:p></o:p></p>
<p class="MsoPlainText">+ open-source userspace of the DRM subsystem. DRM developers are
<o:p></o:p></p>
<p class="MsoPlainText">+perfectly fine<o:p></o:p></p>
<p class="MsoPlainText">+ if closed-source blob drivers in userspace use the same uAPI as the
<o:p></o:p></p>
<p class="MsoPlainText">+open<o:p></o:p></p>
<p class="MsoPlainText">+ drivers, but they must do so in the exact same way as the open drivers.<o:p></o:p></p>
<p class="MsoPlainText">+ Creative (ab)use of the interfaces will, and in the past routinely
<o:p></o:p></p>
<p class="MsoPlainText">+has, lead<o:p></o:p></p>
<p class="MsoPlainText">+ to breakage.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">"<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> 2,the patch only doesn't skip the preamble CE ib, so it doesn't break any interface protocol. I really don't understand your phase ---" Apart from that not skipping the IBs would break the IOCTL interface, so it is clearly a NAK"<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">The IOCTL interface requires that we skip the IBs when there isn't any context change. Otherwise adding the flag in the first place wouldn't have made sense. Sorry but this requirement comes a bit late.<o:p></o:p></p>
<p class="MsoPlainText"><span style="color:black"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:red">[ML] well. Since from practice perspective, not skip the preamble CE IB really doesn’t make any harm, and based on the requirement of world switch, preamble CE IB *<b>cannot</b>* be skipped, so I think this interface
need change.<o:p></o:p></span></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Could you summarize why the CP has this strange requirement and what would happen if we don't handle this correctly?<o:p></o:p></p>
<p class="MsoPlainText"><span style="color:black"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:red">[ML] already mentioned above<o:p></o:p></span></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> 3,the patch doesn't insert ring specific code, " <o:p></o:p></p>
<p class="MsoPlainText">> amdgpu_ring_insert_nop" is a common interface for all amdgpu ring,
<o:p></o:p></p>
<p class="MsoPlainText">> *and* be caution that this change is a must otherwise CE will get vm
<o:p></o:p></p>
<p class="MsoPlainText">> fault after we change the scheme of SWITCH_BUFFERS<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> + if (ring->type == AMDGPU_RING_TYPE_GFX)<o:p></o:p></p>
<p class="MsoPlainText">Well isn't this if testing the ring type or not? So it is clearly ring specific code in the common handling.<o:p></o:p></p>
<p class="MsoPlainText"><span style="color:black"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:red">[ML] why common handling cannot tolerate ring specific code ? According to brahma code, you can always find ring specific code in common handling, for example:<o:p></o:p></span></p>
<p class="MsoPlainText"><span style="color:red"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:red">“Checking if preamble CE ib could be skipped” itself is a classic behavior of ring specific code, only gfx ring have preamble CE ib …<o:p></o:p></span></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">If you need to inserts NOPs before everything else you need to add a callback for this, but I would rather say add this into the existing vm_flush or sync engine callback where it belongs.<o:p></o:p></p>
<p class="MsoPlainText"><span style="color:black"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:red">[ML] I really have no strong opinion of the place inserting those NOPS, as long as they are ahead of CE IB is okay for me ! I can change to that way as you wish.<o:p></o:p></span></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">> 4,Only insert one SWITCH_BUFFERs at the end of GFX dma frame is what exactly windows KMD do for GX8.0, this is both for preemption and performance, original scheme of SWITCH_BUFFER is totally wrong, and please check below text I copied
from CP hw guys:<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> ----------------------------------------thread of discussion CE sync
<o:p></o:p></p>
<p class="MsoPlainText">> with DE with Hans--------------------------------------------------<o:p></o:p></p>
<p class="MsoPlainText">> Monk,<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> All your assumptions are correct and to be sure that CE isn’t ahead when it shouldn’t, the safe way is to insert double switch buffers at the end of VMSWICH.<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> Now to the question, why does it work? There is a hardware limitation on how far ahead CE can be in the ring buffer. CE and DE are reading from the same fetcher and that data is stored in a reorder queue (ROQ). The size of this queue
(in gfx8) is 128 DWs. This is how far ahead CE can be. Now, at least for Windows, KMD usually pad (NOPs) each DMA frame to 128 (or 256?) DWs and if CE’s indirect buffer is more than 128 DWs ahead of where DE is updating the page table it will work due to the
padding and the limitation of the ROQ.<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> /Hans<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">When this is the requirement of the hardware team then you should properly implement that and not add crude workarounds like the proposed one.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">See the calls to amdgpu_ring_init() here the align_mask determines how many padding is added for each command submission. We currently only uses 16 for the GFX engine IIRC, just changing that to 256 should fix the issue.<o:p></o:p></p>
<p class="MsoPlainText"><span style="color:black"><o:p> </o:p></span></p>
<p class="MsoPlainText"><span style="color:red">[ML] no, the padding is not needed before command submission, instead it is needed between the first CE_IB and the last package of VM flush!<o:p></o:p></span></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Regards,<o:p></o:p></p>
<p class="MsoPlainText">Christian.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> From: Liu, Monk<o:p></o:p></p>
<p class="MsoPlainText">> Sent: Monday, August 15, 2016 11:35 PM<o:p></o:p></p>
<p class="MsoPlainText">> To: Fernlund, Hans<o:p></o:p></p>
<p class="MsoPlainText">> Cc: Deucher, Alexander; Li, Bingley; Liu, Robert; Wang,
<o:p></o:p></p>
<p class="MsoPlainText">> Daniel(Xiaowei); Jiang, Jerry (SW)<o:p></o:p></p>
<p class="MsoPlainText">> Subject: FW: CE synchronization with DE<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> Hi Hans,<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> we are trying to understand constant engine sync (with DE) principle
<o:p></o:p></p>
<p class="MsoPlainText">> and we still have things not understood, especially the behave of CE<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> can you help us go through it ? thanks very much!<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> 1. CE runs much faster than DE, and before DE finished VMSWICH (vm_invalidate_request & pd preparing ) CE may already start running in CE_IB, which will touch memory through VMID 3 (windows KMD use VMID 3 for GFX engine), we
are wondering why we never saw CE vm fault ?<o:p></o:p></p>
<p class="MsoPlainText">> 2. After CE processed SWITCH_BUFFERS, CE will go to the next DMA frame, which may probably belongs to another process (process B), but meanwhile DE may still not finished VM switch to process B, we also wondering why we never
see CE vm fault under this condition neither…<o:p></o:p></p>
<p class="MsoPlainText">> • NOTE: It only insert one SWITCH_BUFFERS at the end of gfx dma frame, so it won’t block CE continue if Buffer B is never used. ( first IB use buffer A and second use buffer B)<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> Ring buffer figure for above two cases, see blow please :<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> #1 case scenario:<o:p></o:p></p>
<p class="MsoPlainText">> Ring buffer:<o:p></o:p></p>
<p class="MsoPlainText">> /VMSWITCH/……/IB_C /IB_C/IB/EOP/SWITCH_BUFFER/…..<o:p></o:p></p>
<p class="MsoPlainText">> ^ ^<o:p></o:p></p>
<p class="MsoPlainText">> | |<o:p></o:p></p>
<p class="MsoPlainText">> DE CE<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> Assume GFX ring is fresh new, and we just drop one JOB to hardware
<o:p></o:p></p>
<p class="MsoPlainText">> ring, DE is still in VMSWITCH stage (bind PD of current process to
<o:p></o:p></p>
<p class="MsoPlainText">> VMID 3 and then invalidate VM), so now the page table for VMID 3 is
<o:p></o:p></p>
<p class="MsoPlainText">> still not ready, but meanwhile CE may already executing CE_IB,
<o:p></o:p></p>
<p class="MsoPlainText">> accessing address of this CE_IB should trigger VM fault as our
<o:p></o:p></p>
<p class="MsoPlainText">> understanding …<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> We wondering why this never triggering vm fault since page table is not yet fully connected to VMID 3!<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> #2 case scenario:<o:p></o:p></p>
<p class="MsoPlainText">> Ring buffer:<o:p></o:p></p>
<p class="MsoPlainText">> /VMSWITCH-to-P1/……/IB_C /IB_C/IB/EOP/SWITCH_BUFFER/…../VMSWITCH-to-P2/………/IB_C /IB_C/IB/EOP/SWITCH_BUFFER/……<o:p></o:p></p>
<p class="MsoPlainText">> ^ ^<o:p></o:p></p>
<p class="MsoPlainText">> | |<o:p></o:p></p>
<p class="MsoPlainText">> DE CE<o:p></o:p></p>
<p class="MsoPlainText">> Still assume the ring buffer is fresh new, and Assume DE is still in VMSWITCH-TO-P2 stage (P1/P2 means process1/process2), since this time vm page table of P2 yet not been binding to VMID3, if CE is already running in IB belongs to
P2, why we never meet vm fault ?<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> Thanks for your time!<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> BR Monk<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> -----Original Message-----<o:p></o:p></p>
<p class="MsoPlainText">> From: Christian König [<a href="mailto:deathsimple@vodafone.de"><span style="color:windowtext;text-decoration:none">mailto:deathsimple@vodafone.de</span></a>]<o:p></o:p></p>
<p class="MsoPlainText">> Sent: Wednesday, August 24, 2016 4:16 PM<o:p></o:p></p>
<p class="MsoPlainText">> To: Liu, Monk <<a href="mailto:Monk.Liu@amd.com"><span style="color:windowtext;text-decoration:none">Monk.Liu@amd.com</span></a>>;
<a href="mailto:amd-gfx@lists.freedesktop.org"><span style="color:windowtext;text-decoration:none">amd-gfx@lists.freedesktop.org</span></a><o:p></o:p></p>
<p class="MsoPlainText">> Subject: Re: [PATCH] drm/amdgpu:fix DMAframe for GFX8<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> Am 24.08.2016 um 05:42 schrieb Monk Liu:<o:p></o:p></p>
<p class="MsoPlainText">>> 1,drop inserting double SWITCH_BUFFERS scheme, which impacts
<o:p></o:p></p>
<p class="MsoPlainText">>> performance, because double SWITCH_BUFFER actaully doesn't switch
<o:p></o:p></p>
<p class="MsoPlainText">>> buffer, so the CE's ping-pong buffer is not used at all. Now only
<o:p></o:p></p>
<p class="MsoPlainText">>> insert one SWITCH_BUFFERS at the bottom of each GFX dmaframe. And
<o:p></o:p></p>
<p class="MsoPlainText">>> only inserting one SWITCH_BUFFER is a must for Virtualization World Switch!<o:p></o:p></p>
<p class="MsoPlainText">>><o:p> </o:p></p>
<p class="MsoPlainText">>> 2,without double SWITCH_BUFFRES, CE will go very ahead of DE which
<o:p></o:p></p>
<p class="MsoPlainText">>> will trigger VM fault (CE IB run before DE finished VM flush), so we
<o:p></o:p></p>
<p class="MsoPlainText">>> need a way to prevent that happen.<o:p></o:p></p>
<p class="MsoPlainText">>> according to GFX8.0 spec, CE will go ahead of DE at most by 128dw, so
<o:p></o:p></p>
<p class="MsoPlainText">>> we can insert 128 NOP before CE ib, so that CE won't run const IB
<o:p></o:p></p>
<p class="MsoPlainText">>> before DE finished VM flush.<o:p></o:p></p>
<p class="MsoPlainText">>><o:p> </o:p></p>
<p class="MsoPlainText">>> 3,for virtualization, CP requires that each DMAframe need two const
<o:p></o:p></p>
<p class="MsoPlainText">>> IB and one IB, so we cannot remove preamble CE IB even no context
<o:p></o:p></p>
<p class="MsoPlainText">>> switch take place.<o:p></o:p></p>
<p class="MsoPlainText">> Well than we probably can't implement virtualization this way, cause there isn't any guarantee that userspace will use two CE IBs and one DE IB.<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> Apart from that not skipping the IBs would break the IOCTL interface, so it is clearly a NAK.<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">>> 4,each DMAframe won't occupy more than 256dw, so allocate 256dw is
<o:p></o:p></p>
<p class="MsoPlainText">>> enough<o:p></o:p></p>
<p class="MsoPlainText">>><o:p> </o:p></p>
<p class="MsoPlainText">>> TODO:<o:p></o:p></p>
<p class="MsoPlainText">>> use DMAframe entry design to implement ib_schedule(), make sure each
<o:p></o:p></p>
<p class="MsoPlainText">>> DMAframe is aligned and fixed at their offset, which is needed for
<o:p></o:p></p>
<p class="MsoPlainText">>> preemption and easy for ring buffer debug & dump.<o:p></o:p></p>
<p class="MsoPlainText">>><o:p> </o:p></p>
<p class="MsoPlainText">>> Change-Id: I1b98d6352b7ead91b661094921bfd43cfeaae190<o:p></o:p></p>
<p class="MsoPlainText">>> Signed-off-by: Monk Liu <<a href="mailto:Monk.Liu@amd.com"><span style="color:windowtext;text-decoration:none">Monk.Liu@amd.com</span></a>><o:p></o:p></p>
<p class="MsoPlainText">>> ---<o:p></o:p></p>
<p class="MsoPlainText">>> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++<o:p></o:p></p>
<p class="MsoPlainText">>> drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 15 ++++++++++-----<o:p></o:p></p>
<p class="MsoPlainText">>> drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 27 ++++++++++++---------------<o:p></o:p></p>
<p class="MsoPlainText">>> 3 files changed, 24 insertions(+), 20 deletions(-)<o:p></o:p></p>
<p class="MsoPlainText">>><o:p> </o:p></p>
<p class="MsoPlainText">>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h<o:p></o:p></p>
<p class="MsoPlainText">>> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<o:p></o:p></p>
<p class="MsoPlainText">>> index 316bd2a..11bb05f 100644<o:p></o:p></p>
<p class="MsoPlainText">>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h<o:p></o:p></p>
<p class="MsoPlainText">>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<o:p></o:p></p>
<p class="MsoPlainText">>> @@ -337,6 +337,7 @@ struct amdgpu_ring_funcs {<o:p></o:p></p>
<p class="MsoPlainText">>> void (*end_use)(struct amdgpu_ring *ring);<o:p></o:p></p>
<p class="MsoPlainText">>> void (*emit_wreg) (struct amdgpu_ring *ring, uint32_t offset, uint32_t val);<o:p></o:p></p>
<p class="MsoPlainText">>> void (*emit_rreg) (struct amdgpu_ring *ring, uint32_t offset);<o:p></o:p></p>
<p class="MsoPlainText">>> + void (*emit_sb) (struct amdgpu_ring *ring, int cnt);<o:p></o:p></p>
<p class="MsoPlainText">>> };<o:p></o:p></p>
<p class="MsoPlainText">>> <o:p></o:p></p>
<p class="MsoPlainText">>> /*<o:p></o:p></p>
<p class="MsoPlainText">>> @@ -2370,6 +2371,7 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)<o:p></o:p></p>
<p class="MsoPlainText">>> #define amdgpu_ring_emit_hdp_invalidate(r) (r)->funcs->emit_hdp_invalidate((r))<o:p></o:p></p>
<p class="MsoPlainText">>> #define amdgpu_ring_emit_wreg(r, i, v) (r)->funcs->emit_wreg((r), (i), (v))<o:p></o:p></p>
<p class="MsoPlainText">>> #define amdgpu_ring_emit_rreg(r, i) (r)->funcs->emit_rreg((r),
<o:p></o:p></p>
<p class="MsoPlainText">>> (i))<o:p></o:p></p>
<p class="MsoPlainText">>> +#define amdgpu_ring_emit_sb(r, c) (r)->funcs->emit_sb((r), (c))<o:p></o:p></p>
<p class="MsoPlainText">>> #define amdgpu_ring_pad_ib(r, ib) ((r)->funcs->pad_ib((r), (ib)))<o:p></o:p></p>
<p class="MsoPlainText">>> #define amdgpu_ring_init_cond_exec(r) (r)->funcs->init_cond_exec((r))<o:p></o:p></p>
<p class="MsoPlainText">>> #define amdgpu_ring_patch_cond_exec(r,o)<o:p></o:p></p>
<p class="MsoPlainText">>> (r)->funcs->patch_cond_exec((r),(o))<o:p></o:p></p>
<p class="MsoPlainText">>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c<o:p></o:p></p>
<p class="MsoPlainText">>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c<o:p></o:p></p>
<p class="MsoPlainText">>> index a31d7ef..d99af07 100644<o:p></o:p></p>
<p class="MsoPlainText">>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c<o:p></o:p></p>
<p class="MsoPlainText">>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c<o:p></o:p></p>
<p class="MsoPlainText">>> @@ -151,7 +151,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,<o:p></o:p></p>
<p class="MsoPlainText">>> return -EINVAL;<o:p></o:p></p>
<p class="MsoPlainText">>> }<o:p></o:p></p>
<p class="MsoPlainText">>> <o:p></o:p></p>
<p class="MsoPlainText">>> - r = amdgpu_ring_alloc(ring, 256 * num_ibs);<o:p></o:p></p>
<p class="MsoPlainText">>> + r = amdgpu_ring_alloc(ring, 256);<o:p></o:p></p>
<p class="MsoPlainText">>> if (r) {<o:p></o:p></p>
<p class="MsoPlainText">>> dev_err(adev->dev, "scheduling IB failed (%d).\n", r);<o:p></o:p></p>
<p class="MsoPlainText">>> return r;<o:p></o:p></p>
<p class="MsoPlainText">>> @@ -174,15 +174,16 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,<o:p></o:p></p>
<p class="MsoPlainText">>> /* always set cond_exec_polling to CONTINUE */<o:p></o:p></p>
<p class="MsoPlainText">>> *ring->cond_exe_cpu_addr = 1;<o:p></o:p></p>
<p class="MsoPlainText">>> <o:p></o:p></p>
<p class="MsoPlainText">>> +<o:p></o:p></p>
<p class="MsoPlainText">>> + /* emit 128 dw nop before IBc */<o:p></o:p></p>
<p class="MsoPlainText">>> + if (ring->type == AMDGPU_RING_TYPE_GFX)<o:p></o:p></p>
<p class="MsoPlainText">>> + amdgpu_ring_insert_nop(ring, 128);<o:p></o:p></p>
<p class="MsoPlainText">>> +<o:p></o:p></p>
<p class="MsoPlainText">> Please don't add ring specific code into the common handling.<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">>> skip_preamble = ring->current_ctx == ctx;<o:p></o:p></p>
<p class="MsoPlainText">>> need_ctx_switch = ring->current_ctx != ctx;<o:p></o:p></p>
<p class="MsoPlainText">>> for (i = 0; i < num_ibs; ++i) {<o:p></o:p></p>
<p class="MsoPlainText">>> ib = &ibs[i];<o:p></o:p></p>
<p class="MsoPlainText">>> <o:p></o:p></p>
<p class="MsoPlainText">>> - /* drop preamble IBs if we don't have a context switch */<o:p></o:p></p>
<p class="MsoPlainText">>> - if ((ib->flags & AMDGPU_IB_FLAG_PREAMBLE) && skip_preamble)<o:p></o:p></p>
<p class="MsoPlainText">>> - continue;<o:p></o:p></p>
<p class="MsoPlainText">>> -<o:p></o:p></p>
<p class="MsoPlainText">> This is a clear NAK since it is an userspace visible change to stop doing this.<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> Regards,<o:p></o:p></p>
<p class="MsoPlainText">> Christian.<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">>> amdgpu_ring_emit_ib(ring, ib, job ? job->vm_id : 0,<o:p></o:p></p>
<p class="MsoPlainText">>> need_ctx_switch);<o:p></o:p></p>
<p class="MsoPlainText">>> need_ctx_switch = false;<o:p></o:p></p>
<p class="MsoPlainText">>> @@ -210,6 +211,10 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,<o:p></o:p></p>
<p class="MsoPlainText">>> amdgpu_ring_patch_cond_exec(ring, patch_offset);<o:p></o:p></p>
<p class="MsoPlainText">>> <o:p></o:p></p>
<p class="MsoPlainText">>> ring->current_ctx = ctx;<o:p></o:p></p>
<p class="MsoPlainText">>> +<o:p></o:p></p>
<p class="MsoPlainText">>> + /* Insert one SB at the bottom of each DMA frame */<o:p></o:p></p>
<p class="MsoPlainText">>> + if (ring->funcs->emit_sb)<o:p></o:p></p>
<p class="MsoPlainText">>> + amdgpu_ring_emit_sb(ring, 1);<o:p></o:p></p>
<p class="MsoPlainText">>> amdgpu_ring_commit(ring);<o:p></o:p></p>
<p class="MsoPlainText">>> return 0;<o:p></o:p></p>
<p class="MsoPlainText">>> }<o:p></o:p></p>
<p class="MsoPlainText">>> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<o:p></o:p></p>
<p class="MsoPlainText">>> b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<o:p></o:p></p>
<p class="MsoPlainText">>> index dfa2288..37dc64b 100755<o:p></o:p></p>
<p class="MsoPlainText">>> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<o:p></o:p></p>
<p class="MsoPlainText">>> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c<o:p></o:p></p>
<p class="MsoPlainText">>> @@ -5936,12 +5936,6 @@ static void gfx_v8_0_ring_emit_ib_gfx(struct amdgpu_ring *ring,<o:p></o:p></p>
<p class="MsoPlainText">>> {<o:p></o:p></p>
<p class="MsoPlainText">>> u32 header, control = 0;<o:p></o:p></p>
<p class="MsoPlainText">>> <o:p></o:p></p>
<p class="MsoPlainText">>> - /* insert SWITCH_BUFFER packet before first IB in the ring frame */<o:p></o:p></p>
<p class="MsoPlainText">>> - if (ctx_switch) {<o:p></o:p></p>
<p class="MsoPlainText">>> - amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));<o:p></o:p></p>
<p class="MsoPlainText">>> - amdgpu_ring_write(ring, 0);<o:p></o:p></p>
<p class="MsoPlainText">>> - }<o:p></o:p></p>
<p class="MsoPlainText">>> -<o:p></o:p></p>
<p class="MsoPlainText">>> if (ib->flags & AMDGPU_IB_FLAG_CE)<o:p></o:p></p>
<p class="MsoPlainText">>> header = PACKET3(PACKET3_INDIRECT_BUFFER_CONST, 2);<o:p></o:p></p>
<p class="MsoPlainText">>> else<o:p></o:p></p>
<p class="MsoPlainText">>> @@ -6013,11 +6007,9 @@ static void gfx_v8_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring)<o:p></o:p></p>
<p class="MsoPlainText">>> amdgpu_ring_write(ring, 4); /* poll interval */<o:p></o:p></p>
<p class="MsoPlainText">>> <o:p></o:p></p>
<p class="MsoPlainText">>> if (usepfp) {<o:p></o:p></p>
<p class="MsoPlainText">>> - /* synce CE with ME to prevent CE fetch CEIB before context switch done */<o:p></o:p></p>
<p class="MsoPlainText">>> - amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));<o:p></o:p></p>
<p class="MsoPlainText">>> - amdgpu_ring_write(ring, 0);<o:p></o:p></p>
<p class="MsoPlainText">>> - amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));<o:p></o:p></p>
<p class="MsoPlainText">>> - amdgpu_ring_write(ring, 0);<o:p></o:p></p>
<p class="MsoPlainText">>> + /* sync PFP to ME, otherwise we might get invalid PFP reads */<o:p></o:p></p>
<p class="MsoPlainText">>> + amdgpu_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0));<o:p></o:p></p>
<p class="MsoPlainText">>> + amdgpu_ring_write(ring, 0x0);<o:p></o:p></p>
<p class="MsoPlainText">>> }<o:p></o:p></p>
<p class="MsoPlainText">>> }<o:p></o:p></p>
<p class="MsoPlainText">>> <o:p></o:p></p>
<p class="MsoPlainText">>> @@ -6065,10 +6057,6 @@ static void gfx_v8_0_ring_emit_vm_flush(struct amdgpu_ring *ring,<o:p></o:p></p>
<p class="MsoPlainText">>> /* sync PFP to ME, otherwise we might get invalid PFP reads */<o:p></o:p></p>
<p class="MsoPlainText">>> amdgpu_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0));<o:p></o:p></p>
<p class="MsoPlainText">>> amdgpu_ring_write(ring, 0x0);<o:p></o:p></p>
<p class="MsoPlainText">>> - amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));<o:p></o:p></p>
<p class="MsoPlainText">>> - amdgpu_ring_write(ring, 0);<o:p></o:p></p>
<p class="MsoPlainText">>> - amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));<o:p></o:p></p>
<p class="MsoPlainText">>> - amdgpu_ring_write(ring, 0);<o:p></o:p></p>
<p class="MsoPlainText">>> }<o:p></o:p></p>
<p class="MsoPlainText">>> }<o:p></o:p></p>
<p class="MsoPlainText">>> <o:p></o:p></p>
<p class="MsoPlainText">>> @@ -6170,6 +6158,14 @@ static void gfx_v8_0_ring_emit_wreg_kiq(struct amdgpu_ring *ring, u32 idx, u32 v<o:p></o:p></p>
<p class="MsoPlainText">>> amdgpu_ring_write(ring, val);<o:p></o:p></p>
<p class="MsoPlainText">>> }<o:p></o:p></p>
<p class="MsoPlainText">>> <o:p></o:p></p>
<p class="MsoPlainText">>> +static void gfx_v8_ring_emit_sb(struct amdgpu_ring *ring, int cnt) {<o:p></o:p></p>
<p class="MsoPlainText">>> + while (cnt--) {<o:p></o:p></p>
<p class="MsoPlainText">>> + amdgpu_ring_write(ring, PACKET3(PACKET3_SWITCH_BUFFER, 0));<o:p></o:p></p>
<p class="MsoPlainText">>> + amdgpu_ring_write(ring, 0);<o:p></o:p></p>
<p class="MsoPlainText">>> + }<o:p></o:p></p>
<p class="MsoPlainText">>> +}<o:p></o:p></p>
<p class="MsoPlainText">>> +<o:p></o:p></p>
<p class="MsoPlainText">>> static void gfx_v8_0_set_gfx_eop_interrupt_state(struct amdgpu_device *adev,<o:p></o:p></p>
<p class="MsoPlainText">>> enum amdgpu_interrupt_state state)<o:p></o:p></p>
<p class="MsoPlainText">>> {<o:p></o:p></p>
<p class="MsoPlainText">>> @@ -6477,6 +6473,7 @@ static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_gfx = {<o:p></o:p></p>
<p class="MsoPlainText">>> .test_ib = gfx_v8_0_ring_test_ib,<o:p></o:p></p>
<p class="MsoPlainText">>> .insert_nop = amdgpu_ring_insert_nop,<o:p></o:p></p>
<p class="MsoPlainText">>> .pad_ib = amdgpu_ring_generic_pad_ib,<o:p></o:p></p>
<p class="MsoPlainText">>> + .emit_sb = gfx_v8_ring_emit_sb,<o:p></o:p></p>
<p class="MsoPlainText">>> };<o:p></o:p></p>
<p class="MsoPlainText">>> <o:p></o:p></p>
<p class="MsoPlainText">>> static const struct amdgpu_ring_funcs gfx_v8_0_ring_funcs_compute
<o:p></o:p></p>
<p class="MsoPlainText">>> = {<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">_______________________________________________<o:p></o:p></p>
<p class="MsoPlainText">amd-gfx mailing list<o:p></o:p></p>
<p class="MsoPlainText"><a href="mailto:amd-gfx@lists.freedesktop.org"><span style="color:windowtext;text-decoration:none">amd-gfx@lists.freedesktop.org</span></a><o:p></o:p></p>
<p class="MsoPlainText"><a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx"><span style="color:windowtext;text-decoration:none">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</span></a><o:p></o:p></p>
</div>
</body>
</html>