Change to allocate reserved_mems dynamically. Static reserved regions
must be reserved before any memblock allocations. The reserved_mems
array couldn't be allocated until memblock and linear mapping are ready.
So move the allocation and initialization of records and reserved memory
from early_init_fdt_scan_reserved_mem() to of_reserved_mem_init().
Signed-off-by: Calvin Zhang
---
arch/arc/mm/init.c | 3 ++
arch/arm/kernel/setup.c| 2 +
arch/arm64/kernel/setup.c | 3 ++
arch/csky/kernel/setup.c | 3 ++
arch/h8300/kernel/setup.c | 2 +
arch/mips/kernel/setup.c | 3 ++
arch/nds32/kernel/setup.c | 3 ++
arch/nios2/kernel/setup.c | 2 +
arch/openrisc/kernel/setup.c | 3 ++
arch/powerpc/kernel/setup-common.c | 3 ++
arch/riscv/kernel/setup.c | 2 +
arch/sh/kernel/setup.c | 3 ++
arch/xtensa/kernel/setup.c | 2 +
drivers/of/fdt.c | 1 -
drivers/of/of_reserved_mem.c | 66 --
15 files changed, 79 insertions(+), 22 deletions(-)
diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index ce4e939a7f07..a75f0e693f37 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -10,6 +10,7 @@
#include
#endif
#include
+#include
#include
#include
#include
@@ -165,6 +166,8 @@ void __init setup_arch_memory(void)
#endif /* CONFIG_HIGHMEM */
+ of_reserved_mem_init();
+
free_area_init(max_zone_pfn);
}
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 284a80c0b6e1..e76737effbf4 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -20,6 +20,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -1153,6 +1154,7 @@ void __init setup_arch(char **cmdline_p)
early_ioremap_reset();
paging_init(mdesc);
+ of_reserved_mem_init();
kasan_init();
request_standard_resources(mdesc);
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index be5f85b0a24d..4624e5193d6e 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -339,6 +340,8 @@ void __init __no_sanitize_address setup_arch(char
**cmdline_p)
paging_init();
+ of_reserved_mem_init();
+
acpi_table_upgrade();
/* Parse the ACPI tables for possible boot-time configuration */
diff --git a/arch/csky/kernel/setup.c b/arch/csky/kernel/setup.c
index c64e7be2045b..40878906644d 100644
--- a/arch/csky/kernel/setup.c
+++ b/arch/csky/kernel/setup.c
@@ -6,6 +6,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -64,6 +65,8 @@ static void __init csky_memblock_init(void)
#endif
memblock_set_current_limit(PFN_PHYS(max_low_pfn));
+ of_reserved_mem_init();
+
dma_contiguous_reserve(0);
free_area_init(max_zone_pfn);
diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
index 61091a76eb7e..0f0ec72a260e 100644
--- a/arch/h8300/kernel/setup.c
+++ b/arch/h8300/kernel/setup.c
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -87,6 +88,7 @@ static void __init bootmem_init(void)
early_init_fdt_reserve_self();
early_init_fdt_scan_reserved_mem();
+ of_reserved_mem_init();
memblock_dump_all();
}
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index f979adfd4fc2..053a10d80cb9 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -27,6 +27,7 @@
#include
#include
#include
+#include
#include
#include
@@ -776,6 +777,8 @@ void __init setup_arch(char **cmdline_p)
cpu_cache_init();
paging_init();
+ of_reserved_mem_init();
+
memblock_dump_all();
}
diff --git a/arch/nds32/kernel/setup.c b/arch/nds32/kernel/setup.c
index b3d34d646652..1054804526c5 100644
--- a/arch/nds32/kernel/setup.c
+++ b/arch/nds32/kernel/setup.c
@@ -10,6 +10,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -301,6 +302,8 @@ void __init setup_arch(char **cmdline_p)
/* paging_init() sets up the MMU and marks all pages as reserved */
paging_init();
+ of_reserved_mem_init();
+
/* invalidate all TLB entries because the new mapping is created */
__nds32__tlbop_flua();
diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c
index 40bc8fb75e0b..7e40e90bc3cd 100644
--- a/arch/nios2/kernel/setup.c
+++ b/arch/nios2/kernel/setup.c
@@ -19,6 +19,7 @@
#include
#include
#include
+#include
#include
#include
@@ -173,6 +174,7 @@ void __init setup_arch(char **cmdline_p)
early_init_fdt_reserve_self();
early_init_fdt_scan_reserved_mem();
+ of_reserved_mem_init();
unflatten_and_copy_device_tree();
diff --git a/arch/ope