[PATCH 06/46] csky: reserved_mem: Implement the new processing order for reserved memory

From: Oreoluwa Babatunde
Date: Fri Jan 26 2024 - 19:01:24 EST


Call early_fdt_scan_reserved_mem() in place of
early_init_fdt_scan_reserved_mem() to carry out the first stage of the
reserved memory processing only.

The early_fdt_scan_reserved_mem() function is used to scan through the
DT and mark all the reserved memory regions as reserved or nomap as
needed, as well as allocate the memory required by the
dynamically-placed
reserved memory regions.

The second stage of the reserved memory processing is done by
fdt_init_reserved_mem(). This function is used to store the information
of the statically-placed reserved memory nodes in the reserved_mem
array as well as call the region specific initialization function on all
the stored reserved memory regions.

The call to fdt_init_reserved_mem() is placed after setup_arch_memory()
in preparation for the dynamic allocation of the reserved_mem array
using memblock. This is because memblock allocated memory is not
writable until after the page tables have been setup on the csky
architecture.

Signed-off-by: Oreoluwa Babatunde <quic_obabatun@xxxxxxxxxxx>
---
arch/csky/kernel/setup.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/csky/kernel/setup.c b/arch/csky/kernel/setup.c
index 51012e90780d..4e2b739ac968 100644
--- a/arch/csky/kernel/setup.c
+++ b/arch/csky/kernel/setup.c
@@ -6,6 +6,7 @@
#include <linux/initrd.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
+#include <linux/of_reserved_mem.h>
#include <linux/start_kernel.h>
#include <linux/dma-map-ops.h>
#include <asm/sections.h>
@@ -22,7 +23,7 @@ static void __init csky_memblock_init(void)
memblock_reserve(__pa(_start), _end - _start);

early_init_fdt_reserve_self();
- early_init_fdt_scan_reserved_mem();
+ early_fdt_scan_reserved_mem();

memblock_dump_all();

@@ -72,6 +73,8 @@ void __init setup_arch(char **cmdline_p)

csky_memblock_init();

+ fdt_init_reserved_mem();
+
unflatten_and_copy_device_tree();

#ifdef CONFIG_SMP
--
2.17.1