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 1/5] dma-buf: cleanup dma_fence_unwrap selftest
Date: Thu, 5 May 2022 15:29:19 +0200 [thread overview]
Message-ID: <YnPRL7ndeh9z01mW@phenom.ffwll.local> (raw)
In-Reply-To: <20220504122256.1654-1-christian.koenig@amd.com>
On Wed, May 04, 2022 at 02:22:52PM +0200, Christian König wrote:
> The selftests, fix the error handling, remove unused functions and stop
> leaking memory in failed tests.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/dma-buf/st-dma-fence-unwrap.c | 40 +++++++++++----------------
> 1 file changed, 16 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/dma-buf/st-dma-fence-unwrap.c b/drivers/dma-buf/st-dma-fence-unwrap.c
> index 039f016b57be..59628add93f5 100644
> --- a/drivers/dma-buf/st-dma-fence-unwrap.c
> +++ b/drivers/dma-buf/st-dma-fence-unwrap.c
> @@ -4,27 +4,19 @@
> * Copyright (C) 2022 Advanced Micro Devices, Inc.
> */
>
> +#include <linux/dma-fence.h>
> +#include <linux/dma-fence-array.h>
> +#include <linux/dma-fence-chain.h>
> #include <linux/dma-fence-unwrap.h>
> -#if 0
> -#include <linux/kernel.h>
> -#include <linux/kthread.h>
> -#include <linux/mm.h>
> -#include <linux/sched/signal.h>
> -#include <linux/slab.h>
> -#include <linux/spinlock.h>
> -#include <linux/random.h>
> -#endif
>
> #include "selftest.h"
>
> #define CHAIN_SZ (4 << 10)
>
> -static inline struct mock_fence {
> +struct mock_fence {
> struct dma_fence base;
> spinlock_t lock;
> -} *to_mock_fence(struct dma_fence *f) {
> - return container_of(f, struct mock_fence, base);
> -}
> +};
>
> static const char *mock_name(struct dma_fence *f)
> {
> @@ -45,7 +37,8 @@ static struct dma_fence *mock_fence(void)
> return NULL;
>
> spin_lock_init(&f->lock);
> - dma_fence_init(&f->base, &mock_ops, &f->lock, 0, 0);
> + dma_fence_init(&f->base, &mock_ops, &f->lock,
> + dma_fence_context_alloc(1), 1);
>
> return &f->base;
> }
> @@ -113,7 +106,6 @@ static int sanitycheck(void *arg)
> if (!chain)
> return -ENOMEM;
>
> - dma_fence_signal(f);
> dma_fence_put(chain);
> return err;
> }
> @@ -154,10 +146,10 @@ static int unwrap_array(void *arg)
> err = -EINVAL;
> }
>
> - dma_fence_signal(f1);
> - dma_fence_signal(f2);
> + dma_fence_put(f1);
> + dma_fence_put(f2);
I'm completely lost on why you add these _put() calls? The reference we
create all get transferred over to the container object, and that takes
care of releasing them.
The other bits with error handling and code cleanup all look good, and
dropping dma_fence_signal calls also makes sense. But this one I don't
get.
-Daniel
> dma_fence_put(array);
> - return 0;
> + return err;
> }
>
> static int unwrap_chain(void *arg)
> @@ -196,10 +188,10 @@ static int unwrap_chain(void *arg)
> err = -EINVAL;
> }
>
> - dma_fence_signal(f1);
> - dma_fence_signal(f2);
> + dma_fence_put(f1);
> + dma_fence_put(f2);
> dma_fence_put(chain);
> - return 0;
> + return err;
> }
>
> static int unwrap_chain_array(void *arg)
> @@ -242,10 +234,10 @@ static int unwrap_chain_array(void *arg)
> err = -EINVAL;
> }
>
> - dma_fence_signal(f1);
> - dma_fence_signal(f2);
> + dma_fence_put(f1);
> + dma_fence_put(f2);
> dma_fence_put(chain);
> - return 0;
> + return err;
> }
>
> int dma_fence_unwrap(void)
> --
> 2.25.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2022-05-05 13:29 UTC|newest]
Thread overview: 11+ 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
2022-05-05 13:29 ` Daniel Vetter [this message]
2022-05-05 17:46 ` [PATCH 1/5] dma-buf: cleanup dma_fence_unwrap selftest 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=YnPRL7ndeh9z01mW@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