From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: daniel@ffwll.ch, dri-devel@lists.freedesktop.org,
linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org
Subject: Re: [PATCH 03/24] dma-buf: drop excl_fence parameter from dma_resv_get_fences
Date: Wed, 22 Dec 2021 22:13:20 +0100 [thread overview]
Message-ID: <YcOU8CJq83TzaD1+@phenom.ffwll.local> (raw)
In-Reply-To: <20211207123411.167006-4-christian.koenig@amd.com>
On Tue, Dec 07, 2021 at 01:33:50PM +0100, Christian König wrote:
> Returning the exclusive fence separately is no longer used.
>
> Instead add a write parameter to indicate the use case.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/dma-buf/dma-resv.c | 48 ++++++++------------
> drivers/dma-buf/st-dma-resv.c | 26 ++---------
> drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 ++-
> drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 2 +-
> drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 3 +-
> include/linux/dma-resv.h | 4 +-
> 6 files changed, 31 insertions(+), 58 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
> index a12a3a39f280..480c305554a1 100644
> --- a/drivers/dma-buf/dma-resv.c
> +++ b/drivers/dma-buf/dma-resv.c
> @@ -611,57 +611,45 @@ EXPORT_SYMBOL(dma_resv_copy_fences);
> * dma_resv_get_fences - Get an object's shared and exclusive
> * fences without update side lock held
> * @obj: the reservation object
> - * @fence_excl: the returned exclusive fence (or NULL)
> - * @shared_count: the number of shared fences returned
> - * @shared: the array of shared fence ptrs returned (array is krealloc'd to
> - * the required size, and must be freed by caller)
> - *
> - * Retrieve all fences from the reservation object. If the pointer for the
> - * exclusive fence is not specified the fence is put into the array of the
> - * shared fences as well. Returns either zero or -ENOMEM.
> + * @write: true if we should return all fences
I'm assuming that this will be properly documented later on in the series
...
> + * @num_fences: the number of fences returned
> + * @fences: the array of fence ptrs returned (array is krealloc'd to the
> + * required size, and must be freed by caller)
> + *
> + * Retrieve all fences from the reservation object.
> + * Returns either zero or -ENOMEM.
> */
> -int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **fence_excl,
> - unsigned int *shared_count, struct dma_fence ***shared)
> +int dma_resv_get_fences(struct dma_resv *obj, bool write,
> + unsigned int *num_fences, struct dma_fence ***fences)
> {
> struct dma_resv_iter cursor;
> struct dma_fence *fence;
>
> - *shared_count = 0;
> - *shared = NULL;
> -
> - if (fence_excl)
> - *fence_excl = NULL;
> + *num_fences = 0;
> + *fences = NULL;
>
> - dma_resv_iter_begin(&cursor, obj, true);
> + dma_resv_iter_begin(&cursor, obj, write);
> dma_resv_for_each_fence_unlocked(&cursor, fence) {
>
> if (dma_resv_iter_is_restarted(&cursor)) {
> unsigned int count;
>
> - while (*shared_count)
> - dma_fence_put((*shared)[--(*shared_count)]);
> + while (*num_fences)
> + dma_fence_put((*fences)[--(*num_fences)]);
>
> - if (fence_excl)
> - dma_fence_put(*fence_excl);
> -
> - count = cursor.shared_count;
> - count += fence_excl ? 0 : 1;
> + count = cursor.shared_count + 1;
>
> /* Eventually re-allocate the array */
> - *shared = krealloc_array(*shared, count,
> + *fences = krealloc_array(*fences, count,
> sizeof(void *),
> GFP_KERNEL);
> - if (count && !*shared) {
> + if (count && !*fences) {
> dma_resv_iter_end(&cursor);
> return -ENOMEM;
> }
> }
>
> - dma_fence_get(fence);
> - if (dma_resv_iter_is_exclusive(&cursor) && fence_excl)
> - *fence_excl = fence;
> - else
> - (*shared)[(*shared_count)++] = fence;
> + (*fences)[(*num_fences)++] = dma_fence_get(fence);
> }
> dma_resv_iter_end(&cursor);
>
> diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c
> index bc32b3eedcb6..cbe999c6e7a6 100644
> --- a/drivers/dma-buf/st-dma-resv.c
> +++ b/drivers/dma-buf/st-dma-resv.c
> @@ -275,7 +275,7 @@ static int test_shared_for_each_unlocked(void *arg)
>
> static int test_get_fences(void *arg, bool shared)
> {
> - struct dma_fence *f, *excl = NULL, **fences = NULL;
> + struct dma_fence *f, **fences = NULL;
> struct dma_resv resv;
> int r, i;
>
> @@ -304,35 +304,19 @@ static int test_get_fences(void *arg, bool shared)
> }
> dma_resv_unlock(&resv);
>
> - r = dma_resv_get_fences(&resv, &excl, &i, &fences);
> + r = dma_resv_get_fences(&resv, shared, &i, &fences);
> if (r) {
> pr_err("get_fences failed\n");
> goto err_free;
> }
>
> - if (shared) {
> - if (excl != NULL) {
> - pr_err("get_fences returned unexpected excl fence\n");
> - goto err_free;
> - }
> - if (i != 1 || fences[0] != f) {
> - pr_err("get_fences returned unexpected shared fence\n");
> - goto err_free;
> - }
> - } else {
> - if (excl != f) {
> - pr_err("get_fences returned unexpected excl fence\n");
> - goto err_free;
> - }
> - if (i != 0) {
> - pr_err("get_fences returned unexpected shared fence\n");
> - goto err_free;
> - }
> + if (i != 1 || fences[0] != f) {
> + pr_err("get_fences returned unexpected fence\n");
> + goto err_free;
> }
>
> dma_fence_signal(f);
> err_free:
> - dma_fence_put(excl);
> while (i--)
> dma_fence_put(fences[i]);
> kfree(fences);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index 68108f151dad..d17e1c911689 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -200,8 +200,10 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,
> goto unpin;
> }
>
> - r = dma_resv_get_fences(new_abo->tbo.base.resv, NULL,
> - &work->shared_count, &work->shared);
> + /* TODO: Unify this with other drivers */
> + r = dma_resv_get_fences(new_abo->tbo.base.resv, true,
> + &work->shared_count,
> + &work->shared);
> if (unlikely(r != 0)) {
> DRM_ERROR("failed to get fences for buffer\n");
> goto unpin;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> index b7fb72bff2c1..be48487e2ca7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
> @@ -112,7 +112,7 @@ void amdgpu_pasid_free_delayed(struct dma_resv *resv,
> unsigned count;
> int r;
>
> - r = dma_resv_get_fences(resv, NULL, &count, &fences);
> + r = dma_resv_get_fences(resv, true, &count, &fences);
> if (r)
> goto fallback;
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> index b5e8ce86dbe7..64c90ff348f2 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> @@ -189,8 +189,7 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit)
> continue;
>
> if (bo->flags & ETNA_SUBMIT_BO_WRITE) {
> - ret = dma_resv_get_fences(robj, NULL,
> - &bo->nr_shared,
> + ret = dma_resv_get_fences(robj, true, &bo->nr_shared,
> &bo->shared);
> if (ret)
> return ret;
> diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
> index 3baf2a4a9a0d..fa2002939b19 100644
> --- a/include/linux/dma-resv.h
> +++ b/include/linux/dma-resv.h
> @@ -436,8 +436,8 @@ void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence);
> void dma_resv_replace_fences(struct dma_resv *obj, uint64_t context,
> struct dma_fence *fence);
> void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence);
> -int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **pfence_excl,
> - unsigned *pshared_count, struct dma_fence ***pshared);
> +int dma_resv_get_fences(struct dma_resv *obj, bool write,
> + unsigned int *num_fences, struct dma_fence ***fences);
> int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src);
> long dma_resv_wait_timeout(struct dma_resv *obj, bool wait_all, bool intr,
> unsigned long timeout);
> --
> 2.25.1
>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2021-12-22 21:13 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-07 12:33 completely rework the dma_resv semantic Christian König
2021-12-07 12:33 ` [PATCH 01/24] dma-buf: add dma_resv_replace_fences Christian König
2021-12-22 21:05 ` Daniel Vetter
2022-01-03 10:48 ` Christian König
2022-01-14 16:28 ` Daniel Vetter
2021-12-07 12:33 ` [PATCH 02/24] dma-buf: finally make the dma_resv_list private Christian König
2021-12-22 21:08 ` Daniel Vetter
2021-12-07 12:33 ` [PATCH 03/24] dma-buf: drop excl_fence parameter from dma_resv_get_fences Christian König
2021-12-22 21:13 ` Daniel Vetter [this message]
2021-12-07 12:33 ` [PATCH 04/24] dma-buf: add dma_resv_get_singleton v2 Christian König
2021-12-22 21:21 ` Daniel Vetter
2022-01-03 11:13 ` Christian König
2022-01-14 16:31 ` Daniel Vetter
2022-01-17 11:26 ` Christian König
2021-12-07 12:33 ` [PATCH 05/24] RDMA: use dma_resv_wait() instead of extracting the fence Christian König
2021-12-22 21:23 ` Daniel Vetter
2021-12-07 12:33 ` [PATCH 06/24] drm/etnaviv: stop using dma_resv_excl_fence Christian König
2021-12-22 21:26 ` Daniel Vetter
2021-12-07 12:33 ` [PATCH 07/24] drm/nouveau: " Christian König
2021-12-22 21:26 ` Daniel Vetter
2021-12-07 12:33 ` [PATCH 08/24] drm/vmwgfx: " Christian König
2021-12-22 21:31 ` Daniel Vetter
2021-12-07 12:33 ` [PATCH 09/24] drm/radeon: " Christian König
2021-12-22 21:30 ` Daniel Vetter
2021-12-07 12:33 ` [PATCH 10/24] drm/amdgpu: remove excl as shared workarounds Christian König
2021-12-22 21:34 ` Daniel Vetter
2021-12-07 12:33 ` [PATCH 11/24] drm/amdgpu: use dma_resv_for_each_fence for CS workaround Christian König
2021-12-22 21:37 ` Daniel Vetter
2022-01-03 12:24 ` Christian König
2021-12-07 12:33 ` [PATCH 12/24] dma-buf: finally make dma_resv_excl_fence private Christian König
2021-12-22 21:39 ` Daniel Vetter
2021-12-07 12:34 ` [PATCH 13/24] dma-buf: drop the DAG approach for the dma_resv object Christian König
2021-12-22 21:43 ` Daniel Vetter
2022-01-04 15:08 ` Christian König
2022-01-14 16:33 ` Daniel Vetter
2021-12-07 12:34 ` [PATCH 14/24] dma-buf/drivers: make reserving a shared slot mandatory v2 Christian König
2021-12-22 21:50 ` Daniel Vetter
2021-12-07 12:34 ` [PATCH 15/24] drm: support more than one write fence in drm_gem_plane_helper_prepare_fb Christian König
2021-12-22 21:51 ` Daniel Vetter
2021-12-07 12:34 ` [PATCH 16/24] drm/nouveau: support more than one write fence in fenv50_wndw_prepare_fb Christian König
2021-12-22 21:52 ` Daniel Vetter
2021-12-07 12:34 ` [PATCH 17/24] drm/amdgpu: use dma_resv_get_singleton in amdgpu_pasid_free_cb Christian König
2021-12-22 21:53 ` Daniel Vetter
2021-12-07 12:34 ` [PATCH 18/24] dma-buf: add enum dma_resv_usage v3 Christian König
2021-12-22 22:00 ` Daniel Vetter
2021-12-07 12:34 ` [PATCH 19/24] dma-buf: specify usage while adding fences to dma_resv obj v2 Christian König
2021-12-07 12:34 ` [PATCH 20/24] dma-buf: add DMA_RESV_USAGE_KERNEL Christian König
2021-12-22 22:05 ` Daniel Vetter
2021-12-07 12:34 ` [PATCH 21/24] dma-buf: add DMA_RESV_USAGE_BOOKKEEP Christian König
2021-12-22 22:10 ` Daniel Vetter
2021-12-07 12:34 ` [PATCH 22/24] dma-buf: wait for map to complete for static attachments Christian König
2021-12-22 22:16 ` Daniel Vetter
2021-12-07 12:34 ` [PATCH 23/24] amdgpu: remove DMA-buf fence workaround Christian König
2021-12-07 12:34 ` [PATCH 24/24] drm/ttm: remove bo->moving Christian König
2021-12-17 14:39 ` completely rework the dma_resv semantic Christian König
2021-12-22 22:17 ` Daniel Vetter
2021-12-23 9:11 ` Christian König
2022-01-14 16:35 ` Daniel Vetter
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=YcOU8CJq83TzaD1+@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--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