diff mbox series

[v2] lmb: Reserve U-Boot separately if relocation is disabled

Message ID 20211015154856.42090-1-marek.vasut@gmail.com
State Accepted
Delegated to: Tom Rini
Headers show
Series [v2] lmb: Reserve U-Boot separately if relocation is disabled | expand

Commit Message

Marek Vasut Oct. 15, 2021, 3:48 p.m. UTC
From: Marek Vasut <marek.vasut+renesas@gmail.com>

In case U-Boot starts with GD_FLG_SKIP_RELOC, the U-Boot code is
not relocated, however the stack and heap is at the end of DRAM
after relocation. Reserve a LMB area for the non-relocated U-Boot
code so it won't be overwritten.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
---
V2: Make this fully generic
---
 lib/lmb.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Simon Glass Oct. 24, 2021, 7:53 p.m. UTC | #1
On Fri, 15 Oct 2021 at 09:49, <marek.vasut@gmail.com> wrote:
>
> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>
> In case U-Boot starts with GD_FLG_SKIP_RELOC, the U-Boot code is
> not relocated, however the stack and heap is at the end of DRAM
> after relocation. Reserve a LMB area for the non-relocated U-Boot
> code so it won't be overwritten.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
> V2: Make this fully generic
> ---
>  lib/lmb.c | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Oct. 25, 2021, 6:32 p.m. UTC | #2
On Fri, Oct 15, 2021 at 05:48:56PM +0200, marek.vasut@gmail.com wrote:

> From: Marek Vasut <marek.vasut+renesas@gmail.com>
> 
> In case U-Boot starts with GD_FLG_SKIP_RELOC, the U-Boot code is
> not relocated, however the stack and heap is at the end of DRAM
> after relocation. Reserve a LMB area for the non-relocated U-Boot
> code so it won't be overwritten.
> 
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
> V2: Make this fully generic
> ---
>  lib/lmb.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/lib/lmb.c b/lib/lmb.c
> index 676b3a0bda..d868633899 100644
> --- a/lib/lmb.c
> +++ b/lib/lmb.c
> @@ -13,6 +13,7 @@
>  #include <malloc.h>
>  
>  #include <asm/global_data.h>
> +#include <asm/sections.h>
>  
>  DECLARE_GLOBAL_DATA_PTR;
>  
> @@ -144,6 +145,10 @@ void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align)
>  			bank_end = end - 1;
>  
>  		lmb_reserve(lmb, sp, bank_end - sp + 1);
> +
> +		if (gd->flags & GD_FLG_SKIP_RELOC)
> +			lmb_reserve(lmb, (phys_addr_t)_start, gd->mon_len);
> +
>  		break;
>  	}
>  }

I now see:
   sandbox:  w+   sandbox
+  150 |                         lmb_reserve(lmb, (phys_addr_t)_start, gd->mon_len);
+      |                                          ^
w+lib/lmb.c: In function 'arch_lmb_reserve_generic':
w+lib/lmb.c:150:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
diff mbox series

Patch

diff --git a/lib/lmb.c b/lib/lmb.c
index 676b3a0bda..d868633899 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -13,6 +13,7 @@ 
 #include <malloc.h>
 
 #include <asm/global_data.h>
+#include <asm/sections.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -144,6 +145,10 @@  void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align)
 			bank_end = end - 1;
 
 		lmb_reserve(lmb, sp, bank_end - sp + 1);
+
+		if (gd->flags & GD_FLG_SKIP_RELOC)
+			lmb_reserve(lmb, (phys_addr_t)_start, gd->mon_len);
+
 		break;
 	}
 }