drm_gem_prime_handle_to_fd(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… drm_gem_prime_handle_to_fd(9) β€” the Kernel API Manual page, bestie edition

okay so you're in the Kernel API Manual and you found the page for drm_gem_prime_handle_to_fd β€” the PRIME export function for GEM drivers. sit down, grab a strawberry, we're gonna get into it πŸ“βœ¨


🌸 NAME 🌸

drm_gem_prime_handle_to_fd β€” the PRIME export function for GEM drivers. yes that's the whole name, it's a long one, we love her anyway πŸŽ€


✨ SYNOPSIS ✨

int drm_gem_prime_handle_to_fd (struct drm_device *dev , struct drm_file
*file_priv , uint32_t handle , uint32_t flags , int *prime_fd );

like, it takes five things and gives you back an int. iconic behaviour fr fr πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • dev β€” the dev you're exporting the buffer from. that's home base 🏠
  • file_priv β€” the drm file-private structure. you know, the private one πŸ™ˆ
  • handle β€” the buffer handle you wanna export. this is the buffer, the main character πŸ‘‘
  • flags β€” flags like DRM_CLOEXEC. yeah, the little switchy ones ⭐
  • prime_fd β€” pointer to storage for the fd id of the create dma-buf. a pointer to where the fd goes, so it can be all "here's your fd bestie" 🫢

πŸ”₯ DESCRIPTION πŸ”₯

mkay so this is the PRIME export function, and listen β€” it must be used mandatorily by GEM drivers. mandatory mandatory, not "if you feel like it" mandatory. the whole reason is so the underlying GEM object gets correct lifetime management, which is the boring-sounding but extremely real thing that keeps your kernel from crying πŸ’€

so basically this function is the vibe check, but the actual exporting from the GEM object to a dma-buf? that's not done here. that's done through the drm_gem_object_funcs.export callback. so like, this function is the doorway, the callback is the room, iykyk πŸšͺβž‘οΈπŸ›‹οΈ

ngl the split is lowkey elegant. this one handles the handle β†’ fd pipeline and the lifetime stuff, the callback handles the actual GEM-object-to-dma-buf transformation. slay πŸ’…βœ¨

ok real talk though β€” the "must be used mandatorily" part is not a suggestion and not a cute flourish. it's literally in the description because your GEM driver's lifetime management depends on it. no cap πŸ”₯

🌈 SEE ALSO 🌈

go read these, they're all part of the family okay 🫢:

like twenty-three whole cross-references?? she's connected, she knows everybody at the party 🧚✨


πŸŽ€ sign-off πŸŽ€

this little beauty lives in ./drivers/gpu/drm, dated October 2026, and it's page drm_gem_prime_handle_to_fd(9) of the Kernel API Manual. now go export some buffers responsibly, bestie πŸ’–πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from