[PATCH 08/46] microblaze: reserved_mem: Implement the new processing order for reserved memory

From: Oreoluwa Babatunde
Date: Fri Jan 26 2024 - 19:06:32 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_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 microblaze
architecture.

Signed-off-by: Oreoluwa Babatunde <quic_obabatun@xxxxxxxxxxx>
---
arch/microblaze/kernel/setup.c | 3 +++
arch/microblaze/mm/init.c | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c
index f417333eccae..631faa4613ec 100644
--- a/arch/microblaze/kernel/setup.c
+++ b/arch/microblaze/kernel/setup.c
@@ -29,6 +29,7 @@
#include <linux/pci.h>
#include <linux/cache.h>
#include <linux/of.h>
+#include <linux/of_reserved_mem.h>
#include <linux/dma-mapping.h>
#include <asm/cacheflush.h>
#include <asm/entry.h>
@@ -54,6 +55,8 @@ void __init setup_arch(char **cmdline_p)

setup_memory();

+ fdt_init_reserved_mem();
+
console_verbose();

unflatten_device_tree();
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 3827dc76edd8..9e73a1433dfa 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -262,7 +262,7 @@ asmlinkage void __init mmu_init(void)

parse_early_param();

- early_init_fdt_scan_reserved_mem();
+ early_fdt_scan_reserved_mem();

/* CMA initialization */
dma_contiguous_reserve(memory_start + lowmem_size - 1);
--
2.17.1