From patchwork Tue Oct 24 15:17:26 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: 157569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2016242vqx; Tue, 24 Oct 2023 08:19:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdz09tO1H9lrAWGJ8u5ZObyLNX/FSu5x7P2ReaSU/gwonsfWTJk2OoIKUTajd23eZ9BsLh X-Received: by 2002:a05:6359:1b82:b0:168:d161:c907 with SMTP id ur2-20020a0563591b8200b00168d161c907mr7053283rwb.18.1698160763796; Tue, 24 Oct 2023 08:19:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698160763; cv=none; d=google.com; s=arc-20160816; b=LJbng7NNkaZp1ybMVE6Fo+cV0mTEnDGYpA+cnMan1hI0bRgPQ/CBLP3juE/K1Gwk1I tXTvr2Hngi9ZgvWInbvHJUW3C0CcbM4g/jPIuikjYPqR/BgrdaXVEnghGmUHTcYCE1wm ciV16VhaNqj0x28Dleg/a5gu0BecLL7yDArOO4LG9XPBGiJpN7wa7sA6tG97sxgGrQn8 /q9uh+ECAWszfXvK8zj53ZDKSvn+h0VH2S7pjzWMUWy/+5jYaojcWZ3UiWtZlzChHiIp ojQ93WWFLrNNuPZFv5naYbQOmPL2j6VXclN+TzOrK9nmWb1PNx31neB5r94RKkD0lE3L Kreg== 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=CjScRbjimPWolEjPv1iNmcYG5tuVKE74LVx0kYeqVqg=; fh=n/hNKOBwq2yLiZtHUXdrVYIb15Q112aXmz8Dk56reME=; b=cHAVW9Kkba/atXBnQsrnt1Anp/r0w88s2zoYRrrq+Wjtta1RWnA5939pIf67xsxsQ4 ZbwZjSezN/yCmhQD1YGSd4w7jPQcvQJezZEmJuZQqmQaQeo6NOAm0p1hArC2jDFc4WIM iF/0UYNWvjUa3jxTPPOXa4/4sE07XLxbDyzycAhDbjYKoKbFJ2iFBZkzr7GoT0ycKAzv levu6skLdj201q+6oldOWs6fsp+/qlQn9nEkL9TZrlsjpBzSYj4vDnJE6g7htd2Vypag kFblmPD3D8ccaf2k+s3HA7VLs0Sug0MPznpsk8fDcUhV1S+zVsOERu8I+T3obUGY2yom tAOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=vWxJVtsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id x4-20020a63db44000000b005b106cd44d1si8506531pgi.486.2023.10.24.08.19.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 08:19:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=vWxJVtsg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id F32CD8069D9B; Tue, 24 Oct 2023 08:19:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343732AbjJXPTU (ORCPT + 27 others); Tue, 24 Oct 2023 11:19:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234736AbjJXPS0 (ORCPT ); Tue, 24 Oct 2023 11:18:26 -0400 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 D9BA4199A; Tue, 24 Oct 2023 08:17:35 -0700 (PDT) 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=CjScRbjimPWolEjPv1iNmcYG5tuVKE74LVx0kYeqVqg=; b=vWxJVtsg7WAxV+31eW086kiVVz +Nfq4GNnO/goU36WX82JXeCpyz1NRsTtPu+wCbSUfXCIxDEs8V2oWVRggK16YBGzFFxeQ+OnMmZJx SKduHKqxOYaitZ5qSYpjaCC0mvbjdemJ7HST9R8ycAJWqs8qXQ/6cjIBtkPQnUeXcUewNThjp+aOB 3aqMMgcdALK6mkVwT0lgVBdBJKtVLR6yPuBhyST5VM/0eclmOmMma1u7G/bGi/oWtm9qAcpwTa/tA rxS9YGk4y0z9idXXB4mRIJ5H2iWjMlEX9mJu2motC/v1mbTTHrodN2WdAL7T9Y+SC/cMdxPfwyp5P 9dxgHRjw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:34774 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 1qvJ9o-0004Pd-3B; Tue, 24 Oct 2023 16:17:25 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qvJ9q-00AqQI-F8; Tue, 24 Oct 2023 16:17:26 +0100 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 15/39] LoongArch: Switch over to GENERIC_CPU_DEVICES MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Tue, 24 Oct 2023 16:17:26 +0100 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 24 Oct 2023 08:19:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780650621167020795 X-GMAIL-MSGID: 1780650621167020795 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 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 2bddd202470e..5bed51adc68c 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 3fd166006698..bf58351beac1 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); } EXPORT_SYMBOL(arch_register_cpu); @@ -36,21 +29,3 @@ void arch_unregister_cpu(int cpu) } EXPORT_SYMBOL(arch_unregister_cpu); #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);