[RFC,v2,16/35] ACPI: processor: Register CPUs that are online, but not described in the DSDT
Message ID | 20230913163823.7880-17-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 t13csp1221298vqx; Wed, 13 Sep 2023 09:53:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnf0XLZbdUxvShamnIlm6riRQQfUul52eX740mxcDllUGkGBn0dqJMvbJoYBObITylOcX5 X-Received: by 2002:a05:6808:148:b0:3ab:83e1:ef6d with SMTP id h8-20020a056808014800b003ab83e1ef6dmr3141273oie.6.1694624018024; Wed, 13 Sep 2023 09:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694624017; cv=none; d=google.com; s=arc-20160816; b=s+SMaM3qDZyWNWB/1mE2sH9udLzdSVhGGkK4Lyl5wRAHYIKAZ9dxjTmjcTOQgIZo+m kbF8NA39K1KMxR6c4sOYlpvCLZYHP1if9Xv/hE8nWpyVmIg8GnaZnx+qjVR+kQ7HWANa IQi6504eJkKmLZRPC1tCXTciMrpGQCEpY8IcQEqlawRmoLZ6zxIry3bCNnHEIgNEjNDm CzdJhGqfeAdwdSl7XjUAP/VB5UqI8fOuKoEvwQHmHy0fyf0Lg2lyZ2VQQE/rf07yFiii Ylvyv1hjOZ6D09bsvN2Y26JQKv6fyhzvvz0lkM4x1ID99t6WBqJEZxcqv2j39reunaOJ mv3w== 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=cef7MF5f3I17g0157LoKvxFl/FQw5el5kskhTeMcejU=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=zHg5AB9BHU2Db6Ston+MlMq3cYcuFcOZlD3eXR65kusXEWJG85a/9IRs6RXrTBLgpQ CnON+yZ6qYiPbxJQk9rSgr6DCc1m3yXeaiTBCpHr0sulFtYGFDb0iBpfd4hrDgAQqKRO yy0rqTUNl8Xq9Dm07N26HBM1im4vv6ltWNFdLurblCbLLuyMR+3mtLB0/SrB59223oyH kAo6hF/kjYYcZWMOkrvt67zM0jgqsW+ahLB35JttJN37eszz0N1L2mOtu0NHpHdu2EAB UAyUuqHNEqGv2ET+rh8wFBqlUneRoH4isWmH0XQxlDoWAjtPBD8X5jfLg9S06HJneCOP wPYA== 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:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id fa9-20020a056a002d0900b0068e48477befsi5598250pfb.211.2023.09.13.09.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:53:37 -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; 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=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id BF2D881DC608; Wed, 13 Sep 2023 09:40:46 -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 S231326AbjIMQkb (ORCPT <rfc822;pwkd43@gmail.com> + 35 others); Wed, 13 Sep 2023 12:40:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230493AbjIMQjs (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 13 Sep 2023 12:39:48 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 34C7419B1; Wed, 13 Sep 2023 09:39:25 -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 35227FEC; Wed, 13 Sep 2023 09:40:02 -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 3A6373F5A1; Wed, 13 Sep 2023 09:39:23 -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 16/35] ACPI: processor: Register CPUs that are online, but not described in the DSDT Date: Wed, 13 Sep 2023 16:38:04 +0000 Message-Id: <20230913163823.7880-17-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 (lipwig.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:40:46 -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 lipwig.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776942074645396638 X-GMAIL-MSGID: 1776942074645396638 |
Series |
ACPI/arm64: add support for virtual cpuhotplug
|
|
Commit Message
James Morse
Sept. 13, 2023, 4:38 p.m. UTC
ACPI has two descriptions of CPUs, one in the MADT/APIC table, the other
in the DSDT. Both are required. (ACPI 6.5's 8.4 "Declaring Processors"
says "Each processor in the system must be declared in the ACPI
namespace"). Having two descriptions allows firmware authors to get
this wrong.
If CPUs are described in the MADT/APIC, they will be brought online
early during boot. Once the register_cpu() calls are moved to ACPI,
they will be based on the DSDT description of the CPUs. When CPUs are
missing from the DSDT description, they will end up online, but not
registered.
Add a helper that runs after acpi_init() has completed to register
CPUs that are online, but weren't found in the DSDT. Any CPU that
is registered by this code triggers a firmware-bug warning and kernel
taint.
Qemu TCG only describes the first CPU in the DSDT, unless cpu-hotplug
is configured.
Signed-off-by: James Morse <james.morse@arm.com>
---
drivers/acpi/acpi_processor.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
Comments
On Wed, 13 Sep 2023 16:38:04 +0000 James Morse <james.morse@arm.com> wrote: > ACPI has two descriptions of CPUs, one in the MADT/APIC table, the other > in the DSDT. Both are required. (ACPI 6.5's 8.4 "Declaring Processors" > says "Each processor in the system must be declared in the ACPI > namespace"). Having two descriptions allows firmware authors to get > this wrong. > > If CPUs are described in the MADT/APIC, they will be brought online > early during boot. Once the register_cpu() calls are moved to ACPI, > they will be based on the DSDT description of the CPUs. When CPUs are > missing from the DSDT description, they will end up online, but not > registered. > > Add a helper that runs after acpi_init() has completed to register > CPUs that are online, but weren't found in the DSDT. Any CPU that > is registered by this code triggers a firmware-bug warning and kernel > taint. > > Qemu TCG only describes the first CPU in the DSDT, unless cpu-hotplug > is configured. We should fix that as who likes warnings and taint :) I dread to think how common this will turn out to be. > > Signed-off-by: James Morse <james.morse@arm.com> LGTM Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > --- > drivers/acpi/acpi_processor.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c > index b4bde78121bb..a01e315aa16a 100644 > --- a/drivers/acpi/acpi_processor.c > +++ b/drivers/acpi/acpi_processor.c > @@ -790,6 +790,25 @@ void __init acpi_processor_init(void) > acpi_pcc_cpufreq_init(); > } > > +static int __init acpi_processor_register_missing_cpus(void) > +{ > + int cpu; > + > + if (acpi_disabled) > + return 0; > + > + for_each_online_cpu(cpu) { > + if (!get_cpu_device(cpu)) { > + pr_err_once(FW_BUG "CPU %u has no ACPI namespace description!\n", cpu); > + add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK); > + arch_register_cpu(cpu); > + } > + } > + > + return 0; > +} > +subsys_initcall_sync(acpi_processor_register_missing_cpus); > + > #ifdef CONFIG_ACPI_PROCESSOR_CSTATE > /** > * acpi_processor_claim_cst_control - Request _CST control from the platform.
On 9/14/23 02:38, James Morse wrote: > ACPI has two descriptions of CPUs, one in the MADT/APIC table, the other > in the DSDT. Both are required. (ACPI 6.5's 8.4 "Declaring Processors" > says "Each processor in the system must be declared in the ACPI > namespace"). Having two descriptions allows firmware authors to get > this wrong. > > If CPUs are described in the MADT/APIC, they will be brought online > early during boot. Once the register_cpu() calls are moved to ACPI, > they will be based on the DSDT description of the CPUs. When CPUs are > missing from the DSDT description, they will end up online, but not > registered. > > Add a helper that runs after acpi_init() has completed to register > CPUs that are online, but weren't found in the DSDT. Any CPU that > is registered by this code triggers a firmware-bug warning and kernel > taint. > > Qemu TCG only describes the first CPU in the DSDT, unless cpu-hotplug > is configured. > > Signed-off-by: James Morse <james.morse@arm.com> > --- > drivers/acpi/acpi_processor.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > Reviewed-by: Gavin Shan <gshan@redhat.com> > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c > index b4bde78121bb..a01e315aa16a 100644 > --- a/drivers/acpi/acpi_processor.c > +++ b/drivers/acpi/acpi_processor.c > @@ -790,6 +790,25 @@ void __init acpi_processor_init(void) > acpi_pcc_cpufreq_init(); > } > > +static int __init acpi_processor_register_missing_cpus(void) > +{ > + int cpu; > + > + if (acpi_disabled) > + return 0; > + > + for_each_online_cpu(cpu) { > + if (!get_cpu_device(cpu)) { > + pr_err_once(FW_BUG "CPU %u has no ACPI namespace description!\n", cpu); > + add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK); > + arch_register_cpu(cpu); > + } > + } > + > + return 0; > +} > +subsys_initcall_sync(acpi_processor_register_missing_cpus); > + > #ifdef CONFIG_ACPI_PROCESSOR_CSTATE > /** > * acpi_processor_claim_cst_control - Request _CST control from the platform.
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index b4bde78121bb..a01e315aa16a 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -790,6 +790,25 @@ void __init acpi_processor_init(void) acpi_pcc_cpufreq_init(); } +static int __init acpi_processor_register_missing_cpus(void) +{ + int cpu; + + if (acpi_disabled) + return 0; + + for_each_online_cpu(cpu) { + if (!get_cpu_device(cpu)) { + pr_err_once(FW_BUG "CPU %u has no ACPI namespace description!\n", cpu); + add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK); + arch_register_cpu(cpu); + } + } + + return 0; +} +subsys_initcall_sync(acpi_processor_register_missing_cpus); + #ifdef CONFIG_ACPI_PROCESSOR_CSTATE /** * acpi_processor_claim_cst_control - Request _CST control from the platform.