<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/dma-buf/heaps, branch v6.19.11</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.19.11'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2025-11-21T05:18:00+00:00</updated>
<entry>
<title>dma-buf: system_heap: use larger contiguous mappings instead of per-page mmap</title>
<updated>2025-11-21T05:18:00+00:00</updated>
<author>
<name>Barry Song</name>
<email>v-songbaohua@oppo.com</email>
</author>
<published>2025-10-21T04:20:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=04c7adb5871ad04c9e3fd645570e21c93f1b2f54'/>
<id>urn:sha1:04c7adb5871ad04c9e3fd645570e21c93f1b2f54</id>
<content type='text'>
We can allocate high-order pages, but mapping them one by
one is inefficient. This patch changes the code to map
as large a chunk as possible. The code looks somewhat
complicated mainly because supporting mmap with a
non-zero offset is a bit tricky.

Using the micro-benchmark below, we see that mmap becomes
35X faster:

  #include &lt;stdio.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;linux/dma-heap.h&gt;
  #include &lt;sys/ioctl.h&gt;
  #include &lt;sys/mman.h&gt;
  #include &lt;time.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;stdlib.h&gt;

  #define SIZE   (512UL * 1024 * 1024)
  #define PAGE   4096
  #define STRIDE (PAGE/sizeof(int))
  #define PAGES  (SIZE/PAGE)

  int main(void) {
      int heap = open("/dev/dma_heap/system", O_RDONLY);
      struct dma_heap_allocation_data d =
            { .len = SIZE, .fd_flags = O_RDWR|O_CLOEXEC };
      ioctl(heap, DMA_HEAP_IOCTL_ALLOC, &amp;d);

      struct timespec t0, t1;
      clock_gettime(CLOCK_MONOTONIC, &amp;t0);
      int *p = mmap(NULL, SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, d.fd, 0);
      clock_gettime(CLOCK_MONOTONIC, &amp;t1);

      for (int i = 0; i &lt; PAGES; i++) p[i*STRIDE] = i;
      for (int i = 0; i &lt; PAGES; i++)
          if (p[i*STRIDE] != i) {
              fprintf(stderr, "mismatch at page %d\n", i);
              exit(1);
          }

      long ns = (t1.tv_sec-t0.tv_sec)*1000000000L +
                (t1.tv_nsec-t0.tv_nsec);
      printf("mmap 512MB took %.3f us, verify OK\n", ns/1000.0);
      return 0;
  }

W/ patch:

~ # ./a.out
mmap 512MB took 200266.000 us, verify OK
~ # ./a.out
mmap 512MB took 198151.000 us, verify OK
~ # ./a.out
mmap 512MB took 197069.000 us, verify OK
~ # ./a.out
mmap 512MB took 196781.000 us, verify OK
~ # ./a.out
mmap 512MB took 198102.000 us, verify OK
~ # ./a.out
mmap 512MB took 195552.000 us, verify OK

W/o patch:

~ # ./a.out
mmap 512MB took 6987470.000 us, verify OK
~ # ./a.out
mmap 512MB took 6970739.000 us, verify OK
~ # ./a.out
mmap 512MB took 6984383.000 us, verify OK
~ # ./a.out
mmap 512MB took 6971311.000 us, verify OK
~ # ./a.out
mmap 512MB took 6991680.000 us, verify OK

Signed-off-by: Barry Song &lt;v-songbaohua@oppo.com&gt;
Acked-by: John Stultz &lt;jstultz@google.com&gt;
Reviewed-by: Maxime Ripard &lt;mripard@kernel.org&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
  [sumits: correct from 3.5x to 35x]
Link: https://patch.msgid.link/20251021042022.47919-1-21cnbao@gmail.com
</content>
</entry>
<entry>
<title>dma-buf: heaps: cma: Create CMA heap for each CMA reserved region</title>
<updated>2025-10-18T16:01:22+00:00</updated>
<author>
<name>Maxime Ripard</name>
<email>mripard@kernel.org</email>
</author>
<published>2025-10-13T08:35:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=4f5f8baf73411d799f3a51b73190ebecf522eb83'/>
<id>urn:sha1:4f5f8baf73411d799f3a51b73190ebecf522eb83</id>
<content type='text'>
Aside from the main CMA region, it can be useful to allow userspace to
allocate from the other CMA reserved regions.

Indeed, those regions can have specific properties that can be useful to
a specific us-case.

For example, one of them platform I've been with has ECC enabled on the
entire memory but for a specific region. Using that region to allocate
framebuffers can be particular beneficial because enabling the ECC has a
performance and memory footprint cost.

Thus, exposing these regions as heaps user-space can allocate from and
import wherever needed allows to cover that use-case.

For now, only shared-dma-pools regions with the reusable property (ie,
backed by CMA) are supported, but eventually we'll want to support other
DMA pools types.

Since we collected all the CMA regions created during boot, we can
simply iterate over all of them to create the heaps.

This has a weird interaction with the recent work on the CMA name, in
particular the backward compatibility code created by commit
854acbe75ff4 ("dma-buf: heaps: Give default CMA heap a fixed name").

Indeed, the old name was either 'reserved', or the name of the
reserved-memory region device tree node if the linux,cma-default
property was set.

In both these cases, we have now collected this region during boot, and
we're using the same name. So we're now largely redundant with the
code to handle backward compatibility code, and we can thus remove it
and the associated Kconfig option.

Reviewed-by: T.J. Mercier &lt;tjmercier@google.com&gt;
Signed-off-by: Maxime Ripard &lt;mripard@kernel.org&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
   [sumits: rebased the doc to latest]
Link: https://lore.kernel.org/r/20251013-dma-buf-ecc-heap-v8-5-04ce150ea3d9@kernel.org
</content>
</entry>
<entry>
<title>dma-buf: heaps: cma: Register list of CMA regions at boot</title>
<updated>2025-10-18T16:01:21+00:00</updated>
<author>
<name>Maxime Ripard</name>
<email>mripard@kernel.org</email>
</author>
<published>2025-10-13T08:35:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=8b5690d5c942a80535f095c8965028262d4ab0f7'/>
<id>urn:sha1:8b5690d5c942a80535f095c8965028262d4ab0f7</id>
<content type='text'>
In order to create a CMA heap instance for each CMA region found in the
system, we need to register each of these instances.

While it would appear trivial, the CMA regions are created super early
in the kernel boot process, before most of the subsystems are
initialized. Thus, we can't just create an exported function to create a
heap from the CMA region being initialized.

What we can do however is create a two-step process, where we collect
all the CMA regions into an array early on, and then when we initialize
the heaps we iterate over that array and create the heaps from the CMA
regions we collected.

Reviewed-by: T.J. Mercier &lt;tjmercier@google.com&gt;
Signed-off-by: Maxime Ripard &lt;mripard@kernel.org&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Link: https://lore.kernel.org/r/20251013-dma-buf-ecc-heap-v8-2-04ce150ea3d9@kernel.org
</content>
</entry>
<entry>
<title>dma-buf: heaps: Give default CMA heap a fixed name</title>
<updated>2025-07-09T10:21:40+00:00</updated>
<author>
<name>Jared Kangas</name>
<email>jkangas@redhat.com</email>
</author>
<published>2025-06-10T13:12:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=854acbe75ff406ea2c72ef3048578dfd99425ba9'/>
<id>urn:sha1:854acbe75ff406ea2c72ef3048578dfd99425ba9</id>
<content type='text'>
The CMA heap's name in devtmpfs can vary depending on how the heap is
defined. Its name defaults to "reserved", but if a CMA area is defined
in the devicetree, the heap takes on the devicetree node's name, such as
"default-pool" or "linux,cma". To simplify naming, unconditionally name
it "default_cma_region", but keep a legacy node in place backed by the
same underlying allocator for backwards compatibility.

Reviewed-by: Maxime Ripard &lt;mripard@kernel.org&gt;
Signed-off-by: Jared Kangas &lt;jkangas@redhat.com&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Link: https://lore.kernel.org/r/20250610131231.1724627-4-jkangas@redhat.com
</content>
</entry>
<entry>
<title>dma-buf: heaps: Parameterize heap name in __add_cma_heap()</title>
<updated>2025-07-09T10:21:39+00:00</updated>
<author>
<name>Jared Kangas</name>
<email>jkangas@redhat.com</email>
</author>
<published>2025-06-10T13:12:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=86e59cc5069700361041aa5bf536a8a66be6b9ec'/>
<id>urn:sha1:86e59cc5069700361041aa5bf536a8a66be6b9ec</id>
<content type='text'>
Prepare for the introduction of a fixed-name CMA heap by replacing the
unused void pointer parameter in __add_cma_heap() with the heap name.

Reviewed-by: Maxime Ripard &lt;mripard@kernel.org&gt;
Acked-by: John Stultz &lt;jstultz@google.com&gt;
Signed-off-by: Jared Kangas &lt;jkangas@redhat.com&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Link: https://lore.kernel.org/r/20250610131231.1724627-3-jkangas@redhat.com
</content>
</entry>
<entry>
<title>dma-buf: system_heap: No separate allocation for attachment sg_tables</title>
<updated>2025-07-09T10:21:39+00:00</updated>
<author>
<name>T.J. Mercier</name>
<email>tjmercier@google.com</email>
</author>
<published>2025-04-17T18:09:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a951020202b88cee91feab00b36946c62e5a71d3'/>
<id>urn:sha1:a951020202b88cee91feab00b36946c62e5a71d3</id>
<content type='text'>
struct dma_heap_attachment is a separate allocation from the struct
sg_table it contains, but there is no reason for this. Let's use the
slab allocator just once instead of twice for dma_heap_attachment.

Signed-off-by: T.J. Mercier &lt;tjmercier@google.com&gt;
Reviewed-by: Christian König &lt;christian.koenig@amd.com&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Link: https://lore.kernel.org/r/20250417180943.1559755-1-tjmercier@google.com
</content>
</entry>
<entry>
<title>dma-buf: heaps: system: Remove global variable</title>
<updated>2025-04-08T09:48:39+00:00</updated>
<author>
<name>Maxime Ripard</name>
<email>mripard@kernel.org</email>
</author>
<published>2025-04-07T16:29:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=92a2bf257ec4729d13ed17f5b04192ad8e3b7024'/>
<id>urn:sha1:92a2bf257ec4729d13ed17f5b04192ad8e3b7024</id>
<content type='text'>
The system heap is storing its struct dma_heap pointer in a global
variable but isn't using it anywhere.

Let's move the global variable into system_heap_create() to make it
local.

Signed-off-by: Maxime Ripard &lt;mripard@kernel.org&gt;
Reviewed-by: Christian König &lt;christian.koenig@amd.com&gt;
Reviewed-by: Mattijs Korpershoek &lt;mkorpershoek@kernel.org&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20250407-dma-buf-ecc-heap-v3-1-97cdd36a5f29@kernel.org
Signed-off-by: Christian König &lt;christian.koenig@amd.com&gt;
</content>
</entry>
<entry>
<title>dma-buf/heaps: replace kmap_atomic with kmap_local_page</title>
<updated>2024-10-14T14:46:03+00:00</updated>
<author>
<name>Pintu Kumar</name>
<email>quic_pintu@quicinc.com</email>
</author>
<published>2024-10-01T17:50:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=4a1cb63bf321c1e498d3f19a6049e56838b18f82'/>
<id>urn:sha1:4a1cb63bf321c1e498d3f19a6049e56838b18f82</id>
<content type='text'>
Use of kmap_atomic/kunmap_atomic is deprecated, use
kmap_local_page/kunmap_local instead.

This is reported by checkpatch.
Also fix repeated word issue.

WARNING: Deprecated use of 'kmap_atomic', prefer 'kmap_local_page' instead
+                       void *vaddr = kmap_atomic(page);

WARNING: Deprecated use of 'kunmap_atomic', prefer 'kunmap_local' instead
+                       kunmap_atomic(vaddr);

WARNING: Possible repeated word: 'by'
+                        * has been killed by by SIGKILL

total: 0 errors, 3 warnings, 405 lines checked

Signed-off-by: Pintu Kumar &lt;quic_pintu@quicinc.com&gt;
Reviewed-by: T.J. Mercier &lt;tjmercier@google.com&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20241001175057.27172-1-quic_pintu@quicinc.com
</content>
</entry>
<entry>
<title>Merge drm/drm-next into drm-misc-next</title>
<updated>2024-09-30T08:50:54+00:00</updated>
<author>
<name>Thomas Zimmermann</name>
<email>tzimmermann@suse.de</email>
</author>
<published>2024-09-30T08:50:54+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=2dd0ef5d951e9b565ddb324fe26c531b6a40bf82'/>
<id>urn:sha1:2dd0ef5d951e9b565ddb324fe26c531b6a40bf82</id>
<content type='text'>
Get drm-misc-next to up v6.12-rc1.

Signed-off-by: Thomas Zimmermann &lt;tzimmermann@suse.de&gt;
</content>
</entry>
<entry>
<title>dma-buf: heaps: Add __init to CMA and system heap module_init functions</title>
<updated>2024-09-09T10:21:54+00:00</updated>
<author>
<name>T.J. Mercier</name>
<email>tjmercier@google.com</email>
</author>
<published>2024-09-06T00:03:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7a4fe6525450eb950de040336de996775e40176e'/>
<id>urn:sha1:7a4fe6525450eb950de040336de996775e40176e</id>
<content type='text'>
Shrink the kernel .text a bit after successful initialization of the
heaps.

Signed-off-by: T.J. Mercier &lt;tjmercier@google.com&gt;
Acked-by: John Stultz &lt;jstultz@google.com&gt;
Signed-off-by: Sumit Semwal &lt;sumit.semwal@linaro.org&gt;
Link: https://patchwork.freedesktop.org/patch/msgid/20240906000314.2368749-1-tjmercier@google.com
</content>
</entry>
</feed>
