Skip to contentSkip to conversation

Documentation: dma-buf: heaps: Add heap name definitions

PATCH Applied Maxime Ripard 2 participants 2 messages Mar 6, 2025 – Mar 12, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 Documentation: dma-buf: heaps: Add heap name definitions

Following a recent discussion at last Plumbers, John Stultz, Sumit Sewal, TJ Mercier and I came to an agreement that we should document what the dma-buf heaps names are expected to be, and what the buffers attributes you'll get should be documented.

Let's create that doc to make sure those attributes and names are guaranteed going forward.

---
Changes from v3:
- Add TJ RB
- Fix a few typos.

Changes from v2:
- Remove exhaustive list of names for platforms, and just mention the alternatives.
- Add MAINTAINERS entry

Changes from v1:
- Add the mention that the cma / reserved heap is optional.

---
 Documentation/userspace-api/dma-buf-heaps.rst | 25 +++++++++++++++++++
 Documentation/userspace-api/index.rst         |  1 +
 MAINTAINERS                                   |  1 +
 3 files changed, 27 insertions(+)
 create mode 100644 Documentation/userspace-api/dma-buf-heaps.rst
Documentation/userspace-api/dma-buf-heaps.rst new file +25 -0
new file mode 100644
index 000000000000..535f49047ce6
@@ -0,0 +1,25 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+==============================
+Allocating dma-buf using heaps
+==============================
+
+Dma-buf Heaps are a way for userspace to allocate dma-buf objects. They are
+typically used to allocate buffers from a specific allocation pool, or to share
+buffers across frameworks.
+
+Heaps
+=====
+
+A heap represents a specific allocator. The Linux kernel currently supports the
+following heaps:
+
+ - The ``system`` heap allocates virtually contiguous, cacheable, buffers.
+
+ - The ``cma`` heap allocates physically contiguous, cacheable,
+   buffers. Only present if a CMA region is present. Such a region is
+   usually created either through the kernel commandline through the
+   `cma` parameter, a memory region Device-Tree node with the
+   `linux,cma-default` property set, or through the `CMA_SIZE_MBYTES` or
+   `CMA_SIZE_PERCENTAGE` Kconfig options. Depending on the platform, it
+   might be called ``reserved``, ``linux,cma``, or ``default-pool``.
Documentation/userspace-api/index.rst +1 -0
index b1395d94b3fd..9cbe4390c872 100644
@@ -42,10 +42,11 @@ Devices and I/O
 
 .. toctree::
    :maxdepth: 1
 
    accelerators/ocxl
+   dma-buf-heaps
    dma-buf-alloc-exchange
    gpio/index
    iommufd
    media/index
    dcdbas
MAINTAINERS +1 -0
index 8e0736dc2ee0..ef0364e65aef 100644
@@ -6911,10 +6911,11 @@ R:	T.J. Mercier <[email protected]>
 L:	[email protected]
 L:	[email protected]
 L:	[email protected] (moderated for non-subscribers)
 S:	Maintained
 T:	git https://gitlab.freedesktop.org/drm/misc/kernel.git
+F:	Documentation/userspace-api/dma-buf-heaps.rst
 F:	drivers/dma-buf/dma-heap.c
 F:	drivers/dma-buf/heaps/*
 F:	include/linux/dma-heap.h
 F:	include/uapi/linux/dma-heap.h
 F:	tools/testing/selftests/dmabuf-heaps/
Signature · 1 line
2.48.1
maintainer Applied
#1 lore raw
Quoted 21 lines · Maxime Ripard

Following a recent discussion at last Plumbers, John Stultz, Sumit Sewal, TJ Mercier and I came to an agreement that we should document what the dma-buf heaps names are expected to be, and what the buffers attributes you'll get should be documented.

Let's create that doc to make sure those attributes and names are guaranteed going forward.

---
Changes from v3:
- Add TJ RB
- Fix a few typos.

Changes from v2:
- Remove exhaustive list of names for platforms, and just mention the alternatives.
- Add MAINTAINERS entry

Quoted 8 lines

Changes from v1:
- Add the mention that the cma / reserved heap is optional.

---
 Documentation/userspace-api/dma-buf-heaps.rst | 25 +++++++++++++++++++
 Documentation/userspace-api/index.rst         |  1 +
 MAINTAINERS                                   |  1 +
 3 files changed, 27 insertions(+)
 create mode 100644 Documentation/userspace-api/dma-buf-heaps.rst

I've applied this, thanks.

jon