drivers/dma-buf/st-dma-fence-unwrap.c
Source file repositories/reference/linux-study-clean/drivers/dma-buf/st-dma-fence-unwrap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma-buf/st-dma-fence-unwrap.c- Extension
.c- Size
- 12176 bytes
- Lines
- 607
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/dma-fence.hlinux/dma-fence-array.hlinux/dma-fence-chain.hlinux/dma-fence-unwrap.h
Detected Declarations
struct mock_fencefunction test_sanitycheckfunction test_unwrap_arrayfunction dma_fence_unwrap_for_eachfunction test_unwrap_chainfunction dma_fence_unwrap_for_eachfunction test_unwrap_chain_arrayfunction dma_fence_unwrap_for_eachfunction test_unwrap_mergefunction dma_fence_unwrap_for_eachfunction test_unwrap_merge_duplicatefunction dma_fence_unwrap_for_eachfunction test_unwrap_merge_seqnofunction dma_fence_unwrap_for_eachfunction test_unwrap_merge_orderfunction dma_fence_unwrap_for_eachfunction test_unwrap_merge_complexfunction dma_fence_unwrap_for_eachfunction test_unwrap_merge_complex_seqnofunction dma_fence_unwrap_for_each
Annotated Snippet
struct mock_fence {
struct dma_fence base;
spinlock_t lock;
};
static const char *mock_name(struct dma_fence *f)
{
return "mock";
}
static const struct dma_fence_ops mock_ops = {
.get_driver_name = mock_name,
.get_timeline_name = mock_name,
};
static struct dma_fence *__mock_fence(u64 context, u64 seqno)
{
struct mock_fence *f;
f = kmalloc_obj(*f);
if (!f)
return NULL;
spin_lock_init(&f->lock);
dma_fence_init(&f->base, &mock_ops, &f->lock, context, seqno);
return &f->base;
}
static struct dma_fence *mock_fence(void)
{
return __mock_fence(dma_fence_context_alloc(1), 1);
}
static struct dma_fence *mock_array(unsigned int num_fences, ...)
{
struct dma_fence_array *array;
struct dma_fence **fences;
va_list valist;
int i;
fences = kzalloc_objs(*fences, num_fences);
if (!fences)
goto error_put;
va_start(valist, num_fences);
for (i = 0; i < num_fences; ++i)
fences[i] = va_arg(valist, typeof(*fences));
va_end(valist);
array = dma_fence_array_create(num_fences, fences,
dma_fence_context_alloc(1),
1);
if (!array)
goto error_free;
return &array->base;
error_free:
kfree(fences);
error_put:
va_start(valist, num_fences);
for (i = 0; i < num_fences; ++i)
dma_fence_put(va_arg(valist, typeof(*fences)));
va_end(valist);
return NULL;
}
static struct dma_fence *mock_chain(struct dma_fence *prev,
struct dma_fence *fence)
{
struct dma_fence_chain *f;
f = dma_fence_chain_alloc();
if (!f) {
dma_fence_put(prev);
dma_fence_put(fence);
return NULL;
}
dma_fence_chain_init(f, prev, fence, 1);
return &f->base;
}
static void test_sanitycheck(struct kunit *test)
{
struct dma_fence *f, *chain, *array;
f = mock_fence();
KUNIT_ASSERT_NOT_NULL(test, f);
Annotation
- Immediate include surface: `kunit/test.h`, `linux/dma-fence.h`, `linux/dma-fence-array.h`, `linux/dma-fence-chain.h`, `linux/dma-fence-unwrap.h`.
- Detected declarations: `struct mock_fence`, `function test_sanitycheck`, `function test_unwrap_array`, `function dma_fence_unwrap_for_each`, `function test_unwrap_chain`, `function dma_fence_unwrap_for_each`, `function test_unwrap_chain_array`, `function dma_fence_unwrap_for_each`, `function test_unwrap_merge`, `function dma_fence_unwrap_for_each`.
- Atlas domain: Driver Families / drivers/dma-buf.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.