|
| 1 | + |
| 2 | +How to Configure the CMA Size |
| 3 | +============================= |
| 4 | + |
| 5 | +Contiguous Memory allocation (CMA) is commonly used by memory-to-memory (M2M) devices that do not have |
| 6 | +have MMU support. By default in Linux, the CMA size will be 32 MB. For the common TI board, this is far |
| 7 | +too small. There are a handful of components that need to use CMA in order for proper operation as well as |
| 8 | +achieving optimal performance. These components include, but are not limited to, the multimedia Codecs, CSI, |
| 9 | +and TIDSS. TI has already increased the amount of CMA that comes in |__SDK_FULL_NAME__|. The amount that has |
| 10 | +been allocated can be checked by running the following command on target: |
| 11 | + |
| 12 | +.. code-block:: console |
| 13 | +
|
| 14 | + target$ cat /proc/meminfo | grep Cma |
| 15 | +
|
| 16 | +After executing, an output similar to the one below will be seen. |
| 17 | + |
| 18 | +.. code-block:: console |
| 19 | +
|
| 20 | + CmaTotal: 589824 kB |
| 21 | + CmaFree: 583984 kB |
| 22 | +
|
| 23 | +These logs can be used to obtain the amount of CMA that has been allocated and how much of that is still available |
| 24 | +for use. Depending on the particular use case, it may be of interest to decrease the size of this allocation pool. |
| 25 | +To do so, locate the device tree (.dts) file that contains the main domain for the target board. For example, if |
| 26 | +using the AM62PX SoC, open up :file:`arch/arm64/boot/dts/ti/k3-am62p5-sk.dts`. These device tree files contain a |
| 27 | +node for reserved memory. A portion of this reserved memory area is for CMA, therefore the area has been named |
| 28 | +`linux,cma`. This node contains an attribute called size; changing the value of this attribute cause the CMA region |
| 29 | +to grow or shrink. Once attribute is changed to desired value, save and close the dts file so it can be compiled into |
| 30 | +proper device tree blob (.dtb). Update the target with new .dtb file and check that new CMA region matches the size |
| 31 | +set in the device tree. |
| 32 | + |
| 33 | +CMA allocation can also be changed without re-compilation of device tree. One can stop at u-boot prompt during boot |
| 34 | +and update the CMA parameter as shown below: |
| 35 | + |
| 36 | +.. code-block:: console |
| 37 | +
|
| 38 | + target # setenv args_all $args_all cma=1000M |
| 39 | + target # boot |
| 40 | +
|
| 41 | +.. note:: |
| 42 | + |
| 43 | + Allocating at u-boot tends to place the CMA in the lower 32 bit region of memory. Many of the common components have been |
| 44 | + ported to operate in the higher 48 bit region of memory. It is recommended to take the approach with changing device tree, |
| 45 | + but this method is fine for quick validation. |
0 commit comments