From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: daniel@ffwll.ch, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, linux-media@vger.kernel.org,
"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH 5/5] drm: use dma_fence_unwrap_merge() in drm_syncobj
Date: Thu, 5 May 2022 16:12:40 +0200 [thread overview]
Message-ID: <YnPbWNumTafUUEk9@phenom.ffwll.local> (raw)
In-Reply-To: <20220504122256.1654-5-christian.koenig@amd.com>
On Wed, May 04, 2022 at 02:22:56PM +0200, Christian König wrote:
> The unwrap merge function is now intended for this use case.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
Yeah this starts to make sense now as refactor.
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
> drivers/gpu/drm/drm_syncobj.c | 57 +++++------------------------------
> 1 file changed, 7 insertions(+), 50 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index 7e48dcd1bee4..bbad9e4696e7 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -184,6 +184,7 @@
> */
>
> #include <linux/anon_inodes.h>
> +#include <linux/dma-fence-unwrap.h>
> #include <linux/file.h>
> #include <linux/fs.h>
> #include <linux/sched/signal.h>
> @@ -853,57 +854,12 @@ drm_syncobj_fd_to_handle_ioctl(struct drm_device *dev, void *data,
> &args->handle);
> }
>
> -
> -/*
> - * Try to flatten a dma_fence_chain into a dma_fence_array so that it can be
> - * added as timeline fence to a chain again.
> - */
> -static int drm_syncobj_flatten_chain(struct dma_fence **f)
> -{
> - struct dma_fence_chain *chain = to_dma_fence_chain(*f);
> - struct dma_fence *tmp, **fences;
> - struct dma_fence_array *array;
> - unsigned int count;
> -
> - if (!chain)
> - return 0;
> -
> - count = 0;
> - dma_fence_chain_for_each(tmp, &chain->base)
> - ++count;
> -
> - fences = kmalloc_array(count, sizeof(*fences), GFP_KERNEL);
> - if (!fences)
> - return -ENOMEM;
> -
> - count = 0;
> - dma_fence_chain_for_each(tmp, &chain->base)
> - fences[count++] = dma_fence_get(tmp);
> -
> - array = dma_fence_array_create(count, fences,
> - dma_fence_context_alloc(1),
> - 1, false);
> - if (!array)
> - goto free_fences;
> -
> - dma_fence_put(*f);
> - *f = &array->base;
> - return 0;
> -
> -free_fences:
> - while (count--)
> - dma_fence_put(fences[count]);
> -
> - kfree(fences);
> - return -ENOMEM;
> -}
> -
> static int drm_syncobj_transfer_to_timeline(struct drm_file *file_private,
> struct drm_syncobj_transfer *args)
> {
> struct drm_syncobj *timeline_syncobj = NULL;
> + struct dma_fence *fence, *tmp;
> struct dma_fence_chain *chain;
> - struct dma_fence *fence;
> int ret;
>
> timeline_syncobj = drm_syncobj_find(file_private, args->dst_handle);
> @@ -912,13 +868,14 @@ static int drm_syncobj_transfer_to_timeline(struct drm_file *file_private,
> }
> ret = drm_syncobj_find_fence(file_private, args->src_handle,
> args->src_point, args->flags,
> - &fence);
> + &tmp);
> if (ret)
> goto err_put_timeline;
>
> - ret = drm_syncobj_flatten_chain(&fence);
> - if (ret)
> - goto err_free_fence;
> + fence = dma_fence_unwrap_merge(tmp);
> + dma_fence_put(tmp);
> + if (!fence)
> + goto err_put_timeline;
>
> chain = dma_fence_chain_alloc();
> if (!chain) {
> --
> 2.25.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2022-05-05 14:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-04 12:22 [PATCH 1/5] dma-buf: cleanup dma_fence_unwrap selftest Christian König
2022-05-04 12:22 ` [PATCH 2/5] dma-buf: cleanup dma_fence_unwrap implementation Christian König
2022-05-05 13:44 ` Daniel Vetter
2022-05-04 12:22 ` [PATCH 3/5] dma-buf: return only unsignaled fences in dma_fence_unwrap_for_each Christian König
2022-05-05 14:08 ` Daniel Vetter
2022-05-04 12:22 ` [PATCH 4/5] dma-buf: generalize dma_fence unwrap & merging v2 Christian König
2022-05-05 14:11 ` Daniel Vetter
2022-05-04 12:22 ` [PATCH 5/5] drm: use dma_fence_unwrap_merge() in drm_syncobj Christian König
2022-05-05 14:12 ` Daniel Vetter [this message]
2022-05-05 13:29 ` [PATCH 1/5] dma-buf: cleanup dma_fence_unwrap selftest Daniel Vetter
2022-05-05 17:46 ` Christian König
-- strict thread matches above, loose matches on Subject: below --
2022-05-06 14:10 [PATCH 1/5] dma-buf: cleanup dma_fence_unwrap selftest v2 Christian König
2022-05-06 14:10 ` [PATCH 5/5] drm: use dma_fence_unwrap_merge() in drm_syncobj Christian König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YnPbWNumTafUUEk9@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=christian.koenig@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox