new file mode 100644
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@flygoat.com>
+ */
+
+#ifndef __ASM_MACH_GENERIC_MMZONE_H
+#define __ASM_MACH_GENERIC_MMZONE_H
+
+/* Intentionally empty file ... */
+
+#endif /* __ASM_MACH_GENERIC_MMZONE_H */
new file mode 100644
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@flygoat.com>
+ */
+
+#ifndef __ASM_MACH_GENERIC_NUMA_H
+#define __ASM_MACH_GENERIC_NUMA_H
+
+#include <asm-generic/numa.h>
+
+#endif /* __ASM_NUMA_H */
@@ -1 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef __ASM_MACH_GENERIC_TOPOLOGY_H
+#define __ASM_MACH_GENERIC_TOPOLOGY_H
+
+#include <asm/numa.h>
#include <asm-generic/topology.h>
+
+#endif
new file mode 100644
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@flygoat.com>
+ */
+
+#ifndef __ASM_MACH_NUMA_H
+#define __ASM_MACH_NUMA_H
+
+#ifdef CONFIG_NUMA
+extern unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES];
+
+#define node_distance(from, to) (__node_distances[(from)][(to)])
+#endif
+
+/* Hanlded in platform code */
+static inline void numa_store_cpu_info(unsigned int cpu) { }
+static inline void numa_add_cpu(unsigned int cpu) { }
+static inline void numa_remove_cpu(unsigned int cpu) { }
+static inline void arch_numa_init(void) { }
+static inline void early_map_cpu_to_node(unsigned int cpu, int nid) { }
+
+#endif /* __ASM_NUMA_H */
@@ -4,6 +4,7 @@
#include <asm/sn/types.h>
#include <asm/mmzone.h>
+#include <asm/numa.h>
struct cpuinfo_ip27 {
nasid_t p_nasid; /* my node ID in numa-as-id-space */
@@ -13,15 +14,12 @@ struct cpuinfo_ip27 {
extern struct cpuinfo_ip27 sn_cpu_info[NR_CPUS];
-#define cpu_to_node(cpu) (cputonasid(cpu))
+#define early_cpu_to_node(cpu) (cputonasid(cpu))
+#define cpu_to_node(cpu) early_cpu_to_node(cpu)
#define cpumask_of_node(node) ((node) == -1 ? \
cpu_all_mask : \
&hub_data(node)->h_cpus)
-extern unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES];
-
-#define node_distance(from, to) (__node_distances[(from)][(to)])
-
#include <asm-generic/topology.h>
#endif /* _ASM_MACH_TOPOLOGY_H */
new file mode 100644
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@flygoat.com>
+ */
+
+#ifndef __ASM_MACH_LOONGSON64_NUMA_H
+#define __ASM_MACH_LOONGSON64_NUMA_H
+
+#ifdef CONFIG_NUMA
+extern unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES];
+
+#define node_distance(from, to) (__node_distances[(from)][(to)])
+#endif
+
+/* Hanlded in platform code */
+static inline void numa_store_cpu_info(unsigned int cpu) { }
+static inline void numa_add_cpu(unsigned int cpu) { }
+static inline void numa_remove_cpu(unsigned int cpu) { }
+static inline void arch_numa_init(void) { }
+static inline void early_map_cpu_to_node(unsigned int cpu, int nid) { }
+
+#endif /* __ASM_NUMA_H */
@@ -2,17 +2,15 @@
#ifndef _ASM_MACH_TOPOLOGY_H
#define _ASM_MACH_TOPOLOGY_H
-#ifdef CONFIG_NUMA
+#include <asm/numa.h>
-#define cpu_to_node(cpu) (cpu_logical_map(cpu) >> 2)
+#ifdef CONFIG_NUMA
+#define early_cpu_to_node(cpu) (cpu_logical_map(cpu) >> 2)
+#define cpu_to_node(cpu) early_cpu_to_node(cpu)
extern cpumask_t __node_cpumask[];
#define cpumask_of_node(node) (&__node_cpumask[node])
-extern unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES];
-
-#define node_distance(from, to) (__node_distances[(from)][(to)])
-
#endif
#include <asm-generic/topology.h>
@@ -7,10 +7,7 @@
#define _ASM_MMZONE_H_
#include <asm/page.h>
-
-#ifdef CONFIG_NUMA
-# include <mmzone.h>
-#endif
+#include <mmzone.h>
#ifndef pa_to_nid
#define pa_to_nid(addr) 0
new file mode 100644
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@flygoat.com>
+ */
+
+#ifndef __ASM_NUMA_H
+#define __ASM_NUMA_H
+
+#include <asm/topology.h>
+#include <numa.h>
+
+#endif /* __ASM_NUMA_H */
@@ -664,6 +664,7 @@ static void __init arch_mem_init(char **cmdline_p)
mips_parse_crashkernel();
device_tree_init();
+ arch_numa_init();
/*
* In order to reduce the possibility of kernel panic when failed to
Massage headers so that we can include asm-generic/numa.h for generic platform. Provide dummy arch_numa like functions in Loongson64/IP27 platform to fill the gap between them and generic platform. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> --- arch/mips/include/asm/mach-generic/mmzone.h | 11 +++++++++++ arch/mips/include/asm/mach-generic/numa.h | 11 +++++++++++ arch/mips/include/asm/mach-generic/topology.h | 7 +++++++ arch/mips/include/asm/mach-ip27/numa.h | 22 ++++++++++++++++++++++ arch/mips/include/asm/mach-ip27/topology.h | 8 +++----- arch/mips/include/asm/mach-loongson64/numa.h | 22 ++++++++++++++++++++++ arch/mips/include/asm/mach-loongson64/topology.h | 10 ++++------ arch/mips/include/asm/mmzone.h | 5 +---- arch/mips/include/asm/numa.h | 12 ++++++++++++ arch/mips/kernel/setup.c | 1 + 10 files changed, 94 insertions(+), 15 deletions(-)