From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67C99C4167B for ; Thu, 9 Nov 2023 10:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232700AbjKIKO2 (ORCPT ); Thu, 9 Nov 2023 05:14:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231768AbjKIKOZ (ORCPT ); Thu, 9 Nov 2023 05:14:25 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB5972D7D for ; Thu, 9 Nov 2023 02:13:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699524821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3rYhpoB4lYmS4MLIzZUo4ZMf6R8bUZVPeYV6RdLZieo=; b=E2v8fSxBvFkLindDHRP2KJPgblNMHkW5wXqmQ+/apgPHwlPiakJhyxihtFqlR+fqJRJw56 HzFnXWYIGjKlxkrikxytVcuOz13Yhfz/VL9zfUmXIC+bxB4eLhhtVph02VZYZA9niZNBb9 mp2Q5zwCIOB1CgJt0jSs2y6MM3F/XpM= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-487-mmbZ3kFmOBih4YuMeR5HMw-1; Thu, 09 Nov 2023 05:13:39 -0500 X-MC-Unique: mmbZ3kFmOBih4YuMeR5HMw-1 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-2800fffc08eso192801a91.0 for ; Thu, 09 Nov 2023 02:13:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699524814; x=1700129614; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3rYhpoB4lYmS4MLIzZUo4ZMf6R8bUZVPeYV6RdLZieo=; b=Yl/047Dj9+T7ESXEgh084Atnwzx/NbVU7RpfTKiqD2k7qbc5sxHp8N2Ppv+vZWSCK9 Vmy9WC0Uk36SJPP30z0Y8GngXfTT7HStE5eLMQOSKIAV+qR8oUaKPGyZWgIO+sTIgO2P moU+4CwrvZMSwvSHPnR+r7Ik41ceqwwgqopMyHUeBuORphpb3mFO+US9fjvUufDxHMUz xkIMRi9NX4jUOsD3VsFV6pe0UExn++1O2NnztA3rK2mJPLrGq7ITuykrKUAKVgRGexFd Kw4RL/gWmO696GCUg7/FHVp+PYqsK4Pqv0mA7g6Odl7tjas4aVrX2r5XyjGiW2NvNwDS kr8g== X-Gm-Message-State: AOJu0YxVqnDYFA39MyxL50hjtbkwRZ+lD81VemhJmfg5t3HkCE9lUxjV RcC3anUxGw30F98LaoPh+u8S52G4j5HXTmjvtIJgKDlLQu/m4GAFqAJpxaTp7GcPErT2aU+Ssmi oQ+vbB+sfOXk8z0LIULwYModi X-Received: by 2002:a17:903:120e:b0:1cc:ebe:5547 with SMTP id l14-20020a170903120e00b001cc0ebe5547mr5043360plh.0.1699524813773; Thu, 09 Nov 2023 02:13:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMYccyPUYXdRLbiWAt/Rrr2lff8DkVfjHrlmnPr9rVOEThxcSXfzeRdAMTZ0+vEY8CCgW5xw== X-Received: by 2002:a17:903:120e:b0:1cc:ebe:5547 with SMTP id l14-20020a170903120e00b001cc0ebe5547mr5043330plh.0.1699524813447; Thu, 09 Nov 2023 02:13:33 -0800 (PST) Received: from [10.66.61.39] ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id p2-20020a170902e74200b001c60a2b5c61sm3165370plf.134.2023.11.09.02.13.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Nov 2023 02:13:33 -0800 (PST) Message-ID: <6341a77d-ba42-3f3a-4a2a-b598fb5c0e20@redhat.com> Date: Thu, 9 Nov 2023 18:13:26 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH RFC 07/22] drivers: base: Allow parts of GENERIC_CPU_DEVICES to be overridden Content-Language: en-US To: "Russell King (Oracle)" , 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 References: From: Shaoqin Huang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/7/23 18:29, Russell King (Oracle) wrote: > 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) Reviewed-by: Shaoqin Huang > --- > 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 -- Shaoqin