drm_gem_prim...le_to_dmabuf(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… drm_gem_prim...le_to_dmabuf(9) β€” the Kernel API Manual, bestie edition ✨

okay so this is a page from the Kernel API Manual, and honestly it's giving "niche but iconic." Buckle up πŸŽ€


🌸 NAME 🌸

drm_gem_prime_handle_to_dmabuf β€” the PRIME export function for GEM drivers. yes, that's its whole job and it does it slayfully πŸ’–


✨ SYNOPSIS ✨

struct dma_buf * drm_gem_prime_handle_to_dmabuf (struct drm_device *dev
, struct drm_file *file_priv , uint32_t handle , uint32_t flags );

like, look at that signature. main character energy fr fr πŸ‘‘


🫢 ARGUMENTS 🫢

  • dev β€” the dev you're exporting the buffer from. the origin story, if you will πŸ’«
  • file_priv β€” the drm file-private structure. it's giving "private but make it structural" πŸ™ˆ
  • handle β€” the buffer handle you wanna export. this is the thing itself 🌸
  • flags β€” flags like DRM_CLOEXEC. yes, like the one you know and love πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

so this is the PRIME export function, and here's the tea: GEM drivers must use it β€” like, mandatorily, no cap β€” to make sure the underlying GEM object's lifetime gets managed correctly. it's not optional, it's a vibe check you have to pass 😀

the actual exporting from the GEM object to a dma-buf? that's handled through the drm_gem_object_funcs.export callback. so this function is more like the manager, and the callback does the actual work 🧚

now, unlike drm_gem_prime_handle_to_fd, this one returns the struct dma_buf it created β€” without attaching it to any file descriptors. literally just hands you the object, no strings attached πŸŽ€

the difference between the two is similar to the difference between anon_inode_getfile and anon_inode_getfd. and the reason matters, bestie: insertion into the descriptor table is something you cannot revert if any cleanup is needed. so the descriptor-returning variants should only be used when you're past the last failure exit and the only thing left to do is pass the new file descriptor to userland. that's it, that's the finish line 🏁

so when all you need is the object itself, or when you need to do something else that might fail β€” use that one instead. lowkey the safer choice, highkey the smarter one πŸ’œ

πŸ”₯ SEE ALSO πŸ”₯

the whole friend group, in order πŸ’–:


and that's the whole page, bestie 🫢 this one lives under ./drivers/gpu/drm and it's dated October 2026 β€” so go forth, export those buffers responsibly, and remember: no reverting descriptor table insertions πŸ’€βœ¨ mwah πŸŽ€

πŸ“¦ where this page comes from