drivers/dma-buf/st-dma-fence-chain.c
Source file repositories/reference/linux-study-clean/drivers/dma-buf/st-dma-fence-chain.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma-buf/st-dma-fence-chain.c- Extension
.c- Size
- 14717 bytes
- Lines
- 680
- 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/delay.hlinux/dma-fence.hlinux/dma-fence-chain.hlinux/kernel.hlinux/kthread.hlinux/mm.hlinux/sched/signal.hlinux/slab.hlinux/spinlock.hlinux/random.h
Detected Declarations
struct fence_chainsstruct find_racefunction mock_fence_releasefunction test_sanitycheckfunction seqno_incfunction fence_chains_initfunction fence_chains_finifunction test_find_seqnofunction test_find_signaledfunction test_find_out_of_orderfunction seqno_inc2function test_find_gapfunction __find_racefunction test_find_racefunction test_signal_forwardfunction test_signal_backwardfunction __wait_fence_chainsfunction test_wait_forwardfunction test_wait_backwardfunction randomise_fencesfunction test_wait_randomfunction dma_fence_chain_suite_initfunction dma_fence_chain_suite_exit
Annotated Snippet
struct fence_chains {
unsigned int chain_length;
struct dma_fence **fences;
struct dma_fence **chains;
struct dma_fence *tail;
};
static uint64_t seqno_inc(unsigned int i)
{
return i + 1;
}
static int fence_chains_init(struct fence_chains *fc, unsigned int count,
uint64_t (*seqno_fn)(unsigned int))
{
unsigned int i;
int err = 0;
fc->chains = kvmalloc_objs(*fc->chains, count, GFP_KERNEL | __GFP_ZERO);
if (!fc->chains)
return -ENOMEM;
fc->fences = kvmalloc_objs(*fc->fences, count, GFP_KERNEL | __GFP_ZERO);
if (!fc->fences) {
err = -ENOMEM;
goto err_chains;
}
fc->tail = NULL;
for (i = 0; i < count; i++) {
fc->fences[i] = mock_fence();
if (!fc->fences[i]) {
err = -ENOMEM;
goto unwind;
}
fc->chains[i] = mock_chain(fc->tail,
fc->fences[i],
seqno_fn(i));
if (!fc->chains[i]) {
err = -ENOMEM;
goto unwind;
}
fc->tail = fc->chains[i];
dma_fence_enable_sw_signaling(fc->chains[i]);
}
fc->chain_length = i;
return 0;
unwind:
for (i = 0; i < count; i++) {
dma_fence_put(fc->fences[i]);
dma_fence_put(fc->chains[i]);
}
kvfree(fc->fences);
err_chains:
kvfree(fc->chains);
return err;
}
static void fence_chains_fini(struct fence_chains *fc)
{
unsigned int i;
for (i = 0; i < fc->chain_length; i++) {
dma_fence_signal(fc->fences[i]);
dma_fence_put(fc->fences[i]);
}
kvfree(fc->fences);
for (i = 0; i < fc->chain_length; i++)
dma_fence_put(fc->chains[i]);
kvfree(fc->chains);
}
static void test_find_seqno(struct kunit *test)
{
struct fence_chains fc;
struct dma_fence *fence;
int err;
int i;
err = fence_chains_init(&fc, 64, seqno_inc);
KUNIT_ASSERT_EQ_MSG(test, err, 0, "Failed to init fence chains");
fence = dma_fence_get(fc.tail);
Annotation
- Immediate include surface: `kunit/test.h`, `linux/delay.h`, `linux/dma-fence.h`, `linux/dma-fence-chain.h`, `linux/kernel.h`, `linux/kthread.h`, `linux/mm.h`, `linux/sched/signal.h`.
- Detected declarations: `struct fence_chains`, `struct find_race`, `function mock_fence_release`, `function test_sanitycheck`, `function seqno_inc`, `function fence_chains_init`, `function fence_chains_fini`, `function test_find_seqno`, `function test_find_signaled`, `function test_find_out_of_order`.
- 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.