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@xxxxxxxxxxx> --- 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(-) diff --git a/arch/mips/include/asm/mach-generic/mmzone.h b/arch/mips/include/asm/mach-generic/mmzone.h new file mode 100644 index 000000000000..d4374b71a900 --- /dev/null +++ b/arch/mips/include/asm/mach-generic/mmzone.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx> + */ + +#ifndef __ASM_MACH_GENERIC_MMZONE_H +#define __ASM_MACH_GENERIC_MMZONE_H + +/* Intentionally empty file ... */ + +#endif /* __ASM_MACH_GENERIC_MMZONE_H */ diff --git a/arch/mips/include/asm/mach-generic/numa.h b/arch/mips/include/asm/mach-generic/numa.h new file mode 100644 index 000000000000..311a5871807c --- /dev/null +++ b/arch/mips/include/asm/mach-generic/numa.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx> + */ + +#ifndef __ASM_MACH_GENERIC_NUMA_H +#define __ASM_MACH_GENERIC_NUMA_H + +#include <asm-generic/numa.h> + +#endif /* __ASM_NUMA_H */ diff --git a/arch/mips/include/asm/mach-generic/topology.h b/arch/mips/include/asm/mach-generic/topology.h index 5428f333a02c..fa82d18ba9e7 100644 --- a/arch/mips/include/asm/mach-generic/topology.h +++ b/arch/mips/include/asm/mach-generic/topology.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 diff --git a/arch/mips/include/asm/mach-ip27/numa.h b/arch/mips/include/asm/mach-ip27/numa.h new file mode 100644 index 000000000000..e2adadf8a589 --- /dev/null +++ b/arch/mips/include/asm/mach-ip27/numa.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx> + */ + +#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 */ diff --git a/arch/mips/include/asm/mach-ip27/topology.h b/arch/mips/include/asm/mach-ip27/topology.h index 0ad74e2e0d85..33d5bf925431 100644 --- a/arch/mips/include/asm/mach-ip27/topology.h +++ b/arch/mips/include/asm/mach-ip27/topology.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 */ diff --git a/arch/mips/include/asm/mach-loongson64/numa.h b/arch/mips/include/asm/mach-loongson64/numa.h new file mode 100644 index 000000000000..2fac370d981f --- /dev/null +++ b/arch/mips/include/asm/mach-loongson64/numa.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx> + */ + +#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 */ diff --git a/arch/mips/include/asm/mach-loongson64/topology.h b/arch/mips/include/asm/mach-loongson64/topology.h index c60ccdbe5a94..ebb086821401 100644 --- a/arch/mips/include/asm/mach-loongson64/topology.h +++ b/arch/mips/include/asm/mach-loongson64/topology.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> diff --git a/arch/mips/include/asm/mmzone.h b/arch/mips/include/asm/mmzone.h index 14226ea42036..f472c8ec3a63 100644 --- a/arch/mips/include/asm/mmzone.h +++ b/arch/mips/include/asm/mmzone.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 diff --git a/arch/mips/include/asm/numa.h b/arch/mips/include/asm/numa.h new file mode 100644 index 000000000000..ff1eb9ef51e6 --- /dev/null +++ b/arch/mips/include/asm/numa.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2024 Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx> + */ + +#ifndef __ASM_NUMA_H +#define __ASM_NUMA_H + +#include <asm/topology.h> +#include <numa.h> + +#endif /* __ASM_NUMA_H */ diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 12a1a4ffb602..655391c04477 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -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 -- 2.46.0