diff mbox series

arm: bootm: wrong lmb region reservation when PRAM is used

Message ID VI1PR06MB4029E1CC5BB0B8777A317DB9D2849@VI1PR06MB4029.eurprd06.prod.outlook.com
State Needs Review / ACK
Delegated to: Tom Rini
Headers show
Series arm: bootm: wrong lmb region reservation when PRAM is used | expand

Commit Message

Aleksandar Gerasimovski Feb. 19, 2021, 9:46 p.m. UTC
This is a draft patch to describe the problem and to initiate
a discussion for solution.

PRAM usage is not taken into account when reserving lmb for ARM
architecture, this means that predefined PRAM region is reserved
by the u-boot and cannot be used by the u-boot users.

In our case this bug leads to non functional ramfs boot, as the PRAM and
ram rootfs address ranges are getting reserved by the u-boot.

It is obvious that here PRAM region is ignored, but my question is is this
clear to everyone and expected?

Taking  board_f.c as reference, when calculating relocation address PRAM
area is taken into account so I would expect that to be case here.
Here the intention is to reserve unused space at the end of the effective
RAM but PRAM is not part of that.

Possible solution would be to introduce something like
get_effective_memsize here e.g powerpc/lib/bootm.c but then also
NR_DRAM_BANKS has to be considered?

Signed-off-by: Aleksandar Gerasimovski <aleksandar.gerasimovski@hitachi-powergrids.com>
 arch/arm/lib/bootm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index 11af9e2..4b06d25 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -54,7 +54,7 @@  static ulong get_sp(void)
 void arch_lmb_reserve(struct lmb *lmb)
-	ulong sp, bank_end;
+	ulong sp, bank_end, pram = 0;
 	int bank;
@@ -69,6 +69,11 @@  void arch_lmb_reserve(struct lmb *lmb)
 	sp = get_sp();
 	debug("## Current stack ends at 0x%08lx ", sp);
+	pram = env_get_ulong("pram", 10, CONFIG_PRAM);
+	pram = pram << 10;	/* size is in kB */
 	/* adjust sp by 4K to be safe */
 	sp -= 4096;
 	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
@@ -76,8 +81,9 @@  void arch_lmb_reserve(struct lmb *lmb)
 		    sp < gd->bd->bi_dram[bank].start)
 		/* Watch out for RAM at end of address space! */
+		/* @todo: pram obviously wrong if NR_DRAM_BANKS > 1 */
 		bank_end = gd->bd->bi_dram[bank].start +
-			gd->bd->bi_dram[bank].size - 1;
+			   gd->bd->bi_dram[bank].size - pram - 1;
 		if (sp > bank_end)
 		if (bank_end > gd->ram_top)