[PATCH] arm: bootm: wrong lmb region reservation when PRAM is used

Aleksandar Gerasimovski aleksandar.gerasimovski at hitachi-powergrids.com
Thu Jun 3 06:40:23 CEST 2021


Hi Folks,

I hope you are all doing well!
Is it possible this patch to get some attention?

Thanks!

Regards,
Aleksandar

-----Original Message-----
From: Tom Rini <trini at konsulko.com> 
Sent: Freitag, 30. April 2021 13:53
To: Aleksandar Gerasimovski <aleksandar.gerasimovski at hitachi-powergrids.com>; Patrick Delaunay <patrick.delaunay at foss.st.com>; Michal Simek <michal.simek at xilinx.com>; . Simon Goldschmidt <simon.k.r.goldschmidt at gmail.com>
Cc: u-boot at lists.denx.de
Subject: Re: [PATCH] arm: bootm: wrong lmb region reservation when PRAM is used

On Fri, Feb 19, 2021 at 09:46:49PM +0000, Aleksandar Gerasimovski wrote:

> 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 at hitachi-powergrids.com>
> ---
>  arch/arm/lib/bootm.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> 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);
>  
> +#ifdef CONFIG_PRAM
> +	pram = env_get_ulong("pram", 10, CONFIG_PRAM);
> +	pram = pram << 10;	/* size is in kB */
> +#endif
> +
>  	/* 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)
>  			continue;
>  		/* 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)
>  			continue;
>  		if (bank_end > gd->ram_top)

Adding a few folks who have touched lmb code relatively recently for their thoughts.  Thanks!

--
Tom


More information about the U-Boot mailing list