iMX7D - missing 256MB RAM when start RPMsg FreeRTOS on M4

Today I spot one strange thing.
When I load M4 firmware according to
[link text][1]
Linux kernel recognize only 256MB of RAM

<\n>[    0.000000] Booting Linux on physical CPU 0x0<\r>
<\n>[    0.000000] Initializing cgroup subsys cpu<\r>
<\n>[    0.000000] Initializing cgroup subsys cpuacct<\r>
<\n>[    0.000000] Linux version 4.1.41-00683-g756b319-dirty (test@ubuntu) (gcc version 5.2.1 20151005 (Linaro GCC 5.2-2015.11-2) ) #9 SMP Thu Jul 13 11:29:58 IST 2017<\r>
<\n>[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d<\r>
<\n>[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache<\r>
<\n>[    0.000000] Machine model: Toradex Colibri iMX7D on Colibri Evaluation Board V3<\r>
<\n>[    0.000000] Reserved memory: created CMA memory pool at 0x86000000, size 128 MiB<\r>
<\n>[    0.000000] Reserved memory: initialized node linux,cma, compatible id shared-dma-pool<\r>
<\n>[    0.000000] Memory policy: Data cache writealloc<\r>
<\n>[    0.000000] PERCPU: Embedded 12 pages/cpu @8fb8b000 s16960 r8192 d24000 u49152<\r>
<\n>[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 64516<\r>
<\n>[    0.000000] Kernel command line: ubi.mtd=ubi root=ubi0:rootfs rootfstype=ubifs ubi.fm_autoconvert=1 console=tty1 console=ttymxc0,115200n8 consoleblank=0 video=mxsfb:640x480M-16@60<\r>
<\n>[    0.000000] PID hash table entries: 1024 (order: 0, 4096 bytes)<\r>
<\n>[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)<\r>
<\n>[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)<\r>
<\n>[    0.000000] Memory: 117284K/260096K available (6060K kernel code, 285K rwdata, 1928K rodata, 312K init, 377K bss, 11740K reserved, 131072K cma-reserved)<\r>

but without automatic M4 firmware in uboot I have 512MB as it should be.

<\n>[    0.000000] Booting Linux on physical CPU 0x0<\r>
<\n>[    0.000000] Initializing cgroup subsys cpu<\r>
<\n>[    0.000000] Initializing cgroup subsys cpuacct<\r>
<\n>[    0.000000] Linux version 4.1.41-00683-g756b319-dirty (test@ubuntu) (gcc version 5.2.1 20151005 (Linaro GCC 5.2-2015.11-2) ) #9 SMP Thu Jul 13 11:29:58 IST 2017<\r>
<\n>[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d<\r>
<\n>[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache<\r>
<\n>[    0.000000] Machine model: Toradex Colibri iMX7D on Colibri Evaluation Board V3<\r>
<\n>[    0.000000] Truncating RAM at 0xc0000000-0xffffffff to -0xef800000<\r>
<\n>[    0.000000] Reserved memory: created CMA memory pool at 0x96000000, size 128 MiB<\r>
<\n>[    0.000000] Reserved memory: initialized node linux,cma, compatible id shared-dma-pool<\r>
<\n>[    0.000000] Memory policy: Data cache writealloc<\r>
<\n>[    0.000000] PERCPU: Embedded 12 pages/cpu @9f989000 s16960 r8192 d24000 u49152<\r>
<\n>[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 129540<\r>
<\n>[    0.000000] Kernel command line: ubi.mtd=ubi root=ubi0:rootfs rootfstype=ubifs ubi.fm_autoconvert=1 console=tty1 console=ttymxc0,115200n8 consoleblank=0 video=mxsfb:640x480M-16@60<\r>
<\n>[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)<\r>
<\n>[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)<\r>
<\n>[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)<\r>
<\n>[    0.000000] Memory: 377184K/522240K available (6060K kernel code, 285K rwdata, 1928K rodata, 312K init, 377K bss, 13984K reserved, 131072K cma-reserved)<\r>

Im using latest u-boot and kernel build, Device Tree slightly modified for custom board. I assume that this could be related with VRING0/1_BASE address of RPMsg .
Do I have to change it if I need full 512MB of RAM??
[1]: FreeRTOS on the Cortex-M4 of a Colibri iMX7 | Toradex Developer Center

I was able to reproduce this at my end. Created a ticket internally on this issue and we will try to locate the root cause.

Great. Thanks

It turns out that Linux cannot handle the 1MiB carved out area well. Increasing it to 2MiB, which is ARM Linux’ page middle directory (PMD) size, seems to regain access to the rest of the memory. I pushed a fix for U-Boot to our git tree:

http://git1.toradex.com/cgit/u-boot-toradex.git/commit/?h=2016.11-toradex-next&id=4107d058835967d258403f54ec73245b8c450eab

Tested this and it does fix the issue.