drivers/dma-buf/st-dma-resv.c
Source file repositories/reference/linux-study-clean/drivers/dma-buf/st-dma-resv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma-buf/st-dma-resv.c- Extension
.c- Size
- 6789 bytes
- Lines
- 316
- Domain
- Driver Families
- Bucket
- drivers/dma-buf
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.hlinux/slab.hlinux/spinlock.hlinux/dma-resv.h
Detected Declarations
struct dma_resv_usage_paramfunction test_sanitycheckfunction test_signalingfunction test_for_eachfunction test_for_each_unlockedfunction test_get_fences
Annotated Snippet
struct dma_resv_usage_param {
enum dma_resv_usage usage;
const char *desc;
};
static const char *fence_name(struct dma_fence *f)
{
return "selftest";
}
static const struct dma_fence_ops fence_ops = {
.get_driver_name = fence_name,
.get_timeline_name = fence_name,
};
static struct dma_fence *alloc_fence(void)
{
struct dma_fence *f;
f = kmalloc_obj(*f);
if (!f)
return NULL;
dma_fence_init(f, &fence_ops, &fence_lock, 0, 0);
return f;
}
static void test_sanitycheck(struct kunit *test)
{
struct dma_resv resv;
struct dma_fence *f;
int r;
f = alloc_fence();
KUNIT_ASSERT_NOT_NULL(test, f);
dma_fence_enable_sw_signaling(f);
dma_fence_signal(f);
dma_fence_put(f);
dma_resv_init(&resv);
r = dma_resv_lock(&resv, NULL);
if (r)
KUNIT_FAIL(test, "Resv locking failed\n");
else
dma_resv_unlock(&resv);
dma_resv_fini(&resv);
}
static void test_signaling(struct kunit *test)
{
const struct dma_resv_usage_param *param = test->param_value;
enum dma_resv_usage usage = param->usage;
struct dma_resv resv;
struct dma_fence *f;
int r;
f = alloc_fence();
KUNIT_ASSERT_NOT_NULL(test, f);
dma_fence_enable_sw_signaling(f);
dma_resv_init(&resv);
r = dma_resv_lock(&resv, NULL);
if (r) {
KUNIT_FAIL(test, "Resv locking failed");
goto err_free;
}
r = dma_resv_reserve_fences(&resv, 1);
if (r) {
KUNIT_FAIL(test, "Resv shared slot allocation failed");
goto err_unlock;
}
dma_resv_add_fence(&resv, f, usage);
if (dma_resv_test_signaled(&resv, usage)) {
KUNIT_FAIL(test, "Resv unexpectedly signaled");
goto err_unlock;
}
dma_fence_signal(f);
if (!dma_resv_test_signaled(&resv, usage)) {
KUNIT_FAIL(test, "Resv not reporting signaled");
goto err_unlock;
}
err_unlock:
dma_resv_unlock(&resv);
err_free:
dma_resv_fini(&resv);
Annotation
- Immediate include surface: `kunit/test.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/dma-resv.h`.
- Detected declarations: `struct dma_resv_usage_param`, `function test_sanitycheck`, `function test_signaling`, `function test_for_each`, `function test_for_each_unlocked`, `function test_get_fences`.
- Atlas domain: Driver Families / drivers/dma-buf.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.