DRM_IOCTL_PR...FD_TO_HANDLE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

DRM_IOCTL_PRIME_FD_TO_HANDLE β€” convert a DMA-BUF FD to a GEM handle, bestie πŸ’…

Okay so this is the DRM_IOCTL_PR...FD_TO_HANDLE(9) page from the Kernel API Manual β€” and it's literally the import-side glow-up: DMA-BUF FD in, GEM handle out. No cap. ✨

✨ SYNOPSIS ✨

DRM_IOCTL_PRIME_FD_TO_HANDLE

πŸŽ€ DESCRIPTION πŸŽ€

So user-space sets drm_prime_handle.fd with a DMA-BUF file descriptor to import 🫢, and gets back a GEM handle in drm_prime_handle.handle. And drm_prime_handle.flags? Unused. Iconic but unused. πŸ’€

Now here's the tea: if an existing GEM handle refers to the memory object backing the DMA-BUF, that GEM handle is returned. So user-space which needs to handle arbitrary DMA-BUFs must have a user-space lookup data structure to manually reference-count duplicated GEM handles. For more information see DRM_IOCTL_GEM_CLOSE β€” she explains the close side. πŸ’…

The import can fail for any driver-specific reason, e.g. because import is only supported for DMA-BUFs allocated on this DRM device. So yes, driver-specific chaos is possible, no universal slay. 😭

Support for importing DMA-BUFs is advertised via DRM_PRIME_CAP_IMPORT ✨.

🌈 SEE ALSO 🌈

Every single ref from the original is here β€” no skipping, bestie:


Cute sign-off tea: source/version ./tools/perf/trace/beauty/incl..., date October 2026, page DRM_IOCTL_PR...FD_TO_HANDLE(9). Bye bestie! πŸ«ΆπŸ’–

πŸ“¦ where this page comes from