2247936_en-US

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

2247936_en-US

2247936_en-US

How to adjust i.MX8MP's reserved-memory accroding different DDR size?

Hello NXP Experts,

We searched the entire community, but couldn’t find a satisfactory answer.

Following is the reserved-memory node in imx8mp.dtsi in NXP's Linux 6.12 

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
/*
* Memory reserved for optee usage. Please do not use.
* This will be automaticky added to dtb if OP-TEE is installed.
* optee@56000000 {
* reg = <0 0x56000000 0 0x2000000>;
* no-map;
* };
*/
/* global autoconfigured region for contiguous allocations */
linux,cma {
compatible = "shared-dma-pool";
reusable;
size = <0 0x3c000000>;
alloc-ranges = <0 0x40000000 0 0xC0000000>;
linux,cma-default;
};

gpu_reserved: gpu_reserved@100000000 {
no-map;
reg = <0x1 0x00000000 0 0x10000000>;
};

dsp_reserved: dsp@92400000 {
reg = <0 0x92400000 0 0x1000000>;
no-map;
};
dsp_reserved_heap: dsp_reserved_heap@93400000 {
reg = <0 0x93400000 0 0xef0000>;
no-map;
};
dsp_vdev0vring0: vdev0vring0@942f0000 {
reg = <0 0x942f0000 0 0x8000>;
no-map;
};

dsp_vdev0vring1: vdev0vring1@942f8000 {
reg = <0 0x942f8000 0 0x8000>;
no-map;
};

dsp_vdev0buffer: vdev0buffer@94300000 {
compatible = "shared-dma-pool";
reg = <0 0x94300000 0 0x100000>;
no-map;
};
};

1.How to adjust reserved-memory/linux,cma/size and reserved-memory/linux,cma/alloc-ranges for i.MX8MP with 2GB/4GB/8GB DDR size? (It is obvious that size(960MB) is to big for 2GB DDR and alloc-ranges also out of range of 2GB DDR)

2.Execpt linux,cma/size and linux,cma/alloc-ranges, are there any other propertys need be changed acroding different DDR size 2GB/4GB/8GB?

3.It is obvious that the reg of gpu_reserved node is out of range for 2GB ddr, how shoud it change?


we notice that reserved-memory/linux,cma/size&alloc-ranges is changed in NXP's linux6.12 arch/arm64/boot/dts/freescale/imx8mp-tqma8mpql-mba8mpxl.dts:

reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;

/* global autoconfigured region for contiguous allocations */
linux,cma {
compatible = "shared-dma-pool";
reusable;
size = <0 0x38000000>;
alloc-ranges = <0 0x40000000 0 0xB0000000>;
linux,cma-default;
};
};

4.What triggered this modification? Is it attributed to different DDR sizes?


we also notice that the node/reserved-memory is changed more in NXP's linux 6.12 arch/arm64/boot/dts/freescale/imx8mp-evk-root.dts.

&{/reserved-memory} {
jh_reserved: jh@fdc00000 {
no-map;
reg = <0 0xfdc00000 0x0 0x400000>;
};

loader_reserved: loader@fdb00000 {
no-map;
reg = <0 0xfdb00000 0x0 0x00100000>;
};

ivshmem_reserved: ivshmem@fda00000 {
no-map;
reg = <0 0xfda00000 0x0 0x00100000>;
};

ivshmem2_reserved: ivshmem2@fd900000 {
no-map;
reg = <0 0xfd900000 0x0 0x00100000>;
};

pci_reserved: pci@fd700000 {
no-map;
reg = <0 0xfd700000 0x0 0x00200000>;
};

inmate_reserved: inmate@c0000000 {
no-map;
reg = <0 0xc0000000 0x0 0x3d700000>;
};
};

&{/reserved-memory/linux,cma} {
size = <0 0x28000000>;
alloc-ranges = <0 0x40000000 0 0x60000000>;
};

 5. under what circumstances should the new-added node jh_reserved/loader_reserved/ivshmem_reserved/ivshmem2_reserved/pci_reserved/inmate_reserved be used? 

Please provide a detailed explanation to address my aforementioned doubts.

i.MX 8M | i.MX 8M Mini | i.MX 8M NanoRe: How to adjust i.MX8MP's reserved-memory accroding different DDR size?

Hello JorgeCas,

We really appreciate your assistance. We still have doubts about Quction6.

In our custom imx8mp boards with 2GB/4GB/8GB DDR(based on imx8mpevk board with 6GB DDR), we have a separate u-boot.imx for each board with different DDR size,  and keep the following 'memory@40000000' node unchange form imx8mp-evk.dts in linux6.12 source code.

memory@40000000 {
device_type = "memory";
reg = <0x0 0x40000000 0 0xc0000000>,
<0x1 0x00000000 0 0xc0000000>; //3GB+3GB=6GB
};

And our imx8mp boards run well. Also they can pass a hole night memtester.
Below is my imx8mp board with 4GB DDR:

root@router:/# free
total used free shared buff/cache available
Mem: 3686580 159528 2914044 19536 613008 3458156       //Recognizing a total of 3686580 KB is reasonable for 4GB DDR.
Swap: 0 0 0
root@router:/# /media/MCB2/memtester 3G
memtester version 4.3.0 (32-bit)
Copyright (C) 2001-2012 Charles Cazabon.
Licensed under the GNU General Public License version 2 (only).

pagesize is 4096
pagesizemask is 0xfffff000
want 3072MB (3221225472 bytes)
got 3072MB (3221225472 bytes), trying mlock ...locked.
Loop 1:
Stuck Address : testing 3[ 3326.210063] clean_cache.sh (100707): drop_caches: 1
[ 3326.277139] clean_cache.sh (100707): drop_caches: 2
[ 3326.316299] clean_cache.sh (100707): drop_caches: 3
ok
Random Value : ok
Compare XOR : ok
Compare SUB : ok
Compare MUL : ok
Compare DIV : ok
Compare OR : ok
Compare AND : ok
Sequential Increment: ok
Solid Bits : ok
Block Sequential : ok
Checkerboard : ok
Bit Spread : ok

... // Overnight testing showed no issues.

Here is the memory info in the kernel startup stage of 4GB DDR device:
[ 0.000000] Machine model: NXP i.MX8MPlus EVK board
[ 0.000000] efi: UEFI not found.
[ 0.000000] Reserved memory: created CMA memory pool at 0x00000000c4000000, size 960 MiB
[ 0.000000] OF: reserved mem: initialized node linux,cma, compatible id shared-dma-pool
[ 0.000000] OF: reserved mem: 0x00000000c4000000..0x00000000ffffffff (983040 KiB) map reusable linux,cma
[ 0.000000] OF: reserved mem: 0x0000000057c00000..0x0000000057ffffff (4096 KiB) nomap non-reusable optee_shm@0x57c00000
[ 0.000000] OF: reserved mem: 0x0000000056000000..0x0000000057bfffff (28672 KiB) nomap non-reusable optee_core@0x56000000
[ 0.000000] OF: reserved mem: 0x0000000100000000..0x000000010fffffff (262144 KiB) nomap non-reusable gpu_reserved@100000000
[ 0.000000] OF: reserved mem: 0x0000000092400000..0x00000000933fffff (16384 KiB) nomap non-reusable dsp@92400000
[ 0.000000] OF: reserved mem: 0x0000000093400000..0x00000000942effff (15296 KiB) nomap non-reusable dsp_reserved_heap@93400000
[ 0.000000] OF: reserved mem: 0x00000000942f0000..0x00000000942f7fff (32 KiB) nomap non-reusable vdev0vring0@942f0000
[ 0.000000] OF: reserved mem: 0x00000000942f8000..0x00000000942fffff (32 KiB) nomap non-reusable vdev0vring1@942f8000
[ 0.000000] Reserved memory: created DMA memory pool at 0x0000000094300000, size 1 MiB
[ 0.000000] OF: reserved mem: initialized node vdev0buffer@94300000, compatible id shared-dma-pool
[ 0.000000] OF: reserved mem: 0x0000000094300000..0x00000000943fffff (1024 KiB) nomap non-reusable vdev0buffer@94300000
[ 0.000000] NUMA: Faking a node at [mem 0x0000000040000000-0x000000013fffffff]
[ 0.000000] NODE_DATA(0) allocated [mem 0x13f84a840-0x13f84d3bf]
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000040000000-0x00000000ffffffff]
[ 0.000000] DMA32 empty
[ 0.000000] Normal [mem 0x0000000100000000-0x000000013fffffff]
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000040000000-0x0000000055ffffff]
[ 0.000000] node 0: [mem 0x0000000058000000-0x00000000923fffff]
[ 0.000000] node 0: [mem 0x0000000092400000-0x00000000943fffff]
[ 0.000000] node 0: [mem 0x0000000094400000-0x00000000ffffffff]
[ 0.000000] node 0: [mem 0x0000000100000000-0x000000010fffffff]
[ 0.000000] node 0: [mem 0x0000000110000000-0x000000013fffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000013fffffff]
[ 0.000000] On node 0, zone DMA: 8192 pages in unavailable ranges


1. Can you identify any unreasonable logs caused by the 6GB reg configuration in the memory@40000000 node for a actully 4GB DDR device?
2.So I speculate that the kernel does not calculate the memory range solely based on the memory@40000000/reg configuration in the DTS. Instead, it comprehensively determines the range by combining the actual physical memory size — which is passed from U-Boot to the kernel via ATAGs. In other words, I believe there may be no need to prepare separate DTB files for 2GB/4GB/8GB memory configurations. Could you please confirm this for us?

Thank you again.

Re: How to adjust i.MX8MP's reserved-memory accroding different DDR size?

Hello,

1.

There is no a specific documentation to adjust reserved-memory nodes in device tree since these values depends of the DDR size and you application, the only limitation will be the max memory region assigned for each module as is described in memory map of reference manual.

Default CMA size in BSP can be 960MB, as you mention for 2GB DDR, 960MB is too large and a common practice is to reduce CMA to 256MB–512MB or similar. You must focus in allocate in a valid DDR space.

2.

There is no need to add additional properties.

3.

You can re-organize each node according to the available size in your design, for example:

gpu_reserved: gpu_reserved@70000000 {
    no-map;
    reg = <0 0x70000000 0 0x10000000>;
};

Similar for the others.

4.

That device tree is used for reserved memory of hypervisors.

5.

These nodes are used for Jailhouse/PCIe/virtualization, if you don’t use them, you can omit these nodes.

You can use this document as reference for more information.

i.MX Virtualization User's Guide

6.

Yes, it should match to each DDR size.

Best regards.

Re: How to adjust i.MX8MP's reserved-memory accroding different DDR size?

Quction 6:(Additional )

Does the reg property in the memory@40000000 node(in arch/arm64/boot/dts/freescale/imx8mp-evk.dts) need to be modified according to the DDR capacity (2GB/4GB/8GB)?

memory@40000000 {
device_type = "memory";
reg = <0x0 0x40000000 0 0xc0000000>,
<0x1 0x00000000 0 0xc0000000>;
};
If yes, does this mean that our custom i.MX8MP boards with different DDR sizes require separate DTB files?

Thinks in advance!

Re: How to adjust i.MX8MP's reserved-memory accroding different DDR size?Hello JorgeCas,
Since the kernel will use the DDR size passed from U-boot, what is the purpose of configuring memory@40000000/reg in the DTS?
Re: How to adjust i.MX8MP's reserved-memory accroding different DDR size?

Hello, 

Thank you for the information.

1.

There are no critical logs such as errors or warnings, The Kernel just uses the memory range that is available from U-boot.

2.

Both U-boot and DTS configurations are used by the kernel. 

In device tree you can assign more virtual memory even if you do not have enough physical memory but if you have a lot of RAM usage, the system can crash. 

Best regards.

Re: How to adjust i.MX8MP's reserved-memory accroding different DDR size?

Hello,

I confirmed with internal team.

The U-boot configuration has the correct data about your available physical DDR memory but the DTS reserved memory node is also passed to the Kernel, in your case you can assign more virtual memory in the node but if you full all the physical reserved memory you will get errors because there is no available memory, the physical address does not exist or you will have resource issues because it may be used by other module.

You need to adapt the reserved memory to each board, as you mention, it works but if you have a lot if RAM usage, it is possible that you will get an error/kernel panic.

I will correct my last reply.

Best regards.

标记 (1)
无评分
版本历史
最后更新:
‎12-03-2025 04:24 AM
更新人: