# Configure and manage memory The Qualcomm^®^ Linux kernel baseline supports all memory management features and allocators. The following information outlines customizing the memory map and performing heap management. For more information about Linux kernel memory management, see [Memory management](https://www.kernel.org/doc/html/next/core-api/index.html#memory-management). **Memory map** Memory map describes the areas that are reserved for subsystems, such as modem, camera, aDSP, and cDSP during kernel boot. The memory map sets `no-map` for the carved out regions in the DTSI, making them inaccessible to the kernel. Configurable carved-out regions are defined in the `arch/arm64/boot/dts/qcom/qcs6490.dtsi` file under the `reserved-memory` node. reserved-memory { cdsp_secure_heap_mem: cdsp-secure-heap@81800000 { reg = <0x0 0x81800000 0x0 0x1e00000>; no-map; }; camera_mem: camera@84300000 { reg = <0x0 0x84300000 0x0 0x500000>; no-map; }; wpss_mem: wpss@0x84800000 { reg = <0x0 0x84800000 0x0 0x1900000>; no-map; }; adsp_mem: adsp@86100000 { reg = <0x0 0x86100000 0x0 0x2800000>; no-map; }; }; Copy to clipboard Note For Qualcomm SoCs, see the SoC-specific Qualcomm DTSI files to get this information. The following early boot log shows carved out region creation for different subsystems: [ 0.000000] OF: reserved mem: 0x0000000081800000..0x00000000835fffff (30720 KiB) nomap non-reusable cdsp-secure-heap@81800000 [ 0.000000] OF: reserved mem: 0x0000000084300000..0x00000000847fffff (5120 KiB) nomap non-reusable camera@84300000 [ 0.000000] OF: reserved mem: 0x0000000084800000..0x00000000860fffff (25600 KiB) nomap non-reusable wpss@0x84800000 [ 0.000000] OF: reserved mem: 0x0000000086100000..0x00000000888fffff (40960 KiB) nomap non-reusable adsp@86100000 Copy to clipboard ## Contiguous memory allocator Qualcomm Linux distribution supports CMA to allocate large physically contiguous memory. CMA reserves a large physically contiguous memory area at boot time and provides physically continuous memory to CMA allocation. When not in use, CMA memory is available to the kernel buddy allocator for movable allocations. To change the size of the default CMA region, run `cma=size_in_MB` in the kernel command-line arguments. For more information on how to use the kernel parameter, see the following example: cma=nn[MG]@[start[MG][-end[MG]]] [KNL,CMA] Sets the size of kernel global memory area for contiguous memory allocations and optionally the placement constraint by the physical address range of memory allocations. A value of 0 disables CMA altogether. For more information, see kernel/dma/contiguous.c Copy to clipboard The custom CMA regions are defined under the `reserved-memory` node with a `shared-dma-pool` compatible tag indicating the CMA region: adsp_heap_mem: adsp-heap { compatible = "shared-dma-pool"; alloc-ranges = <0x0 0x00000000 0x0 0xffffffff>; reusable; alignment = <0x0 0x400000>; size = <0x0 0xc00000>; }; Copy to clipboard The following is a sample log for an aDSP CMA memory region reserved on boot: [ 0.000000] OF: reserved mem: initialized node adsp-heap, compatible id shared-dma-pool [ 0.000000] OF: reserved mem: 0x00000000ff000000..0x00000000ffbfffff (12288 KiB) map reusable adsp-heap Copy to clipboard ### Add custom CMA heaps To create custom CMA regions using DMA-BUF heaps, use the existing DMA-BUF framework in the Qualcomm Linux kernel. The Qualcomm Linux kernel exports the `cma_heap_add()` API for the custom DMA-BUF heaps. /** * cma_heap_add - adds a CMA heap to dmabuf heaps * @cma: pointer to the CMA pool to register the heap for * @data: unused * * Returns 0 on success. Else, returns errno. */ int cma_heap_add(struct cma *cma, void *data); Copy to clipboard The DMA-BUF heap exported to the user space, has the same name as the phandle of the CMA region in the device tree. To add a custom CMA heap, do the following: 1. To create a custom CMA region see [Contiguous memory allocator](https://docs.qualcomm.com/doc/80-70030-3/topic/memory.html#memory-contiguous). 2. In the driver to which you are adding a custom heap: 1. Parse the device tree for the newly added CMA region. 2. Add a DMA-BUF heap associated with the driver. int create_my_cma_heap(struct device *dev) { int rc = 0, idx = 0; rc = of_reserved_mem_device_init_by_idx(dev, dev->of_node, 0); // Parse the devicetree for the cma region if (rc) { pr_err("No reserved DMA memory, ret=%d\n", rc); rc = -EINVAL; goto err; } rc = cma_heap_add(dev->cma_area, NULL); // Add a dmabuf heap associated with the cma region if (rc) { pr_err("cma_heap_add failed, ret=%d\n", rc); rc = -EINVAL; goto err; } err: return rc; } Copy to clipboard Note Align CMA regions to the 4 MB address base and size to support page migration. The migration happens at 2 ^pageblock\_order^ pages at the page-block level. The page-block order is 10 in the Qualcomm Linux kernel. ### Supported heaps The following table lists the heaps that are supported by default on the Qualcomm Linux distribution: Table: Default supported heaps | Heap name | Dev node | Description | Usage | | --- | --- | --- | --- | | System | /dev/dma_heap/system
Copy to clipboard | The kernel creates the default DMA-BUF heap. | All generic use cases must follow the system heap that uses the common Linux memory management buddy allocator underneath. | | Reserved | /dev/dma_heap/reserved
Copy to clipboard | The default CMA-type heap created in the system uses the default *reserved* CMA region. | If you need contiguous memory due to any constraints, use the CMA heap. | | Custom CMA heaps | /dev/dma_heap/my_cma_heap
Copy to clipboard | User-defined CMA-type heaps. | If you want to create your own CMA-type heap for specific custom CMA heaps. | ### Use DMA-BUF heaps DMA-BUF heaps are supported on the Qualcomm Linux distribution to assign custom CMA heaps. With DMA-BUF heaps, a device file is present for each heap in the `/dev/dma_heap` file system. Apart from the system heap and the common CMA reserved heap, you can create your own CMA-type DMA-BUF heaps. The following is a sample program that demonstrates how to use the DMA-BUF system heap created by the Qualcomm Linux kernel in `/dev/dma_heap/system:` include include include include include include include #include define DMA_HEAP_NAME "system" define SZ_4 0x00000004 // to allocate a 4K buffer int main() { int fd, dma_buf_fd; struct dma_heap_allocation_data dma_alloc_data = { .len = SZ_4, .fd_flags = O_RDWR | O_CLOEXEC, }; struct dma_buf_sync sync_start = { .flags = DMA_BUF_SYNC_START, }; struct dma_buf_sync sync_end = { .flags = DMA_BUF_SYNC_END, }; fd = open("/dev/dma_heap/system", O_RDWR); if (fd < 0) { perror("open"); return errno; } dma_buf_fd = ioctl(fd, DMA_HEAP_IOCTL_ALLOC, &dma_alloc_data); if (dma_buf_fd < 0) { perror("ioctl"); return errno; } printf("Allocated DMA buffer with fd %d\n", dma_buf_fd); if (ioctl(dma_buf_fd, DMA_BUF_IOCTL_SYNC, &sync_start)) { perror("ioctl DMA_BUF_IOCTL_SYNC start"); return errno; } // Do something with the buffer here if (ioctl(dma_buf_fd, DMA_BUF_IOCTL_SYNC, &sync_end)) { perror("ioctl DMA_BUF_IOCTL_SYNC end"); return errno; } if (close(dma_buf_fd)) { perror("close"); return errno; } if (close(fd)) { perror("close"); return errno; } return 0; } Copy to clipboard ### Configure ZRAM as a swap device ZRAM is a compressed swap mechanism that creates a virtual block device in RAM. ZRAM is enabled as a module within the kernel defconfig. ZRAM is configured in the Yocto build system in the `recipes-extended/zram/zram/zram-swap-init-update` file. To enable or configure ZRAM, do the following: # check if zram module is loaded lsmod | grep zram # else load it modprobe zram # Configure /dev/zram0 size according to your RAM size echo 128M > /sys/block/zram0/disksize # activate swap mkswap /dev/zram0 swapon /dev/zram0 Copy to clipboard To configure ZRAM as a swap device, see [zram: Compressed RAM-based block devices](https://www.kernel.org/doc/html/v6.6/admin-guide/blockdev/zram.html). ### Extend the memory map To extend the memory map, adjust the addresses and sizes of memory regions in a DTSI file. Use the following information to extend the carved out regions: Add the carved out region in the `arch/arm64/boot/dts/qcom/--.dts` file in the **reserved-memory** node using the following syntax: my_carveout_mem: my_carveout_mem@address { reg= <0x0 0xbase_address 0x0 0xsize>; no-map; } Copy to clipboard For example: my_carveout_mem: my_carveout_mem@d0800000 { reg= <0x0 0xd0800000 0x0 0x100000>; no-map; } Copy to clipboard Table: Syntax for carved out region | Variable | Description | | --- | --- | | my_carveout_mem@d0800000
Copy to clipboard | Indicates the name of the device node. The convention mandates that you append the base address of the memory region to the name. | | my_carveout_mem
Copy to clipboard | Indicates the label assigned to this node that can be used to reference this node from within the other nodes in the device tree using phandles. | | reg
Copy to clipboard | Indicates the property, which is a 64‑bit value that defines the base and size of the memory region. | | no-map
Copy to clipboard | Indicates that this region is carved out and the kernel should remove the mapping from its addressable range. | Note - None of the regions should overlap. If you must increase a region size, shift all other subsequent regions, and configure them in the device tree to avoid overlapping. - The kernel expects all memory region boundaries defined for kernel usage to be 1 MB. - Existing carved out regions are protected by trusted firmware from kernel access. Decreasing their size or deleting them may result in an external abort, leading to a kernel crash. **Add CMA region** To add the CMA region in the `arch/arm64/boot/dts/qcom/--.dts` file under **reserved-memory** node, use the following syntax: my_cma_mem: my_cma { compatible = "shared-dma-pool"; alloc-ranges = <0x0 0x00000000 0x0 0xffffffff>; reusable; alignment = <0x0 0x400000>; size = <0x0 0x1400000>; }; Copy to clipboard Table : Syntax for adding CMA region | Parameters | Description | | --- | --- | | my_cma_mem
Copy to clipboard | Label for the CMA node and can be accessed as a phandle. The label `my_cma` is the name of the CMA region. | | shared-dma-pool
Copy to clipboard | Indicates that this region is a CMA area. | | alloc-ranges
Copy to clipboard | Indicates if the region should be within a certain memory limit, as some devices can not access memory regions beyond the 32‑bit address limit. | | reusable
Copy to clipboard | Indicates that the kernel can use the memory in this region when it’s free. | | alignment
Copy to clipboard | Indicates any alignment requirements in this region. | | size
Copy to clipboard | Indicates the size of the region. | | reg
Copy to clipboard | This is an optional attribute that indicates the fixed region for memory allocation, in the absence of which memory is dynamically allocated at a random address. | Last Published: Jun 25, 2026 [Previous Topic Configure the remoteprocessor (remoteproc) subsystems](https://docs.qualcomm.com/bundle/publicresource/80-70030-3/topics/remoteproc-overview.md) [Next Topic Configure the scheduler](https://docs.qualcomm.com/bundle/publicresource/80-70030-3/topics/scheduler.md)