Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp391062rdf; Tue, 21 Nov 2023 05:46:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IH7uRQAvOs5rGoFimYd5OUW0uN47NOXw0Miv+v59bspeYB71A+UR+lkAt7OEaY6u+kAM2Yl X-Received: by 2002:a05:6a21:19d:b0:187:a4df:4e57 with SMTP id le29-20020a056a21019d00b00187a4df4e57mr11717888pzb.20.1700574394339; Tue, 21 Nov 2023 05:46:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700574394; cv=none; d=google.com; s=arc-20160816; b=HzS9TNA4a4MbbjEJU2oqGvoLZwY27+D4gM01kZZ+dTjOvSRVTnA2TQiN/URMJQ9BKy 7bDlybqDSlLeeV8qEI/anUniufgwx6nEKlw3i5gnfXIsITE3K8XaqzsMMmFK5G8y3xbN Jq6avEnU/vSpIZpbr0PoJk0TZsmSN+lfTcIiyaVgDpACVTwGu6xDGEIvXv2WI2b0/AdV tLooM0RGKmIp9JsfYxGCvID3jlQT4pVfW47cPTEnITKLVw/Ljftvam1X1AkZnK5KDsbZ D7Mb/dFrzbRUlfrulGHYIZocceKrc/iYmbZQH3ZY7AE+A/FJfizSxbcw8SauatxWc74R cXzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:sender:message-id:content-transfer-encoding :content-disposition:mime-version:subject:cc:to:from:references :in-reply-to:dkim-signature; bh=fV0o2gSQt/DARDPlY5D5Cx2+ZCg+hXWngrJYRPplfQE=; fh=n/hNKOBwq2yLiZtHUXdrVYIb15Q112aXmz8Dk56reME=; b=K8STtHpVwPqlEBau726lVgIykd0PhpyNWrCLbg1XXZFqnEgbT9Q0PrEJX9ygQASjGN UeFIPch+vfHwouBWdVDDsyP75WwbIGhWhs4cMPsT8u9SSfJPy89vwnLwse7wz+ZD2uro ySPtPS5kyNEzIhbWr8NAZJJSbGYG+JOl8bH+cn2hUR00IdIGcp8sv98cx8ZrXOQBANZq 1h/AFCIzEgKds0p6boIt30mByQer3lNQT5WETGIOUV3jcmKZmiZq1KQEeAqsNeZGRv9i JeFjKl+uNGZ3mDRyE9YkAByRuXqDwjzy3NwA/4/ubyycBb2DEICVcugf6x9op5aK0ipx qsHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=ou9nnJrW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id f18-20020a056a001ad200b006bf840df9bdsi10790172pfv.27.2023.11.21.05.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 05:46:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=ou9nnJrW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3D7938084615; Tue, 21 Nov 2023 05:46:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234385AbjKUNqS (ORCPT + 99 others); Tue, 21 Nov 2023 08:46:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234515AbjKUNpw (ORCPT ); Tue, 21 Nov 2023 08:45:52 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5AA61FD6; Tue, 21 Nov 2023 05:45:22 -0800 (PST) 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=fV0o2gSQt/DARDPlY5D5Cx2+ZCg+hXWngrJYRPplfQE=; b=ou9nnJrWjEgMHuEDll4a2ldYy/ aEEC8HWvvTtzppdXmORNjfuWTkgNdLx0ksTh8En+30oUB+JwowVWENYven+GapDJL5mIu4Kulqfxi RCmYvK3TAi2Y+wqR6dE7YVOBd2sidgsDcfrr3JpedBV1YsK4eHt8e/v9kc1NSr62wDMIJDcWBmhRc vaD4Azk83j1nvMTBIcfo9EjJQcUWTDn4iLmYlAYu2DQul2ClFC6jXG5kuCaHak1HQi9OYAt8OEAPd q/x+oLg39zUnyLL+6heGUpBGZMR99r+0Qh9+4TvWzo+YLMyWTXbsgmanjcb2AwqSdKNGZ9MpxYoms EETGaG9A==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:43166 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 1r5R3z-0007Ao-1E; Tue, 21 Nov 2023 13:45:15 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1r5R41-00Ct04-Bg; Tue, 21 Nov 2023 13:45:17 +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 , Huacai Chen , WANG Xuerui Subject: [PATCH 17/21] LoongArch: Switch over to GENERIC_CPU_DEVICES MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Tue, 21 Nov 2023 13:45:17 +0000 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 21 Nov 2023 05:46:31 -0800 (PST) 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 is a subtle change. Originally: - on boot, topology_init() would have marked present CPUs that io_master() is true for as hotplug-incapable. - if a CPU is hotplugged that is an io_master(), it can later be hot-unplugged. The new behaviour is that any CPU that io_master() is true for will now always be marked as hotplug-incapable, thus even if it was hotplugged, it can no longer be hot-unplugged. 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: Gavin Shan Signed-off-by: Russell King (Oracle) --- Changes since RFC v2: * Explain the change in behaviour in the patch description (highlighted by Jonathan Cameron - thanks.) Add note about initialisation order change. --- arch/loongarch/Kconfig | 1 + arch/loongarch/kernel/topology.c | 29 ++--------------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index 331becb2cb4f..15d05dd2b7f3 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -72,6 +72,7 @@ config LOONGARCH select GENERIC_CLOCKEVENTS select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE + select GENERIC_CPU_DEVICES select GENERIC_ENTRY select GENERIC_GETTIMEOFDAY select GENERIC_IOREMAP if !ARCH_IOREMAP diff --git a/arch/loongarch/kernel/topology.c b/arch/loongarch/kernel/topology.c index ae860fe81536..7dfb46c68f58 100644 --- a/arch/loongarch/kernel/topology.c +++ b/arch/loongarch/kernel/topology.c @@ -10,20 +10,13 @@ #include -static DEFINE_PER_CPU(struct cpu, cpu_devices); - #ifdef CONFIG_HOTPLUG_CPU int arch_register_cpu(int cpu) { - int ret; struct cpu *c = &per_cpu(cpu_devices, cpu); - c->hotpluggable = 1; - ret = register_cpu(c, cpu); - if (ret < 0) - pr_warn("register_cpu %d failed (%d)\n", cpu, ret); - - return ret; + c->hotpluggable = !io_master(cpu); + return register_cpu(c, cpu); } void arch_unregister_cpu(int cpu) @@ -34,21 +27,3 @@ void arch_unregister_cpu(int cpu) unregister_cpu(c); } #endif - -static int __init topology_init(void) -{ - int i, ret; - - for_each_present_cpu(i) { - struct cpu *c = &per_cpu(cpu_devices, i); - - c->hotpluggable = !io_master(i); - ret = register_cpu(c, i); - if (ret < 0) - pr_warn("topology_init: register_cpu %d failed (%d)\n", i, ret); - } - - return 0; -} - -subsys_initcall(topology_init); -- 2.30.2