[RFC,v2,20/35] ACPI: Rename acpi_processor_hotadd_init and remove pre-processor guards
Message ID | 20230913163823.7880-21-james.morse@arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1219094vqx; Wed, 13 Sep 2023 09:50:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtchcn9KnWKYqQPznKT87l4oPXOYryoK04mQnZEN/Cdga9NEwQDxNH45GmR6AY/tzl9Dio X-Received: by 2002:a17:90a:ca03:b0:273:e142:f710 with SMTP id x3-20020a17090aca0300b00273e142f710mr2764700pjt.31.1694623800066; Wed, 13 Sep 2023 09:50:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623800; cv=none; d=google.com; s=arc-20160816; b=D0oZivxdL1LJBSFomiMTxStCXIX9ZjGa5doGlyDfaFKATRapZ6sCc97WetpRsai19a 00mZUJjbvMqyItJzGWBphqpxZcNLRcaZhuTpVryr+QWww3+xrk92zUf9c1MfGDYXNk/N VR10wQTxjo9MmwJxhUOLFxtiWtSl2vNvglfjVmEt+s51Cp+sF4hbi78TSkxNUQdCpnEe zYl3aHyQ4y8GJ7RsrLGxua9ivDsl3SpIgDizoMo7d3wOzNTwykCtNeohGJ5xwZ4z4AyU EDEQ05pxfwAgs2x2cYjm12L8oYnoIbPUR5cBS3WpqUBE4pmLnvl9zOP39wf3x+taW2se eD9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1ctR8ZCNNr7f0XTIyigb3hM1NYAwEJ1wpNQUZMMRwAM=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=lph6zVFpI4VXVyaiNh1/V8oD8sSWBfJ+TPxpcHx9xQxXKkHlVGe5qmYPmuakFez+Dz 9jf4I6pMYT1QD5evGxR+l8Ys49PPmV6MtemQWzvWFDETSOq5kheY4ZHJeDSUeRlzHrKY zifranKC0KWGF64gwcJOTaJEmD1whd3yXX0uxA4hJMqinZf0RRS8hAwnMjMVc7bDvzpU 5TdjACX8I1hwDhzNo/NRCoz261Aff8stmBTaHL68HSPfXgHesFkKWkUbh+Y6ikmVbq0E TpKsE1RQ8CjjMpiOwBEZ7Bl4uNRurRWf4O+YN0B1aGh0bMgz6TO+EbRR1nZcj/quZBIi 9KQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id gv15-20020a17090b11cf00b00267ba1c43adsi1861478pjb.101.2023.09.13.09.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:50:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 8854D835C14D; Wed, 13 Sep 2023 09:41:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231247AbjIMQkt (ORCPT <rfc822;pwkd43@gmail.com> + 35 others); Wed, 13 Sep 2023 12:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231245AbjIMQj5 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Sep 2023 12:39:57 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5CBC51BD6; Wed, 13 Sep 2023 09:39:33 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5BBDB1FB; Wed, 13 Sep 2023 09:40:10 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 57FDF3F5A1; Wed, 13 Sep 2023 09:39:31 -0700 (PDT) From: James Morse <james.morse@arm.com> 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 Cc: x86@kernel.org, Salil Mehta <salil.mehta@huawei.com>, Russell King <linux@armlinux.org.uk>, Jean-Philippe Brucker <jean-philippe@linaro.org>, jianyong.wu@arm.com, justin.he@arm.com Subject: [RFC PATCH v2 20/35] ACPI: Rename acpi_processor_hotadd_init and remove pre-processor guards Date: Wed, 13 Sep 2023 16:38:08 +0000 Message-Id: <20230913163823.7880-21-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230913163823.7880-1-james.morse@arm.com> References: <20230913163823.7880-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:41:06 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=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 pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941845843805703 X-GMAIL-MSGID: 1776941845843805703 |
Series |
ACPI/arm64: add support for virtual cpuhotplug
|
|
Commit Message
James Morse
Sept. 13, 2023, 4:38 p.m. UTC
acpi_processor_hotadd_init() will make a CPU present by mapping it
based on its hardware id.
'hotadd_init' is ambiguous once there are two different behaviours
for cpu hotplug. This is for toggling the _STA present bit. Subsequent
patches will add support for toggling the _STA enabled bit, named
acpi_processor_make_enabled().
Rename it acpi_processor_make_present() to make it clear this is
for CPUs that were not previously present.
Expose the function prototypes it uses to allow the preprocessor
guards to be removed. The IS_ENABLED() check will let the compiler
dead-code elimination pass remove this if it isn't going to be
used.
Signed-off-by: James Morse <james.morse@arm.com>
---
drivers/acpi/acpi_processor.c | 14 +++++---------
include/linux/acpi.h | 2 --
2 files changed, 5 insertions(+), 11 deletions(-)
Comments
On Wed, 13 Sep 2023 16:38:08 +0000 James Morse <james.morse@arm.com> wrote: > acpi_processor_hotadd_init() will make a CPU present by mapping it > based on its hardware id. > > 'hotadd_init' is ambiguous once there are two different behaviours > for cpu hotplug. This is for toggling the _STA present bit. Subsequent > patches will add support for toggling the _STA enabled bit, named > acpi_processor_make_enabled(). > > Rename it acpi_processor_make_present() to make it clear this is > for CPUs that were not previously present. > > Expose the function prototypes it uses to allow the preprocessor > guards to be removed. The IS_ENABLED() check will let the compiler > dead-code elimination pass remove this if it isn't going to be > used. > > Signed-off-by: James Morse <james.morse@arm.com> > --- > drivers/acpi/acpi_processor.c | 14 +++++--------- > include/linux/acpi.h | 2 -- > 2 files changed, 5 insertions(+), 11 deletions(-) > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c > index 75257fae10e7..22a15a614f95 100644 > --- a/drivers/acpi/acpi_processor.c > +++ b/drivers/acpi/acpi_processor.c > @@ -182,13 +182,15 @@ static void __init acpi_pcc_cpufreq_init(void) {} > #endif /* CONFIG_X86 */ > > /* Initialization */ > -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU > -static int acpi_processor_hotadd_init(struct acpi_processor *pr) > +static int acpi_processor_make_present(struct acpi_processor *pr) > { > unsigned long long sta; > acpi_status status; > int ret; > > + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) > + return -ENODEV; > + > if (invalid_phys_cpuid(pr->phys_id)) > return -ENODEV; > > @@ -222,12 +224,6 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) > cpu_maps_update_done(); > return ret; > } > -#else > -static inline int acpi_processor_hotadd_init(struct acpi_processor *pr) > -{ > - return -ENODEV; > -} > -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ > > static int acpi_processor_get_info(struct acpi_device *device) > { > @@ -335,7 +331,7 @@ static int acpi_processor_get_info(struct acpi_device *device) > * because cpuid <-> apicid mapping is persistent now. > */ > if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { > - int ret = acpi_processor_hotadd_init(pr); > + int ret = acpi_processor_make_present(pr); > > if (ret) > return ret; > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index 651dd43976a9..b7ab85857bb7 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -316,12 +316,10 @@ static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, > } > #endif > > -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU > /* Arch dependent functions for cpu hotplug support */ > int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, > int *pcpu); > int acpi_unmap_cpu(int cpu); I've lost track somewhat but I think the definitions of these are still under ifdefs which is messy if nothing else and might cause build issues. > -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ > > #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC > int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
On 9/15/23 00:17, Jonathan Cameron wrote: > On Wed, 13 Sep 2023 16:38:08 +0000 > James Morse <james.morse@arm.com> wrote: > >> acpi_processor_hotadd_init() will make a CPU present by mapping it >> based on its hardware id. >> >> 'hotadd_init' is ambiguous once there are two different behaviours >> for cpu hotplug. This is for toggling the _STA present bit. Subsequent >> patches will add support for toggling the _STA enabled bit, named >> acpi_processor_make_enabled(). >> >> Rename it acpi_processor_make_present() to make it clear this is >> for CPUs that were not previously present. >> >> Expose the function prototypes it uses to allow the preprocessor >> guards to be removed. The IS_ENABLED() check will let the compiler >> dead-code elimination pass remove this if it isn't going to be >> used. >> >> Signed-off-by: James Morse <james.morse@arm.com> >> --- >> drivers/acpi/acpi_processor.c | 14 +++++--------- >> include/linux/acpi.h | 2 -- >> 2 files changed, 5 insertions(+), 11 deletions(-) >> >> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c >> index 75257fae10e7..22a15a614f95 100644 >> --- a/drivers/acpi/acpi_processor.c >> +++ b/drivers/acpi/acpi_processor.c >> @@ -182,13 +182,15 @@ static void __init acpi_pcc_cpufreq_init(void) {} >> #endif /* CONFIG_X86 */ >> >> /* Initialization */ >> -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU >> -static int acpi_processor_hotadd_init(struct acpi_processor *pr) >> +static int acpi_processor_make_present(struct acpi_processor *pr) >> { >> unsigned long long sta; >> acpi_status status; >> int ret; >> >> + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) >> + return -ENODEV; >> + >> if (invalid_phys_cpuid(pr->phys_id)) >> return -ENODEV; >> >> @@ -222,12 +224,6 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) >> cpu_maps_update_done(); >> return ret; >> } >> -#else >> -static inline int acpi_processor_hotadd_init(struct acpi_processor *pr) >> -{ >> - return -ENODEV; >> -} >> -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ >> >> static int acpi_processor_get_info(struct acpi_device *device) >> { >> @@ -335,7 +331,7 @@ static int acpi_processor_get_info(struct acpi_device *device) >> * because cpuid <-> apicid mapping is persistent now. >> */ >> if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { >> - int ret = acpi_processor_hotadd_init(pr); >> + int ret = acpi_processor_make_present(pr); >> >> if (ret) >> return ret; >> diff --git a/include/linux/acpi.h b/include/linux/acpi.h >> index 651dd43976a9..b7ab85857bb7 100644 >> --- a/include/linux/acpi.h >> +++ b/include/linux/acpi.h >> @@ -316,12 +316,10 @@ static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, >> } >> #endif >> >> -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU >> /* Arch dependent functions for cpu hotplug support */ >> int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, >> int *pcpu); >> int acpi_unmap_cpu(int cpu); > > I've lost track somewhat but I think the definitions of these are still under ifdefs > which is messy if nothing else and might cause build issues. > Yup, it's not safe to use 'if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU))' in acpi_processor_make_present() until the ifdefs are removed for those two functions in individual architectures. >> -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ >> >> #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC >> int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr); Thanks, Gavin
On Mon, Sep 18, 2023 at 03:50:09PM +1000, Gavin Shan wrote: > > On 9/15/23 00:17, Jonathan Cameron wrote: > > On Wed, 13 Sep 2023 16:38:08 +0000 > > James Morse <james.morse@arm.com> wrote: > > > > > acpi_processor_hotadd_init() will make a CPU present by mapping it > > > based on its hardware id. > > > > > > 'hotadd_init' is ambiguous once there are two different behaviours > > > for cpu hotplug. This is for toggling the _STA present bit. Subsequent > > > patches will add support for toggling the _STA enabled bit, named > > > acpi_processor_make_enabled(). > > > > > > Rename it acpi_processor_make_present() to make it clear this is > > > for CPUs that were not previously present. > > > > > > Expose the function prototypes it uses to allow the preprocessor > > > guards to be removed. The IS_ENABLED() check will let the compiler > > > dead-code elimination pass remove this if it isn't going to be > > > used. > > > > > > Signed-off-by: James Morse <james.morse@arm.com> > > > --- > > > drivers/acpi/acpi_processor.c | 14 +++++--------- > > > include/linux/acpi.h | 2 -- > > > 2 files changed, 5 insertions(+), 11 deletions(-) > > > > > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c > > > index 75257fae10e7..22a15a614f95 100644 > > > --- a/drivers/acpi/acpi_processor.c > > > +++ b/drivers/acpi/acpi_processor.c > > > @@ -182,13 +182,15 @@ static void __init acpi_pcc_cpufreq_init(void) {} > > > #endif /* CONFIG_X86 */ > > > /* Initialization */ > > > -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU > > > -static int acpi_processor_hotadd_init(struct acpi_processor *pr) > > > +static int acpi_processor_make_present(struct acpi_processor *pr) > > > { > > > unsigned long long sta; > > > acpi_status status; > > > int ret; > > > + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) > > > + return -ENODEV; > > > + > > > if (invalid_phys_cpuid(pr->phys_id)) > > > return -ENODEV; > > > @@ -222,12 +224,6 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) > > > cpu_maps_update_done(); > > > return ret; > > > } > > > -#else > > > -static inline int acpi_processor_hotadd_init(struct acpi_processor *pr) > > > -{ > > > - return -ENODEV; > > > -} > > > -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ > > > static int acpi_processor_get_info(struct acpi_device *device) > > > { > > > @@ -335,7 +331,7 @@ static int acpi_processor_get_info(struct acpi_device *device) > > > * because cpuid <-> apicid mapping is persistent now. > > > */ > > > if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { > > > - int ret = acpi_processor_hotadd_init(pr); > > > + int ret = acpi_processor_make_present(pr); > > > if (ret) > > > return ret; > > > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > > > index 651dd43976a9..b7ab85857bb7 100644 > > > --- a/include/linux/acpi.h > > > +++ b/include/linux/acpi.h > > > @@ -316,12 +316,10 @@ static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, > > > } > > > #endif > > > -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU > > > /* Arch dependent functions for cpu hotplug support */ > > > int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, > > > int *pcpu); > > > int acpi_unmap_cpu(int cpu); > > > > I've lost track somewhat but I think the definitions of these are still under ifdefs > > which is messy if nothing else and might cause build issues. > > > > Yup, it's not safe to use 'if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU))' in > acpi_processor_make_present() until the ifdefs are removed for those two functions > in individual architectures. The same thing appears in a final patch that James seems to have added to the repository: ACPI: processor: Only call arch_unregister_cpu() if HOTPLUG_CPU is selected in which acpi_processor_post_eject() has this change: - if (!device) + if (!IS_ENABLED(CONFIG_HOTPLUG_CPU) || !device) I'm wondering if that's caused by a previous patch making the weak definition of arch_unregister_cpu() dependent on HOTPLUG_CPU, and whether dropping that ifdef around the function would be better. I think I already asked that question, but this final patch seems to be the confirmation that we need to provide a definition of it. I think the reason James did it like that is because unregister_cpu() is dependent upon CONFIG_HOTPLUG_CPU, but it's probably better to do: #ifdef CONFIG_HOTPLUG_CPU void __weak arch_unregister_cpu(int num) { unregister_cpu(&per_cpu(cpu_devices, num)); } #else void __weak arch_unregister_cpu(int num) { } #endif Agreed?
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 75257fae10e7..22a15a614f95 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -182,13 +182,15 @@ static void __init acpi_pcc_cpufreq_init(void) {} #endif /* CONFIG_X86 */ /* Initialization */ -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU -static int acpi_processor_hotadd_init(struct acpi_processor *pr) +static int acpi_processor_make_present(struct acpi_processor *pr) { unsigned long long sta; acpi_status status; int ret; + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) + return -ENODEV; + if (invalid_phys_cpuid(pr->phys_id)) return -ENODEV; @@ -222,12 +224,6 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) cpu_maps_update_done(); return ret; } -#else -static inline int acpi_processor_hotadd_init(struct acpi_processor *pr) -{ - return -ENODEV; -} -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ static int acpi_processor_get_info(struct acpi_device *device) { @@ -335,7 +331,7 @@ static int acpi_processor_get_info(struct acpi_device *device) * because cpuid <-> apicid mapping is persistent now. */ if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { - int ret = acpi_processor_hotadd_init(pr); + int ret = acpi_processor_make_present(pr); if (ret) return ret; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 651dd43976a9..b7ab85857bb7 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -316,12 +316,10 @@ static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, } #endif -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU /* Arch dependent functions for cpu hotplug support */ int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, int *pcpu); int acpi_unmap_cpu(int cpu); -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);