From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: phasta@mailbox.org, tursulin@ursulin.net,
matthew.brost@intel.com, sumit.semwal@linaro.org
Cc: dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org
Subject: [PATCH 6/9] dma-buf/selftests: test RCU ops and inline lock v2
Date: Tue, 20 Jan 2026 11:54:45 +0100 [thread overview]
Message-ID: <20260120105655.7134-7-christian.koenig@amd.com> (raw)
In-Reply-To: <20260120105655.7134-1-christian.koenig@amd.com>
Drop the mock_fence and the kmem_cache, instead use the inline lock and
test if the ops are properly dropped after signaling.
v2: move the RCU check to the end of the test
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
---
drivers/dma-buf/st-dma-fence.c | 44 ++++++++--------------------------
1 file changed, 10 insertions(+), 34 deletions(-)
diff --git a/drivers/dma-buf/st-dma-fence.c b/drivers/dma-buf/st-dma-fence.c
index 5d0d9abc6e21..0d9d524d79b6 100644
--- a/drivers/dma-buf/st-dma-fence.c
+++ b/drivers/dma-buf/st-dma-fence.c
@@ -14,43 +14,26 @@
#include "selftest.h"
-static struct kmem_cache *slab_fences;
-
-static struct mock_fence {
- struct dma_fence base;
- struct spinlock 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)
{
return "mock";
}
-static void mock_fence_release(struct dma_fence *f)
-{
- kmem_cache_free(slab_fences, to_mock_fence(f));
-}
-
static const struct dma_fence_ops mock_ops = {
.get_driver_name = mock_name,
.get_timeline_name = mock_name,
- .release = mock_fence_release,
};
static struct dma_fence *mock_fence(void)
{
- struct mock_fence *f;
+ struct dma_fence *f;
- f = kmem_cache_alloc(slab_fences, GFP_KERNEL);
+ f = kmalloc(sizeof(*f), GFP_KERNEL);
if (!f)
return NULL;
- spin_lock_init(&f->lock);
- dma_fence_init(&f->base, &mock_ops, &f->lock, 0, 0);
-
- return &f->base;
+ dma_fence_init(f, &mock_ops, NULL, 0, 0);
+ return f;
}
static int sanitycheck(void *arg)
@@ -100,6 +83,11 @@ static int test_signaling(void *arg)
goto err_free;
}
+ if (rcu_dereference_protected(f->ops, true)) {
+ pr_err("Fence ops not cleared on signal\n");
+ goto err_free;
+ }
+
err = 0;
err_free:
dma_fence_put(f);
@@ -540,19 +528,7 @@ int dma_fence(void)
SUBTEST(test_stub),
SUBTEST(race_signal_callback),
};
- int ret;
pr_info("sizeof(dma_fence)=%zu\n", sizeof(struct dma_fence));
-
- slab_fences = KMEM_CACHE(mock_fence,
- SLAB_TYPESAFE_BY_RCU |
- SLAB_HWCACHE_ALIGN);
- if (!slab_fences)
- return -ENOMEM;
-
- ret = subtests(tests, NULL);
-
- kmem_cache_destroy(slab_fences);
-
- return ret;
+ return subtests(tests, NULL);
}
--
2.43.0
next prev parent reply other threads:[~2026-01-20 10:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-20 10:54 Independence for dma_fences! v6 Christian König
2026-01-20 10:54 ` [PATCH 1/9] dma-buf: add dma_fence_was_initialized function v2 Christian König
2026-01-20 11:33 ` Tvrtko Ursulin
2026-07-13 8:58 ` Jiri Slaby
2026-07-14 7:53 ` Philipp Stanner
2026-07-14 8:43 ` Philipp Stanner
2026-01-20 10:54 ` [PATCH 2/9] dma-buf: protected fence ops by RCU v5 Christian König
2026-01-20 10:54 ` [PATCH 3/9] dma-buf: detach fence ops on signal v2 Christian König
2026-01-20 10:54 ` [PATCH 4/9] dma-buf: abstract fence locking Christian König
2026-01-20 10:54 ` [PATCH 5/9] dma-buf: inline spinlock for fence protection v4 Christian König
2026-01-20 11:41 ` Tvrtko Ursulin
2026-01-21 8:48 ` Christian König
2026-01-21 9:03 ` Tvrtko Ursulin
2026-01-27 4:56 ` kernel test robot
2026-01-20 10:54 ` Christian König [this message]
2026-01-20 10:54 ` [PATCH 7/9] dma-buf: use inline lock for the stub fence v2 Christian König
2026-01-21 9:29 ` Philipp Stanner
2026-01-20 10:54 ` [PATCH 8/9] dma-buf: use inline lock for the dma-fence-array Christian König
2026-01-20 10:54 ` [PATCH 9/9] dma-buf: use inline lock for the dma-fence-chain 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=20260120105655.7134-7-christian.koenig@amd.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=matthew.brost@intel.com \
--cc=phasta@mailbox.org \
--cc=sumit.semwal@linaro.org \
--cc=tursulin@ursulin.net \
/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