[PATCH 05/46] arm64: reserved_mem: Implement the new processing order for reserved memory

From: Oreoluwa Babatunde
Date: Fri Jan 26 2024 - 19:01:44 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 arm64
architecture.

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

diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 42c690bb2d60..2a9e98104af7 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -27,6 +27,7 @@
#include <linux/proc_fs.h>
#include <linux/memblock.h>
#include <linux/of_fdt.h>
+#include <linux/of_reserved_mem.h>
#include <linux/efi.h>
#include <linux/psci.h>
#include <linux/sched/task.h>
@@ -346,6 +347,8 @@ void __init __no_sanitize_address setup_arch(char **cmdline_p)

paging_init();

+ fdt_init_reserved_mem();
+
acpi_table_upgrade();

/* Parse the ACPI tables for possible boot-time configuration */
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 74c1db8ce271..0fe8587e550c 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -310,7 +310,7 @@ void __init arm64_memblock_init(void)
initrd_end = initrd_start + phys_initrd_size;
}

- early_init_fdt_scan_reserved_mem();
+ early_fdt_scan_reserved_mem();

high_memory = __va(memblock_end_of_DRAM() - 1) + 1;
}
--
2.17.1