On 11/12/2025 13:16, Christian König wrote:
Drop the mock_fence and the kmem_cache, instead use the inline lock and
test if the ops are properly dropped after signaling.
Signed-off-by: Christian König <[email protected]>
---
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..65221270fd06 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)
@@ -90,6 +73,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;
+ }
Bump to after the signaled check just below? Otherwise the signaled
state hasn't been ascertained yet.
+
if (!dma_fence_is_signaled(f)) {
pr_err("Fence not reporting signaled\n");
goto err_free;
@@ -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 |
Hm.. race_signal_callback looks like it could be depending on
SLAB_TYPESAFE_BY_RCU. To you not?
Regards,
Tvrtko
- SLAB_HWCACHE_ALIGN);
- if (!slab_fences)
- return -ENOMEM;
-
- ret = subtests(tests, NULL);
-
- kmem_cache_destroy(slab_fences);
-
- return ret;
+ return subtests(tests, NULL);
}