From patchwork Tue Nov 21 13:45:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13463157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ED6C2C61D96 for ; Tue, 21 Nov 2023 13:46:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vAeoLZ7uKC6WF2HYSfw0qsZF07s2kvDOsmB7u6qFUbc=; b=eTtA0wMHjAW/Vs Lg6D31yyR/bbyTh/WstTJYSewFJmivommTE8DOh5mX7WOr/v6uOkayAodL/zlUWzmGxRhxjxvs5nA dLv4GgYKy9Iss8JgVe48lWeRDEDOIWKsnywEMng064OnR9T60muEfkPA+wJ6PfaoiU7Eq8Evdpde4 7HE9r09oMhfAGPrtw6p0MahkvO9s+NPTleXsvTi1xYhTey491rqBbwJ7Omv1zukpTDizKeniKpozy 0tK7uGhpwaE1wF9DNa3Pje0yoxDhk47D5EYhBXDndFK2UVFIZL9ITBFjB71R3gl0g5jTuy0UphodS SuDkHI7V9J/DoY8qZwDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5R4h-00Gs1w-25; Tue, 21 Nov 2023 13:45:59 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5R4N-00Grib-1T; Tue, 21 Nov 2023 13:45:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=MybTCs6tsYZDrwJz/++A+jmJRhrdL7CvULTcPkTUtec=; b=yzid5gv5SI5zY82Hlc1Gt6Bd9y m9LlGnvDe1oaHlCUMboOtTQz5h6uH+Ke+69oLozVrDB6dLaORXxXl/DbU6QPKyWF5l0zxta33zkKG cWFLEBGo7dus40E3F+EA+glDPsU7Vj5WNTCB11yCB3RakaNWaCQ9L64M0i8WZpwaP074iuyAl44tP H0ieRtkQOt4gZijRMlEVjeHmr9p3sPOD7shJvXB8jyy5p7eF/kJ/7LFE2eGUed00r5eWDSYwl//fN t5iFOFTK0Ng7gnrCXr4WCSAoouBK3GUsmLGOi9NXTSNb73eKSfyYpuzymHp4J4xHG88yq9zmZ0R59 /VUfegHQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:32994 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1r5R4E-0007Bi-2f; Tue, 21 Nov 2023 13:45:30 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1r5R4G-00Ct0M-PS; Tue, 21 Nov 2023 13:45:32 +0000 In-Reply-To: References: From: Russell King (Oracle) To: linux-pm@vger.kernel.org, loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, kvmarm@lists.linux.dev, x86@kernel.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse , Paul Walmsley , Palmer Dabbelt , Albert Ou Subject: [PATCH 20/21] riscv: Switch over to GENERIC_CPU_DEVICES MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Tue, 21 Nov 2023 13:45:32 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231121_054539_522072_02DD44D4 X-CRM114-Status: GOOD ( 12.67 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: James Morse Now that GENERIC_CPU_DEVICES calls arch_register_cpu(), which can be overridden by the arch code, switch over to this to allow common code to choose when the register_cpu() call is made. This allows topology_init() to be removed. This is an intermediate step to the logic being moved to drivers/acpi, where GENERIC_CPU_DEVICES will do the work when booting with acpi=off. This patch also has the effect of moving the registration of CPUs from subsys to driver core initialisation, prior to any initcalls running. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron Acked-by: Palmer Dabbelt Reviewed-by: Gavin Shan Signed-off-by: Russell King (Oracle) Reviewed-by: Samuel Holland Tested-by: Samuel Holland --- Changes since RFC v2: * Add note about initialisation order change. --- arch/riscv/Kconfig | 1 + arch/riscv/kernel/setup.c | 19 ++++--------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 95a2a06acc6a..162425cb9739 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -71,6 +71,7 @@ config RISCV select GENERIC_ARCH_TOPOLOGY select GENERIC_ATOMIC64 if !64BIT select GENERIC_CLOCKEVENTS_BROADCAST if SMP + select GENERIC_CPU_DEVICES select GENERIC_EARLY_IOREMAP select GENERIC_ENTRY select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index 535a837de55d..b3a0aa2b78d5 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -51,7 +51,6 @@ atomic_t hart_lottery __section(".sdata") #endif ; unsigned long boot_cpu_hartid; -static DEFINE_PER_CPU(struct cpu, cpu_devices); /* * Place kernel memory regions on the resource tree so that @@ -299,23 +298,13 @@ void __init setup_arch(char **cmdline_p) riscv_user_isa_enable(); } -static int __init topology_init(void) +int arch_register_cpu(int cpu) { - int i, ret; + struct cpu *c = &per_cpu(cpu_devices, cpu); - for_each_possible_cpu(i) { - struct cpu *cpu = &per_cpu(cpu_devices, i); - - cpu->hotpluggable = cpu_has_hotplug(i); - ret = register_cpu(cpu, i); - if (unlikely(ret)) - pr_warn("Warning: %s: register_cpu %d failed (%d)\n", - __func__, i, ret); - } - - return 0; + c->hotpluggable = cpu_has_hotplug(cpu); + return register_cpu(c, cpu); } -subsys_initcall(topology_init); void free_initmem(void) {