2024-01-26 23:58:03

by Oreoluwa Babatunde

[permalink] [raw]
Subject: [PATCH 04/46] ARM: reserved_mem: Implement the new processing order for reserved memory

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 paging_init()
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 arm
architecture.

Signed-off-by: Oreoluwa Babatunde <[email protected]>
---
arch/arm/kernel/setup.c | 4 ++++
arch/arm/mm/init.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index ff2299ce1ad7..8cf3709ed985 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -20,6 +20,7 @@
#include <linux/libfdt.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
+#include <linux/of_reserved_mem.h>
#include <linux/cpu.h>
#include <linux/interrupt.h>
#include <linux/smp.h>
@@ -1161,6 +1162,9 @@ void __init setup_arch(char **cmdline_p)
early_ioremap_reset();

paging_init(mdesc);
+
+ fdt_init_reserved_mem();
+
kasan_init();
request_standard_resources(mdesc);

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index a42e4cd11db2..e0a8e518ec31 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -193,7 +193,7 @@ void __init arm_memblock_init(const struct machine_desc *mdesc)
if (mdesc->reserve)
mdesc->reserve();

- early_init_fdt_scan_reserved_mem();
+ early_fdt_scan_reserved_mem();

/* reserve memory for DMA contiguous allocations */
dma_contiguous_reserve(arm_dma_limit);
--
2.17.1