<div dir="ltr"><div>Pierre-Loup, does this do what you requested?</div><div><br></div><div>Thanks,</div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 23, 2020 at 3:17 PM Christian König <<a href="mailto:ckoenig.leichtzumerken@gmail.com">ckoenig.leichtzumerken@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <div>That the CPU round trip is gone now.<br>
      <br>
      Christian.<br>
      <br>
      Am 23.11.20 um 20:49 schrieb Marek Olšák:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div>What is the behavior we should expect?</div>
        <div><br>
        </div>
        <div>Marek<br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Mon, Nov 23, 2020 at 7:31
          AM Christian König <<a href="mailto:ckoenig.leichtzumerken@gmail.com" target="_blank">ckoenig.leichtzumerken@gmail.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Ping,
          Pierre/Marek does this change works as expected?<br>
          <br>
          Regards,<br>
          Christian.<br>
          <br>
          Am 18.11.20 um 14:20 schrieb Christian König:<br>
          > This allows for optimizing the CPU round trip away.<br>
          ><br>
          > Signed-off-by: Christian König <<a href="mailto:christian.koenig@amd.com" target="_blank">christian.koenig@amd.com</a>><br>
          > ---<br>
          >   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c   |  2 +-<br>
          >   drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 27
          ++++++++++++++++++++++++<br>
          >   drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h |  1 +<br>
          >   3 files changed, 29 insertions(+), 1 deletion(-)<br>
          ><br>
          > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
          b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
          > index 79342976fa76..68f9a4adf5d2 100644<br>
          > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
          > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c<br>
          > @@ -1014,7 +1014,7 @@ static int
          amdgpu_syncobj_lookup_and_add_to_sync(struct amdgpu_cs_parser
          *p,<br>
          >               return r;<br>
          >       }<br>
          >   <br>
          > -     r = amdgpu_sync_fence(&p->job->sync,
          fence);<br>
          > +     r =
          amdgpu_sync_fence_chain(&p->job->sync, fence);<br>
          >       dma_fence_put(fence);<br>
          >   <br>
          >       return r;<br>
          > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
          b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c<br>
          > index 8ea6c49529e7..d0d64af06f54 100644<br>
          > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c<br>
          > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c<br>
          > @@ -28,6 +28,8 @@<br>
          >    *    Christian König <<a href="mailto:christian.koenig@amd.com" target="_blank">christian.koenig@amd.com</a>><br>
          >    */<br>
          >   <br>
          > +#include <linux/dma-fence-chain.h><br>
          > +<br>
          >   #include "amdgpu.h"<br>
          >   #include "amdgpu_trace.h"<br>
          >   #include "amdgpu_amdkfd.h"<br>
          > @@ -169,6 +171,31 @@ int amdgpu_sync_fence(struct
          amdgpu_sync *sync, struct dma_fence *f)<br>
          >       return 0;<br>
          >   }<br>
          >   <br>
          > +/**<br>
          > + * amdgpu_sync_fence_chain - unpack dma_fence_chain and
          sync<br>
          > + *<br>
          > + * @sync: sync object to add fence to<br>
          > + * @f: potential dma_fence_chain to sync to.<br>
          > + *<br>
          > + * Add the fences inside the chain to the sync object.<br>
          > + */<br>
          > +int amdgpu_sync_fence_chain(struct amdgpu_sync *sync,
          struct dma_fence *f)<br>
          > +{<br>
          > +     int r;<br>
          > +<br>
          > +     dma_fence_chain_for_each(f, f) {<br>
          > +             if (dma_fence_is_signaled(f))<br>
          > +                     continue;<br>
          > +<br>
          > +             r = amdgpu_sync_fence(sync, f);<br>
          > +             if (r) {<br>
          > +                     dma_fence_put(f);<br>
          > +                     return r;<br>
          > +             }<br>
          > +     }<br>
          > +     return 0;<br>
          > +}<br>
          > +<br>
          >   /**<br>
          >    * amdgpu_sync_vm_fence - remember to sync to this VM
          fence<br>
          >    *<br>
          > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h
          b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h<br>
          > index 7c0fe20c470d..b142175b65b6 100644<br>
          > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h<br>
          > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.h<br>
          > @@ -48,6 +48,7 @@ struct amdgpu_sync {<br>
          >   <br>
          >   void amdgpu_sync_create(struct amdgpu_sync *sync);<br>
          >   int amdgpu_sync_fence(struct amdgpu_sync *sync, struct
          dma_fence *f);<br>
          > +int amdgpu_sync_fence_chain(struct amdgpu_sync *sync,
          struct dma_fence *f);<br>
          >   int amdgpu_sync_vm_fence(struct amdgpu_sync *sync,
          struct dma_fence *fence);<br>
          >   int amdgpu_sync_resv(struct amdgpu_device *adev, struct
          amdgpu_sync *sync,<br>
          >                    struct dma_resv *resv, enum
          amdgpu_sync_mode mode,<br>
          <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" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </div>

</blockquote></div>