Generated by GPT-5-mini| DMA-BUF | |
|---|---|
| Name | DMA-BUF |
| Caption | Shared buffer mechanism for Linux kernel |
| Origin | Linux kernel |
| Developer | Linus Torvalds |
| Introduced | 2013 |
DMA-BUF DMA-BUF is a Linux kernel facility for sharing buffer objects between device drivers and userspace components without copying. It enables zero-copy graphics and multimedia pipelines by coordinating memory ownership and scatter-gather mappings among subsystems such as graphics, video, and camera stacks. Designed to integrate with modern display and compute infrastructures, DMA-BUF interacts with subsystems including DRM, V4L2, and Wayland compositors to reduce latency and CPU overhead.
DMA-BUF originated to address cross-driver buffer sharing challenges in the Linux kernel and to harmonize interactions between subsystems like Direct Rendering Manager, Video4Linux, Wayland (display server protocol), Android (operating system), and X.Org Server. It provides a unified handle representing a buffer that can be exported by one driver and imported by others, coordinating with kernel features such as scatter/gather DMA, IOMMU, and slab allocator. Prominent contributors include engineers associated with Intel Corporation, NVIDIA Corporation, ARM Holdings, and volunteer developers active in the Linux Foundation community. DMA-BUF complements other kernel mechanisms like mmap(2), msync(2), and kmalloc-based allocations by enabling cross-device DMA mapping semantics used by hardware from vendors such as Qualcomm Incorporated, Broadcom, and Imagination Technologies.
The core abstraction is a file-descriptor-backed buffer object exported via the kernel's file operations, interacting with subsystems including POSIX, Golang-based tooling only at userspace boundary when needed, and userspace libraries like libdrm, libwayland, libcamera, GStreamer, and Mesa (computer graphics). DMA-BUF defines operations resembling those found in Linux kernel subsystems: reference counting influenced by refcount_t patterns, buffer ops callbacks similar to file_operations, and mapping behaviors interacting with ioctl(2) interfaces. It coordinates with mediator frameworks such as ION (Android), dma-buf heap, and allocator implementations from vendors like Samsung Electronics and Texas Instruments, while exposing synchronization primitives compatible with futex, poll(2), and fences based on sync_file semantics developed by contributors from Google LLC and Collabora Ltd..
Common usage scenarios include zero-copy composition pipelines between KWin, Weston, and Sway (window manager), camera capture pipelines used by OpenCV, GStreamer, and FFmpeg, and GPU compute offload between OpenCL, Vulkan, and media encoders from Intel Corporation and AMD. Implementations exist across SoC vendors and GPU vendors including NVIDIA Corporation's proprietary stacks, open drivers in Mesa (computer graphics), and in embedded platforms from Raspberry Pi (trademark), NXP Semiconductors, and MediaTek. In smartphone ecosystems, DMA-BUF supports composition between the display controller used by Qualcomm Incorporated's Snapdragon, camera ISP pipelines from Sony Corporation sensors, and Android frameworks like SurfaceFlinger. Desktop compositors and toolkits such as GTK+, Qt (software), Electron (software framework), and Chromium (web browser) leverage DMA-BUF indirectly through display and GPU integration.
Performance benefits stem from zero-copy transfers that reduce CPU cycles and cache pressure when interacting with accelerators like GPUs from AMD and NVIDIA Corporation, video encoders from Broadcom, or DSPs from Texas Instruments. DMA-BUF integrates with IOMMU to control device access to physical memory, assisting threat mitigation models associated with direct device DMA hazards discussed in standards bodies such as Trusted Computing Group. Security considerations include permissioning and lifetime semantics enforced by descriptor-based access control, interactions with SELinux policies maintained by NSA contributors to the NSA SELinux project and with namespaces in systemd-managed containers, as well as potential side channels mitigated by kernel hardening efforts like those from Kernel Self Protection Project contributors. Synchronization of concurrent access uses fence drivers and sync_file semantics authored by engineers at Google LLC and partners to ensure ordering for producers and consumers.
DMA-BUF lives in the Linux kernel and uses kernel subsystems such as devm_kmalloc, dma_map_single, and bus-specific DMA APIs. Development occurs through mailing lists like Linux Kernel Mailing List and repositories mirrored in GitHub by companies such as Intel Corporation and community groups like Freedesktop.org. Key interfaces include exporter and importer callbacks registered via internal kernel APIs; drivers implement ops similar to platform_driver and integrate with frameworks including DRM (Direct Rendering Manager), V4L2 (Video4Linux2), and audio/multimedia subsystems. Test suites and CI integrations are contributed by organizations including Intel Corporation, Collabora Ltd., and Linaro Limited.
Interoperability spans graphics stacks like DRM (Direct Rendering Manager), display servers including Wayland (display server protocol) and legacy X.Org Server, multimedia frameworks such as GStreamer and FFmpeg, and mobile stacks including Android (operating system). Compatibility challenges arise with proprietary drivers from NVIDIA Corporation and with differing allocator implementations like ION (Android) versus dma-buf heaps; solutions involve exporters providing metadata, modifiers used by drm_fourcc formats, and negotiation layers in compositors like Weston. Cross-vendor efforts from Freedesktop.org and specification discussions in Kernel Summit meetings aim to standardize behavior across hardware from Qualcomm Incorporated, Samsung Electronics, NXP Semiconductors, and cloud providers such as Amazon Web Services and Google Cloud Platform that offer GPU instances for virtualization.