lmb: Switch to generic arch_lmb_reserve_generic()
authorMarek Vasut <marek.vasut@gmail.com>
Fri, 10 Sep 2021 20:47:10 +0000 (22:47 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 23 Sep 2021 18:15:32 +0000 (14:15 -0400)
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>
arch/arc/lib/cache.c
arch/arm/lib/stack.c
arch/m68k/lib/bootm.c
arch/microblaze/lib/bootm.c
arch/mips/lib/bootm.c
arch/powerpc/lib/bootm.c

index 4ba1804..4c696cb 100644 (file)
@@ -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);
 }
index 3f961f4..52d9f15 100644 (file)
@@ -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);
 }
index 51a6f93..27729db 100644 (file)
@@ -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[],
index 6695ac6..3a6da6e 100644 (file)
@@ -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)
index fde90fc..cab8da4 100644 (file)
@@ -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)
index 31c17b5..8d65047 100644 (file)
@@ -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);