diff mbox series

[14/14] lmb: Switch imx board_lmb_reserve() to arch_lmb_reserve()

Message ID 20210815181314.132330-14-marek.vasut+renesas@gmail.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series [01/14] configs: Disable LMB and BDI for tools-only | expand

Commit Message

Marek Vasut Aug. 15, 2021, 6:13 p.m. UTC
This function is clearly architecture specific code, not board specific
code. The only difference from the generic arm arch_lmb_reserve() is the
extra reservation of 16k of memory below the stack bottom, rather than
the default 4k. Switch this from board_lmb_reserve() to arch_lmb_reserve()
and use arch_lmb_reserve_generic() with 16k stack reservation parameter
instead of replicating older version of arch_lmb_reserve() here.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
Cc: Angelo Dureghello <angelo@sysam.it>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Cc: Hai Pham <hai.pham.ud@renesas.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Ye Li <ye.li@nxp.com>
---
 arch/arm/mach-imx/misc.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

Comments

Tom Rini Aug. 15, 2021, 7:47 p.m. UTC | #1
On Sun, Aug 15, 2021 at 08:13:14PM +0200, Marek Vasut wrote:

> This function is clearly architecture specific code, not board specific
> code. The only difference from the generic arm arch_lmb_reserve() is the
> extra reservation of 16k of memory below the stack bottom, rather than
> the default 4k. Switch this from board_lmb_reserve() to arch_lmb_reserve()
> and use arch_lmb_reserve_generic() with 16k stack reservation parameter
> instead of replicating older version of arch_lmb_reserve() here.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Alexey Brodkin <alexey.brodkin@synopsys.com>
> Cc: Angelo Dureghello <angelo@sysam.it>
> Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
> Cc: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
> Cc: Hai Pham <hai.pham.ud@renesas.com>
> Cc: Michal Simek <monstr@monstr.eu>
> Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Ye Li <ye.li@nxp.com>
> ---
>  arch/arm/mach-imx/misc.c | 21 ++-------------------
>  1 file changed, 2 insertions(+), 19 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/misc.c b/arch/arm/mach-imx/misc.c
> index d82efa7f8f..529601156f 100644
> --- a/arch/arm/mach-imx/misc.c
> +++ b/arch/arm/mach-imx/misc.c
> @@ -86,24 +86,7 @@ static ulong get_sp(void)
>  	return ret;
>  }
>  
> -void board_lmb_reserve(struct lmb *lmb)
> +void arch_lmb_reserve(struct lmb *lmb)
>  {
> -	ulong sp, bank_end;
> -	int bank;
> -
> -	sp = get_sp();
> -	debug("## Current stack ends at 0x%08lx ", sp);
> -
> -	/* adjust sp by 16K to be safe */
> -	sp -= 4096 << 2;
> -	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
> -		if (sp < gd->bd->bi_dram[bank].start)
> -			continue;
> -		bank_end = gd->bd->bi_dram[bank].start +
> -			gd->bd->bi_dram[bank].size;
> -		if (sp >= bank_end)
> -			continue;
> -		lmb_reserve(lmb, sp, bank_end - sp);
> -		break;
> -	}
> +	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 16384);
>  }

As I previously said, this should be the generic ARM one.  And arguably
all device-tree using architectures should give themselves more headroom
here, based on the additional context we got.  Calling the iMX entry
the arch one is wrong.  If we don't want to address the general problem
more, we should keep this as a board one that reserves an additional
12KiB.
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/misc.c b/arch/arm/mach-imx/misc.c
index d82efa7f8f..529601156f 100644
--- a/arch/arm/mach-imx/misc.c
+++ b/arch/arm/mach-imx/misc.c
@@ -86,24 +86,7 @@  static ulong get_sp(void)
 	return ret;
 }
 
-void board_lmb_reserve(struct lmb *lmb)
+void arch_lmb_reserve(struct lmb *lmb)
 {
-	ulong sp, bank_end;
-	int bank;
-
-	sp = get_sp();
-	debug("## Current stack ends at 0x%08lx ", sp);
-
-	/* adjust sp by 16K to be safe */
-	sp -= 4096 << 2;
-	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
-		if (sp < gd->bd->bi_dram[bank].start)
-			continue;
-		bank_end = gd->bd->bi_dram[bank].start +
-			gd->bd->bi_dram[bank].size;
-		if (sp >= bank_end)
-			continue;
-		lmb_reserve(lmb, sp, bank_end - sp);
-		break;
-	}
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 16384);
 }