drm_gem_prime_handle_to_fd(9)
π 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β thedevyou'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 likeDRM_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 π«Ά:
- Kernel file
./drivers/gpu/drm/drm_prime.coverview and lifetime rules(9) drm_gem_dmabuf_export(9)drm_gem_dmabuf_release(9)drm_gem_prime_fd_to_handle(9)drm_gem_prime_handle_to_dmabuf(9)PRIME Helpers(9)drm_gem_map_attach(9)drm_gem_map_detach(9)drm_gem_map_dma_buf(9)drm_gem_unmap_dma_buf(9)drm_gem_dmabuf_vmap(9)drm_gem_dmabuf_vunmap(9)drm_gem_prime_mmap(9)drm_gem_dmabuf_mmap(9)drm_prime_pages_to_sg(9)drm_prime_get_contiguous_size(9)drm_gem_prime_export(9)drm_gem_is_prime_exported_dma_buf(9)drm_gem_prime_import_dev(9)drm_gem_prime_import(9)drm_prime_sg_to_page_array(9)drm_prime_sg_to_dma_addr_array(9)drm_prime_gem_destroy(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms