<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">
      <blockquote type="cite">I don't understand why we need all existed update fence for CS</blockquote>
      We don't need all updates for CS, we just need all updates for per
      VM BOs for CS because we don't know which BOs are used in the CS.<br>
      <br>
      That's the overall problem of using per VM BOs, the kernel doesn't
      know what is actually used by this CS and what isn't.<br>
      <br>
      Because of this we need to expect the worst case and sync to all
      the va operations on per VM BOs in flight.<br>
      <br>
      <blockquote type="cite">We need to expand va ioctl.</blockquote>
      Well, we could expand the VA ioctl to provide better performance
      but that can only be a second step.<br>
      <br>
      First of all we must fix the existing handling to do what is
      expected here.<br>
      <br>
      Regards,<br>
      Christian.<br>
      <br>
      Am 11.09.2017 um 14:30 schrieb Zhou, David(ChunMing):<br>
    </div>
    <blockquote type="cite"
cite="mid:MWHPR1201MB0206E76FCF5A0B58F57EFCC2B4680@MWHPR1201MB0206.namprd12.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <meta content="text/html; charset=utf-8">
It still doesn't make sense, I don't understand why we need all existed update fence for CS, which could implicitly contain unrelated fence next CS used. For moved list case, we already synced. We should explicitly sync the needed fence.<br>
      <br>
For per VM BOs, we lack mapping fence, that's why VM fault happens. We need to expand va ioctl.<br>
      <br>
      Regards,<br>
      David <br>
      <br>
      <p dir="ltr" style="display:inline"><span style="color:#888888"><span
            style="font-size:0.81em">发自坚果 Pro</span></span></p>
      <style type="text/css">
<!--
* body
        {padding:0 16px 30px!important;
        margin:0!important;
        background-color:#ffffff;
        line-height:1.4;
        word-wrap:break-word;
        word-break:normal}
div
        {word-wrap:break-word;
        word-break:normal}
p
        {word-wrap:break-word;
        word-break:normal;
        text-indent:0pt!important}
span
        {word-wrap:break-word;
        word-break:normal}
a
        {word-wrap:break-word;
        word-break:normal}
td
        {word-wrap:break-word;
        word-break:break-all}
-->
</style>
      <div class="quote">
        <div style="margin:0 0px; font-size:105%"><font
            style="line-height:1.4" color="#629140"><span>Christian K鰊ig
              <a class="moz-txt-link-rfc2396E" href="mailto:deathsimple@vodafone.de"><deathsimple@vodafone.de></a> 于 2017年9月11日 下午8:00写道:</span></font></div>
        <br type="attribution">
      </div>
      <div>
        <div class="moz-cite-prefix">Ok then we have a misunderstanding
          here. This applies to all per VM BOs, not just kernel BOs.<br>
          <br>
          It's just that as long as the per VM BOs aren't used the
          handling is still correct and we don't have any updates to UMD
          BOs we implicitly wait on.<br>
          <br>
          Sorry I should have waited a bit more, but since it is a very
          rather urgent bug fix I've already pushed it with Rogers rb.<br>
          <br>
          Regards,<br>
          Christian.<br>
          <br>
          Am 11.09.2017 um 13:42 schrieb Zhou, David(ChunMing):<br>
        </div>
        <blockquote type="cite">
          <meta name="Generator" content="Microsoft Exchange Server">
          <style>
<!--
.EmailQuote
        {margin-left:1pt;
        padding-left:4pt;
        border-left:#800000 2px solid}
-->
</style>
          <div>My mean is you should add a condition in code to check if BO is kernel BO or not. I expect V3.<br>
            <br>
            Regards,<br>
            David<br>
            <br>
            <p dir="ltr" style="display:inline"><span
                style="color:#888888"><span style="font-size:0.81em">发自坚果
                  Pro</span></span></p>
            <style type="text/css">
<!--
* body
        {padding:0 16px 30px!important;
        margin:0!important;
        background-color:#ffffff;
        line-height:1.4;
        word-wrap:break-word;
        word-break:normal}
div
        {word-wrap:break-word;
        word-break:normal}
p
        {word-wrap:break-word;
        word-break:normal;
        text-indent:0pt!important}
span
        {word-wrap:break-word;
        word-break:normal}
a
        {word-wrap:break-word;
        word-break:normal}
td
        {word-wrap:break-word;
        word-break:break-all}
-->
</style>
            <div class="x_quote">
              <div style="margin:0 0px; font-size:105%"><font
                  style="line-height:1.4" color="#629140"><span>He,
                    Roger
                    <a class="moz-txt-link-rfc2396E"
                      href="mailto:Hongbo.He@amd.com"
                      moz-do-not-send="true"><Hongbo.He@amd.com></a>
                    于 2017年9月11日 下午6:57写道:</span></font></div>
              <br type="attribution">
            </div>
          </div>
          <font size="2"><span style="font-size:10pt">
              <div class="PlainText">Reviewed-by: Roger He <a
                  class="moz-txt-link-rfc2396E"
                  href="mailto:Hongbo.He@amd.com" moz-do-not-send="true">
                  <Hongbo.He@amd.com></a><br>
                <br>
                Thanks<br>
                Roger(Hongbo.He)<br>
                -----Original Message-----<br>
                From: amd-gfx [<a
                  href="mailto:amd-gfx-bounces@lists.freedesktop.org"
                  moz-do-not-send="true">mailto:amd-gfx-bounces@lists.freedesktop.org</a>]
                On Behalf Of Christian K?nig<br>
                Sent: Monday, September 11, 2017 6:53 PM<br>
                To: Zhou, David(ChunMing) <a
                  class="moz-txt-link-rfc2396E"
                  href="mailto:David1.Zhou@amd.com"
                  moz-do-not-send="true">
                  <David1.Zhou@amd.com></a>; <a
                  class="moz-txt-link-abbreviated"
                  href="mailto:amd-gfx@lists.freedesktop.org"
                  moz-do-not-send="true">
                  amd-gfx@lists.freedesktop.org</a><br>
                Subject: Re: [PATCH] drm/amdgpu: fix VM sync with always
                valid BOs v2<br>
                <br>
                Am 11.09.2017 um 11:10 schrieb zhoucm1:<br>
                ><br>
                ><br>
                > On 2017年09月11日 17:04, Christian König wrote:<br>
                >>> NAK, as Roger pointed, the performance of
                Vulkan Dota2 drops from <br>
                >>> 72fps to 24fps.<br>
                >>><br>
                >>> This patches will kill Per-vm-BO
                advantages, even drop to 1/3 of <br>
                >>> previous non-per-vm-bo.<br>
                >><br>
                >> This is irrelevant and actually a foreseen
                consequence of per VM BOs.<br>
                >><br>
                >> If the performance drops is in-acceptable then
                the UMD shouldn't use <br>
                >> this feature.<br>
                > I got your mean, if UMD doesn't use this feature,
                then all BOs should <br>
                > be kernel only, then this change should only be
                limited to kernel VM <br>
                > BOs, not include UMD BOs.<br>
                > With this limitation, I think the change also can
                fix your issue.<br>
                <br>
                Correct, yes. Can I get your rb or ab now? We need to
                get this fixed asap.<br>
                <br>
                Thanks,<br>
                Christian.<br>
                <br>
                ><br>
                > Regards,<br>
                > David Zhou<br>
                >><br>
                >>> all moved and relocated fence have already
                synced, we just need to <br>
                >>> catch the va mapping but which is CS itself
                required, as my proposal <br>
                >>> in another thread, we maybe need to expand
                va_ioctl to return <br>
                >>> mapping fence to UMD, then UMD passes it to
                CS as dependency.<br>
                >><br>
                >> That can be an addition to the existing
                handling, but first of all <br>
                >> the current state must be corrected.<br>
                >><br>
                >> There are at least two bug reports on the open
                driver fixed by this, <br>
                >> so please review.<br>
                >><br>
                >> Thanks,<br>
                >> Christian.<br>
                >><br>
                >> Am 11.09.2017 um 10:59 schrieb zhoucm1:<br>
                >>> NAK, as Roger pointed, the performance of
                Vulkan Dota2 drops from <br>
                >>> 72fps to 24fps.<br>
                >>><br>
                >>> This patches will kill Per-vm-BO
                advantages, even drop to 1/3 of <br>
                >>> previous non-per-vm-bo.<br>
                >>><br>
                >>> all moved and relocated fence have already
                synced, we just need to <br>
                >>> catch the va mapping but which is CS itself
                required, as my proposal <br>
                >>> in another thread, we maybe need to expand
                va_ioctl to return <br>
                >>> mapping fence to UMD, then UMD passes it to
                CS as dependency.<br>
                >>><br>
                >>><br>
                >>> Regards,<br>
                >>><br>
                >>> David Zhou<br>
                >>><br>
                >>><br>
                >>> On 2017年09月11日 15:53, Christian König
                wrote:<br>
                >>>> From: Christian König <a
                  class="moz-txt-link-rfc2396E"
                  href="mailto:christian.koenig@amd.com"
                  moz-do-not-send="true">
                  <christian.koenig@amd.com></a><br>
                >>>><br>
                >>>> All users of a VM must always wait for
                updates with always valid <br>
                >>>> BOs to be completed.<br>
                >>>><br>
                >>>> v2: remove debugging leftovers, rename
                struct member<br>
                >>>><br>
                >>>> Signed-off-by: Christian König <a
                  class="moz-txt-link-rfc2396E"
                  href="mailto:christian.koenig@amd.com"
                  moz-do-not-send="true">
                  <christian.koenig@amd.com></a><br>
                >>>> ---<br>
                >>>>  
                drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 10 ++++++----<br>
                >>>>  
                drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15
                ++++++++++-----<br>
                >>>>  
                drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h |  2 +-<br>
                >>>>   3 files changed, 17 insertions(+), 10
                deletions(-)<br>
                >>>><br>
                >>>> diff --git
                a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
                >>>>
                b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
                >>>> index 8aa37e0..4681dcc 100644<br>
                >>>> ---
                a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
                >>>> +++
                b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
                >>>> @@ -752,10 +752,6 @@ static int
                amdgpu_bo_vm_update_pte(struct <br>
                >>>> amdgpu_cs_parser *p)<br>
                >>>>       if (r)<br>
                >>>>           return r;<br>
                >>>>   -    r = amdgpu_sync_fence(adev,
                &p->job->sync, <br>
                >>>> vm->last_dir_update);<br>
                >>>> -    if (r)<br>
                >>>> -        return r;<br>
                >>>> -<br>
                >>>>       r = amdgpu_vm_clear_freed(adev,
                vm, NULL);<br>
                >>>>       if (r)<br>
                >>>>           return r;<br>
                >>>> @@ -810,6 +806,12 @@ static int
                amdgpu_bo_vm_update_pte(struct <br>
                >>>> amdgpu_cs_parser *p)<br>
                >>>>       }<br>
                >>>>         r =
                amdgpu_vm_handle_moved(adev, vm,
                &p->job->sync);<br>
                >>>> +    if (r)<br>
                >>>> +        return r;<br>
                >>>> +<br>
                >>>> +    r = amdgpu_sync_fence(adev,
                &p->job->sync, vm->last_update);<br>
                >>>> +    if (r)<br>
                >>>> +        return r;<br>
                >>>>         if (amdgpu_vm_debug &&
                p->bo_list) {<br>
                >>>>           /* Invalidate all BOs to test
                for userspace bugs */ diff <br>
                >>>> --git
                a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
                >>>>
                b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
                >>>> index 55f1ecb..5042f09 100644<br>
                >>>> ---
                a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
                >>>> +++
                b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
                >>>> @@ -1140,9 +1140,8 @@ static int
                amdgpu_vm_update_level(struct <br>
                >>>> amdgpu_device *adev,<br>
                >>>>                   goto error_free;<br>
                >>>>                
                amdgpu_bo_fence(parent->base.bo, fence, true);<br>
                >>>> -           
                dma_fence_put(vm->last_dir_update);<br>
                >>>> -            vm->last_dir_update =
                dma_fence_get(fence);<br>
                >>>> -            dma_fence_put(fence);<br>
                >>>> +           
                dma_fence_put(vm->last_update);<br>
                >>>> +            vm->last_update =
                fence;<br>
                >>>>           }<br>
                >>>>       }<br>
                >>>>   @@ -1803,6 +1802,12 @@ int
                amdgpu_vm_bo_update(struct <br>
                >>>> amdgpu_device *adev,<br>
                >>>>              
                trace_amdgpu_vm_bo_mapping(mapping);<br>
                >>>>       }<br>
                >>>>   +    if (bo_va->base.bo &&<br>
                >>>> +        bo_va->base.bo->tbo.resv
                == vm->root.base.bo->tbo.resv) {<br>
                >>>> +       
                dma_fence_put(vm->last_update);<br>
                >>>> +        vm->last_update =
                dma_fence_get(bo_va->last_pt_update);<br>
                >>>> +    }<br>
                >>>> +<br>
                >>>>       return 0;<br>
                >>>>   }<br>
                >>>>   @@ -2586,7 +2591,7 @@ int
                amdgpu_vm_init(struct amdgpu_device <br>
                >>>> *adev, struct amdgpu_vm *vm,<br>
                >>>>               
                vm->use_cpu_for_update ? "CPU" : "SDMA");<br>
                >>>>      
                WARN_ONCE((vm->use_cpu_for_update & <br>
                >>>> !amdgpu_vm_is_large_bar(adev)),<br>
                >>>>             "CPU update of VM
                recommended only for large BAR <br>
                >>>> system\n");<br>
                >>>> -    vm->last_dir_update = NULL;<br>
                >>>> +    vm->last_update = NULL;<br>
                >>>>         flags =
                AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS |<br>
                >>>>              
                AMDGPU_GEM_CREATE_VRAM_CLEARED; @@ -2692,7 +2697,7 @@ <br>
                >>>> void amdgpu_vm_fini(struct
                amdgpu_device *adev, struct amdgpu_vm <br>
                >>>> *vm)<br>
                >>>>       }<br>
                >>>>        
                amdgpu_vm_free_levels(&vm->root);<br>
                >>>> -   
                dma_fence_put(vm->last_dir_update);<br>
                >>>> +    dma_fence_put(vm->last_update);<br>
                >>>>       for (i = 0; i <
                AMDGPU_MAX_VMHUBS; i++)<br>
                >>>>          
                amdgpu_vm_free_reserved_vmid(adev, vm, i);<br>
                >>>>   }<br>
                >>>> diff --git
                a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
                >>>>
                b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
                >>>> index c1accd1..cb6a622 100644<br>
                >>>> ---
                a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
                >>>> +++
                b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
                >>>> @@ -140,7 +140,7 @@ struct amdgpu_vm {<br>
                >>>>         /* contains the page directory
                */<br>
                >>>>       struct amdgpu_vm_pt     root;<br>
                >>>> -    struct dma_fence   
                *last_dir_update;<br>
                >>>> +    struct dma_fence    *last_update;<br>
                >>>>         /* protecting freed */<br>
                >>>>       spinlock_t        freed_lock;<br>
                >>><br>
                >>>
                _______________________________________________<br>
                >>> amd-gfx mailing list<br>
                >>> <a class="moz-txt-link-abbreviated"
                  href="mailto:amd-gfx@lists.freedesktop.org"
                  moz-do-not-send="true">
                  amd-gfx@lists.freedesktop.org</a><br>
                >>> <a
                  href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx"
                  moz-do-not-send="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
                >><br>
                >><br>
                ><br>
                > _______________________________________________<br>
                > amd-gfx mailing list<br>
                > <a class="moz-txt-link-abbreviated"
                  href="mailto:amd-gfx@lists.freedesktop.org"
                  moz-do-not-send="true">
                  amd-gfx@lists.freedesktop.org</a><br>
                > <a
                  href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx"
                  moz-do-not-send="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
                <br>
                <br>
                _______________________________________________<br>
                amd-gfx mailing list<br>
                <a class="moz-txt-link-abbreviated"
                  href="mailto:amd-gfx@lists.freedesktop.org"
                  moz-do-not-send="true">amd-gfx@lists.freedesktop.org</a><br>
                <a
                  href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx"
                  moz-do-not-send="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
              </div>
            </span></font><br>
          <fieldset class="mimeAttachmentHeader"></fieldset>
          <br>
          <pre>_______________________________________________
amd-gfx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org" moz-do-not-send="true">amd-gfx@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" moz-do-not-send="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
</pre>
        </blockquote>
        <p><br>
        </p>
      </div>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>