[PATCH v2 0/4] Relocate U-Boot in the last bank
Ilias Apalodimas
ilias.apalodimas at linaro.org
Tue Mar 31 10:01:10 CEST 2026
Hi,
This is v2 of [1]
There was a discussion recently on the mailing lists regarding our
management of memory above ram_top [0]. The tl;dr is that we have two problems.
The first one is that U-Boot always relocates to the top of the first available
bank unless there's special board code to sidestep that. The second is we don't
successfully deal with devices that can only do 32-bit DMA.
This patch series deals with the first problem by adding a Kconfig option
allowing platforms to relocate to the top of the last discovered bank.
It's worth noting that this is easily testable with QEMU
qemu-system-aarch64 -m 8192 -smp 2 -nographic -cpu cortex-a57 \
-machine virt,secure=off \
-bios u-boot.bin \
-device virtio-rng-pci \
-drive id=os,if=none,file="$image" \
-device virtio-blk-device,drive=os \
-object memory-backend-ram,id=ram0,size=4G \
-object memory-backend-ram,id=ram1,size=4G \
-numa node,memdev=ram0 \
-numa node,memdev=ram1
# RELOCATE_LAST_BANK not set
Hit any key to stop autoboot: 0
=> bdinfo
[...]
relocaddr = 0x000000013f66c000
reloc off = 0x000000013f66c000
[...]
lmb_dump_all:
memory.count = 0x1
memory[0] [0x40000000-0x23fffffff], 0x200000000 bytes, flags: none
reserved.count = 0x2
reserved[0] [0x13d507000-0x13d509fff], 0x3000 bytes, flags: no-notify, no-overwrite
reserved[1] [0x13d50aff0-0x23fffffff], 0x102af5010 bytes, flags: no-overwrite
devicetree = board
[...]
TLB addr = 0x000000013ffe0000
irq_sp = 0x000000013e50aff0
sp start = 0x000000013e50aff0
Early malloc usage: e88 / 2000
=>
# RELOCATE_LAST_BANK enabled
=> bdinfo
[...]
relocaddr = 0x000000023f66c000
reloc off = 0x000000023f66c000
[...]
lmb_dump_all:
memory.count = 0x1
memory[0] [0x40000000-0x23fffffff], 0x200000000 bytes, flags: none
reserved.count = 0x2
reserved[0] [0x23d507000-0x23d509fff], 0x3000 bytes, flags: no-notify, no-overwrite
reserved[1] [0x23d50aff0-0x23fffffff], 0x2af5010 bytes, flags: no-overwrite
devicetree = board
[...]
TLB addr = 0x000000023ffe0000
irq_sp = 0x000000023e50aff0
sp start = 0x000000023e50aff0
Early malloc usage: e88 / 2000
=>
[1] https://lore.kernel.org/u-boot/20260326115111.1631261-1-ilias.apalodimas@linaro.org/
Changes since v1:
- Adjusted the commit message of patch #4 and explain potential
breakages
- ram_size recalculation is now split in its own function
- Slighly better description of the Kconfig option
- error checking on fdtdec_setup_mem_ram_top()
Ilias Apalodimas (2):
fdtdec: Introduce fdtdec_setup_ram_size() to determine the memory size
common: Allow relocations on the top of the last bank
Marek Vasut (2):
fdtdec: Deduplicate iterator function
fdtdec: Introduce fdtdec_setup_mem_ram_top() to determine end of
topmost DRAM bank
Kconfig | 7 ++++
common/board_f.c | 15 +++++++
include/fdtdec.h | 31 ++++++++++++++
lib/fdtdec.c | 105 ++++++++++++++++++++++++++++-------------------
4 files changed, 115 insertions(+), 43 deletions(-)
--
2.53.0
More information about the U-Boot
mailing list