diff mbox series

[v5,1/2] sh: Restructure call site for early_reserve_mem()

Message ID 20240718021822.1545976-2-quic_obabatun@quicinc.com (mailing list archive)
State New
Headers show
Series sh: Restructure setup code to reserve memory regions earlier | expand

Commit Message

Oreoluwa Babatunde July 18, 2024, 2:18 a.m. UTC
early_reserve_mem() reserves memory for important regions in the kernel
such as kernel text region and bootmem bitmap.
Reserving these memory regions should take precedence over any other
reserved memory allocations so that the system does not unknowingly
reserve them for some other use case.

Hence, move the call site of early_reserve_mem() out of the
paging_init() function and into an earlier point in setup_arch()

Signed-off-by: Oreoluwa Babatunde <quic_obabatun@quicinc.com>
---
 arch/sh/include/asm/mmu.h | 1 +
 arch/sh/kernel/setup.c    | 3 +++
 arch/sh/mm/init.c         | 5 ++---
 3 files changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/arch/sh/include/asm/mmu.h b/arch/sh/include/asm/mmu.h
index 172e329fd92d..696e303a2f19 100644
--- a/arch/sh/include/asm/mmu.h
+++ b/arch/sh/include/asm/mmu.h
@@ -96,6 +96,7 @@  static inline int pmb_unmap(void __iomem *addr)
 
 #endif /* CONFIG_PMB */
 
+void __init early_reserve_mem(void);
 static inline void __iomem *
 pmb_remap(phys_addr_t phys, unsigned long size, pgprot_t prot)
 {
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 620e5cf8ae1e..3b0bc191a2a2 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -40,6 +40,7 @@ 
 #include <asm/setup.h>
 #include <asm/clock.h>
 #include <asm/smp.h>
+#include <asm/mmu.h>
 #include <asm/mmu_context.h>
 #include <asm/mmzone.h>
 #include <asm/processor.h>
@@ -319,6 +320,8 @@  void __init setup_arch(char **cmdline_p)
 
 	sh_mv_setup();
 
+	early_reserve_mem();
+
 	/* Let earlyprintk output early console messages */
 	sh_early_platform_driver_probe("earlyprintk", 1, 1);
 
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index bf1b54055316..643e3617c6a6 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -19,6 +19,7 @@ 
 #include <linux/io.h>
 #include <linux/dma-mapping.h>
 #include <linux/export.h>
+#include <asm/mmu.h>
 #include <asm/mmu_context.h>
 #include <asm/mmzone.h>
 #include <asm/kexec.h>
@@ -242,7 +243,7 @@  static void __init do_init_bootmem(void)
 	sparse_init();
 }
 
-static void __init early_reserve_mem(void)
+void __init early_reserve_mem(void)
 {
 	unsigned long start_pfn;
 	u32 zero_base = (u32)__MEMORY_START + (u32)PHYSICAL_OFFSET;
@@ -282,8 +283,6 @@  void __init paging_init(void)
 
 	sh_mv.mv_mem_init();
 
-	early_reserve_mem();
-
 	/*
 	 * Once the early reservations are out of the way, give the
 	 * platforms a chance to kick out some memory.