Skip to main content
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. 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/kodiak.dtsi file under the reserved-memory node.
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:

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:
The custom CMA regions are defined under the reserved-memory node with a shared-dma-pool compatible tag indicating the CMA region:
The following is the sample log for an aDSP CMA memory region reserved on boot:

Supported heaps

The following table lists the heaps that are supported by default on the Qualcomm Linux distribution: Table: Default supported 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:

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 in the recipes-extended/zram/zram/zram-swap-init-update file. To enable or configure ZRAM, do the following:
To configure ZRAM as a swap device, see zram: Compressed RAM-based block devices.

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/<SoC>-<board>-<variant>.dts file in the reserved-memory node using the following syntax:
For example:
Table: Syntax for carved out region
  • 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/<SoC>-<board>-<variant>.dts file under reserved-memory node, use the following syntax:
Table : Syntax for adding CMA region