From: Daniel Vetter <daniel@ffwll.ch>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>
Cc: sumit.semwal@linaro.org, gustavo@padovan.org,
daniel.vetter@ffwll.ch, linux-media@vger.kernel.org,
dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH 1/3] dma-buf/sync_file: cleanup fence merging a bit
Date: Wed, 4 May 2022 10:34:24 +0200 [thread overview]
Message-ID: <YnI6kPd01lG/q0N2@phenom.ffwll.local> (raw)
In-Reply-To: <20220426124637.329764-1-christian.koenig@amd.com>
On Tue, Apr 26, 2022 at 02:46:35PM +0200, Christian König wrote:
> krealloc_array() ignores attempts to reduce the array size, so the attempt
> to save memory is completely pointless here.
>
> Also move testing for the no fence case into sync_file_set_fence(), this
> way we don't even touch the fence array when we don't have any fences.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
> drivers/dma-buf/sync_file.c | 21 +++++++--------------
> 1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
> index 514d213261df..0fe564539166 100644
> --- a/drivers/dma-buf/sync_file.c
> +++ b/drivers/dma-buf/sync_file.c
> @@ -157,9 +157,15 @@ static int sync_file_set_fence(struct sync_file *sync_file,
> * we already own a new reference to the fence. For num_fence > 1
> * we own the reference of the dma_fence_array creation.
> */
> - if (num_fences == 1) {
> +
> + if (num_fences == 0) {
> + sync_file->fence = dma_fence_get_stub();
> + kfree(fences);
> +
> + } else if (num_fences == 1) {
> sync_file->fence = fences[0];
> kfree(fences);
> +
> } else {
> array = dma_fence_array_create(num_fences, fences,
> dma_fence_context_alloc(1),
> @@ -261,19 +267,6 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
> }
> }
>
> - if (index == 0)
> - fences[index++] = dma_fence_get_stub();
> -
> - if (num_fences > index) {
> - struct dma_fence **tmp;
> -
> - /* Keep going even when reducing the size failed */
> - tmp = krealloc_array(fences, index, sizeof(*fences),
> - GFP_KERNEL);
> - if (tmp)
> - fences = tmp;
> - }
> -
> if (sync_file_set_fence(sync_file, fences, index) < 0)
> goto err_put_fences;
>
> --
> 2.25.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
prev parent reply other threads:[~2022-05-04 8:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-26 12:46 [PATCH 1/3] dma-buf/sync_file: cleanup fence merging a bit Christian König
2022-04-26 12:46 ` [PATCH 2/3] dma-buf: cleanup dma_fence_unwrap implementation and selftest Christian König
2022-05-04 8:37 ` Daniel Vetter
2022-04-26 12:46 ` [PATCH 3/3] dma-buf: generalize fence merging Christian König
2022-05-04 8:43 ` Daniel Vetter
2022-05-04 8:52 ` Christian König
2022-05-04 9:24 ` Daniel Vetter
2022-05-04 8:34 ` Daniel Vetter [this message]
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=YnI6kPd01lG/q0N2@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=christian.koenig@amd.com \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=gustavo@padovan.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-media@vger.kernel.org \
--cc=sumit.semwal@linaro.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