mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
dma-buf/selftests: test RCU ops and inline lock v2
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> Link: https://lore.kernel.org/r/20260219160822.1529-6-christian.koenig@amd.com
This commit is contained in:
parent
1f32f310a1
commit
3695d754ff
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user