[tip: x86/platform] x86/of: Move the x86_flattree_get_config() call out of x86_dtb_init()

From: tip-bot2 for Saurabh Sengar
Date: Mon Oct 02 2023 - 15:41:11 EST


The following commit has been merged into the x86/platform branch of tip:

Commit-ID: 0d294c8c4efa5c0f283a6dfc82dc014a5dbd9308
Gitweb: https://git.kernel.org/tip/0d294c8c4efa5c0f283a6dfc82dc014a5dbd9308
Author: Saurabh Sengar <ssengar@xxxxxxxxxxxxxxxxxxx>
AuthorDate: Fri, 25 Aug 2023 00:47:36 -07:00
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitterDate: Mon, 02 Oct 2023 21:30:09 +02:00

x86/of: Move the x86_flattree_get_config() call out of x86_dtb_init()

Fetching the device tree configuration before initmem_init() is necessary
to allow the parsing of NUMA node information. However moving the entire
x86_dtb_init() call before initmem_init() is not correct as APIC/IO-APIC enumeration
has to be after initmem_init().

Thus, move the x86_flattree_get_config() call out of x86_dtb_init(),
into setup_arch(), to call it before initmem_init(), and
leave the ACPI/IOAPIC registration sequence as-is.

[ mingo: Updated the changelog for clarity. ]

Signed-off-by: Saurabh Sengar <ssengar@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
Link: https://lore.kernel.org/r/1692949657-16446-1-git-send-email-ssengar@xxxxxxxxxxxxxxxxxxx
---
arch/x86/include/asm/prom.h | 5 +++++
arch/x86/kernel/devicetree.c | 6 +-----
arch/x86/kernel/setup.c | 2 ++
3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/x86/include/asm/prom.h b/arch/x86/include/asm/prom.h
index b716d29..65dee24 100644
--- a/arch/x86/include/asm/prom.h
+++ b/arch/x86/include/asm/prom.h
@@ -31,6 +31,11 @@ static inline void x86_dtb_init(void) { }
#define of_ioapic 0
#endif

+#ifdef CONFIG_OF_EARLY_FLATTREE
+void x86_flattree_get_config(void);
+#else
+static inline void x86_flattree_get_config(void) { }
+#endif
extern char cmd_line[COMMAND_LINE_SIZE];

#endif /* __ASSEMBLY__ */
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c
index 87d38f1..afd0992 100644
--- a/arch/x86/kernel/devicetree.c
+++ b/arch/x86/kernel/devicetree.c
@@ -278,7 +278,7 @@ static void __init dtb_apic_setup(void)
}

#ifdef CONFIG_OF_EARLY_FLATTREE
-static void __init x86_flattree_get_config(void)
+void __init x86_flattree_get_config(void)
{
u32 size, map_len;
void *dt;
@@ -300,14 +300,10 @@ static void __init x86_flattree_get_config(void)
unflatten_and_copy_device_tree();
early_memunmap(dt, map_len);
}
-#else
-static inline void x86_flattree_get_config(void) { }
#endif

void __init x86_dtb_init(void)
{
- x86_flattree_get_config();
-
if (!of_have_populated_dt())
return;

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index b9145a6..ef73704 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -1221,6 +1221,8 @@ void __init setup_arch(char **cmdline_p)

early_acpi_boot_init();

+ x86_flattree_get_config();
+
initmem_init();
dma_contiguous_reserve(max_pfn_mapped << PAGE_SHIFT);