From patchwork Fri Aug 9 19:25:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13759183 Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (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 2BE08155322; Fri, 9 Aug 2024 19:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231508; cv=none; b=AKA9wme9FR1CZIZJfReoO7ee5fEm7920qdt8YlMNlpduWBAjGe7GVhxUzXMebavRtzKBNDAXaXzxatjjkpdZJejJGJfOrzJvV4XIduBBffriclQYigRewIdPyi2EHQyHDvjfu4Zfp+qzsELEue4Zkn8zjFHylNXr0c+/yE2ZoxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231508; c=relaxed/simple; bh=uUe6W4q60TIzM6COGxfpl3s1qGv48UEeL5is+BxJTZQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WEb+g5lqJ9xZqdCYPrD7V22BYui8bc6pAu0paNUabazuEjXa0PfGTq/eRqxxFOywpDywsdOCSNwzUE/GVnujzr2t9uupF4F0kAMlmtZxhhbD7DG/tzUbgMMrJWkdj0t12VmdWFQ9xkldzR+p+YBY8TO8kiPBFybHsZc+58CNV84= 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=BKtJwp+j; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=cipjsr7o; arc=none smtp.client-ip=103.168.172.145 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="BKtJwp+j"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="cipjsr7o" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id 3797113881AA; Fri, 9 Aug 2024 15:25:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 09 Aug 2024 15:25:06 -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=1723231506; x=1723317906; bh=O51QGHyzhP4I5QaSt0wfYi1b+qABRQdEpVBQKmlKluc=; b= BKtJwp+j9RPHJvqItEhOAvnPjwmaaDw/Ig6FFJOS8DZWrCSxyJPwlTwi1zZ0tYmt Kidhysln2CKU/c/O5wM5Vx0t9oU+wra0/6l9h6TUk7CUFBofv0oG1DEoBdkpGSxL 45IyZ+8jMmoX7KyO6rLk/fiAj9+Cahn3HpfEK4IJYPsOKegVLcgccRpJ1An77j4i rP9dQ4G1Y9R70aezIZiDBNN8QaypppoBc6IljKgvdnvgQUJMKADZOG+kZqzIxYFQ wbAOi15LAzrDJYX0QTIsnEhf+nk2dkBZlWwc+Nj9F8uLaEbx87K5G0PUuadsEIeH VMWEsqrrjRPX5oNPXMghtA== 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=1723231506; x= 1723317906; bh=O51QGHyzhP4I5QaSt0wfYi1b+qABRQdEpVBQKmlKluc=; b=c ipjsr7oMvvKhKDcrBmrSjrdco8pEGcKPB4CwGgx8jYoDETo9tIRCbmFqyE3t67u7 AUFbuFSYMo2zIkD3UkhQXbAezYBU34aL/6qcMr3qVZqwDWWrpC2GIhLKmvHdJ6LD f6GDZy6ImoddpdCZmzvHCGr8oUaJjt/uS7G7+ViiznxZ/aPwPZ7gGSKLvH5F494N bVzXrLeBRWHa4fsqwG1Sz0HLdP9D6LslJdsTtYe68S/HUd+o/qQFn7Yx2CIcQWuy FclQde8ew8zUTivN4YfBKc1kOhJSr/R7CekZmVU6ecWcj7rtOA0h8G7eLuoTC3ar 1DR2n1nAKGh60dG2WR+rQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrleeggddufeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eprghrnhgusegrrhhnuggsrdguvgdprhgtphhtthhopehjihgrgihunhdrhigrnhhgsehf lhihghhorghtrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrh drkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhssghoghgvnhgusegrlhhphhgrrdhf rhgrnhhkvghnrdguvgdprhgtphhtthhopegthhgvnhhhuhgrtggriheskhgvrhhnvghlrd horhhgpdhrtghpthhtoheplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdho rhhgpdhrtghpthhtoheplhhinhhugidqrghrtghhsehvghgvrhdrkhgvrhhnvghlrdhorh hgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Aug 2024 15:25:05 -0400 (EDT) From: Jiaxun Yang Date: Fri, 09 Aug 2024 20:25:01 +0100 Subject: [PATCH 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: <20240809-mips-numa-v1-1-568751803bf8@flygoat.com> References: <20240809-mips-numa-v1-0-568751803bf8@flygoat.com> In-Reply-To: <20240809-mips-numa-v1-0-568751803bf8@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=1532; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=uUe6W4q60TIzM6COGxfpl3s1qGv48UEeL5is+BxJTZQ=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrRtufzR4hlp8zd+/pHryf22jGm3ucPr5eGd/27t2imon 3Bc9uKTjlIWBjEuBlkxRZYQAaW+DY0XF1x/kPUHZg4rE8gQBi5OAZiI82yGf/rh5u/XLd3rzR57 N3NxuuP/+Njja6cFNSwJ3mVXLuPhnMbwv6yvKeTP2jCB+NbyiGK5vp96Xyd5CTUKXNjnn3qg430 NCwA= 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. Signed-off-by: Jiaxun Yang --- drivers/base/arch_numa.c | 7 +++++++ include/asm-generic/numa.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c index 8d49893c0e94..d464baeee69a 100644 --- a/drivers/base/arch_numa.c +++ b/drivers/base/arch_numa.c @@ -305,6 +305,11 @@ static int __init arch_acpi_numa_init(void) } #endif +int __init __weak arch_platform_numa_init(void) +{ + return -EOPNOTSUPP; +} + /** * arch_numa_init() - Initialize NUMA * @@ -318,6 +323,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 Fri Aug 9 19:25:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13759184 Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (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 7C2A315FA8A; Fri, 9 Aug 2024 19:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231510; cv=none; b=RAEKeCjiJfyjND6PnXw3MvsqI6wkDFe27LWr2mPJ284xD4WxCK3zC8SlK2yLX5dQbYwiqzNognPkkTLdq8VC2fDaViZVuRDo0KZD0gwR+yQfvO3C+an7yyMqCoXLDY6t/3I7rBV/Bw/tgsA062sahc2KiuEvETb25TaNBkofDKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231510; c=relaxed/simple; bh=GaLop2K+QIkqMSJJz9AAraVySsj9T+4NejqFddiZQMc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NmYktwVnrhCVWTlPMNM5QlPi53PjdKWn/EjcSbAg6Ha0oafwQWP4zClj8SwERXRoziStrYx09lASflF5raVI2V4bqbVKl46i+pLrp5upnB8D1k+M6Sy2a4CzD43cv2V6X59fdwvvy2cIRex/PAebcPWC5IY4Cn7Vw6f/jB4OLE0= 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=AzCJQawp; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=LNJDAauL; arc=none smtp.client-ip=103.168.172.145 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="AzCJQawp"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="LNJDAauL" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id 8F83F1388004; Fri, 9 Aug 2024 15:25:07 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 09 Aug 2024 15:25:07 -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=1723231507; x=1723317907; bh=ZKGq9+O9qy8NbbI92dWd4mhTg7vxYZDdv7ZdobM9JZ0=; b= AzCJQawpNwVPdnmQl1PolPtOYNPG1G6TOb1dVl2BpURlreniaueSW3e6r3XeJoJn pS02dRx6XNk3dYmDlUtXdphPWF3k1Z12epdtwTH/WVHVjShf8V1IOiN+vKsjqS0O qMJqsDRV8caYUS1iBU3Fn5Az+7EyrqxwXZnR9yaozsRcP58Lvyvk+t3NuSoiVeCw lnegYhBC3aX4+zQTn2ie0bjPUTdYNfboEQe/cPqardjxo9oagULhuUYSqT0qyoSo WtI9NsktN54sMdzC6Gf18I0o3T5snWVD82hFmOTjzcW9ANwPTXUpwuVV5jQggD3C zyWA5BSfLQBSLb4UJRSDqw== 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=1723231507; x= 1723317907; bh=ZKGq9+O9qy8NbbI92dWd4mhTg7vxYZDdv7ZdobM9JZ0=; b=L NJDAauLWQMMHMkOva/BeRr7o3LnnkvS99LbdbgtcOQw7kadU6I/29av2Irrx0b9M KYRZYvGAogzMFuc9R6cVhmxeEUDOStwzVhB4luViYJeOrbVjw+P9Mafg8+OdZ8m0 PgoIhiAGAdkeBlK3snFRyyOwA8DzOPHbgG5s3paeCM0AwH//aOyQOXVRn5j4kYEj dU9IKiIAja0fB8Q48eNT7LTGnLZJ39fMcWnUE5KoYyKlMrgrV7XzhH6Yo7pfQ4Mn QXdYbTm7u+/tRimwugIw2Wa432cjKF8FNABfEzME8HGJ39DqaDKJ7uucxdCOwreA 9zs/JSZ9ndUYOD6KJ0k6g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrleeggddufeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eprghrnhgusegrrhhnuggsrdguvgdprhgtphhtthhopehjihgrgihunhdrhigrnhhgsehf lhihghhorghtrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrh drkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhssghoghgvnhgusegrlhhphhgrrdhf rhgrnhhkvghnrdguvgdprhgtphhtthhopegthhgvnhhhuhgrtggriheskhgvrhhnvghlrd horhhgpdhrtghpthhtoheplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdho rhhgpdhrtghpthhtoheplhhinhhugidqrghrtghhsehvghgvrhdrkhgvrhhnvghlrdhorh hgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Aug 2024 15:25:06 -0400 (EDT) From: Jiaxun Yang Date: Fri, 09 Aug 2024 20:25:02 +0100 Subject: [PATCH 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: <20240809-mips-numa-v1-2-568751803bf8@flygoat.com> References: <20240809-mips-numa-v1-0-568751803bf8@flygoat.com> In-Reply-To: <20240809-mips-numa-v1-0-568751803bf8@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=owGbwMvMwCXmXMhTe71c8zDjabUkhrRtufwMevNePb99wlKicJeOavZeu8tSvhKHezqq2y++1 5E//PppRykLgxgXg6yYIkuIgFLfhsaLC64/yPoDM4eVCWwIF6cATMTlKCPDosQnsju/Kz3bXGZ5 dLv1FYH5c2LiQ6N2mO++wah4ftnd74wM6yXdv9e2TNqpcHHGd9klDhsSw6zMOUQ0E6Lyay/fvJ3 CCgA= 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 Fri Aug 9 19:25:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13759185 Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (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 D61D8160860; Fri, 9 Aug 2024 19:25:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231511; cv=none; b=iIuk67hCRGJHYh6tqov6uczZvmrpCvpebSqJ/weAKRgzCcLSz6b/ntBGV/GygN9MEAnM9HEYnzx7Dycc+msMHpCV9Ta7ww66YyAgHAnhiCe19lJS1iwB3MCTvGaPB2URxAE89tNdwBGgCPbCKfhEIvr2fpURy3VAjr+/QpSKMCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231511; c=relaxed/simple; bh=/2vM9Jarepf6oyk/v8ZwnyJnwqhxSDzHMZeDhKKDNNc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rMmu1YhHGv6TnXZM2KkRrwxSbNkKyFZexHxxvRXKwmxdHMANhiXOYjSbaf2ItFrIJc4GJUm07Y2Xqjp+OOkpyPZzlfRl19k5xi1mKARQjqv0snD3x26LMzk4gT811nxBNBBQIpn9NBamGCcRzXSvq9kumhLSx5FLt2AccHHIm6Q= 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=PLd0laW2; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=vVm6+gSU; arc=none smtp.client-ip=103.168.172.145 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="PLd0laW2"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="vVm6+gSU" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id E8FAB138F206; Fri, 9 Aug 2024 15:25:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 09 Aug 2024 15:25:08 -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=1723231508; x=1723317908; bh=Lux1sMrQcX9bqRHe6vEl5Vg0QIiAUMpeYGep9wxBF34=; b= PLd0laW2eUF08ApyM3Jtu/1rm7oB3mg3MVPV8U/0YYpQvX6F9Wv1MmimHzHh0Dnq Dhc3PSCsxcpTO1RF5wpAuFEMOejzGhLheTjhzduzCDVGnEEtM/VKgh7GVdyHyLgA 0F4f7JP68G3gVdJTMezLAuTsNaDx4/XW/ygK4hbUfD+B1HNwNCtI74usyDB6kyA0 +3uvbL6c6BddgUmnr8jDXRApmto5yq9NnC8cSPI5e5qBHkqVrQFCJonvxdUlwe5Y sM6E47b6GS7tK+Tuh0ypC7j3ewRat3zfNWYjHYjUkulUK4/9B8N0qK5LBAGG1SV0 CukcIaV02tizgXsl/i9l7w== 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=1723231508; x= 1723317908; bh=Lux1sMrQcX9bqRHe6vEl5Vg0QIiAUMpeYGep9wxBF34=; b=v Vm6+gSUi5zI1yM+EJxPZRhiVADyZGuGHXzag7PhRC6wDME6UA5i1b768ICwVYHp9 zzNVpXfEbGTvjH2o7KFuTrtAhBc3HVk2wEvW2CqpGte5xiWxNNeNfBIQzgdRs2jD bE5A9TUhwYDy4317kH/350PLQuVE8DM9L1hpqOJHSDjqf9EnY7q+GkvC+40+i990 fXWZ25+d1JbSO5bWRufsINfhVsOXt7XNNnLQBy8ObMpV//60RGSi2swsGcgHoW+O qwDS6Jg8SHxKVbiCGs5uv7VLDan6D2Dkf7ljQUp2C+sLscJBomby/H7/x3/kYdS0 cJFrKlK3SnRBR3ZtLVkOg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrleeggddufeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eprghrnhgusegrrhhnuggsrdguvgdprhgtphhtthhopehjihgrgihunhdrhigrnhhgsehf lhihghhorghtrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrh drkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhssghoghgvnhgusegrlhhphhgrrdhf rhgrnhhkvghnrdguvgdprhgtphhtthhopegthhgvnhhhuhgrtggriheskhgvrhhnvghlrd horhhgpdhrtghpthhtoheplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdho rhhgpdhrtghpthhtoheplhhinhhugidqrghrtghhsehvghgvrhdrkhgvrhhnvghlrdhorh hgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Aug 2024 15:25:07 -0400 (EDT) From: Jiaxun Yang Date: Fri, 09 Aug 2024 20:25:03 +0100 Subject: [PATCH 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: <20240809-mips-numa-v1-3-568751803bf8@flygoat.com> References: <20240809-mips-numa-v1-0-568751803bf8@flygoat.com> In-Reply-To: <20240809-mips-numa-v1-0-568751803bf8@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=owGbwMvMwCXmXMhTe71c8zDjabUkhrRtufyXl1/oa+CcGhS45FRCtPr57Sanpn2xlUznlfijO atJdvG5jlIWBjEuBlkxRZYQAaW+DY0XF1x/kPUHZg4rE8gQBi5OAZjIR0aG/6H7Or/e+VDeLea9 xmij+r6Ga/kvu285pj4PO6GroVxyzYThn+IB/1MRLFyhLyQYIpxmbBcW6k4Xdzr09UibiZRFaqI VBwA= 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 Fri Aug 9 19:25:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13759186 Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (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 0D191166312; Fri, 9 Aug 2024 19:25:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231512; cv=none; b=rI1dG6RAZJMQ7pYgCJHTTVQ3IIugKiDc0JToRzWfBmMQYgjXXaMTOYo1r3V1goBeuYcEL7cTmtP+nrajh+YtM+lR07YymEgwBf//bO9Womlq4xe35GIL0xHbpri8uDZ9iGtMoON7VI5pDBMDbeLKzWzu+3jHFNOQOwetTrfWLZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231512; c=relaxed/simple; bh=+ejYp7maBb/oUUXF+jD1Nmv9exkAFT7PhKXpA9pkTKI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EwTKQLdrIV7yf8NnmTAHKYd2HtNsMUTMIklxw9Hpsg1TKAZDDhfAdsyTngCI4ba85zktGmyaFNjsyleU1sIQ2jaHxGyYtXD5p3NxJQgtSON/ZnG3LcxxqVgexMarRBQXWhSiV5H+tsMY9yxot/H4KkJ4VIjVqd66uuuZHAuRpl8= 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=YC7TOh2Q; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=LCKy1Ho9; arc=none smtp.client-ip=103.168.172.145 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="YC7TOh2Q"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="LCKy1Ho9" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.nyi.internal (Postfix) with ESMTP id 3404F138FC56; Fri, 9 Aug 2024 15:25:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 09 Aug 2024 15:25:10 -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=1723231510; x=1723317910; bh=FjgaJBEUF4kGFFxF8k99q8oZGLiVdvrhufwANUqc7y4=; b= YC7TOh2Qr+OgBz9NvWJcCb3lHgTl6UPdyeOL5GuXgcZGo4fbkZoyt4UH8I97krBq 1qO+giF2Cb0VEz8JLDYK5sxqXHnxY2r1yD7EuXbpYwSn8le4IdsEFqSm7TQMIXvR 4Pxt5n+CXd5/eGC5tWOPXXBSXtIUy4ykxDS6m9WUDi7K0xe0qweH0kijQxtS528H gtuxfghNLVqhc7oiLecv9cSnG2enkzyuODtKPaFv47F/fmCd6EqHzlfwYvlAi+Ea drqI3x5r6n7Veq8jIW6NsDas1No7x6T47tj5XMaobTUbvhU6PxvddNeOPF9D/OvQ bEh840LqL+dT+jjqp4uEaQ== 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=1723231510; x= 1723317910; bh=FjgaJBEUF4kGFFxF8k99q8oZGLiVdvrhufwANUqc7y4=; b=L CKy1Ho9ri/ak3uczziaE43V/rvzd7vAscHshnuupgRzdfWp6gQSeJspxZZPS//3L i603T0f5QJHP2L1LRkER78jREyBssIq+a6SMsbtrG7/50VQRyUJvVHefyZnIOKZz 7c62IBO6hm4AgXPE7kDG2vIdWmSjWJjORGAphtpRCGkNnAswX0w/Ul84EE8xHF9A /mnNQ63HK7KwxU/gEn/PcZramtOyfvLAajzNGTij+nFepSEo+nDFHFqCEMyh8kSh i7dBzExmkuT54oUhp4mFYqZ8JFnKD01ExvMznF+EA98OhqStwrPi2d82snQMK8qz DO4VYR8e6Evct9wGaaG1w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrleeggddufeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eprghrnhgusegrrhhnuggsrdguvgdprhgtphhtthhopehjihgrgihunhdrhigrnhhgsehf lhihghhorghtrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrh drkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhssghoghgvnhgusegrlhhphhgrrdhf rhgrnhhkvghnrdguvgdprhgtphhtthhopegthhgvnhhhuhgrtggriheskhgvrhhnvghlrd horhhgpdhrtghpthhtoheplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdho rhhgpdhrtghpthhtoheplhhinhhugidqrghrtghhsehvghgvrhdrkhgvrhhnvghlrdhorh hgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Aug 2024 15:25:09 -0400 (EDT) From: Jiaxun Yang Date: Fri, 09 Aug 2024 20:25:04 +0100 Subject: [PATCH 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: <20240809-mips-numa-v1-4-568751803bf8@flygoat.com> References: <20240809-mips-numa-v1-0-568751803bf8@flygoat.com> In-Reply-To: <20240809-mips-numa-v1-0-568751803bf8@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=owGbwMvMwCXmXMhTe71c8zDjabUkhrRtufzf/jCYK16smWg2o5HTbuoPz9Yuvnw9lbpXBSYHl /lfq+PvKGVhEONikBVTZAkRUOrb0HhxwfUHWX9g5rAygQxh4OIUgIlcnc7I0DFN7mC64YINjySS HKTl8uTWaR/uFtHtfGWd/NTpVqftP0aGlohtZ/5Lhn9e4dEqp9guFmL1fHaJ8btz6VPPCx7s8Gt jBwA= 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 Fri Aug 9 19:25:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13759187 Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (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 309B0168491; Fri, 9 Aug 2024 19:25:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231513; cv=none; b=gj/vQrt+RHhpvur5WEtsk9OxGlOAVf3a/usAG595+uezHgsrd73ctwuY61neX4rsw86jNAFY1pnjuABu5YtU2mLMdYIvd9UhtxpYBhQ34bLz95gKtgrjNFCtzSIjUS5ZJDUCioyReUlxeNGEC3W+8gZHTVHsDAXqOt/V2BbNvQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231513; c=relaxed/simple; bh=25PGnrDbozNqXeo66FAaZeG/EjrxdTBJIrhq5W4w0Zg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jc5V8EA+PElzcICeqQuPpIWH8ZIBA+O7jatsnL+mW2PFR3jutCtaIHs5d5Kjp2XJp7qbY4LlMPZTLuMmHQiAkpxaacF7YjZ2Cgl9t/TpdN7cmXlKnyc5k3kBQc3rOUZtAF1hP7qzJ5VxqXfKRMSANTg3RJcqjqblCmXpIkk6XGM= 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=FlUrNbVu; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=mL4aVRj2; arc=none smtp.client-ip=103.168.172.145 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="FlUrNbVu"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="mL4aVRj2" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id 8B2421388193; Fri, 9 Aug 2024 15:25:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 09 Aug 2024 15:25:11 -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=1723231511; x=1723317911; bh=91Ntn8+8S3tkwtkpXtQo+UUnbH7tPRABNLmEHtSRkko=; b= FlUrNbVuM7/wrsS0RQ6onehyaerYTFf/sTAMkFpo4g5NWPzZfApMyNWYgQ76wnOv jHYd0TqAMB1gDnbm2Qnlurdp5ugq80GbC6yMvbCCviXixFMCkDpfcN5zG6d3Crew 2lcpcYtwzS+hyYizziW1cqUjxMH1zxKirFOWeKf1rnN9HZ0vTniW6Fwb9Ej8lK3G hrQiCWgGXcvhOuF+M3MgUby0UDG+HGfEaIXSEBB6jvj0KJwKm+IMbhH5Zq8qHXjL bLNRDWWqk6RLxBfBRJO/9Wr463MY/AE0ZMRygxel6fnlaiuydzf3QxUq5c1R5fiq H3+DAyDrbqtnxzxY398aSQ== 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=1723231511; x= 1723317911; bh=91Ntn8+8S3tkwtkpXtQo+UUnbH7tPRABNLmEHtSRkko=; b=m L4aVRj20J54gh//0E554dy1KLgUuYcY50hSwvxQI0l2VhrWOn+ehY3hkoh7oPo3I dBYls/iwIeGuPRlg66Oko0O+qQXbpg8dihFgotJA/AhJkOJbEpAki5OfTM9mq2fm /8hJbv1CrMg/xNAx3q8NFJOY8ve1shSkXRRfTF60EK+2pBpdiMwjl0mV7q2YCr8D K3EJUIgUV9rkvuOckypAAmKUiGIy4uloHuRNsIw2Fgoq5PiIexDDAQiHnuMb3ZJu qoPMaX91CDQkUFcEek931VDi1KtMy1zp6jAlOmrpSPXx66Hm2fcg17efuDKpxf+o 4iQaFdWGOYXbBqqy1VH4g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrleeggddufeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eprghrnhgusegrrhhnuggsrdguvgdprhgtphhtthhopehjihgrgihunhdrhigrnhhgsehf lhihghhorghtrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrh drkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhssghoghgvnhgusegrlhhphhgrrdhf rhgrnhhkvghnrdguvgdprhgtphhtthhopegthhgvnhhhuhgrtggriheskhgvrhhnvghlrd horhhgpdhrtghpthhtoheplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdho rhhgpdhrtghpthhtoheplhhinhhugidqrghrtghhsehvghgvrhdrkhgvrhhnvghlrdhorh hgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Aug 2024 15:25:10 -0400 (EDT) From: Jiaxun Yang Date: Fri, 09 Aug 2024 20:25:05 +0100 Subject: [PATCH 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: <20240809-mips-numa-v1-5-568751803bf8@flygoat.com> References: <20240809-mips-numa-v1-0-568751803bf8@flygoat.com> In-Reply-To: <20240809-mips-numa-v1-0-568751803bf8@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=owGbwMvMwCXmXMhTe71c8zDjabUkhrRtufxx1o+nFocyPGJadDPpM2+4rAH7XPYysey3TVqhk 9UOXznYUcrCIMbFICumyBIioNS3ofHigusPsv7AzGFlAhnCwMUpABPRi2T4H63g0Vy68Hzg04aT PNLilRHh+243bJF8IjZ9z4JZjZLKTgz//awOP745f6t+bkf5seM7P6Tph04+YFF/0H5z6e/i9ab hbAA= 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 Fri Aug 9 19:25:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13759188 Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (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 BD36716A92B; Fri, 9 Aug 2024 19:25:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231515; cv=none; b=ZzXjGdp7RiLg0jlZmVaOw9K/AnoXf67YwaMFdEenTO1/2W/YMDyYgAvJNEgD5tVf5gczih6E5d0xjDni8BGSQy3jPW0JAfb+1AygNSrOhbz/F55vJmSrp28OLhMIY82MO6f5DfHzDyA10X8eKgQzuZ4k38QYQosg/ZSQJU1Zn2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231515; 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=dQDQVfJRtKFvBjA+U8fNjI7DRWsrYj0hLdqvfIhTdt7W7bOREp9MbrmL9YsI+YiK1l6mM6qR2m7dkRZmcS99CVA7enTAbsyJkp05H8KnVjAoKe3dCmOdtqSXMwfdkGgjW+Ra8u1CZywnMn1nhIZJXOTLWSMuanDb2DN9Tf9wYZ4= 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=Rtjs0aYZ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=NPy6tjut; arc=none smtp.client-ip=103.168.172.145 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="Rtjs0aYZ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="NPy6tjut" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.nyi.internal (Postfix) with ESMTP id D1CE4138E768; Fri, 9 Aug 2024 15:25:12 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 09 Aug 2024 15:25:12 -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=1723231512; x=1723317912; bh=Qvz55kKdJIbJNrXhcKsilfBcMcr0pmQRWrdGCF4uAkU=; b= Rtjs0aYZh+RywneCHHAR7LX8hkdgTh5l5OY8HxynRQGLa0jlG8YERozDlrubPUGK xWNRPrWBuDIQyfrmQsRXjC7nm/1TDO0NOQ0BJqmn+fOIA6u7Gb+OfxOHbGFQKRVt N4vxJHnEanialV2WqkRSdsCBTRY5VPuLFGnrYeFyG7hag+ov581WJhSISv62BVds plOgqQhcOhx8U/Pl6msKHbpZ2AKpBtTMxVniOq1KHuWrnwjyqMDMvWmjquYqfz1g mVCsVGZiqnYUAyMySSUMrC2G8WBIpulcoi5idw+LRZ0oZ7qQ200BIowfonWvVghy mhaGB75JoE3ImCSU2hySvg== 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=1723231512; x= 1723317912; bh=Qvz55kKdJIbJNrXhcKsilfBcMcr0pmQRWrdGCF4uAkU=; b=N Py6tjutpqPHSd09r1YilZuv+ovS/STt9/P41bzSPFo6gQddKuU3e2vXLZ5DYBuUW 9WWKLB/gbkzeQR6wbsOGd03m5EONcBnXH968eb459zz3/TxBE8SAzf8qrW7Kj1Fn Y8RIVK8+V85X4HlhPlbffKN+gqTfIVtT1ZmSXDrwPTL27gdhh3SPZTNgqd3IoGMh vvEyF4mUzZyDBaUm+nA1hAbwH9KLzh+rcakwcg8k9yYCrK89ykC6cM7207/+WG7I hTPrFzlK0U6xB0QBQe9n2kTCD2y8FBOGTFBBDzo+x89hXE4du75b2qo5pJPMLa1B rBzKyZQCGwPhRyTbzgzmw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrleeggddufeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eprghrnhgusegrrhhnuggsrdguvgdprhgtphhtthhopehjihgrgihunhdrhigrnhhgsehf lhihghhorghtrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrh drkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhssghoghgvnhgusegrlhhphhgrrdhf rhgrnhhkvghnrdguvgdprhgtphhtthhopegthhgvnhhhuhgrtggriheskhgvrhhnvghlrd horhhgpdhrtghpthhtoheplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdho rhhgpdhrtghpthhtoheplhhinhhugidqrghrtghhsehvghgvrhdrkhgvrhhnvghlrdhorh hgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Aug 2024 15:25:11 -0400 (EDT) From: Jiaxun Yang Date: Fri, 09 Aug 2024 20:25:06 +0100 Subject: [PATCH 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: <20240809-mips-numa-v1-6-568751803bf8@flygoat.com> References: <20240809-mips-numa-v1-0-568751803bf8@flygoat.com> In-Reply-To: <20240809-mips-numa-v1-0-568751803bf8@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=owGbwMvMwCXmXMhTe71c8zDjabUkhrRtufwNF7L3HtJonnR/9RH5z4tOqB616xX89cP3vsa0v 8K795lO6ihlYRDjYpAVU2QJEVDq29B4ccH1B1l/YOawMoEMYeDiFICJ8Ocy/A/+UrR919cqV9+H X66/7zIzu3t12i279pr3uqJR52cc3nSKkaE1QCnzse7XJwY1cm5PNbUTHGJiX/tLd+0sfHW+dm2 DOAsA 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 Fri Aug 9 19:25:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 13759189 Received: from fout2-smtp.messagingengine.com (fout2-smtp.messagingengine.com [103.168.172.145]) (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 EBAAC16B39F; Fri, 9 Aug 2024 19:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.145 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231516; cv=none; b=ANaiT4Pcx/i8ybtTS+klmzMTYR2522huw770yzn78c55B21PzUv1AfDNnN8eI5RrW8/KsSV+GNd60RmoEdWhX121L8zLI/I5KHQsTfNa0NrDlyvmEnW99zCJBqDZawhInmJPbgtlHYNs/lf9X2zaPrfy8zb8sEgoXE0VlvQybiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723231516; c=relaxed/simple; bh=+0h3Rgyd67gfl84X0A0L2yZJ6tl+tasYgp9SNGwj598=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Sz3fzLyrowNCi6XuNX2yYEbf5Jm1CQEMEOXxY2WZ3pw3520G+ADMwropLqHtuyYsa5FFmAxN5jUETQS4xaI0YG9VrJQ0A79qr4K9d+PQUvnBw0BMaNsgdNO4z6Xxl/uySf7OoFu3CwYw5MMPXk9V6PWJaGDZ/9Qss01/xvOgMrA= 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=V2NrbCtI; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ec01uNAe; arc=none smtp.client-ip=103.168.172.145 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="V2NrbCtI"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ec01uNAe" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.nyi.internal (Postfix) with ESMTP id 4FC00138FC4A; Fri, 9 Aug 2024 15:25:14 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 09 Aug 2024 15:25:14 -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=1723231514; x=1723317914; bh=g3CvfVEBDaUPTY5RbshqMg36ReqhANIf4Ba8J3xVInE=; b= V2NrbCtIRjIJvPfWvtWnD0dyfszX7QbypqYT7Ze5nHE/o/UGHGQaw8P8DJoCsHA/ qGGaQDq5GlR52DAziYhuRcHEt4gWiFKTXFkpA04qHPlYCf6EDTVgsttsaeAQ954i lhkltcFCuXmHXBmbqU/kQvXSTM66OlVNB7m6bVcwIvrNonvhkycfrlJPoUvwV0n0 u7jl8EUVe6QhPbiSqJXRGVCUjwqrPE3reaNXcaPVp8mQMJghuHTjLDK0przEyolk rZPj7LQznWO8Vnc3vOlBg2F4tG6MifRVwhXzPhB8noJfww28vc77Vk6QEvWAcyWY 50Ax31mDiBJplsHLZVjXAA== 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=1723231514; x= 1723317914; bh=g3CvfVEBDaUPTY5RbshqMg36ReqhANIf4Ba8J3xVInE=; b=e c01uNAeBxJ7lOv3LAfJMyrYUJHI/gjPXvHlfMBYrUPDgkBTbMTgdvEnb7kwc7zSq BiEon7kzkYMtP5PaAb9xmO+DD1tLNO2QjP7ZOSYxDzsQ42Iop+qZlJCl2BDMemk8 h/ysvEKaSFJSy7gq9sSot7Dpm0sjbudxsy1V6or7pWdgXZ9LzIVuTCgvo4qpJI36 V3sMNkvwbMlVdla2zKXd+cIe4or5lDksfO/mZiHtt+JgjWi758WSlufTVcTMmm0P HWDjFxfvD93ywaO4mx6NiRpNI86u0ZInRQFAYv6Yx0xUf63yFZBtbmDAk2v5TB0k Sps9eM5R6tNFvmnIOJfew== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrleeggddufeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdej necuhfhrohhmpeflihgrgihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhi hgohgrthdrtghomheqnecuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffek gedugefhtdduudeghfeuveegffegudekjeelnecuvehluhhsthgvrhfuihiivgepfeenuc frrghrrghmpehmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdr tghomhdpnhgspghrtghpthhtohepkedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoh eprghrnhgusegrrhhnuggsrdguvgdprhgtphhtthhopehjihgrgihunhdrhigrnhhgsehf lhihghhorghtrdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrh drkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhssghoghgvnhgusegrlhhphhgrrdhf rhgrnhhkvghnrdguvgdprhgtphhtthhopegthhgvnhhhuhgrtggriheskhgvrhhnvghlrd horhhgpdhrtghpthhtoheplhhinhhugidqmhhiphhssehvghgvrhdrkhgvrhhnvghlrdho rhhgpdhrtghpthhtoheplhhinhhugidqrghrtghhsehvghgvrhdrkhgvrhhnvghlrdhorh hgpdhrtghpthhtoheprhgrfhgrvghlsehkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 9 Aug 2024 15:25:13 -0400 (EDT) From: Jiaxun Yang Date: Fri, 09 Aug 2024 20:25:07 +0100 Subject: [PATCH 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: <20240809-mips-numa-v1-7-568751803bf8@flygoat.com> References: <20240809-mips-numa-v1-0-568751803bf8@flygoat.com> In-Reply-To: <20240809-mips-numa-v1-0-568751803bf8@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=11959; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=+0h3Rgyd67gfl84X0A0L2yZJ6tl+tasYgp9SNGwj598=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrRtufwaJu2vjoUvPhp381TUn+oEhvKt35cIyHP/ubrFN aHse/S7jlIWBjEuBlkxRZYQAaW+DY0XF1x/kPUHZg4rE8gQBi5OAZjIlscM/1MEplV8uPeW97zu i885G93Ptf56sulaQOMyxoUvTUu6LE0ZGZ4JfXymc9PDvKzmdpP7/bgvvLNsymftLGRduTL0wr4 9vawA 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 | 2 +- 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 | 27 ++-- arch/mips/loongson64/numa.c | 153 ++--------------------- arch/mips/loongson64/smp.c | 2 + 8 files changed, 24 insertions(+), 204 deletions(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 9284a06db2b4..1edf36f89171 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -2601,7 +2601,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..dad78bcce93f 100644 --- a/arch/mips/loongson64/init.c +++ b/arch/mips/loongson64/init.c @@ -46,9 +46,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 +58,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 +78,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 +104,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 +128,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<