u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: u-boot@lists.denx.de
Cc: Marek Vasut <marek.vasut+renesas@gmail.com>,
	Tom Rini <trini@konsulko.com>,
	Alexey Brodkin <alexey.brodkin@synopsys.com>,
	Angelo Dureghello <angelo@sysam.it>,
	Daniel Schwierzeck <daniel.schwierzeck@gmail.com>,
	Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>,
	Hai Pham <hai.pham.ud@renesas.com>,
	Michal Simek <monstr@monstr.eu>,
	Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>,
	Wolfgang Denk <wd@denx.de>
Subject: [PATCH 04/12] lmb: Switch to generic arch_lmb_reserve_generic()
Date: Fri, 10 Sep 2021 22:47:10 +0200	[thread overview]
Message-ID: <20210910204718.17765-4-marek.vasut+renesas@gmail.com> (raw)
In-Reply-To: <20210910204718.17765-1-marek.vasut+renesas@gmail.com>

Switch arc/arm/m68k/microblaze/mips/ppc arch_lmb_reserve() to
arch_lmb_reserve_generic().

Reviewed-by: Tom Rini <trini@konsulko.com>
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>
---
V2: Add RB
---
 arch/arc/lib/cache.c        | 18 +-----------------
 arch/arm/lib/stack.c        | 33 +--------------------------------
 arch/m68k/lib/bootm.c       | 18 +-----------------
 arch/microblaze/lib/bootm.c | 28 +---------------------------
 arch/mips/lib/bootm.c       |  9 +--------
 arch/powerpc/lib/bootm.c    | 18 ++----------------
 6 files changed, 7 insertions(+), 117 deletions(-)

diff --git a/arch/arc/lib/cache.c b/arch/arc/lib/cache.c
index 4ba180482c..4c696cb53a 100644
--- a/arch/arc/lib/cache.c
+++ b/arch/arc/lib/cache.c
@@ -832,21 +832,5 @@ static ulong get_sp(void)
 
 void arch_lmb_reserve(struct lmb *lmb)
 {
-	ulong sp;
-
-	/*
-	 * 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;
-	lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp));
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
diff --git a/arch/arm/lib/stack.c b/arch/arm/lib/stack.c
index 3f961f4454..52d9f15298 100644
--- a/arch/arm/lib/stack.c
+++ b/arch/arm/lib/stack.c
@@ -45,36 +45,5 @@ static ulong get_sp(void)
 
 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;
-	}
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 }
diff --git a/arch/m68k/lib/bootm.c b/arch/m68k/lib/bootm.c
index 51a6f93858..27729db67e 100644
--- a/arch/m68k/lib/bootm.c
+++ b/arch/m68k/lib/bootm.c
@@ -32,23 +32,7 @@ static void set_clocks_in_mhz (struct bd_info *kbd);
 
 void arch_lmb_reserve(struct lmb *lmb)
 {
-	ulong sp;
-
-	/*
-	 * 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 1K to be safe */
-	sp -= 1024;
-	lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp));
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 1024);
 }
 
 int do_bootm_linux(int flag, int argc, char *const argv[],
diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c
index 6695ac63c7..3a6da6e29f 100644
--- a/arch/microblaze/lib/bootm.c
+++ b/arch/microblaze/lib/bootm.c
@@ -34,33 +34,7 @@ static ulong get_sp(void)
 
 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 (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, 4096);
 }
 
 static void boot_jump_linux(bootm_headers_t *images, int flag)
diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c
index fde90fced4..cab8da4860 100644
--- a/arch/mips/lib/bootm.c
+++ b/arch/mips/lib/bootm.c
@@ -39,14 +39,7 @@ static ulong arch_get_sp(void)
 
 void arch_lmb_reserve(struct lmb *lmb)
 {
-	ulong sp;
-
-	sp = arch_get_sp();
-	debug("## Current stack ends at 0x%08lx\n", sp);
-
-	/* adjust sp by 4K to be safe */
-	sp -= 4096;
-	lmb_reserve(lmb, sp, gd->ram_top - sp);
+	arch_lmb_reserve_generic(lmb, arch_get_sp(), gd->ram_top, 4096);
 }
 
 static void linux_cmdline_init(void)
diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c
index 31c17b5bb3..8d65047aa4 100644
--- a/arch/powerpc/lib/bootm.c
+++ b/arch/powerpc/lib/bootm.c
@@ -119,7 +119,7 @@ static void boot_jump_linux(bootm_headers_t *images)
 void arch_lmb_reserve(struct lmb *lmb)
 {
 	phys_size_t bootm_size;
-	ulong size, sp, bootmap_base;
+	ulong size, bootmap_base;
 
 	bootmap_base = env_get_bootm_low();
 	bootm_size = env_get_bootm_size();
@@ -141,21 +141,7 @@ void arch_lmb_reserve(struct lmb *lmb)
 		lmb_reserve(lmb, base, bootm_size - size);
 	}
 
-	/*
-	 * 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\n", sp);
-
-	/* adjust sp by 4K to be safe */
-	sp -= 4096;
-	lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + get_effective_memsize() - sp));
+	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
 
 #ifdef CONFIG_MP
 	cpu_mp_lmb_reserve(lmb);
-- 
2.33.0


  parent reply	other threads:[~2021-09-10 20:48 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Marek Vasut [this message]
2021-09-24  2:41   ` [PATCH 04/12] lmb: Switch to " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210910204718.17765-4-marek.vasut+renesas@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=Eugeniy.Paltsev@synopsys.com \
    --cc=alexey.brodkin@synopsys.com \
    --cc=angelo@sysam.it \
    --cc=daniel.schwierzeck@gmail.com \
    --cc=hai.pham.ud@renesas.com \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=monstr@monstr.eu \
    --cc=simon.k.r.goldschmidt@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=wd@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).