Skip to contentSkip to conversation

x86/of: split x86_dtb_init for early x86_flattree_get_config call

PATCH Applied Saurabh Sengar 2 participants 5 messages Aug 25, 2023 – Oct 2, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 x86/of: split x86_dtb_init for early x86_flattree_get_config call

Fetching the device tree configuration before initmem_init is necessary to allow the parsing of NUMA node information. However moving entire x86_dtb_init before initmem_init is not correct as APIC/IO-APIC enumeration has to be after initmem_init. Thus, split the x86_dtb_init function to incorporate a call to x86_flattree_get_config before initmem_init, and leaving the ACPI/IOAPIC registration sequence as is.

---
[V2]
- split the x86_dtb_init to call x86_flattree_get_config early

 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(-)
arch/x86/include/asm/prom.h +5 -0
index b716d291d0d4..65dee2420624 100644
@@ -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__ */
arch/x86/kernel/devicetree.c +1 -5
index 87d38f17ff5c..afd09924094e 100644
@@ -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;
 
arch/x86/kernel/setup.c +2 -0
index b9145a63da77..ef73704fa27f 100644
@@ -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);
 
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 2/2 x86/numa: Add Devicetree support

Hyper-V has usecases where it need to fetch NUMA information from Devicetree. Currently, it is not possible to extract the NUMA information from Devicetree for x86 arch.

Add support for Devicetree in the x86_numa_init function, allowing the retrieval of NUMA node information from the Devicetree.

---
 arch/x86/Kconfig   | 1 +
 arch/x86/mm/numa.c | 3 +++
 2 files changed, 4 insertions(+)
arch/x86/Kconfig +1 -0
index 982b777eadc7..16ac287e9628 100644
@@ -1534,6 +1534,7 @@ config NUMA
 	depends on X86_64 || (X86_32 && HIGHMEM64G && X86_BIGSMP)
 	default y if X86_BIGSMP
 	select USE_PERCPU_NUMA_NODE_ID
+	select OF_NUMA if OF
 	help
 	  Enable NUMA (Non-Uniform Memory Access) support.
 
arch/x86/mm/numa.c +3 -0
index 2aadb2019b4f..c79f12e449ea 100644
@@ -3,6 +3,7 @@
 #include <linux/acpi.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/of.h>
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/memblock.h>
@@ -733,6 +734,8 @@ void __init x86_numa_init(void)
 		if (!numa_init(amd_numa_init))
 			return;
 #endif
+		if (acpi_disabled && !numa_init(of_numa_init))
+			return;
 	}
 
 	numa_init(dummy_numa_init);
Signature · 1 line
2.34.1
merge bot Applied
#2 lore raw

[tip: x86/platform] x86/numa: Add Devicetree support

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

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

Commit-ID:     0c436a58292d0ca1af213ede75b2508995c8af0b
Gitweb:        https://git.kernel.org/tip/0c436a58292d0ca1af213ede75b2508995c8af0b
Author:        Saurabh Sengar <[email protected]>
AuthorDate:    Fri, 25 Aug 2023 00:47:37 -07:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Mon, 02 Oct 2023 21:30:20 +02:00

x86/numa: Add Devicetree support

Hyper-V has usecases where it needs to fetch NUMA information from Devicetree. Currently, it is not possible to extract the NUMA information from Devicetree for the x86 arch.

Add support for Devicetree in the x86_numa_init() function, allowing the retrieval of NUMA node information from the Devicetree.

---
 arch/x86/Kconfig   | 1 +
 arch/x86/mm/numa.c | 3 +++
 2 files changed, 4 insertions(+)
arch/x86/Kconfig +1 -0
index 66bfaba..aab5e32 100644
@@ -1534,6 +1534,7 @@ config NUMA
 	depends on X86_64 || (X86_32 && HIGHMEM64G && X86_BIGSMP)
 	default y if X86_BIGSMP
 	select USE_PERCPU_NUMA_NODE_ID
+	select OF_NUMA if OF
 	help
 	  Enable NUMA (Non-Uniform Memory Access) support.
 
arch/x86/mm/numa.c +3 -0
index 2aadb20..c79f12e 100644
@@ -3,6 +3,7 @@
 #include <linux/acpi.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/of.h>
 #include <linux/string.h>
 #include <linux/init.h>
 #include <linux/memblock.h>
@@ -733,6 +734,8 @@ void __init x86_numa_init(void)
 		if (!numa_init(amd_numa_init))
 			return;
 #endif
+		if (acpi_disabled && !numa_init(of_numa_init))
+			return;
 	}
 
 	numa_init(dummy_numa_init);
#3 lore raw
In reply to Saurabh Sengar
Quoted 76 lines · Saurabh Sengar

Fetching the device tree configuration before initmem_init is necessary to allow the parsing of NUMA node information. However moving entire x86_dtb_init before initmem_init is not correct as APIC/IO-APIC enumeration has to be after initmem_init. Thus, split the x86_dtb_init function to incorporate a call to x86_flattree_get_config before initmem_init, and leaving the ACPI/IOAPIC registration sequence as is.

---
[V2]
- split the x86_dtb_init to call x86_flattree_get_config early

 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(-)
arch/x86/include/asm/prom.h +5 -0
index b716d291d0d4..65dee2420624 100644
@@ -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__ */
arch/x86/kernel/devicetree.c +1 -5
index 87d38f17ff5c..afd09924094e 100644
@@ -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;
 
arch/x86/kernel/setup.c +2 -0
index b9145a63da77..ef73704fa27f 100644
@@ -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);
 
Signature · 1 line
2.34.1

Kind reminder to review this patch series.

- Saurabh

merge bot Applied
#4 lore raw

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

In reply to Saurabh Sengar
The following commit has been merged into the x86/platform branch of tip:

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 <[email protected]>
AuthorDate:    Fri, 25 Aug 2023 00:47:36 -07:00
Committer:     Ingo Molnar <[email protected]>
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. ]

---
 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(-)
arch/x86/include/asm/prom.h +5 -0
index b716d29..65dee24 100644
@@ -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__ */
arch/x86/kernel/devicetree.c +1 -5
index 87d38f1..afd0992 100644
@@ -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;
 
arch/x86/kernel/setup.c +2 -0
index b9145a6..ef73704 100644
@@ -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);