From patchwork Mon Aug 12 09:37:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13760354 Received: from fhigh7-smtp.messagingengine.com (fhigh7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7FC715099B; Mon, 12 Aug 2024 09:37:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455447; cv=none; b=eV+eaxCtNhKKFb5qB578zQiRUKGyhPcLmsRTxsw5USLNgtgOSBLxwDtlt18oA8wA471jMPncs52cT6ZZR7RG6Ei6Qbv/j1ReVugpFgVTGMbXiHsrnYxHelYGCf5DvquonnGCAy1DhSntCD79yHy0OhzkP7O/cYjuNWX5Hl2Dq10= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455447; c=relaxed/simple; bh=HZtNM2iYdTDdJK9RBWXmVSgejXa+e7s20WbxWq/3ZHY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=d4Od+DL1B/EV79g8zX3JUvyUSy4/fQ0S6qF9WtsHEhCc/sRq6tbtnfR3he9a5Sp3ChVnbEGY9VIVEBIi+/e5XuML+kgRCcnJfBW8UO7fBrAwF4G6YJR6pjNsu6zL57VaLqnONKWXUt5Rkah+oZC6pksNKSVFdEthEVWPs2O5LbA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=YWRxtvtu; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=LXNA/x1J; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="YWRxtvtu"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="LXNA/x1J" Received: from phl-compute-06.internal (phl-compute-06.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id E42BE114AB6B; Mon, 12 Aug 2024 05:37:24 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Mon, 12 Aug 2024 05:37:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1723455444; x=1723541844; bh=63VkM8R6TTBXVYCj/tQEl1CrLjl1cy5T2PmvGmxYctU=; b= YWRxtvtuRRFl+/0dABaEySxEMLxzAIOq31Vcqwk52a05HCcn8RpyW6xIxNIPQEHt fb5SBSsPy+O1N8ztVicXSzEXC3mgCgtHcVOi7bUQ6oaAvGifNFwgD7y0eS/g6ziR TK3WJOnVt+MsIA3k6r/2EZuM1NpQoXVtFPk+R0p2RbzEJsenO9sQxiEopFceIiQM BSshfaqobo6qU3KIanKBsJXwldg1g56WGjLZwrfw8GIDc+FRBPC8IcDkL0CipqwV xRvB7AdhOz7qsZET/HkISMWW01nI215vnXfSPtPpfgg/r6MxlxhZ/gTYGTwRc9lU AVAv/ZEnmPDN5JDuVsB1Gw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1723455444; x= 1723541844; bh=63VkM8R6TTBXVYCj/tQEl1CrLjl1cy5T2PmvGmxYctU=; b=L XNA/x1Jtm0al2hkeTZF3C0EkIFieIhrtGqs2nKE+RED00Pv1ZYrRTf82JS0W3hJt fvPT3PQ9ybQ1b1KZtQQ5l+Q2BflxcakG2Hmw3M2D2ZTZZoup+JqWO5E1Dnoqq4ml EYRqviIcKN7nS/peTQg4k9iy09sRtsKhWvHQ4pgUbAEoqDVfFrk7ECwlReaqF8Io 2FCNoaq0oiIPyjOjOYO8v0w1zOs585raBwxzCckWG5oCe/UAEKY6L/picXkGJ0Op n1f9pze2em7scEWD7cJ01syC5sym1lhHZJc5bQrocVt2uLSmymXt0nR9S7aJVJLr m9720iTPJtJnmuJ0fnRFA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddttddgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohep tghhvghnhhhurggtrghisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqd grrhgthhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehrrghfrggvlhes khgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghrnhgusegrrhhnuggsrdguvgdprhgtph htthhopehtshgsohhgvghnugesrghlphhhrgdrfhhrrghnkhgvnhdruggvpdhrtghpthht oheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Aug 2024 05:37:23 -0400 (EDT) From: Jiaxun Yang Date: Mon, 12 Aug 2024 10:37:15 +0100 Subject: [PATCH v2 1/7] arch_numa: Provide platform numa init hook Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240812-mips-numa-v2-1-fd9bdb2033b9@flygoat.com> References: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> In-Reply-To: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> To: "Rafael J. Wysocki" , Arnd Bergmann , Thomas Bogendoerfer , Huacai Chen Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mips@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2225; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=HZtNM2iYdTDdJK9RBWXmVSgejXa+e7s20WbxWq/3ZHY=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrSd1y9t+t7VMvfflPYDNjNzdk6btq5gStL+OfeOK243S /qrE2eypKOUhUGMi0FWTJElRECpb0PjxQXXH2T9gZnDygQyhIGLUwAmYsvJ8D/frnFBS7npvWuJ nxdk1L11iNXc2CazfY725FUMDuzflTsZ/hctSuvaeKxr9ZlUY88Nr/a/+qy23zj2VNGrfacdfM8 sjGQAAA== X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 For some pre-devicetree systems, NUMA information may come from platform specific way. Provide platform numa init hook to allow platform code kick in as last resort method to supply NUMA configuration, and use ARCH_PLATFORM_NUMA Kconfig symbol to gate that function. Signed-off-by: Jiaxun Yang --- v2: Use Kconfig symbol instead of weak function (arnd) --- drivers/base/Kconfig | 4 ++++ drivers/base/arch_numa.c | 9 +++++++++ include/asm-generic/numa.h | 1 + 3 files changed, 14 insertions(+) diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig index 064eb52ff7e2..e169627b9172 100644 --- a/drivers/base/Kconfig +++ b/drivers/base/Kconfig @@ -231,6 +231,10 @@ config GENERIC_ARCH_NUMA Enable support for generic NUMA implementation. Currently, RISC-V and ARM64 use it. +config ARCH_PLATFORM_NUMA + bool + depends on GENERIC_ARCH_NUMA + config FW_DEVLINK_SYNC_STATE_TIMEOUT bool "sync_state() behavior defaults to timeout instead of strict" help diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c index 8d49893c0e94..19be18b35430 100644 --- a/drivers/base/arch_numa.c +++ b/drivers/base/arch_numa.c @@ -305,6 +305,13 @@ static int __init arch_acpi_numa_init(void) } #endif +#ifndef CONFIG_ARCH_PLATFORM_NUMA +int __init arch_platform_numa_init(void) +{ + return -EOPNOTSUPP; +} +#endif + /** * arch_numa_init() - Initialize NUMA * @@ -318,6 +325,8 @@ void __init arch_numa_init(void) return; if (acpi_disabled && !numa_init(of_numa_init)) return; + if (!numa_init(arch_platform_numa_init)) + return; } numa_init(dummy_numa_init); diff --git a/include/asm-generic/numa.h b/include/asm-generic/numa.h index c2b046d1fd82..53a8210fde00 100644 --- a/include/asm-generic/numa.h +++ b/include/asm-generic/numa.h @@ -31,6 +31,7 @@ static inline const struct cpumask *cpumask_of_node(int node) #endif void __init arch_numa_init(void); +int __init arch_platform_numa_init(void); int __init numa_add_memblk(int nodeid, u64 start, u64 end); void __init early_map_cpu_to_node(unsigned int cpu, int nid); int __init early_cpu_to_node(int cpu); From patchwork Mon Aug 12 09:37:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13760355 Received: from fout4-smtp.messagingengine.com (fout4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 242B616132B; Mon, 12 Aug 2024 09:37:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455448; cv=none; b=gdNnNFzNUsuZ8aroElxbt1Ap0YRy9db2f2bTaYHgN9TSe3ZGIKqH/IAFC4Mjis8CvzOJQNJ2t/LRwdL82DuYhghn/LrG2CL386PrWVdPZ3SpXVTqH505wUNfySJI/OJjvDZiGV+nwuckgzlmDOIbYKuFZcyTymHgjvQ81xpO+sE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455448; c=relaxed/simple; bh=GaLop2K+QIkqMSJJz9AAraVySsj9T+4NejqFddiZQMc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rVUrY8tet8NpnSUNnhYBXFl/vT1Harl+3/IlkcRykAkwQTDpfyXuxNwpplQj0EFnYeEsUHZVz2fnxPF0cB6KeY+g/sVaGMoTzEZYDcW8hK2REfSJOLXJeXjjyqfG9oI0g6rZ1WDhmxQjBc6g/xOFBV/fp24TbyEm+y3P6V7tbJM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=LSKfliIh; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=mR6KyuL9; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="LSKfliIh"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mR6KyuL9" Received: from phl-compute-04.internal (phl-compute-04.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id 36C56138FD52; Mon, 12 Aug 2024 05:37:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Mon, 12 Aug 2024 05:37:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1723455446; x=1723541846; bh=ZKGq9+O9qy8NbbI92dWd4mhTg7vxYZDdv7ZdobM9JZ0=; b= LSKfliIhqnmUdfSqnGcT3JS/oDdK7Ei8uHE4HMkogsuU2OiW4ahvavD4gLFx4d86 l6zt+XW9589atiLLlCdDvV4nf1dSan2+ZlYFMRy4/GcTUm0l6DIyYbL+CdSHYfW7 xB+M/M7so3A7dVsvTE1n+hS9ZuUGR3sAkTaeb6FeV8HmeQwl34WRWGezuZJTPgKa Lwn656ebOgHx4+ckI/yq9u1P05tDjOoXOEU2FzR/1nLGbMi++deAqToNfGZMIPy5 87UiGXHBggsjgx58ixr5dDPAteAajOiIbhAybhyILB4cjH1XCWkndWA00w9+Qca6 Y9x4DtIKXRAOmA5FtEY2fw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1723455446; x= 1723541846; bh=ZKGq9+O9qy8NbbI92dWd4mhTg7vxYZDdv7ZdobM9JZ0=; b=m R6KyuL994a4qCvzuGhuRsH6EtuKPupvXAQtIcGlm0u3+3Dr8ReW+jH8vtUQEBNyt PvVKCJFhDOT8ClsMgj4JngCR5HJMjY3wjchI9rI9CfhY0oJgVcRDhy/FYKxMqEht XZQ9cgB9Y7B76uLLK7fxpGeszje4gp4CElXXfHHFrH99j03Pv80w9XL436e9RLyd kL6m8HoIQ7EE7kOom6BSbkPeMllKW137k+lsJNQpYn4+LZTBjUfuiP+zvy/JU2yZ Y42Zmu9Aqg1le28CZSVAswIAlvBGmCpcCwkOugPo996B4Pt6yQ3ab33mgIcS/Pc7 n2pVIVSLP75Mnh8t5/tDg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddttddgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohep tghhvghnhhhurggtrghisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqd grrhgthhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehrrghfrggvlhes khgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghrnhgusegrrhhnuggsrdguvgdprhgtph htthhopehtshgsohhgvghnugesrghlphhhrgdrfhhrrghnkhgvnhdruggvpdhrtghpthht oheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Aug 2024 05:37:25 -0400 (EDT) From: Jiaxun Yang Date: Mon, 12 Aug 2024 10:37:16 +0100 Subject: [PATCH v2 2/7] MIPS: pci: Unify pcibus_to_node implementation Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240812-mips-numa-v2-2-fd9bdb2033b9@flygoat.com> References: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> In-Reply-To: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> To: "Rafael J. Wysocki" , Arnd Bergmann , Thomas Bogendoerfer , Huacai Chen Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mips@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=4206; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=GaLop2K+QIkqMSJJz9AAraVySsj9T+4NejqFddiZQMc=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrSd1y9lH6y77HTGxn7ToY1cp/m+PoiLDI5c8zDumN+c2 ZfmSZw611HKwiDGxSArpsgSIqDUt6Hx4oLrD7L+wMxhZQIZwsDFKQATmXqY4Z+KbM5B9px28cvH 2B4mz91ynXd1iNFTboXZ6/yWqTVHSxowMiyRZTO//Prr+r28FT+jjESyJKVUGdabzRafmL6xIk1 oDgMA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Nowadays PCI Bus NUMA node information is always stored in struct device of host bridge. Unify the implementation of pcibus_to_node to simplify code. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/mach-ip27/topology.h | 4 ---- arch/mips/include/asm/mach-loongson64/topology.h | 5 ----- arch/mips/include/asm/pci.h | 12 ++++++++++++ arch/mips/loongson64/numa.c | 7 ------- arch/mips/pci/pci-ip27.c | 10 ---------- arch/mips/pci/pci-xtalk-bridge.c | 1 + 6 files changed, 13 insertions(+), 26 deletions(-) diff --git a/arch/mips/include/asm/mach-ip27/topology.h b/arch/mips/include/asm/mach-ip27/topology.h index d66cc53feab8..0ad74e2e0d85 100644 --- a/arch/mips/include/asm/mach-ip27/topology.h +++ b/arch/mips/include/asm/mach-ip27/topology.h @@ -17,10 +17,6 @@ extern struct cpuinfo_ip27 sn_cpu_info[NR_CPUS]; #define cpumask_of_node(node) ((node) == -1 ? \ cpu_all_mask : \ &hub_data(node)->h_cpus) -struct pci_bus; -extern int pcibus_to_node(struct pci_bus *); - -#define cpumask_of_pcibus(bus) (cpumask_of_node(pcibus_to_node(bus))) extern unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES]; diff --git a/arch/mips/include/asm/mach-loongson64/topology.h b/arch/mips/include/asm/mach-loongson64/topology.h index 3414a1fd1783..c60ccdbe5a94 100644 --- a/arch/mips/include/asm/mach-loongson64/topology.h +++ b/arch/mips/include/asm/mach-loongson64/topology.h @@ -9,11 +9,6 @@ extern cpumask_t __node_cpumask[]; #define cpumask_of_node(node) (&__node_cpumask[node]) -struct pci_bus; -extern int pcibus_to_node(struct pci_bus *); - -#define cpumask_of_pcibus(bus) (cpu_online_mask) - extern unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES]; #define node_distance(from, to) (__node_distances[(from)][(to)]) diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h index d993df6302dc..09323348d362 100644 --- a/arch/mips/include/asm/pci.h +++ b/arch/mips/include/asm/pci.h @@ -134,6 +134,18 @@ static inline int pci_proc_domain(struct pci_bus *bus) } #endif /* CONFIG_PCI_DOMAINS */ +#ifdef CONFIG_NUMA +static inline int pcibus_to_node(struct pci_bus *bus) +{ + return dev_to_node(&bus->dev); +} +#ifndef cpumask_of_pcibus +#define cpumask_of_pcibus(bus) (pcibus_to_node(bus) == -1 ? \ + cpu_all_mask : \ + cpumask_of_node(pcibus_to_node(bus))) +#endif +#endif + #endif /* __KERNEL__ */ /* Do platform specific device initialization at pci_enable_device() time */ diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c index 8388400d052f..d49180562c9f 100644 --- a/arch/mips/loongson64/numa.c +++ b/arch/mips/loongson64/numa.c @@ -171,13 +171,6 @@ void __init mem_init(void) setup_zero_pages(); /* This comes from node 0 */ } -/* All PCI device belongs to logical Node-0 */ -int pcibus_to_node(struct pci_bus *bus) -{ - return 0; -} -EXPORT_SYMBOL(pcibus_to_node); - void __init prom_init_numa_memory(void) { pr_info("CP0_Config3: CP0 16.3 (0x%x)\n", read_c0_config3()); diff --git a/arch/mips/pci/pci-ip27.c b/arch/mips/pci/pci-ip27.c index 973faea61cad..d919c70e02b1 100644 --- a/arch/mips/pci/pci-ip27.c +++ b/arch/mips/pci/pci-ip27.c @@ -17,16 +17,6 @@ #include #include -#ifdef CONFIG_NUMA -int pcibus_to_node(struct pci_bus *bus) -{ - struct bridge_controller *bc = BRIDGE_CONTROLLER(bus); - - return bc->nasid; -} -EXPORT_SYMBOL(pcibus_to_node); -#endif /* CONFIG_NUMA */ - static void ip29_fixup_phy(struct pci_dev *dev) { int nasid = pcibus_to_node(dev->bus); diff --git a/arch/mips/pci/pci-xtalk-bridge.c b/arch/mips/pci/pci-xtalk-bridge.c index 45ddbaa6c123..45b2b390e553 100644 --- a/arch/mips/pci/pci-xtalk-bridge.c +++ b/arch/mips/pci/pci-xtalk-bridge.c @@ -633,6 +633,7 @@ static int bridge_probe(struct platform_device *pdev) return -ENOMEM; } + set_dev_node(dev, bd->nasid); pci_set_flags(PCI_PROBE_ONLY); host = devm_pci_alloc_host_bridge(dev, sizeof(*bc)); From patchwork Mon Aug 12 09:37:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13760357 Received: from fout4-smtp.messagingengine.com (fout4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8645616D9DB; Mon, 12 Aug 2024 09:37:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455451; cv=none; b=n+mcab5D7C8hbcGhLzQcscVPJX6yo627nTYpQvUWT+NogR7R4byxMex/IfmLz1BezgGCNdHmA0TYfY8V9HH9CXweem0IxmCZp+aquLWJTqsVZM/H3P8omHTIDcTKiI7DnCAj1SMuvr5BtAp53E4jquPhBjBIB2ywaww+OlnNGRU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455451; c=relaxed/simple; bh=/2vM9Jarepf6oyk/v8ZwnyJnwqhxSDzHMZeDhKKDNNc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Xelr/9LTzbQc2/k69D3u0cqHkJeG9ehQ/aoVubNpGvj+RUdn4q5QIjhf7gdbOUt1FWdVmDwzKASGOzvtmFvhm+LU3qcCCg4/GfCcxr1Vyg5gfVWXnORq+EfXdU6wECxODY+BwKZmWMSWHXd6V6FJP3PecqHnRlXX0DSKg7qvQvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=XH8JYUX9; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=gFecbiKM; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="XH8JYUX9"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="gFecbiKM" Received: from phl-compute-06.internal (phl-compute-06.nyi.internal [10.202.2.46]) by mailfout.nyi.internal (Postfix) with ESMTP id 8E864138FC87; Mon, 12 Aug 2024 05:37:27 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Mon, 12 Aug 2024 05:37:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1723455447; x=1723541847; bh=Lux1sMrQcX9bqRHe6vEl5Vg0QIiAUMpeYGep9wxBF34=; b= XH8JYUX9o+wI5vUkqD/azjyMbzSom9Q5gUC1Gq7wGro4hYLHlxmaEjUDT3N4a2Mg BtRCQvm0SljkUe8tInoEK4LzYfKzUNIpiqO1KYX7TZwJqRatNACxA+v0MqXyTvMy anNSxjnxOwZ5p8dy7xl9kggy2INA99wtsXmXMIu8XydlQJKGDHt/OKkVBcKRVDRI 65mVlc6c/5E5MgklgdNHfmx9Q2KEDAk6JWUynqu4+QkiO/CpH81ucw/v5Q3uyhtQ 46inRYtV8dVOCxEfo29mKGH09ZTat08UnLbxbFtDmJcgEwU51yi9/d0zQstDUa0m iqgwVuJoMHUncgv+A98hZA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1723455447; x= 1723541847; bh=Lux1sMrQcX9bqRHe6vEl5Vg0QIiAUMpeYGep9wxBF34=; b=g FecbiKMWWnSz6E/wRPOTnC5ItgMhlIS7l7M65DdIiAD7Nenzmyv13g2rxoG41L9H NzBQyOpLfj1niuay4oz5YBR/5vEdMO3ykn0sA93qSj0/wWAg571f/TEsNC19S4Vh 1DdmXxzxFeT+hP4FZLXQ468bhSOaVNdn7tbhlbUVV0kg76A2MNLY3T18knIJBU4F jKDatW7Pfngmzt1OmSCPIfUN9BdzyVLJh+YQedO+8xBlR/GzNWd7Lwv0X0eBmBGA jl2AScTYs3u6aXnH3YKo8I+Y6ynRF6FdzqcqoYijDbA2c/HGChteYI/fogBMySlP PpYNf5E/S4vAJ2InzVd1Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddttddgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohep tghhvghnhhhurggtrghisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqd grrhgthhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehrrghfrggvlhes khgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghrnhgusegrrhhnuggsrdguvgdprhgtph htthhopehtshgsohhgvghnugesrghlphhhrgdrfhhrrghnkhgvnhdruggvpdhrtghpthht oheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Aug 2024 05:37:26 -0400 (EDT) From: Jiaxun Yang Date: Mon, 12 Aug 2024 10:37:17 +0100 Subject: [PATCH v2 3/7] MIPS: Prepare NUMA headers for arch_numa Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240812-mips-numa-v2-3-fd9bdb2033b9@flygoat.com> References: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> In-Reply-To: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> To: "Rafael J. Wysocki" , Arnd Bergmann , Thomas Bogendoerfer , Huacai Chen Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mips@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=7544; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=/2vM9Jarepf6oyk/v8ZwnyJnwqhxSDzHMZeDhKKDNNc=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrSd1y89kfT0fS4oXPPS8kvF5reevU374s8us7bo1NC2z vqq/+l/RykLgxgXg6yYIkuIgFLfhsaLC64/yPoDM4eVCWQIAxenAEzklzLD/7TqkyYX135VXuHn fSrs6hzDvrTGTgnv83xH7Rs1NofM5WFkOLtWd+nLzTbXn7D0Xz1juWinS/X04l496bNccr0Pnt0 K5QAA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 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 --- 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 + */ + +#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 + */ + +#ifndef __ASM_MACH_GENERIC_NUMA_H +#define __ASM_MACH_GENERIC_NUMA_H + +#include + +#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 #include + +#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 + */ + +#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 #include +#include 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 #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 + */ + +#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 -#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 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 - -#ifdef CONFIG_NUMA -# include -#endif +#include #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 + */ + +#ifndef __ASM_NUMA_H +#define __ASM_NUMA_H + +#include +#include + +#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 From patchwork Mon Aug 12 09:37:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13760356 Received: from fout4-smtp.messagingengine.com (fout4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94F3716DC03; Mon, 12 Aug 2024 09:37:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455451; cv=none; b=jssCq93SF7iwrqeIMl4WITJFfG+AroUpuKxuvPQw6NmBpuTfPcF0ncHYTu7A4ywcP/K+1PD+XlhEVVOQHuAkWiptVVbw8ng3oh6vUkjFfppzUaYZhHY466TaGr+QSDz3+E8lCLilYBQsv5vBTD1/VIAawkLRcLu+HfG+bjrfhJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455451; c=relaxed/simple; bh=+ejYp7maBb/oUUXF+jD1Nmv9exkAFT7PhKXpA9pkTKI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sG7LGofUJ8DfCXe5c0mWkT4OQ+I/31TyXtbiPWM1EWnKp9vgeZgJ3ZvNur6m1YdCu87ihuUEWKfLAZvMLA0w3D2XSEjlBqIHTqE1ofRe4bTAw660OWHgbUCIrPcRzeIK6Kh9BIuNGPeQl25zjaGCgFnhJH3I7w2LhdAMg29lWp0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=BLJqopz+; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=UOuD/2bZ; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="BLJqopz+"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="UOuD/2bZ" Received: from phl-compute-03.internal (phl-compute-03.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id BD092138FDA8; Mon, 12 Aug 2024 05:37:28 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Mon, 12 Aug 2024 05:37:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1723455448; x=1723541848; bh=FjgaJBEUF4kGFFxF8k99q8oZGLiVdvrhufwANUqc7y4=; b= BLJqopz+goXZzrbkhmXtiI6bsNKwpBroCNCrQOBod2zigeUz1spvQaOj8ENMdMu6 kjwYOsFfS2LF2dRxOZQAr2EJ4QCesMzPpKo0A16vyXFNWaxCamf+xZdmO+FViMBE nH2nyZEvdjwcUzUWvBx9PupbVRqTPVwln1WPNR98o4Eq3U9+fXX5D3eRybp8yuz/ U7qRLniStxBh0pFbTdntn16LB869dRIkt4Ids3PhdAFI8AXv5LK8AP6XglshLX2P iGoZU0SOAmQFX5AjYo/SC3PVEtEmSvtPror1El41/0h9sZIBPo7QJ9CbsRgGXD9p h/Os5l0MhPrNdGcR8CbGbQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1723455448; x= 1723541848; bh=FjgaJBEUF4kGFFxF8k99q8oZGLiVdvrhufwANUqc7y4=; b=U OuD/2bZslsgPMv19AlhmpmQdFdCdBuDM7/II7kycRRAbPa59jk0g7WKxoYWK9snG yT+RglJy+VZKnbIRW7Bc+ysYZxPKi0m53Wd9Mt5PC0fpsLGuH15LiKnxq3URhJNM 6/7j2B8hDiFjzkHgXgxqtOdozyTVL/VGYbzM/NQf4DkcsEzeMNRheV6LVLysqKqU +L5fHA8vCP9JtdPsN71mWcp/4rLDajKLifJrYHk6duoNJiJPq1nI9U/KgQZIPhEa iUS5sQK5gu+sYN8dV4rH5BWRPQ1KF0nImqgWQRyO9Gu5Z5Tj1gt3foR8xzutO23W QrSYiZoyA9KSJ01iUFu4Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddttddgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohep tghhvghnhhhurggtrghisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqd grrhgthhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehrrghfrggvlhes khgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghrnhgusegrrhhnuggsrdguvgdprhgtph htthhopehtshgsohhgvghnugesrghlphhhrgdrfhhrrghnkhgvnhdruggvpdhrtghpthht oheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Aug 2024 05:37:27 -0400 (EDT) From: Jiaxun Yang Date: Mon, 12 Aug 2024 10:37:18 +0100 Subject: [PATCH v2 4/7] MIPS: mm: init: Prepare for arch_numa Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240812-mips-numa-v2-4-fd9bdb2033b9@flygoat.com> References: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> In-Reply-To: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> To: "Rafael J. Wysocki" , Arnd Bergmann , Thomas Bogendoerfer , Huacai Chen Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mips@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1793; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=+ejYp7maBb/oUUXF+jD1Nmv9exkAFT7PhKXpA9pkTKI=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrSd1y957ox94R72fO99edHSunmnpu7jZxK40HLzdfZiR btDQtrXOkpZGMS4GGTFFFlCBJT6NjReXHD9QdYfmDmsTCBDGLg4BWAibqsYGaZlLWR88WhRtOpX qS0zPsfNUZ4m6n8lpSt/65kdKfP7+KcyMszw3LhsZ86jA7MeRvWJu/46qsyjy9i26N/jxT2f4zg fpvMCAA== X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Opt-in various mm initailise routines for NUMA platforms with arch_numa enabled. Loongson64 & IP27 have their own implementations but arch_numa is fine with the generic implementation. Signed-off-by: Jiaxun Yang --- arch/mips/mm/init.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c index 4583d1a2a73e..4d7d5e817939 100644 --- a/arch/mips/mm/init.c +++ b/arch/mips/mm/init.c @@ -401,7 +401,7 @@ void maar_init(void) } } -#ifndef CONFIG_NUMA +#if !defined(CONFIG_NUMA) || defined(CONFIG_GENERIC_ARCH_NUMA) void __init paging_init(void) { unsigned long max_zone_pfns[MAX_NR_ZONES]; @@ -424,14 +424,14 @@ void __init paging_init(void) (highend_pfn - max_low_pfn) << (PAGE_SHIFT - 10)); max_zone_pfns[ZONE_HIGHMEM] = max_low_pfn; - max_mapnr = max_low_pfn; + set_max_mapnr(max_low_pfn); } else if (highend_pfn) { - max_mapnr = highend_pfn; + set_max_mapnr(highend_pfn); } else { - max_mapnr = max_low_pfn; + set_max_mapnr(max_low_pfn); } #else - max_mapnr = max_low_pfn; + set_max_mapnr(max_low_pfn); #endif high_memory = (void *) __va(max_low_pfn << PAGE_SHIFT); @@ -482,7 +482,7 @@ void __init mem_init(void) 0x80000000 - 4, KCORE_TEXT); #endif } -#endif /* !CONFIG_NUMA */ +#endif void free_init_pages(const char *what, unsigned long begin, unsigned long end) { @@ -519,7 +519,7 @@ void __ref free_initmem(void) free_initmem_default(POISON_FREE_INITMEM); } -#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA +#if defined(CONFIG_NUMA) && !defined(CONFIG_GENERIC_ARCH_NUMA) unsigned long __per_cpu_offset[NR_CPUS] __read_mostly; EXPORT_SYMBOL(__per_cpu_offset); From patchwork Mon Aug 12 09:37:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13760358 Received: from fhigh7-smtp.messagingengine.com (fhigh7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C030916DEBD; Mon, 12 Aug 2024 09:37:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455453; cv=none; b=BKKuYlwVraETzTlnfTHUEH8g8vSKOw2FAZcF9XAxL+Qqw4nBdRFuG/ZHfc3xCtm2bmyCnxSNJ2dP0vwVUpsO46AVdbounWO17cDnhgrrWwoTLX/oyflU/lSM099b6wA+Y9t++uzYdAugflkGPwbwDgjYLrwP65KQchgyj/yxwdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455453; c=relaxed/simple; bh=25PGnrDbozNqXeo66FAaZeG/EjrxdTBJIrhq5W4w0Zg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y5MzEgNxUfAej9myOIMCQi+X8iKolzvhTLr1mJQqLsgmADs74+v8v0JBYQ+vC2rlaBl9UbZVMmtwpU7jJjVGrSji/UA9XrLRTyvZ/gapu5rqRg72AYFnkw+u9cpdJksIniqrhXiuXJpXB1mFGSDf6TlgnjZs0MnbylqlARohODg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=V3F8WsrQ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=V8lkh58+; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="V3F8WsrQ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="V8lkh58+" Received: from phl-compute-02.internal (phl-compute-02.nyi.internal [10.202.2.42]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 17E69114709A; Mon, 12 Aug 2024 05:37:30 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Mon, 12 Aug 2024 05:37:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1723455450; x=1723541850; bh=91Ntn8+8S3tkwtkpXtQo+UUnbH7tPRABNLmEHtSRkko=; b= V3F8WsrQ5HxTj9fr1WdAgoJUIZOH41ZKKp0Hcsb5lKBpJlqBj6zq8y0P6o8I55S0 1rVRt3nqu8xK2gjqdj/kscR+r0XNWgz/ExqtNu2DM1CwBpUyEfx+XKlmgcksODBM N2A1uTvvre7kV5CeSoDHtF3rrLgU9yWy9AE2yTykAF1QBL4HktvIM66H/bn2rG/v d/0WMhzE9/KnUoHcxVAfQ9ars1kbU1MeNuHpxxnmzmAWQzTuRm6k2UvoAS0T327P kiNjHGEOltHL0JXRL00R9SgUAcjtuYx4ZqsOz7Fymn5OGcab1GtMC0JRsPjIaGiA kHlUVw92tgsHIk4vtZRyww== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1723455450; x= 1723541850; bh=91Ntn8+8S3tkwtkpXtQo+UUnbH7tPRABNLmEHtSRkko=; b=V 8lkh58+LZljnia9kVJFkbHv7FE2jOorprFHvWn8lkJiC/1ecgnysFk3WNbAlCV+7 rPADjnH1WDJyg/wAPjFiHsZatv03miQHQQRbYK4inGiw5ahRViOyOzh6Y2be5p9y sv2kbsjKg590ejVveizTtikqSVJaqtBGYLyOsWR4V5/fKS9Ss1uMVSeUDYxUx5TS 7D9cAnCY+BbHpVxFDzC28ljRd+V3XxIxg6hX7h4sZhTkRsXTUCCaB4AbrNgK/DxH xffcHYymz3dcYTcTu8nhBPlUKJ5Tu3x8c1BH63efKcNcBcxs3zkIBi+hlfNa0/tQ m0OltqUC+siR49jxTNYdA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddttddgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohep tghhvghnhhhurggtrghisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqd grrhgthhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehrrghfrggvlhes khgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghrnhgusegrrhhnuggsrdguvgdprhgtph htthhopehtshgsohhgvghnugesrghlphhhrgdrfhhrrghnkhgvnhdruggvpdhrtghpthht oheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Aug 2024 05:37:28 -0400 (EDT) From: Jiaxun Yang Date: Mon, 12 Aug 2024 10:37:19 +0100 Subject: [PATCH v2 5/7] MIPS: smp: Process NUMA information Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240812-mips-numa-v2-5-fd9bdb2033b9@flygoat.com> References: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> In-Reply-To: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> To: "Rafael J. Wysocki" , Arnd Bergmann , Thomas Bogendoerfer , Huacai Chen Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mips@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=4040; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=25PGnrDbozNqXeo66FAaZeG/EjrxdTBJIrhq5W4w0Zg=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrSd1y9V2ClGO4dcXXeg1GhRzeurThekvFZKPU4Ld8g2P Mt8gzOyo5SFQYyLQVZMkSVEQKlvQ+PFBdcfZP2BmcPKBDKEgYtTACZyeg/DX2FX4ckPp4qkv6lR 0Zviek9bUDZ/666aLNfuvuV7TwjJCTP8r9xubjpjl+Dr57NK1diSfvxvy0zp4hRYfVzr3B6/vfI LGQA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Performing numa_add_cpu and numa_remove_cpu as necessary, store NUMA map from devicetree and fix up if platform SMP code didn't do mapping properly. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/smp-ops.h | 7 +------ arch/mips/kernel/smp-cps.c | 6 ++++++ arch/mips/kernel/smp.c | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/arch/mips/include/asm/smp-ops.h b/arch/mips/include/asm/smp-ops.h index 1617b207723f..4d984f0088cb 100644 --- a/arch/mips/include/asm/smp-ops.h +++ b/arch/mips/include/asm/smp-ops.h @@ -40,12 +40,7 @@ struct plat_smp_ops { extern void register_smp_ops(const struct plat_smp_ops *ops); -static inline void plat_smp_setup(void) -{ - extern const struct plat_smp_ops *mp_ops; /* private */ - - mp_ops->smp_setup(); -} +extern void __init plat_smp_setup(void); extern void mips_smp_send_ipi_single(int cpu, unsigned int action); extern void mips_smp_send_ipi_mask(const struct cpumask *mask, diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c index 395622c37325..be9f13c0b058 100644 --- a/arch/mips/kernel/smp-cps.c +++ b/arch/mips/kernel/smp-cps.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -179,10 +180,14 @@ static void __init cps_smp_setup(void) /* Indicate present CPUs (CPU being synonymous with VPE) */ for (v = 0; v < min_t(unsigned, nvpes, NR_CPUS); v++) { + struct device_node *np = of_get_cpu_node(v, NULL); + set_cpu_possible(v, cpu_cluster(&cpu_data[v]) == 0); set_cpu_present(v, cpu_cluster(&cpu_data[v]) == 0); __cpu_number_map[v] = v; __cpu_logical_map[v] = v; + if (np) + early_map_cpu_to_node(v, of_node_to_nid(np)); } /* Set a coherent default CCA (CWB) */ @@ -553,6 +558,7 @@ static int cps_cpu_disable(void) atomic_sub(1 << cpu_vpe_id(¤t_cpu_data), &core_cfg->vpe_mask); smp_mb__after_atomic(); set_cpu_online(cpu, false); + numa_remove_cpu(cpu); calculate_cpu_foreign_map(); irq_migrate_all_off_this_cpu(); diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index 0362fc5df7b0..17dd97ad3cbb 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c @@ -153,6 +153,11 @@ void calculate_cpu_foreign_map(void) &temp_foreign_map, &cpu_sibling_map[i]); } +bool arch_match_cpu_phys_id(int cpu, u64 phys_id) +{ + return phys_id == cpu_logical_map(cpu); +} + const struct plat_smp_ops *mp_ops; EXPORT_SYMBOL(mp_ops); @@ -164,6 +169,19 @@ void register_smp_ops(const struct plat_smp_ops *ops) mp_ops = ops; } +void __init plat_smp_setup(void) +{ + unsigned int cpu; + + mp_ops->smp_setup(); + + for_each_possible_cpu(cpu) { + /* Workaround platform SMP code not handling NUMA map */ + if (early_cpu_to_node(cpu) == NUMA_NO_NODE) + early_map_cpu_to_node(cpu, 0); + } +} + #ifdef CONFIG_GENERIC_IRQ_IPI void mips_smp_send_ipi_single(int cpu, unsigned int action) { @@ -372,6 +390,7 @@ asmlinkage void start_secondary(void) set_cpu_sibling_map(cpu); set_cpu_core_map(cpu); + numa_add_cpu(cpu); cpumask_set_cpu(cpu, &cpu_coherent_mask); notify_cpu_starting(cpu); @@ -426,6 +445,8 @@ void __init smp_cpus_done(unsigned int max_cpus) /* called from main before smp_init() */ void __init smp_prepare_cpus(unsigned int max_cpus) { + unsigned int cpu; + init_new_context(current, &init_mm); current_thread_info()->cpu = 0; mp_ops->prepare_cpus(max_cpus); @@ -436,6 +457,11 @@ void __init smp_prepare_cpus(unsigned int max_cpus) init_cpu_present(cpu_possible_mask); #endif cpumask_copy(&cpu_coherent_mask, cpu_possible_mask); + + for_each_possible_cpu(cpu) + numa_store_cpu_info(cpu); + + numa_add_cpu(0); } /* preload SMP state for boot cpu */ From patchwork Mon Aug 12 09:37:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13760359 Received: from fhigh7-smtp.messagingengine.com (fhigh7-smtp.messagingengine.com [103.168.172.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD69816D4D9; Mon, 12 Aug 2024 09:37:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.158 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455454; cv=none; b=o+Qv8VRkv6UXpYkWAKv9wJXfb/UpjTih+KkK9fWs+UyDWYTyz7X79ytT3PcGbbVhBv3s1iIrJQxB6mbwEb06luWnW0fyVD5610QsVpwgUwsbiz1JVWK3f9GA3YzpMbp+2H/P8saNehGGlLV2zH7hdIx1Fdj0RJ/ZTZuqmaOvN74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455454; c=relaxed/simple; bh=RY/FthAtkr/nzzBX9lGQDyrUaVP6XUjtTRqG+7Y42O0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=koT+rf1GhGT8y+Lm2gAiHQUQNuNQNAkeaa7Ubr5C+PBCA7Fpvx1EQ29w0gQJPbRd8MxrQmJU3ckLeKZP2ySmu+QMFGoe0rWMhmQTMyTFJfvAaD9ksyKMv7+D6l8ZWZExvpNva+lUR1wZR6DPx58sh1uPbZmEqS8hFYskDRNSh8o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=Kv5025fT; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=P1hfbfwo; arc=none smtp.client-ip=103.168.172.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="Kv5025fT"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="P1hfbfwo" Received: from phl-compute-04.internal (phl-compute-04.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 5780C114AB5D; Mon, 12 Aug 2024 05:37:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Mon, 12 Aug 2024 05:37:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1723455451; x=1723541851; bh=Qvz55kKdJIbJNrXhcKsilfBcMcr0pmQRWrdGCF4uAkU=; b= Kv5025fTsj13tARNHv4wveSyK4yJu5IMoByFxmDjlk2CjbW07yDDVTk6GBoytqt1 g+qo5lIo50ROFU9AGhqvwJAQxN3zPaD7h1mXHVgvW7QHRVbU5ff9N7RdZriMOqSY 9AcrGaGGjhMtQ/TdHM++EJppgxkugolB1Dt4F/2pQDQFx6o13Mvbc55UBfl3hAlI z3brPwiSmoNlBepR6lZFPjjV14GSKdLqyjmTrJLVW5/rYyvwfxSMG0vmUBY33B1E Ul/W7wmXa2yQzASuQ2lZpKEDj6yzQ4/+0Ht/AfBJMZBNxySnEaEmQAuapNO2BSUK +27Cf1vDSQQSLxrEPqgAbA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1723455451; x= 1723541851; bh=Qvz55kKdJIbJNrXhcKsilfBcMcr0pmQRWrdGCF4uAkU=; b=P 1hfbfwoinAaOb5D/LJBW1kCX/XHh2HtBLzXiEoh420fWIzsEiWs574fraRgWZhzK NiOAvYk3rmfQ/FHEgI6J6rydvjSMFRlMOkAXCFZm2tNLgkwYl3dfivzujx9oZyIF j+TbrOrxmy0EEblw6DaDtG5/pcIS5TYgNze7Tz+ncgBhJlyfsSWl+npAPbCP4+a+ pVCirzitlk/ivOPLVVOYpbyMfLsGrJ7O/2SresZJ3Xchl8JXqoXw9xET0tPgpr9L RwZAR/UqIbekAdpCUkqhq4194pBhDQzH3ugUkedFqy1RnzSuPyab0zbYqZCcOWnf f6n7ScH6/br1D4tDiT54Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddttddgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgepudenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohep tghhvghnhhhurggtrghisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqd grrhgthhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehrrghfrggvlhes khgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghrnhgusegrrhhnuggsrdguvgdprhgtph htthhopehtshgsohhgvghnugesrghlphhhrgdrfhhrrghnkhgvnhdruggvpdhrtghpthht oheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Aug 2024 05:37:30 -0400 (EDT) From: Jiaxun Yang Date: Mon, 12 Aug 2024 10:37:20 +0100 Subject: [PATCH v2 6/7] MIPS: generic: Make NUMA available Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240812-mips-numa-v2-6-fd9bdb2033b9@flygoat.com> References: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> In-Reply-To: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> To: "Rafael J. Wysocki" , Arnd Bergmann , Thomas Bogendoerfer , Huacai Chen Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mips@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1336; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=RY/FthAtkr/nzzBX9lGQDyrUaVP6XUjtTRqG+7Y42O0=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrSd1y+12u7uaQspXpa7ofZB0O65yYKyRxles6+6Ptcjc MbljXfdO0pZGMS4GGTFFFlCBJT6NjReXHD9QdYfmDmsTCBDGLg4BWAis30Y/tm+7ZGseTJ7Qbjp mWVPP92apDmxyb1kx0buCxZfysXLJ39g+B+z/qDW5jXTpaSSppuWrVw5zW0Dp/+jGDWbb0WnO8+ umMQBAA== X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Enable arch_numa and dependent options for generic and future NUMA platforms. Enable SPARSEMEM for 64 bit generic kernel. Signed-off-by: Jiaxun Yang --- arch/mips/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 43da6d596e2b..9284a06db2b4 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -140,6 +140,7 @@ choice config MIPS_GENERIC_KERNEL bool "Generic board-agnostic MIPS kernel" + select ARCH_SPARSEMEM_ENABLE if 64BIT select MIPS_GENERIC select BOOT_RAW select BUILTIN_DTB @@ -178,6 +179,7 @@ config MIPS_GENERIC_KERNEL select SYS_SUPPORTS_MIPS16 select SYS_SUPPORTS_MIPS_CPS select SYS_SUPPORTS_MULTITHREADING + select SYS_SUPPORTS_NUMA select SYS_SUPPORTS_RELOCATABLE select SYS_SUPPORTS_SMARTMIPS select SYS_SUPPORTS_ZBOOT @@ -2599,8 +2601,10 @@ config NUMA bool "NUMA Support" depends on SYS_SUPPORTS_NUMA select SMP + select GENERIC_ARCH_NUMA if !SGI_IP27 && !MACH_LOONGSON64 select HAVE_SETUP_PER_CPU_AREA select NEED_PER_CPU_EMBED_FIRST_CHUNK + select USE_PERCPU_NUMA_NODE_ID if GENERIC_ARCH_NUMA help Say Y to compile the kernel to support NUMA (Non-Uniform Memory Access). This option improves performance on systems with more From patchwork Mon Aug 12 09:37:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13760360 Received: from fout4-smtp.messagingengine.com (fout4-smtp.messagingengine.com [103.168.172.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9838A16E87A; Mon, 12 Aug 2024 09:37:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.147 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455455; cv=none; b=A8u4S3DI5J1y1U/jH1Pfk+56K3kAz9XSM+NEvHUIKkJSaqGD8qLdgjUpudq2aPrnSy1GptShBXlbRDGYkQtHPMTyXDMmqUkYcsntD/awCYbqWOlfo6xS6udGpagyKE3XlcXt2VhkvvCud1rz+IDPKktP9j3rrtdzNihttYFaQ5Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723455455; c=relaxed/simple; bh=3l7H3p9zLo1EPln6tiC9rTjTUTU3k6UD3b9C05/yXqE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sueAxxr+xVOIMk91xBd828MK9GVxFWX7pQXTC0zuPKPqhtU9UuGIETdj43K2UBzzExxDkEfAcZb1pU8e1J93gMYsywJIHdEmmaoOFB13RhG2FE0BsaVi9Fwx82ucthcNt5w2dgE7gdY5nv18k2qOfB1tnbpmkAp6YotZhTCkTcg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=LCGWG1gk; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=BtYYtBco; arc=none smtp.client-ip=103.168.172.147 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="LCGWG1gk"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="BtYYtBco" Received: from phl-compute-02.internal (phl-compute-02.nyi.internal [10.202.2.42]) by mailfout.nyi.internal (Postfix) with ESMTP id ABCE4138FD57; Mon, 12 Aug 2024 05:37:32 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Mon, 12 Aug 2024 05:37:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1723455452; x=1723541852; bh=mDe0E8S0TTs375SvjMg65NszKRRCKN3lxU+hJ3lDft8=; b= LCGWG1gkA9W8oLOCAHD0MY3IkaTVsbS8T8pAmNiQ9bLLo6KN1hfsyNHEJppIJx0H t6uYMrQCVk9rE15VUaqt9Ic9Ej+5VssCXDv7tszBrCjn//3BDBuu6beQ69PdseQh LQ3dpPhgMH2s+YUXahy+EgHaIRH5X7+WyfqCbtQHG+BDIokF2GVn00flJuYGlm3u hDGaWggdBDmZ9vYVGznSUkUBEDgBb0YqMmu0+tcrAM4Aa44LKpl8o2+QvzikTe+I WQSHRyUd9tqnINDxQTzJuSzV9nljWE/dIca3zT51vaBobmJYcjAbjHr/D/fycO2y 4/Vbp0IuP9N/5+TKB0StYA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1723455452; x= 1723541852; bh=mDe0E8S0TTs375SvjMg65NszKRRCKN3lxU+hJ3lDft8=; b=B tYYtBcoCCwwOsoDCWD5wcHK/m9D67EG+TWpCfcdilOXkTsNtU7qERQkH9iyU9a2x 0eC8jf3YotMG5OGddSU+J7OneNYG4CeDSqYZfJ4KY4AOzGS0KT8ZzpsQ/brmU4Fz EDLcHISuUno4m9FqhavASUJb/6fcm6budiKbEgeF/oHNY8V/GzGvR/BMGSfDBgw5 OsOs2ySyfon51+4awcEttJZlYJdc2l1jrsp8Z0zI8v9Pkp06z6tMydFW82EWFoej nRXLacYEZUnkDSzaPaCtiX3sVrp5S02IMuzi10qdxl3e2V3bA6GX4/wTVm601RFc S6Obd3raXnl89kvXxu0Ww== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddttddgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohep tghhvghnhhhurggtrghisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqd grrhgthhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehrrghfrggvlhes khgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghrnhgusegrrhhnuggsrdguvgdprhgtph htthhopehtshgsohhgvghnugesrghlphhhrgdrfhhrrghnkhgvnhdruggvpdhrtghpthht oheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Aug 2024 05:37:31 -0400 (EDT) From: Jiaxun Yang Date: Mon, 12 Aug 2024 10:37:21 +0100 Subject: [PATCH v2 7/7] MIPS: Loongson64: Migrate to arch_numa Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240812-mips-numa-v2-7-fd9bdb2033b9@flygoat.com> References: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> In-Reply-To: <20240812-mips-numa-v2-0-fd9bdb2033b9@flygoat.com> To: "Rafael J. Wysocki" , Arnd Bergmann , Thomas Bogendoerfer , Huacai Chen Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mips@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=12463; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=3l7H3p9zLo1EPln6tiC9rTjTUTU3k6UD3b9C05/yXqE=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrSd1y8V9HpMSVq/72m40faS3GlajnMCp0Xyyt7J/lL2s GvNrr07O0pZGMS4GGTFFFlCBJT6NjReXHD9QdYfmDmsTCBDGLg4BWAiO8oZGXauF79UmmpX8yq5 +ttSRo6JxvN+Oei+Et+x/mXq0muKB68x/OEqNV36gNH155zVSZN7G09+0/jSIrTPRWR/bf3O/HU xXTwA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Migrate to generic arch_numa infra to reduce maintenance burden. Signed-off-by: Jiaxun Yang --- arch/mips/Kconfig | 3 +- arch/mips/include/asm/mach-loongson64/mmzone.h | 2 - arch/mips/include/asm/mach-loongson64/numa.h | 22 ---- arch/mips/include/asm/mach-loongson64/topology.h | 18 --- arch/mips/kernel/setup.c | 2 +- arch/mips/loongson64/init.c | 28 ++--- arch/mips/loongson64/numa.c | 153 ++--------------------- arch/mips/loongson64/smp.c | 2 + 8 files changed, 26 insertions(+), 204 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 9284a06db2b4..bd042faa4905 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -472,6 +472,7 @@ config MACH_LOONGSON2EF config MACH_LOONGSON64 bool "Loongson 64-bit family of machines" select ARCH_DMA_DEFAULT_COHERENT + select ARCH_PLATFORM_NUMA if NUMA select ARCH_SPARSEMEM_ENABLE select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO @@ -2601,7 +2602,7 @@ config NUMA bool "NUMA Support" depends on SYS_SUPPORTS_NUMA select SMP - select GENERIC_ARCH_NUMA if !SGI_IP27 && !MACH_LOONGSON64 + select GENERIC_ARCH_NUMA if !SGI_IP27 select HAVE_SETUP_PER_CPU_AREA select NEED_PER_CPU_EMBED_FIRST_CHUNK select USE_PERCPU_NUMA_NODE_ID if GENERIC_ARCH_NUMA diff --git a/arch/mips/include/asm/mach-loongson64/mmzone.h b/arch/mips/include/asm/mach-loongson64/mmzone.h index 8fb70fd3c9c4..f5946e69ad55 100644 --- a/arch/mips/include/asm/mach-loongson64/mmzone.h +++ b/arch/mips/include/asm/mach-loongson64/mmzone.h @@ -14,6 +14,4 @@ #define pa_to_nid(addr) (((addr) & 0xf00000000000) >> NODE_ADDRSPACE_SHIFT) #define nid_to_addrbase(nid) ((unsigned long)(nid) << NODE_ADDRSPACE_SHIFT) -extern void __init prom_init_numa_memory(void); - #endif /* _ASM_MACH_MMZONE_H */ diff --git a/arch/mips/include/asm/mach-loongson64/numa.h b/arch/mips/include/asm/mach-loongson64/numa.h deleted file mode 100644 index 2fac370d981f..000000000000 --- a/arch/mips/include/asm/mach-loongson64/numa.h +++ /dev/null @@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (C) 2024 Jiaxun Yang - */ - -#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 deleted file mode 100644 index ebb086821401..000000000000 --- a/arch/mips/include/asm/mach-loongson64/topology.h +++ /dev/null @@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_MACH_TOPOLOGY_H -#define _ASM_MACH_TOPOLOGY_H - -#include - -#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]) - -#endif - -#include - -#endif /* _ASM_MACH_TOPOLOGY_H */ diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 655391c04477..242945d240c5 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -252,7 +252,7 @@ static unsigned long __init init_initrd(void) * Initialize the bootmem allocator. It also setup initrd related data * if needed. */ -#if defined(CONFIG_SGI_IP27) || (defined(CONFIG_CPU_LOONGSON64) && defined(CONFIG_NUMA)) +#if defined(CONFIG_SGI_IP27) static void __init bootmem_init(void) { diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c index a35dd7311795..26423d323aa9 100644 --- a/arch/mips/loongson64/init.c +++ b/arch/mips/loongson64/init.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -46,9 +47,9 @@ void virtual_early_config(void) node_id_offset = 44; } -void __init szmem(unsigned int node) +static void __init prom_init_memory(void) { - u32 i, mem_type; + u32 i, mem_type, max_node_id = 0; phys_addr_t node_id, mem_start, mem_size; /* Otherwise come from DTB */ @@ -58,8 +59,8 @@ void __init szmem(unsigned int node) /* Parse memory information and activate */ for (i = 0; i < loongson_memmap->nr_map; i++) { node_id = loongson_memmap->map[i].node_id; - if (node_id != node) - continue; + if (node_id > max_node_id) + max_node_id = node_id; mem_type = loongson_memmap->map[i].mem_type; mem_size = loongson_memmap->map[i].mem_size; @@ -78,7 +79,7 @@ void __init szmem(unsigned int node) case UMA_VIDEO_RAM: pr_info("Node %d, mem_type:%d\t[%pa], %pa bytes usable\n", (u32)node_id, mem_type, &mem_start, &mem_size); - memblock_add_node(mem_start, mem_size, node, + memblock_add_node(mem_start, mem_size, node_id, MEMBLOCK_NONE); break; case SYSTEM_RAM_RESERVED: @@ -104,16 +105,11 @@ void __init szmem(unsigned int node) memblock_reserve(virt_to_phys((void *)loongson_sysconf.vgabios_addr), SZ_256K); /* set nid for reserved memory */ - memblock_set_node((u64)node << 44, (u64)(node + 1) << 44, - &memblock.reserved, node); -} - -#ifndef CONFIG_NUMA -static void __init prom_init_memory(void) -{ - szmem(0); + for (i = 0; i <= max_node_id; i++) { + memblock_set_node(nid_to_addrbase(i), nid_to_addrbase(i + 1), + &memblock.reserved, i); + } } -#endif void __init prom_init(void) { @@ -133,11 +129,7 @@ void __init prom_init(void) if (loongson_sysconf.early_config) loongson_sysconf.early_config(); -#ifdef CONFIG_NUMA - prom_init_numa_memory(); -#else prom_init_memory(); -#endif /* Hardcode to CPU UART 0 */ if ((read_c0_prid() & PRID_IMP_MASK) == PRID_IMP_LOONGSON_64R) diff --git a/arch/mips/loongson64/numa.c b/arch/mips/loongson64/numa.c index d49180562c9f..9431e6e0a082 100644 --- a/arch/mips/loongson64/numa.c +++ b/arch/mips/loongson64/numa.c @@ -9,45 +9,10 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include #include -unsigned char __node_distances[MAX_NUMNODES][MAX_NUMNODES]; -EXPORT_SYMBOL(__node_distances); - -cpumask_t __node_cpumask[MAX_NUMNODES]; -EXPORT_SYMBOL(__node_cpumask); - -static void cpu_node_probe(void) -{ - int i; - - nodes_clear(node_possible_map); - nodes_clear(node_online_map); - for (i = 0; i < loongson_sysconf.nr_nodes; i++) { - node_set_state(num_online_nodes(), N_POSSIBLE); - node_set_online(num_online_nodes()); - } - - pr_info("NUMA: Discovered %d cpus on %d nodes\n", - loongson_sysconf.nr_cpus, num_online_nodes()); -} - static int __init compute_node_distance(int row, int col) { int package_row = row * loongson_sysconf.cores_per_node / @@ -63,117 +28,21 @@ static int __init compute_node_distance(int row, int col) return 100; } -static void __init init_topology_matrix(void) -{ - int row, col; - - for (row = 0; row < MAX_NUMNODES; row++) - for (col = 0; col < MAX_NUMNODES; col++) - __node_distances[row][col] = -1; - - for_each_online_node(row) { - for_each_online_node(col) { - __node_distances[row][col] = - compute_node_distance(row, col); - } - } -} - -static void __init node_mem_init(unsigned int node) -{ - unsigned long node_addrspace_offset; - unsigned long start_pfn, end_pfn; - - node_addrspace_offset = nid_to_addrbase(node); - pr_info("Node%d's addrspace_offset is 0x%lx\n", - node, node_addrspace_offset); - - get_pfn_range_for_nid(node, &start_pfn, &end_pfn); - pr_info("Node%d: start_pfn=0x%lx, end_pfn=0x%lx\n", - node, start_pfn, end_pfn); - - alloc_node_data(node); - - NODE_DATA(node)->node_start_pfn = start_pfn; - NODE_DATA(node)->node_spanned_pages = end_pfn - start_pfn; - - if (node == 0) { - /* kernel start address */ - unsigned long kernel_start_pfn = PFN_DOWN(__pa_symbol(&_text)); - - /* kernel end address */ - unsigned long kernel_end_pfn = PFN_UP(__pa_symbol(&_end)); - - /* used by finalize_initrd() */ - max_low_pfn = end_pfn; - - /* Reserve the kernel text/data/bss */ - memblock_reserve(kernel_start_pfn << PAGE_SHIFT, - ((kernel_end_pfn - kernel_start_pfn) << PAGE_SHIFT)); - - /* Reserve 0xfe000000~0xffffffff for RS780E integrated GPU */ - if (node_end_pfn(0) >= (0xffffffff >> PAGE_SHIFT)) - memblock_reserve((node_addrspace_offset | 0xfe000000), - 32 << 20); - - /* Reserve pfn range 0~node[0]->node_start_pfn */ - memblock_reserve(0, PAGE_SIZE * start_pfn); - /* set nid for reserved memory on node 0 */ - memblock_set_node(0, 1ULL << 44, &memblock.reserved, 0); - } -} - -static __init void prom_meminit(void) +int __init arch_platform_numa_init(void) { - unsigned int node, cpu, active_cpu = 0; + int nr_nodes, nid, row, col; - cpu_node_probe(); - init_topology_matrix(); + nr_nodes = loongson_sysconf.nr_nodes; - for (node = 0; node < loongson_sysconf.nr_nodes; node++) { - if (node_online(node)) { - szmem(node); - node_mem_init(node); - cpumask_clear(&__node_cpumask[node]); - } + for (nid = 0; nid < nr_nodes; nid++) { + node_set(nid, numa_nodes_parsed); + numa_add_memblk(nid, nid_to_addrbase(nid), nid_to_addrbase(nid + 1)); } - max_low_pfn = PHYS_PFN(memblock_end_of_DRAM()); - - for (cpu = 0; cpu < loongson_sysconf.nr_cpus; cpu++) { - node = cpu / loongson_sysconf.cores_per_node; - if (node >= num_online_nodes()) - node = 0; - - if (loongson_sysconf.reserved_cpus_mask & (1<