From: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
thomas.hellstrom@linux.intel.com, daniel.vetter@ffwll.ch,
dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org
Cc: "De Marchi, Lucas" <lucas.demarchi@intel.com>
Subject: Re: [Intel-gfx] [PATCH] drm/syncobj: flatten dma_fence_chains on transfer
Date: Wed, 25 May 2022 09:47:07 +0300 [thread overview]
Message-ID: <2bf6b110-cd85-e17f-e9c5-69e5e7eedd0d@intel.com> (raw)
In-Reply-To: <20220209182600.434803-1-christian.koenig@amd.com>
On 09/02/2022 20:26, Christian König wrote:
> It is illegal to add a dma_fence_chain as timeline point. Flatten out
> the fences into a dma_fence_array instead.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/drm_syncobj.c | 61 ++++++++++++++++++++++++++++++++---
> 1 file changed, 56 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index c313a5b4549c..7e48dcd1bee4 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -853,12 +853,57 @@ 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),
Hi Christian,
Sorry for the late answer to this.
It appears this commit is trying to remove the warnings added by
"dma-buf: Warn about dma_fence_chain container rules"
But the context allocation you added just above is breaking some tests.
In particular igt@syncobj_timeline@transfer-timeline-point
That test transfer points into the timeline at point 3 and expects that
we'll still on the previous points to complete.
In my opinion we should be reusing the previous context number if there
is one and only allocate if we don't have a point.
If the application wants to not depend on previous points for wait
operations, it can reset the syncobj prior to adding a new point.
Cheers,
-Lionel
> + 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;
> struct dma_fence_chain *chain;
> + struct dma_fence *fence;
> int ret;
>
> timeline_syncobj = drm_syncobj_find(file_private, args->dst_handle);
> @@ -869,16 +914,22 @@ static int drm_syncobj_transfer_to_timeline(struct drm_file *file_private,
> args->src_point, args->flags,
> &fence);
> if (ret)
> - goto err;
> + goto err_put_timeline;
> +
> + ret = drm_syncobj_flatten_chain(&fence);
> + if (ret)
> + goto err_free_fence;
> +
> chain = dma_fence_chain_alloc();
> if (!chain) {
> ret = -ENOMEM;
> - goto err1;
> + goto err_free_fence;
> }
> +
> drm_syncobj_add_point(timeline_syncobj, chain, fence, args->dst_point);
> -err1:
> +err_free_fence:
> dma_fence_put(fence);
> -err:
> +err_put_timeline:
> drm_syncobj_put(timeline_syncobj);
>
> return ret;
next prev parent reply other threads:[~2022-05-25 6:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-09 18:26 [Intel-gfx] [PATCH] drm/syncobj: flatten dma_fence_chains on transfer Christian König
2022-02-16 0:20 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for " Patchwork
2022-05-25 6:47 ` Lionel Landwerlin [this message]
[not found] ` <dbdb02cb-26fa-4f08-b125-c4a850e73780@gmail.com>
2022-05-25 9:26 ` [Intel-gfx] [PATCH] " Lionel Landwerlin
2022-05-25 9:35 ` Lionel Landwerlin
[not found] ` <419c9bff-4292-3062-b7f2-efeb64b9e79f@gmail.com>
2022-05-25 21:59 ` Lucas De Marchi
[not found] ` <b54b2cc7-f511-e6ce-72fa-da5c8cd5e7b4@gmail.com>
2022-05-30 10:09 ` Lionel Landwerlin
[not found] ` <d363c177-c874-f7c7-1d53-c0a2ea9510a7@gmail.com>
2022-05-30 12:19 ` Lionel Landwerlin
2022-05-25 22:14 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/syncobj: flatten dma_fence_chains on transfer (rev2) Patchwork
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=2bf6b110-cd85-e17f-e9c5-69e5e7eedd0d@intel.com \
--to=lionel.g.landwerlin@intel.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=thomas.hellstrom@linux.intel.com \
/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