1. 为什么要开辟指定的空间
为了防止Wi-Fi长时间运行,导致的内存碎片化,Qualcomm Wi-Fi平台可以从内存空间中,划分出特定的CMA空间段,用以进行内存的申请和释放,下面我们重点介绍下,如何在i.MX8MP Linux 5.15.x平台上为QCA206x Wi-Fi 6/6E预留特定CMA空间的操作步骤。
2. Linux开辟特定的CMA空间
Linux 5.15.x中首先合入如下patch,为cnss driver提前预留CMA空间:
合入上如patch后,dmesg log如下所示:
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[ 0.000000] Linux version 5.15.71+gc7650dccb51c (oe-user@oe-host) (aarch64-poky-linux-gcc (GCC) 11.3.0, GNU ld (GNU Binutils) 2.38.20220708) #1 SMP PREEMPT Wed Apr 12 06:36:33 UTC 2023
[ 0.000000] Machine model: NXP i.MX8MPlus EVK board
[ 0.000000] OF: reserved mem: OVERLAP DETECTED!
[ 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] 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] Reserved memory: created DMA memory pool at 0x00000000a0000000, size 64 MiB // 物理地址的空间范围:0x00000000a0000000--0x00000000a4000000
[ 0.000000] OF: reserved mem: initialized node linux,cnss2, compatible id shared-dma-pool
3. Wi-Fi Driver使能特定CMA区域
下载Wi-Fi驱动:Sign in · GitLab
编译Wi-Fi驱动:
- 编译Wi-Fi驱动的时候,使能"CONFIG_USE_CUSTOMIZED_DMA_MEM=y"宏即可。