dma_fence_init(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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 β€” the dma_fence_ops that 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 on
  • seqno β€” 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:


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