From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Arnd Bergmann <arnd@arndb.de>,
Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Huacai Chen <chenhuacai@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
linux-mips@vger.kernel.org,
Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: [PATCH 3/7] MIPS: Prepare NUMA headers for arch_numa
Date: Fri, 09 Aug 2024 20:25:03 +0100 [thread overview]
Message-ID: <20240809-mips-numa-v1-3-568751803bf8@flygoat.com> (raw)
In-Reply-To: <20240809-mips-numa-v1-0-568751803bf8@flygoat.com>
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(-)
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@flygoat.com>
+ */
+
+#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@flygoat.com>
+ */
+
+#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@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 */
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@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 */
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@flygoat.com>
+ */
+
+#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
next prev parent reply other threads:[~2024-08-09 19:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-09 19:25 [PATCH 0/7] MIPS: arch_numa enablement Jiaxun Yang
2024-08-09 19:25 ` [PATCH 1/7] arch_numa: Provide platform numa init hook Jiaxun Yang
2024-08-09 19:41 ` Arnd Bergmann
2024-08-09 19:56 ` Jiaxun Yang
2024-08-09 20:01 ` Arnd Bergmann
2024-08-09 19:25 ` [PATCH 2/7] MIPS: pci: Unify pcibus_to_node implementation Jiaxun Yang
2024-08-09 19:25 ` Jiaxun Yang [this message]
2024-08-09 19:25 ` [PATCH 4/7] MIPS: mm: init: Prepare for arch_numa Jiaxun Yang
2024-08-09 19:25 ` [PATCH 5/7] MIPS: smp: Process NUMA information Jiaxun Yang
2024-08-09 19:25 ` [PATCH 6/7] MIPS: generic: Make NUMA available Jiaxun Yang
2024-08-09 19:25 ` [PATCH 7/7] MIPS: Loongson64: Migrate to arch_numa Jiaxun Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240809-mips-numa-v1-3-568751803bf8@flygoat.com \
--to=jiaxun.yang@flygoat.com \
--cc=arnd@arndb.de \
--cc=chenhuacai@kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=tsbogend@alpha.franken.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®