Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dma-buf: heaps: Give default CMA heap a fixed name

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 <mripard@kernel.org>
Signed-off-by: Jared Kangas <jkangas@redhat.com>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: https://lore.kernel.org/r/20250610131231.1724627-4-jkangas@redhat.com

authored by

Jared Kangas and committed by
Sumit Semwal
854acbe7 86e59cc5

+34 -3
+5 -2
Documentation/userspace-api/dma-buf-heaps.rst
··· 21 21 usually created either through the kernel commandline through the 22 22 ``cma`` parameter, a memory region Device-Tree node with the 23 23 ``linux,cma-default`` property set, or through the ``CMA_SIZE_MBYTES`` or 24 - ``CMA_SIZE_PERCENTAGE`` Kconfig options. Depending on the platform, it 25 - might be called ``reserved``, ``linux,cma``, or ``default-pool``. 24 + ``CMA_SIZE_PERCENTAGE`` Kconfig options. The heap's name in devtmpfs is 25 + ``default_cma_region``. For backwards compatibility, when the 26 + ``DMABUF_HEAPS_CMA_LEGACY`` Kconfig option is set, a duplicate node is 27 + created following legacy naming conventions; the legacy name might be 28 + ``reserved``, ``linux,cma``, or ``default-pool``.
+10
drivers/dma-buf/heaps/Kconfig
··· 12 12 Choose this option to enable dma-buf CMA heap. This heap is backed 13 13 by the Contiguous Memory Allocator (CMA). If your system has these 14 14 regions, you should say Y here. 15 + 16 + config DMABUF_HEAPS_CMA_LEGACY 17 + bool "Legacy DMA-BUF CMA Heap" 18 + default y 19 + depends on DMABUF_HEAPS_CMA 20 + help 21 + Add a duplicate CMA-backed dma-buf heap with legacy naming derived 22 + from the CMA area's devicetree node, or "reserved" if the area is not 23 + defined in the devicetree. This uses the same underlying allocator as 24 + CONFIG_DMABUF_HEAPS_CMA.
+19 -1
drivers/dma-buf/heaps/cma_heap.c
··· 9 9 * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/ 10 10 * Andrew F. Davis <afd@ti.com> 11 11 */ 12 + 13 + #define pr_fmt(fmt) "cma_heap: " fmt 14 + 12 15 #include <linux/cma.h> 13 16 #include <linux/dma-buf.h> 14 17 #include <linux/dma-heap.h> ··· 25 22 #include <linux/slab.h> 26 23 #include <linux/vmalloc.h> 27 24 25 + #define DEFAULT_CMA_NAME "default_cma_region" 28 26 29 27 struct cma_heap { 30 28 struct dma_heap *heap; ··· 398 394 static int __init add_default_cma_heap(void) 399 395 { 400 396 struct cma *default_cma = dev_get_cma_area(NULL); 397 + const char *legacy_cma_name; 401 398 int ret; 402 399 403 400 if (!default_cma) 404 401 return 0; 405 402 406 - ret = __add_cma_heap(default_cma, cma_get_name(default_cma)); 403 + ret = __add_cma_heap(default_cma, DEFAULT_CMA_NAME); 407 404 if (ret) 408 405 return ret; 406 + 407 + if (IS_ENABLED(CONFIG_DMABUF_HEAPS_CMA_LEGACY)) { 408 + legacy_cma_name = cma_get_name(default_cma); 409 + if (!strcmp(legacy_cma_name, DEFAULT_CMA_NAME)) { 410 + pr_warn("legacy name and default name are the same, skipping legacy heap\n"); 411 + return 0; 412 + } 413 + 414 + ret = __add_cma_heap(default_cma, legacy_cma_name); 415 + if (ret) 416 + pr_warn("failed to add legacy heap: %pe\n", 417 + ERR_PTR(ret)); 418 + } 409 419 410 420 return 0; 411 421 }