[PATCH] drm/amdgpu: unpack dma_fence_chain containers during sync

Christian König ckoenig.leichtzumerken at gmail.com
Mon Nov 23 20:17:47 UTC 2020


That the CPU round trip is gone now.

Christian.

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20201123/519f40cd/attachment-0001.htm>


More information about the amd-gfx mailing list