STRUCT DMA_RESV(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct dma_resv(9) ✨

okay so bestie, welcome to the kernel api manual πŸ’… today's main character is struct dma_resv β€” the reservation object that manages fences for a buffer. yes, fences. no, not the wooden kind πŸŽ€


🌸 SYNOPSIS 🌸

fr fr, here's the whole vibe, character for character:

struct dma_resv {
    struct ww_mutex lock;
    struct dma_resv_list *fences;
 };

πŸ‘‘ Members πŸ‘‘

  • lock β€” the update side lock. like, do not use it directly, bestie 😭 please use the wrapper functions instead, like dma_resv_lock and dma_resv_unlock. that's the whole point.

drivers that use the reservation object to manage memory dynamically also use this lock to protect buffer object state β€” think placement, allocation policies, or throughout command submission. it's giving multitasking queen ✨

  • fences β€” the array of fences which where added to the dma_resv object. (yes, "where". we don't fix the original's grammar, we respect it 🫢)

a new fence gets added by calling dma_resv_add_fence. and the way that this often needs to happen past the point of no return in command submission means it literally cannot fail πŸ”₯ so you need to reserve sufficient slots ahead of time by calling dma_resv_reserve_fences. plan ahead, babe. no cap.


πŸ’– Description πŸ’–

this is a container for dma_fence objects which needs to handle multiple use cases. a container! for multiple things! versatility icon πŸ¦‹

one use is to synchronize cross-driver access to a struct dma_buf β€” either for dynamic buffer management, or just to handle implicit synchronization between different users of the buffer in userspace. see dma_buf.resv for a more in-depth discussion, iykyk 🌈

the other major use is managing access and locking within a driver in a buffer based memory manager. struct ttm_buffer_object is the canonical example here, since this is where reservation objects originated from πŸ‘‘ but use in drivers is spreading, and some drivers also manage struct drm_gem_object with the same scheme. growth era fr fr πŸ“ˆ


🌟 SEE ALSO 🌟

kernel file ./include/linux/dma-resv.h β€” go read it, bestie, it's iconic:


and that's the page, bestie 🫢 this one lives in ./include/linux, dated October 2026, and it's filed under struct dma_resv(9). slay, go forth and fence responsibly πŸ’œ

πŸ“¦ where this page comes from