u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/12] lmb: Always compile arch_lmb_reserve() into U-Boot on arm
@ 2021-09-10 20:47 Marek Vasut
  2021-09-10 20:47 ` [PATCH 02/12] lmb: Always compile arch_lmb_reserve() into U-Boot on arc Marek Vasut
                   ` (11 more replies)
  0 siblings, 12 replies; 28+ messages in thread
From: Marek Vasut @ 2021-09-10 20:47 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Tom Rini, Simon Glass, Simon Goldschmidt

The arch_lmb_reserve() is called by lib/lmb.c lmb_reserve_common() even
if CMD_BOOT{I,M,Z} is not enabled. However, the arm32/arm64 variant of
arch_lmb_reserve() is only compiled in if CMD_BOOT{I,M,Z} is enabled.

This currently does not trigger build error, because there is an empty
weak implementation of arch_lmb_reserve(), however that is not the
function that should be used on arm32/arm64.

Fix this by moving the arch_lmb_reserve() implementation into common
code and always compile it in.

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
---
V2: Add RB
---
 arch/arm/lib/bootm.c | 45 --------------------------------------------
 arch/arm/lib/stack.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index f60ee3a7e6..dd6a69315a 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -16,7 +16,6 @@
 #include <command.h>
 #include <cpu_func.h>
 #include <dm.h>
-#include <lmb.h>
 #include <log.h>
 #include <asm/global_data.h>
 #include <dm/root.h>
@@ -43,50 +42,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static struct tag *params;
 
-static ulong get_sp(void)
-{
-	ulong ret;
-
-	asm("mov %0, sp" : "=r"(ret) : );
-	return ret;
-}
-
-void arch_lmb_reserve(struct lmb *lmb)
-{
-	ulong sp, bank_end;
-	int bank;
-
-	/*
-	 * Booting a (Linux) kernel image
-	 *
-	 * Allocate space for command line and board info - the
-	 * address should be as high as possible within the reach of
-	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
-	 * memory, which means far enough below the current stack
-	 * pointer.
-	 */
-	sp = get_sp();
-	debug("## Current stack ends at 0x%08lx ", sp);
-
-	/* adjust sp by 4K to be safe */
-	sp -= 4096;
-	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
-		if (!gd->bd->bi_dram[bank].size ||
-		    sp < gd->bd->bi_dram[bank].start)
-			continue;
-		/* Watch out for RAM at end of address space! */
-		bank_end = gd->bd->bi_dram[bank].start +
-			gd->bd->bi_dram[bank].size - 1;
-		if (sp > bank_end)
-			continue;
-		if (bank_end > gd->ram_top)
-			bank_end = gd->ram_top - 1;
-
-		lmb_reserve(lmb, sp, bank_end - sp + 1);
-		break;
-	}
-}
-
 __weak void board_quiesce_devices(void)
 {
 }
diff --git a/arch/arm/lib/stack.c b/arch/arm/lib/stack.c
index b03e1cfc80..3f961f4454 100644
--- a/arch/arm/lib/stack.c
+++ b/arch/arm/lib/stack.c
@@ -12,6 +12,7 @@
  */
 #include <common.h>
 #include <init.h>
+#include <lmb.h>
 #include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -33,3 +34,47 @@ int arch_reserve_stacks(void)
 
 	return 0;
 }
+
+static ulong get_sp(void)
+{
+	ulong ret;
+
+	asm("mov %0, sp" : "=r"(ret) : );
+	return ret;
+}
+
+void arch_lmb_reserve(struct lmb *lmb)
+{
+	ulong sp, bank_end;
+	int bank;
+
+	/*
+	 * Booting a (Linux) kernel image
+	 *
+	 * Allocate space for command line and board info - the
+	 * address should be as high as possible within the reach of
+	 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
+	 * memory, which means far enough below the current stack
+	 * pointer.
+	 */
+	sp = get_sp();
+	debug("## Current stack ends at 0x%08lx ", sp);
+
+	/* adjust sp by 4K to be safe */
+	sp -= 4096;
+	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
+		if (!gd->bd->bi_dram[bank].size ||
+		    sp < gd->bd->bi_dram[bank].start)
+			continue;
+		/* Watch out for RAM at end of address space! */
+		bank_end = gd->bd->bi_dram[bank].start +
+			gd->bd->bi_dram[bank].size - 1;
+		if (sp > bank_end)
+			continue;
+		if (bank_end > gd->ram_top)
+			bank_end = gd->ram_top - 1;
+
+		lmb_reserve(lmb, sp, bank_end - sp + 1);
+		break;
+	}
+}
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2021-09-24  2:45 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10 20:47 [PATCH 01/12] lmb: Always compile arch_lmb_reserve() into U-Boot on arm Marek Vasut
2021-09-10 20:47 ` [PATCH 02/12] lmb: Always compile arch_lmb_reserve() into U-Boot on arc Marek Vasut
2021-09-24  2:41   ` Tom Rini
2021-09-10 20:47 ` [PATCH 03/12] lmb: Add generic arch_lmb_reserve_generic() Marek Vasut
2021-09-10 21:10   ` Tom Rini
2021-09-12 19:27   ` Daniel Schwierzeck
2021-09-13  2:08     ` Marek Vasut
2021-09-24  2:41   ` Tom Rini
2021-09-10 20:47 ` [PATCH 04/12] lmb: Switch to " Marek Vasut
2021-09-24  2:41   ` Tom Rini
2021-09-10 20:47 ` [PATCH 05/12] lmb: arm: Increase LMB alignment to 16k in arch_lmb_reserve_generic() Marek Vasut
2021-09-10 21:10   ` Tom Rini
2021-09-24  2:42   ` Tom Rini
2021-09-10 20:47 ` [PATCH 06/12] lmb: Remove imx board_lmb_reserve() Marek Vasut
2021-09-24  2:42   ` Tom Rini
2021-09-10 20:47 ` [PATCH 07/12] lmb: nios2: Add arch_lmb_reserve() Marek Vasut
2021-09-24  2:42   ` Tom Rini
2021-09-10 20:47 ` [PATCH 08/12] lmb: nds32: " Marek Vasut
2021-09-24  2:42   ` Tom Rini
2021-09-10 20:47 ` [PATCH 09/12] lmb: riscv: " Marek Vasut
2021-09-24  2:42   ` Tom Rini
2021-09-10 20:47 ` [PATCH 10/12] lmb: sh: " Marek Vasut
2021-09-24  2:42   ` Tom Rini
2021-09-10 20:47 ` [PATCH 11/12] lmb: xtensa: " Marek Vasut
2021-09-24  2:42   ` Tom Rini
2021-09-10 20:47 ` [PATCH 12/12] lmb: x86: " Marek Vasut
2021-09-24  2:42   ` Tom Rini
2021-09-24  2:41 ` [PATCH 01/12] lmb: Always compile arch_lmb_reserve() into U-Boot on arm Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).