Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp390695rdf; Tue, 21 Nov 2023 05:46:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IHb3v9l6OdCd0wsD+eyFbk/FK2E3YSS2H77FAa6e/CHkdCKjjIWuUeeOiw+rzRdaDUK9Bce X-Received: by 2002:a05:6e02:16c6:b0:35a:d63f:f559 with SMTP id 6-20020a056e0216c600b0035ad63ff559mr13689627ilx.27.1700574361903; Tue, 21 Nov 2023 05:46:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700574361; cv=none; d=google.com; s=arc-20160816; b=rP/IpmctOC1/r33Nt+oOCibZrp4KeEiwf1RoVxj9zkMEH4ZAx9jU1onhUHVVzYH0CV ImyTpxwSn47niAcIP7KK+ImiyIWOu/C/7uM7x03L9YPsdr0yvw/DXXKV3/4qDM9Ie7OQ n1rsmGUPdMKcDVaIf9CLiI8nN4Lm+9XbD1HXC4QT9hGYTzd65VYrkzl13rCPxp97WddS zJcPF22G5z0lsJLEkkMTP2voHeNsE9D2wsQLSEiiyz/UIVF+EMpN5mA4DmHVEa/T5qlG 3HdVjTYB0yE6Idx6hJzA47EoT8Q0fr1rJU/tmpyiFQtgQMGXI9mp8APbdw6spolTRLNo rTQw== 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=winLqcGTMq+SZizf/UjYofCIetGbvjNiBTRLKegVEMg=; fh=LW6ZRmO9kYoQb475Mc6z0FqzhzjQXlW0CJbvlbG+cyY=; b=xMXmLoNS2H7JejmFa00tG+2k0XIHWpQ7DSlCtLtl5t7dgdYEggMLu69IcXIepnIOrW iWoAdhKw0QVzA4RXSLlQ84HcIa3PjuTc+J7D6rl9BsydCA9JPae246zt8vB7OWp3n2ql YHb4loiIZM1nXqpnJytPvKE1OV5m42lDajIFR5Ol6n7cweEc6XjzVsSsHtaLOq96n8su DMey9Q5dbys3BDdnn9R1kbFpWZu4HTJxxDfSTWStwYiba1LfFGMn5fkgiHmz0Mz+n2Lp q7ftQfQznyRCW+k39C20GLVd1qjLEANLz1MTSQkZdrBKrjZwYhomS3WoW8HgGp+5tcnR MCNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b="PUMuHBv/"; 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 b1-20020a6567c1000000b005bd42f6085fsi10397391pgs.344.2023.11.21.05.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 05:46:01 -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="PUMuHBv/"; 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 70B678087279; Tue, 21 Nov 2023 05:45:15 -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 S234494AbjKUNo6 (ORCPT + 99 others); Tue, 21 Nov 2023 08:44:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234431AbjKUNoo (ORCPT ); Tue, 21 Nov 2023 08:44:44 -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 97C2E1721; Tue, 21 Nov 2023 05:44:40 -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=winLqcGTMq+SZizf/UjYofCIetGbvjNiBTRLKegVEMg=; b=PUMuHBv/SPVt12mWH7RCTV7yct rtAqDiaiK+G4xH0InybHlUIy2MghCYS9HSICK65UqkE7bZdyD+GgDNFCImlKtiyGh3OJSTHoqmk9G W3NgRgRXXDW92VmysYEVBLCHvFHjZY822RfhLQa/Vag9qZ8ztxtMjD7wlLC3utEX/nnRUHyeQMAUx KsC4Qxgbl+5QRb9orB4X5xzIGxyWgjnMu9jma0sMRIzIHmWcKs8fgqRlJEJKYue2gHUKYThSMSNkm UEpY5UM8Ak00vS2sIXu4bCYORzvzyeZU337wvBN74Xtd/OYs+xfhEkosJH0Flu+2VWGrBZZs64b23 jrpMiytg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:34688 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 1r5R3A-00077a-0H; Tue, 21 Nov 2023 13:44:24 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1r5R3B-00Csz6-Uh; Tue, 21 Nov 2023 13:44:25 +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 , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Peter Zijlstra Subject: [PATCH 07/21] drivers: base: Allow parts of GENERIC_CPU_DEVICES to be overridden 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:44:25 +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:45:15 -0800 (PST) From: James Morse Architectures often have extra per-cpu work that needs doing before a CPU is registered, often to determine if a CPU is hotpluggable. To allow the ACPI architectures to use GENERIC_CPU_DEVICES, move the cpu_register() call into arch_register_cpu(), which is made __weak so architectures with extra work can override it. This aligns with the way x86, ia64 and loongarch register hotplug CPUs when they become present. Signed-off-by: James Morse Reviewed-by: Shaoqin Huang Reviewed-by: Gavin Shan Signed-off-by: Russell King (Oracle) --- Changes since RFC: * Dropped __init from x86/ia64 arch_register_cpu() Changes since RFC v2: * Dropped unnecessary Loongarch asm/cpu.h changes --- drivers/base/cpu.c | 14 ++++++++++---- include/linux/cpu.h | 4 ++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 34b48f660b6b..579064fda97b 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -525,19 +525,25 @@ bool cpu_is_hotpluggable(unsigned int cpu) EXPORT_SYMBOL_GPL(cpu_is_hotpluggable); #ifdef CONFIG_GENERIC_CPU_DEVICES -static DEFINE_PER_CPU(struct cpu, cpu_devices); +DEFINE_PER_CPU(struct cpu, cpu_devices); + +int __weak arch_register_cpu(int cpu) +{ + return register_cpu(&per_cpu(cpu_devices, cpu), cpu); +} #endif static void __init cpu_dev_register_generic(void) { -#ifdef CONFIG_GENERIC_CPU_DEVICES int i; + if (!IS_ENABLED(CONFIG_GENERIC_CPU_DEVICES)) + return; + for_each_present_cpu(i) { - if (register_cpu(&per_cpu(cpu_devices, i), i)) + if (arch_register_cpu(i)) panic("Failed to register CPU device"); } -#endif } #ifdef CONFIG_GENERIC_CPU_VULNERABILITIES diff --git a/include/linux/cpu.h b/include/linux/cpu.h index fc8094419084..1e982d63eae8 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -88,6 +88,10 @@ extern ssize_t arch_cpu_probe(const char *, size_t); extern ssize_t arch_cpu_release(const char *, size_t); #endif +#ifdef CONFIG_GENERIC_CPU_DEVICES +DECLARE_PER_CPU(struct cpu, cpu_devices); +#endif + /* * These states are not related to the core CPU hotplug mechanism. They are * used by various (sub)architectures to track internal state -- 2.30.2