dma_fence_init(9)
π dma_fence_init β the kernel API manual, but make it make sense
okay so bestie, welcome to dma_fence_init(9) from the Kernel API Manual π this one is short but it's important, so grab your iced coffee and let's go β¨
π NAME π
dma_fence_init β initialize a custom fence. that's it, that's the whole vibe π¦
β¨ SYNOPSIS β¨
void dma_fence_init (struct dma_fence *fence , const struct
dma_fence_ops *ops , spinlock_t *lock , u64 context , u64 seqno );
literally just one function call, no drama π
πΈ ARGUMENTS πΈ
fenceβ the fence you're initializing. the main character, the one getting set up πopsβ thedma_fence_opsthat says what operations apply to this fence. it's giving "here's my instruction manual" πlockβ an optional irqsafe spinlock used for locking this fence. optional!! remember that word, it comes back later π₯contextβ the execution context this fence runs onseqnoβ a linear increasing sequence number for this context. linear!! increasing!! no take-backs π
π DESCRIPTION π
so this is what actually initializes an allocated fence. and here's the cute part: the caller doesn't have to keep its refcount after committing with this fence π«Ά β BUT (and yes there's a but, there's always a but π) it will need to hold a refcount again if dma_fence_ops.enable_signaling gets called. so like... remember your refcount exists, bestie. don't ghost it.
context and seqno are the whole reason comparing fences is easy β they let you check which fence is later by simply using dma_fence_later. convenient?? obsessed π
now the serious bit, no cap: external locks are a relic of legacy use cases that needed a shared lock to serialize signaling when out-of-order signaling wasn't possible through dma_fence_ops.signaled. drivers have fully abandoned this concept since the callback got introduced, but the external lock is still around π it's giving "haunted artifact in the codebase."
new users MUST NOT use external locks π¨ fr fr, because they force the issuer to outlive all fences that reference the lock. that's not a vibe. do not do it. periodt π
π¦ SEE ALSO π¦
the whole friend group, in order:
- Kernel file
./drivers/dma-buf/dma-fence.c DMA fences overview(9)fence cross-driver contract(9)dma_fence_get_stub(9)dma_fence_allocate_private_stub(9)dma_fence_context_alloc(9)fence signalling annotation(9)dma_fence_begin_signalling(9)dma_fence_end_signalling(9)dma_fence_signal_timestamp_locked(9)dma_fence_signal_timestamp(9)dma_fence_signal_locked(9)dma_fence_check_and_signal_locked(9)dma_fence_check_and_signal(9)dma_fence_signal(9)dma_fence_wait_timeout(9)dma_fence_release(9)dma_fence_free(9)dma_fence_enable_signaling(9)dma_fence_add_callback(9)dma_fence_get_status(9)dma_fence_remove_callback(9)dma_fence_default_wait(9)dma_fence_wait_any_timeout(9)deadline hints(9)dma_fence_set_deadline(9)dma_fence_describe(9)dma_fence_init64(9)dma_fence_driver_name(9)dma_fence_timeline_name(9)
and that's the page!! π«Ά this lil guy lives in ./drivers/dma-buf, dated October 2026, and honestly? iconic. go initialize a fence responsibly, bestie. slay π
β¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms