drivers/dma-buf/st-dma-fence.c
Source file repositories/reference/linux-study-clean/drivers/dma-buf/st-dma-fence.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/dma-buf/st-dma-fence.c- Extension
.c- Size
- 10192 bytes
- Lines
- 509
- 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/kernel.hlinux/kthread.hlinux/sched/signal.hlinux/slab.hlinux/spinlock.h
Detected Declarations
struct simple_cbstruct wait_timerstruct race_threadfunction test_sanitycheckfunction test_signalingfunction simple_callbackfunction test_add_callbackfunction test_late_add_callbackfunction test_rm_callbackfunction test_late_rm_callbackfunction test_statusfunction test_errorfunction test_waitfunction wait_timerfunction test_wait_timeoutfunction test_stubfunction __wait_for_callbacksfunction thread_signal_callbackfunction test_race_signal_callbackfunction dma_fence_suite_init
Annotated Snippet
struct simple_cb {
struct dma_fence_cb cb;
bool seen;
};
static void simple_callback(struct dma_fence *f, struct dma_fence_cb *cb)
{
smp_store_mb(container_of(cb, struct simple_cb, cb)->seen, true);
}
static void test_add_callback(struct kunit *test)
{
struct simple_cb cb = {};
struct dma_fence *f;
f = mock_fence();
KUNIT_ASSERT_NOT_NULL(test, f);
if (dma_fence_add_callback(f, &cb.cb, simple_callback)) {
KUNIT_FAIL(test, "Failed to add callback, fence already signaled!");
goto err_free;
}
dma_fence_signal(f);
if (!cb.seen) {
KUNIT_FAIL(test, "Callback failed!");
goto err_free;
}
err_free:
dma_fence_put(f);
}
static void test_late_add_callback(struct kunit *test)
{
struct simple_cb cb = {};
struct dma_fence *f;
f = mock_fence();
KUNIT_ASSERT_NOT_NULL(test, f);
dma_fence_enable_sw_signaling(f);
dma_fence_signal(f);
if (!dma_fence_add_callback(f, &cb.cb, simple_callback)) {
KUNIT_FAIL(test, "Added callback, but fence was already signaled!");
goto err_free;
}
dma_fence_signal(f);
if (cb.seen) {
KUNIT_FAIL(test, "Callback called after failed attachment!");
goto err_free;
}
err_free:
dma_fence_put(f);
}
static void test_rm_callback(struct kunit *test)
{
struct simple_cb cb = {};
struct dma_fence *f;
f = mock_fence();
KUNIT_ASSERT_NOT_NULL(test, f);
if (dma_fence_add_callback(f, &cb.cb, simple_callback)) {
KUNIT_FAIL(test, "Failed to add callback, fence already signaled!");
goto err_free;
}
if (!dma_fence_remove_callback(f, &cb.cb)) {
KUNIT_FAIL(test, "Failed to remove callback!");
goto err_free;
}
dma_fence_signal(f);
if (cb.seen) {
KUNIT_FAIL(test, "Callback still signaled after removal!");
goto err_free;
}
err_free:
dma_fence_put(f);
}
static void test_late_rm_callback(struct kunit *test)
{
Annotation
- Immediate include surface: `kunit/test.h`, `linux/delay.h`, `linux/dma-fence.h`, `linux/kernel.h`, `linux/kthread.h`, `linux/sched/signal.h`, `linux/slab.h`, `linux/spinlock.h`.
- Detected declarations: `struct simple_cb`, `struct wait_timer`, `struct race_thread`, `function test_sanitycheck`, `function test_signaling`, `function simple_callback`, `function test_add_callback`, `function test_late_add_callback`, `function test_rm_callback`, `function test_late_rm_callback`.
- 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.