[PATCH 29/46] xtensa: resrved_mem: Move fdt_init_reserved_mem() below unflatten_device_tree()

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


The unflattened devicetree structure is available to be used not long
after the page tables have been set up on most architectures, and is
available even before that on other architectures.

Hence, move the call to fdt_init_reserved_mem() to after
unflatten_device_tree() is called so that the reserved memory nodes can
be accessed using the unflattened device tree APIs.

Using the unflattened devicetree APIs is more efficient than using the
flattened devicetree APIs.

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

diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c
index bdec4a773af0..cb2fb993de76 100644
--- a/arch/xtensa/kernel/setup.c
+++ b/arch/xtensa/kernel/setup.c
@@ -25,6 +25,7 @@
#include <linux/cpu.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
+#include <linux/of_reserved_mem.h>

#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_DUMMY_CONSOLE)
# include <linux/console.h>
@@ -357,6 +358,7 @@ void __init setup_arch(char **cmdline_p)
kasan_init();
unflatten_and_copy_device_tree();

+ fdt_init_reserved_mem();
#ifdef CONFIG_SMP
smp_init_cpus();
#endif
diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
index ed3dd5f67b4a..e205a89a2097 100644
--- a/arch/xtensa/mm/init.c
+++ b/arch/xtensa/mm/init.c
@@ -26,7 +26,6 @@
#include <linux/nodemask.h>
#include <linux/mm.h>
#include <linux/of_fdt.h>
-#include <linux/of_reserved_mem.h>
#include <linux/dma-map-ops.h>

#include <asm/bootparam.h>
@@ -49,7 +48,6 @@ void __init bootmem_init(void)
memblock_reserve(0, PHYS_OFFSET ? PHYS_OFFSET : 1);

early_fdt_scan_reserved_mem();
- fdt_init_reserved_mem();

if (!memblock_phys_mem_size())
panic("No memory found!\n");
--
2.17.1