<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Calibri;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - AMD Internal Distribution Only]<br>
</p>
<br>
<div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I might have worded that poorly, I meant that it seems like TLB flush is out of sync with the SDMA update, which leads to a page fault reliably. I don't feel it has anything to do with the implicit sync in itself. When TLB fence is created it's added to the
 dma_resv of the vm's root buffer object with BOOKKEEP usage specified, in order to make sure no PD/PT is freed before the flush. But I don't think it's being added as a job dependency within the amdgpu_vm_sdma_update, we're adding all the fences found within
 the dma_resv object with KERNEL usage specified. I may be missing something so I'd love to hear what you think.<br>
<br>
Best regards,</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Dejan</div>
<div id="appendonsend"></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> Koenig, Christian <Christian.Koenig@amd.com><br>
<b>Sent:</b> Thursday, September 5, 2024 2:40 PM<br>
<b>To:</b> Andjelkovic, Dejan <Dejan.Andjelkovic@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Prica, Nikola <Nikola.Prica@amd.com>; Kuehling, Felix <Felix.Kuehling@amd.com>; Deng, Emily <Emily.Deng@amd.com><br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: Raise dma resv usage for created TLB fence</font>
<div> </div>
</div>
<div>Well that explanation doesn't seem to make much sense either.<br>
<br>
What do you mean with TLB flush is occurring prematurely?<br>
<br>
Regards,<br>
Christian.<br>
<br>
<div class="x_moz-cite-prefix">Am 05.09.24 um 14:38 schrieb Andjelkovic, Dejan:<br>
</div>
<blockquote type="cite"><style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<p align="Left" style="font-family:Calibri; font-size:10pt; color:#0000FF; margin:5pt; font-style:normal; font-weight:normal; text-decoration:none">
[AMD Official Use Only - AMD Internal Distribution Only]<br>
</p>
<br>
<div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hi there. We're running into a page fault issue that's very easily reproducible on a SRIOV environment when using SDMA for page table updates. Going through mapping logs and trace files, it seems TLB flush is occurring prematurely. Changing the usage to KERNEL
 completely stops the page fault from occurring with no performance impact, which was confirmed with extensive testing. Looking through amdgpu_vm_sdma.c, namely within amdgpu_vm_sdma_update when waiting for PD/PT moves to be completed, fences are iterated with
 KERNEL usage specified which are then added as a job dependency.</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Best regards,</div>
<div class="x_elementToProof" style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Dejan</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Koenig, Christian
<a class="x_moz-txt-link-rfc2396E" href="mailto:Christian.Koenig@amd.com"><Christian.Koenig@amd.com></a><br>
<b>Sent:</b> Thursday, September 5, 2024 1:17 PM<br>
<b>To:</b> Andjelkovic, Dejan <a class="x_moz-txt-link-rfc2396E" href="mailto:Dejan.Andjelkovic@amd.com">
<Dejan.Andjelkovic@amd.com></a>; <a class="x_moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">
amd-gfx@lists.freedesktop.org</a> <a class="x_moz-txt-link-rfc2396E" href="mailto:amd-gfx@lists.freedesktop.org">
<amd-gfx@lists.freedesktop.org></a><br>
<b>Cc:</b> Prica, Nikola <a class="x_moz-txt-link-rfc2396E" href="mailto:Nikola.Prica@amd.com">
<Nikola.Prica@amd.com></a>; Kuehling, Felix <a class="x_moz-txt-link-rfc2396E" href="mailto:Felix.Kuehling@amd.com">
<Felix.Kuehling@amd.com></a>; Deng, Emily <a class="x_moz-txt-link-rfc2396E" href="mailto:Emily.Deng@amd.com">
<Emily.Deng@amd.com></a><br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: Raise dma resv usage for created TLB fence</font>
<div> </div>
</div>
<div class="x_BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="x_PlainText">Am 05.09.24 um 10:58 schrieb Dejan Andjelkovic:<br>
> When using SDMA for PT updates, a TLB fence hooked to a buffer<br>
> objects dma resv object with usage declared as BOOKKEEP leaves a<br>
> chance for TLB flush to occur prematurely. This will lead to a page<br>
> fault. Raising the usage from BOOKKEEP to KERNEL removes this<br>
> possibility.<br>
<br>
Well that's complete nonsense. The usage model is for implicit syncing <br>
and not even remotely related to TLB flushing.<br>
<br>
What exactly is the problem you run into?<br>
<br>
Regards,<br>
Christian.<br>
<br>
><br>
> Signed-off-by: Dejan Andjelkovic <a class="x_moz-txt-link-rfc2396E" href="mailto:Dejan.Andjelkovic@amd.com">
<Dejan.Andjelkovic@amd.com></a><br>
> ---<br>
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +-<br>
>   1 file changed, 1 insertion(+), 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 f93804902fd3..8efc2cf9bbb0 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
> @@ -928,7 +928,7 @@ amdgpu_vm_tlb_flush(struct amdgpu_vm_update_params *params,<br>
>   <br>
>                /* Makes sure no PD/PT is freed before the flush */<br>
>                dma_resv_add_fence(vm->root.bo->tbo.base.resv, *fence,<br>
> -                                DMA_RESV_USAGE_BOOKKEEP);<br>
> +                                DMA_RESV_USAGE_KERNEL);<br>
>        }<br>
>   }<br>
>   <br>
<br>
</div>
</span></font></div>
</div>
</blockquote>
<br>
</div>
</div>
</body>
</html>