Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1960884rda; Tue, 24 Oct 2023 08:18:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGcKQ0FDmurYl9g3v26AR8hYDU+np9lk0IScWgmX1ds8Ok9gB1AoXsm1OCoqh2mfHWzFQ3g X-Received: by 2002:a05:6a21:300a:b0:15e:e0fd:98e7 with SMTP id yd10-20020a056a21300a00b0015ee0fd98e7mr2339557pzb.20.1698160682927; Tue, 24 Oct 2023 08:18:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698160682; cv=none; d=google.com; s=arc-20160816; b=s+QLATRi5kZvhLyTsyTqam+ajqPkSwdE8YFWmEaCWsfMwhLpYChvApXG9QDBLE0FbB xaWdvRV469fjxCFM3VCaOVWfRvtzKtUanMdHT+39lz2Qe1xwafpjyK60rQBXpC3LZ36w I4/yMxPIVQAmXrhpwEiyOmG8WwuV/8dT0fsKXa6mqrhc6N2GfkxSUE4Eyg339mNWvzuX Zo8pmBm3u1X3d00eQ1XWhtPaJD9hwbaIx6/kCDSZsqfCM6jjGCYTtMJ1rPsK9pqMpl03 o9GBzatNHeR53E3sSOpv5TXDz2k+UVflZp2WJ2r1+lA1ZwfzgStS5O7sVXqYEsNcD3xb njLw== 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=Bek5t65Mv3fYDdKvQVrQkwjkk4n1DGH+oZrcfOeVS74=; fh=LW6ZRmO9kYoQb475Mc6z0FqzhzjQXlW0CJbvlbG+cyY=; b=ypZBOYLYI6HcLcFL5+B5DbQYZbfZKj4mZH77a67lO70bpVBQ/IAG2UWLi3UsdFJpe+ X65hbGzkP1rFOctN1DW2hHdHFLwyfcJ+4JIwQXSVYyYejcoUUsPVNhuwhJXSWNL4WEsU KOwmnQ0TGLeaxmI0SIYxDYAOj2iFNPRecI3D8tAaT0CbfW8yfl8Yf+GUZhwosZIsqDND Vu0wMWxQM9u1uiPyHebRDKaGmgSFxbah/LEwUQpjNTGyJJxpfP97W5X99xCHzbOMiPhP AV/kl092H7liBtqOZzQGs1Rw9mBMxQOW8jTrHlwgNUM+lQpESaorFhNYBm87Tyzq8q94 CIHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=e+a+n+AS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id u135-20020a63798d000000b0057c313b17bbsi567700pgc.125.2023.10.24.08.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 08:18:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=e+a+n+AS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 84231807BECE; Tue, 24 Oct 2023 08:18:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234687AbjJXPRs (ORCPT + 99 others); Tue, 24 Oct 2023 11:17:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233646AbjJXPRR (ORCPT ); Tue, 24 Oct 2023 11:17:17 -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 4AABF1BCC; Tue, 24 Oct 2023 08:16:55 -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=Bek5t65Mv3fYDdKvQVrQkwjkk4n1DGH+oZrcfOeVS74=; b=e+a+n+ASBkVUcxCKNzpfu1MolF 8w3zyx+g85QSlzdy5H0mrU0khmmN6+phJ/d1ilAaVgAxdRja2NJyqqQSe6MjCYf4PaN7Qmt9ix00H FcOjtcEft9LjrZGlx+1xevB+BsQkErxYtUQROPxSX5u0NBISJ7jMaJlR4hmMxIQr6ow5t+yKlBYOk 3ynqwE+Zdn4aQqykomLvfhAtQEUKx7CWIz/hJvJWE2QFI3nfCzxf0SDSehJ+NtkzAWY6c+GN/2+lS 4v5DUvmChM28afv37423PGfptGVcfCKLVQqGMOEDPRbYexCtdBfCRVxpLWLTG3qttpIM72t3LM+UU U6ykb5Sg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:50818 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 1qvJ99-0004Ms-2a; Tue, 24 Oct 2023 16:16:43 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qvJ9B-00AqPS-9x; Tue, 24 Oct 2023 16:16:45 +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 , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Peter Zijlstra Subject: [PATCH 07/39] 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, 24 Oct 2023 16:16:45 +0100 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 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, 24 Oct 2023 08:18:00 -0700 (PDT) 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 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 eb768a866fe3..e117c06e0c6b 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