From patchwork Wed Sep 13 16:38:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138967 Return-Path: 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 + 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 ); 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 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 , Russell King , Jean-Philippe Brucker , 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 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]); 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 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 Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan --- 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.