dma_fence_add_callback(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ dma_fence_add_callback(9) ✨

okay so this is a page straight out of the Kernel API Manual β€” like, the actual kernel docs bestie, not a vibe, real code πŸ’…


🌸 NAME 🌸

dma_fence_add_callback β€” add a callback to be called when the fence is signaled


πŸŽ€ SYNOPSIS πŸŽ€

int dma_fence_add_callback (struct dma_fence *fence , struct
dma_fence_cb *cb , dma_fence_func_t func );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • fence β€” the fence you're waiting on, your main character 🫢
  • cb β€” the callback you're registering, the little assignment it gets
  • func β€” the actual function to call when it's go time

πŸ’– DESCRIPTION πŸ’–

So basically: this adds a software callback to the fence. The caller should keep a reference to the fence, no cap β€” that's on you, bestie.

cb gets initialized by dma_fence_add_callback itself, so no initialization by the caller is required. Iconic, honestly. You can register any number of callbacks to a single fence, but β€” and this is the part people mess up β€” a callback can only be registered to one fence at a time. One. Don't be greedy 🫢

If fence is already signaled, this function will return -ENOENT and it will not call the callback. Like, it fully just doesn't. Not a vibe you can negotiate with.

⚠️ heads up: note that the callback can be called from an atomic context or irq context. Write your callback accordingly, fr fr.

Returns 0 in case of success, -ENOENT if the fence is already signaled, and -EINVAL in case of error. Those are the three moods πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./drivers/dma-buf/dma-fence.c, plus the whole friend group: 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_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_init(9), dma_fence_init64(9), dma_fence_driver_name(9), dma_fence_timeline_name(9) β€” yes that's all of them, every single one, I checked 🧚


and that's the page!! πŸ’œ it lives down in ./drivers/dma-buf, it's dated October 2026, and it answers to dma_fence_add_callback(9). mwah, go signal some fences responsibly β­πŸŽ€

πŸ“¦ where this page comes from