From patchwork Wed Sep 13 16:37:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138943 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1218588vqx; Wed, 13 Sep 2023 09:49:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7hFAKJOAlCe1OQw7aiXP+TR+eyZ54f+Knuz5EszRlxjTQa6nyYVr5KmlWTwYANFVlHTgE X-Received: by 2002:a17:90b:3cc:b0:273:dfb2:2632 with SMTP id go12-20020a17090b03cc00b00273dfb22632mr2876284pjb.15.1694623752427; Wed, 13 Sep 2023 09:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623752; cv=none; d=google.com; s=arc-20160816; b=ij+5KwFem03aNIguuL1AXpQotmT/pRrRY6VMrEFuv5FrJ9iUTFFLS98jRV83CIj6w0 M+5OJD1e+rYkvnXHEtM32Bf+ibtJnw7vbvH7QAIg+q3iTz7wKatH/tnY3NTPfYaDI0C6 LmkJwfNr82sIriAJVi22qZ17UdZQv0nekcqUoqgoChFUII76ooedPG5KFUuQBcVdvean rl30g8n5cPGKGYN86p+ilkB/k2NK2zyEUP2JHDO2K7bYWYOQp9b8L9PSslseen5z3Ufc 4rbo6RHqLlrp3WquXhJ/k6+NaC7ixYIkK7OTt93i+EwE75iFTQVy5LCu+zH4YQuigwq1 JrLg== 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=YqWgmzZy6p0eogxXMB9wHcdx1UpLYYBA6dEEHlHpnKQ=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=ZqMPOGXck6OMMFv5aGOcNOcCYs/+Qh9jq/xaJfLXf5KlH0RHHrINuG/1HtEB9u4t6i nJenljlNoWS4s9PNtmkLPnhKkN8IErIzMty7HYEdm5OaVagN6lB49WvEDZAUdgw+IH7T E2cy5IoJ0OhnN75xhdIh5jlJEtVEyoCSh9F/Kfp/xmd/A7FrMgm2xKt0A6xBSWxKoF+h u2b9F5ypl2MfJx1yOmVQa3N0XuhUZ3A3/IAkZavLOROb3B+JbkFvu5nTTfMMLz5pkyof 4ZFg5uVZ6LzAjTacm3euwCWb9nylJhjnpubQxjtOhS5Nx835T7zvj9oct4TeqJopSEq0 1Qjw== 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 q66-20020a17090a17c800b002742f8fd989si1903153pja.177.2023.09.13.09.49.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:49:12 -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 ED4DC8157DEF; Wed, 13 Sep 2023 09:39:12 -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 S230216AbjIMQjB (ORCPT + 35 others); Wed, 13 Sep 2023 12:39:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbjIMQi7 (ORCPT ); Wed, 13 Sep 2023 12:38:59 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7C7F71BC8; Wed, 13 Sep 2023 09:38:55 -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 4743E1FB; Wed, 13 Sep 2023 09:39:32 -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 4C3E83F5A1; Wed, 13 Sep 2023 09:38:53 -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 01/35] ACPI: Move ACPI_HOTPLUG_CPU to be disabled on arm64 and riscv Date: Wed, 13 Sep 2023 16:37:49 +0000 Message-Id: <20230913163823.7880-2-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 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:39:13 -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: 1776941796087916239 X-GMAIL-MSGID: 1776941796087916239 Neither arm64 nor riscv support physical hotadd of CPUs that were not present at boot. For arm64 much of the platform description is in static tables which do not have update methods. arm64 does support HOTPLUG_CPU, which is backed by a firmware interface to turn CPUs on and off. acpi_processor_hotadd_init() and acpi_processor_remove() are for adding and removing CPUs that were not present at boot. arm64 systems that do this are not supported as there is currently insufficient information in the platform description. (e.g. did the GICR get removed too?) arm64 currently relies on the MADT enabled flag check in map_gicc_mpidr() to prevent CPUs that were not described as present at boot from being added to the system. Similarly, riscv relies on the same check in map_rintc_hartid(). Both architectures also rely on the weak 'always fails' definitions of acpi_map_cpu() and arch_register_cpu(). Subsequent changes will redefine ACPI_HOTPLUG_CPU as making possible CPUs present. Neither arm64 nor riscv support this. Disable ACPI_HOTPLUG_CPU for arm64 and riscv by removing 'default y' and selecting it on the other three ACPI architectures. This allows the weak definitions of some symbols to be removed. Signed-off-by: James Morse --- Changes since RFC: * Expanded conditions to avoid ACPI_HOTPLUG_CPU being enabled when HOTPLUG_CPU isn't. --- arch/ia64/Kconfig | 1 + arch/loongarch/Kconfig | 1 + arch/loongarch/include/asm/cpu.h | 7 +++++++ arch/x86/Kconfig | 1 + drivers/acpi/Kconfig | 1 - drivers/acpi/acpi_processor.c | 18 ------------------ 6 files changed, 10 insertions(+), 19 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 53faa122b0f4..a3bfd42467ab 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -16,6 +16,7 @@ config IA64 select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO select ACPI + select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU select ACPI_NUMA if NUMA select ARCH_ENABLE_MEMORY_HOTPLUG select ARCH_ENABLE_MEMORY_HOTREMOVE diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index e14396a2ddcb..2bddd202470e 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -5,6 +5,7 @@ config LOONGARCH select ACPI select ACPI_GENERIC_GSI if ACPI select ACPI_MCFG if ACPI + select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU select ACPI_PPTT if ACPI select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI select ARCH_BINFMT_ELF_STATE diff --git a/arch/loongarch/include/asm/cpu.h b/arch/loongarch/include/asm/cpu.h index 48b9f7168bcc..7afe8cbb844e 100644 --- a/arch/loongarch/include/asm/cpu.h +++ b/arch/loongarch/include/asm/cpu.h @@ -128,4 +128,11 @@ enum cpu_type_enum { #define LOONGARCH_CPU_HYPERVISOR BIT_ULL(CPU_FEATURE_HYPERVISOR) #define LOONGARCH_CPU_PTW BIT_ULL(CPU_FEATURE_PTW) +#if !defined(__ASSEMBLY__) +#ifdef CONFIG_HOTPLUG_CPU +int arch_register_cpu(int num); +void arch_unregister_cpu(int cpu); +#endif +#endif /* ! __ASSEMBLY__ */ + #endif /* _ASM_CPU_H */ diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 982b777eadc7..a0100a1ab4a0 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -60,6 +60,7 @@ config X86 # select ACPI_LEGACY_TABLES_LOOKUP if ACPI select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI + select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU select ARCH_32BIT_OFF_T if X86_32 select ARCH_CLOCKSOURCE_INIT select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index cee82b473dc5..8456d48ba702 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -309,7 +309,6 @@ config ACPI_HOTPLUG_CPU bool depends on ACPI_PROCESSOR && HOTPLUG_CPU select ACPI_CONTAINER - default y config ACPI_PROCESSOR_AGGREGATOR tristate "Processor Aggregator" diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index c711db8a9c33..c0839bcf78c1 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -183,24 +183,6 @@ static void __init acpi_pcc_cpufreq_init(void) {} /* Initialization */ #ifdef CONFIG_ACPI_HOTPLUG_CPU -int __weak acpi_map_cpu(acpi_handle handle, - phys_cpuid_t physid, u32 acpi_id, int *pcpu) -{ - return -ENODEV; -} - -int __weak acpi_unmap_cpu(int cpu) -{ - return -ENODEV; -} - -int __weak arch_register_cpu(int cpu) -{ - return -ENODEV; -} - -void __weak arch_unregister_cpu(int cpu) {} - static int acpi_processor_hotadd_init(struct acpi_processor *pr) { unsigned long long sta; From patchwork Wed Sep 13 16:37:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138933 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1213338vqx; Wed, 13 Sep 2023 09:40:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrB7nC6YyuOlg7CoorIDHV02wASFVoF4X3QGmOU+0xGxWtuhy0itSfM8mW4NC9fPUGPIJ3 X-Received: by 2002:a05:6808:3085:b0:3ab:73a6:1469 with SMTP id bl5-20020a056808308500b003ab73a61469mr4138736oib.14.1694623226065; Wed, 13 Sep 2023 09:40:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623226; cv=none; d=google.com; s=arc-20160816; b=sbUePj81tXjbUXEg/hkNM8BTHldZn8B/oudSq3DiWskylgmBixJoX8KZbGWn3rSf0a KP2UW+fE3puZKsTVTQUdOGiWwfAYA3kT9j1Q/SU94kw9vU1WZNgdOiRkqeSauIWvyFu4 4fPXyB2KRwFtTmNKO6PF3lc0HzCox1K7MxQXdg0Q7YboVVA2Cs186YWUhXUu2V5lLEem nIYYm+S37MtmMRk2UoLqUHIE2DaCzN/B355aqgsp4dHS+pCOyNpLWSgOiQvqeeyMC60Z cUHjgAmAjt5tQ/SRaWHmBXz3Sq9KhlaqRkUeZIlNRTpAE0bZLhWM8Evh5dy0WkyVQXEn XSjA== 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=Mg7CAxI524LEV8wuMKKj25nOZl8IAzubfL5W7QikByk=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=WUptvHrVK88em3aAurS1bQ1Wod6vbhJaMJiqPeoXUWd4SZfgp0tbtNejYD8mgd/rsh O45QOamo8pf/BP5d+fh89lEaJNL8ZJ5tyPj7PXyVawxA3QCG5Ee/m7wtcZV9VKJiIquQ M4zdhrBjyW9iqF+betu5/FGABHq79VTiK7Sevj+RFD+xnCHCDQ2bbX/ErcW09dUO6znA y6KkqK6Ij7RM4l3LpSgEraR2QW0cZZtbfkjDiC8SIiAZQtlm5J1nbNrPp8v/RxFTBlSz 4+80isWjUI+OkHZpc4Er3x/6Q/dQVgSCwQxjzZCTpRZjRbnjmOFVftJrJyWyIPvPN2sB OLbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id m1-20020a656a01000000b00573fdd098a7si11043850pgu.471.2023.09.13.09.40.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:40:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 830C580BD393; Wed, 13 Sep 2023 09:39:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230335AbjIMQjD (ORCPT + 35 others); Wed, 13 Sep 2023 12:39:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230223AbjIMQjB (ORCPT ); Wed, 13 Sep 2023 12:39:01 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C20519B1; Wed, 13 Sep 2023 09:38:57 -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 4588CC15; Wed, 13 Sep 2023 09:39:34 -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 4A6263F5A1; Wed, 13 Sep 2023 09:38:55 -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 02/35] drivers: base: Use present CPUs in GENERIC_CPU_DEVICES Date: Wed, 13 Sep 2023 16:37:50 +0000 Message-Id: <20230913163823.7880-3-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 (agentk.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:39:09 -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 agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941243973738186 X-GMAIL-MSGID: 1776941243973738186 Three of the five ACPI architectures create sysfs entries using register_cpu() for present CPUs, whereas arm64, riscv and all GENERIC_CPU_DEVICES do this for possible CPUs. Registering a CPU is what causes them to show up in sysfs. It makes very little sense to register all possible CPUs. Registering a CPU is what triggers the udev notifications allowing user-space to react to newly added CPUs. To allow all five ACPI architectures to use GENERIC_CPU_DEVICES, change it to use for_each_present_cpu(). Making the ACPI architectures use GENERIC_CPU_DEVICES is a pre-requisite step to centralise their cpu_register() logic, before moving it into the ACPI processor driver. When ACPI is disabled this work would be done by cpu_dev_register_generic(). Of the ACPI architectures that register possible CPUs, arm64 and riscv do not support making possible CPUs present as they use the weak 'always fails' version of arch_register_cpu(). Only two of the eight architectures that use GENERIC_CPU_DEVICES have a distinction between present and possible CPUs. The following architectures use GENERIC_CPU_DEVICES but are not SMP, so possible == present: * m68k * microblaze * nios2 The following architectures use GENERIC_CPU_DEVICES and consider possible == present: * csky: setup_smp() * parisc: smp_prepare_boot_cpu() marks the boot cpu as present, processor_probe() sets possible for all CPUs and present for all CPUs except the boot cpu. um appears to be a subarchitecture of x86. The remaining architecture using GENERIC_CPU_DEVICES are: * openrisc and hexagon: where smp_init_cpus() makes all CPUs < NR_CPUS possible, whereas smp_prepare_cpus() only makes CPUs < setup_max_cpus present. After this change, openrisc and hexagon systems that use the max_cpus command line argument would not see the other CPUs present in sysfs. This should not be a problem as these CPUs can't bre brought online as _cpu_up() checks cpu_present(). After this change, only CPUs which are present appear in sysfs. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron --- drivers/base/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 9ea22e165acd..34b48f660b6b 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -533,7 +533,7 @@ static void __init cpu_dev_register_generic(void) #ifdef CONFIG_GENERIC_CPU_DEVICES int i; - for_each_possible_cpu(i) { + for_each_present_cpu(i) { if (register_cpu(&per_cpu(cpu_devices, i), i)) panic("Failed to register CPU device"); } From patchwork Wed Sep 13 16:37:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 139263 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp73985vqi; Wed, 13 Sep 2023 19:58:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHR06EkGBTkq5bW/bSiPB3DUzhnqgXfKJ7ZOx9LzjYk/jD2hHIgJRtWmsOASquy+NQr+7kr X-Received: by 2002:a17:902:eb46:b0:1bc:6266:d0e4 with SMTP id i6-20020a170902eb4600b001bc6266d0e4mr4055184pli.69.1694660334587; Wed, 13 Sep 2023 19:58:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694660334; cv=none; d=google.com; s=arc-20160816; b=mKdOvU7iDXBkT1FghEhKbAwTYXj0foK+WuhIDgp3EdAX5jJmgw2zPNjM8aX4OSWA2E tGlijnc8OLroc7jQTffJdMzxSrm96XVqQQULw/mxSVVDxquf1PZRO2HPW6KXbwFVgzYJ Ys/EWJ/w2k5xBeGCbqv2sULwcI/DEItYGP/61xCGPhuHOUiZl5XmQe/XNC+kGPcru399 7QGC9+fyPkJw3ybPPrhrQHK0abu9iQ5IteN7hw+4lWPGuyM1ULkDO9kqeNN7DZKhcXgo TtQh9SrBoqmApaMyamZ4FuzZXV0qPhP79hdTrp8Ml1GiprZ8hCGvh9x3jmGjZq+MKJB/ Esow== 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=otUydan6NGoLc08qN9jzXgp7M4WeHuOHXAKcc89trwg=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=x1qvBkLqhQH72qL6vhAZH2uGX+PQGeyWAQ4TD5wx3yDFs/6CWbqI+b27D6D7HF+2GH Gk5JIoRO4Q4hjb+IGJToiX9gA3PMqqjWh2Pvtxh0fR3p6smXaJSKANYJWzb9/211K3gn 8++9tHDOxGplPmug6WifnGkEJ04Nxqus4M1RgBwlMndAKpvgwF29fHAckAD4saIosAlw mOOkoBZLRJIQiB0KkPTKVtcniBfVrAXbBgECdWesXYRADf+cVJv7yOf5ApqluYDVGszG jlpB+tD1cYz1JBcTo9sXtck5kzxTObXQHoazp4Ys29bAQ6oXFqA17kGQLNpUflbl4WEc CYrg== 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:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ky15-20020a170902f98f00b001b9ffda162csi602127plb.441.2023.09.13.19.58.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 19:58:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 1A42181C7AA9; Wed, 13 Sep 2023 09:39:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230367AbjIMQjK (ORCPT + 35 others); Wed, 13 Sep 2023 12:39:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230327AbjIMQjD (ORCPT ); Wed, 13 Sep 2023 12:39:03 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 488B419A7; Wed, 13 Sep 2023 09:38:59 -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 45A3FFEC; Wed, 13 Sep 2023 09:39:36 -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 4A8B83F5A1; Wed, 13 Sep 2023 09:38:57 -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 03/35] drivers: base: Allow parts of GENERIC_CPU_DEVICES to be overridden Date: Wed, 13 Sep 2023 16:37:51 +0000 Message-Id: <20230913163823.7880-4-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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:39:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776980154782706804 X-GMAIL-MSGID: 1776980154782706804 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 Reviewed-by: Russell King (Oracle) --- Changes since RFC: * Dropped __init from x86/ia64 arch_register_cpu() --- arch/ia64/include/asm/cpu.h | 1 - arch/ia64/kernel/topology.c | 2 +- arch/loongarch/include/asm/cpu.h | 1 - arch/x86/include/asm/cpu.h | 1 - arch/x86/kernel/topology.c | 2 +- drivers/base/cpu.c | 14 ++++++++++---- include/linux/cpu.h | 5 +++++ 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/arch/ia64/include/asm/cpu.h b/arch/ia64/include/asm/cpu.h index db125df9e088..a3e690e685e5 100644 --- a/arch/ia64/include/asm/cpu.h +++ b/arch/ia64/include/asm/cpu.h @@ -16,7 +16,6 @@ DECLARE_PER_CPU(struct ia64_cpu, cpu_devices); DECLARE_PER_CPU(int, cpu_state); #ifdef CONFIG_HOTPLUG_CPU -extern int arch_register_cpu(int num); extern void arch_unregister_cpu(int); #endif diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c index 94a848b06f15..741863a187a6 100644 --- a/arch/ia64/kernel/topology.c +++ b/arch/ia64/kernel/topology.c @@ -59,7 +59,7 @@ void __ref arch_unregister_cpu(int num) } EXPORT_SYMBOL(arch_unregister_cpu); #else -static int __init arch_register_cpu(int num) +int __init arch_register_cpu(int num) { return register_cpu(&sysfs_cpus[num].cpu, num); } diff --git a/arch/loongarch/include/asm/cpu.h b/arch/loongarch/include/asm/cpu.h index 7afe8cbb844e..b8568e637420 100644 --- a/arch/loongarch/include/asm/cpu.h +++ b/arch/loongarch/include/asm/cpu.h @@ -130,7 +130,6 @@ enum cpu_type_enum { #if !defined(__ASSEMBLY__) #ifdef CONFIG_HOTPLUG_CPU -int arch_register_cpu(int num); void arch_unregister_cpu(int cpu); #endif #endif /* ! __ASSEMBLY__ */ diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index 3a233ebff712..96dc4665e87d 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h @@ -28,7 +28,6 @@ struct x86_cpu { }; #ifdef CONFIG_HOTPLUG_CPU -extern int arch_register_cpu(int num); extern void arch_unregister_cpu(int); extern void soft_restart_cpu(void); #endif diff --git a/arch/x86/kernel/topology.c b/arch/x86/kernel/topology.c index ca004e2e4469..0bab03130033 100644 --- a/arch/x86/kernel/topology.c +++ b/arch/x86/kernel/topology.c @@ -54,7 +54,7 @@ void arch_unregister_cpu(int num) EXPORT_SYMBOL(arch_unregister_cpu); #else /* CONFIG_HOTPLUG_CPU */ -static int __init arch_register_cpu(int num) +int __init arch_register_cpu(int num) { return register_cpu(&per_cpu(cpu_devices, num).cpu, num); } 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 0abd60a7987b..a71691d7c2ca 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -80,12 +80,17 @@ extern __printf(4, 5) struct device *cpu_device_create(struct device *parent, void *drvdata, const struct attribute_group **groups, const char *fmt, ...); +extern int arch_register_cpu(int cpu); #ifdef CONFIG_HOTPLUG_CPU extern void unregister_cpu(struct cpu *cpu); 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 From patchwork Wed Sep 13 16:37:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 139261 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp73886vqi; Wed, 13 Sep 2023 19:58:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSO4gRVaufUaAB4s9yr2rDzy+ZxoZRqBDJLye3qe/0JTU/n0lWtlQbxZIRthAVILaF0rU+ X-Received: by 2002:a17:90a:df8a:b0:26b:698f:dda7 with SMTP id p10-20020a17090adf8a00b0026b698fdda7mr4127298pjv.32.1694660312055; Wed, 13 Sep 2023 19:58:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694660312; cv=none; d=google.com; s=arc-20160816; b=aDN7d4yVCv8fYgogC6mkq2KFtX8piNjL6FTBZN+Te2V+iMjm8mIzHrqXfe7jS/5ESw PG2AQGWvTVimjWW3BQ/U4yCmiEU3CvPRrmzUYg0qGSHGr+PwKl6HC/StwdCjky451ajg mbRAqEi2u+OIjI72+feKJ2shzY/YEVbzMHE4FrZoiKhdmsuaX/ZVx7+x7buAo0dPQ/R2 R9exRz0V2nFm+E9k/7/3urUu6P/qEcIaMsReSd9Kn9Rod1qLEiF7I/W7Q2RC6fsVsGJq FoVSvX+RfVoM2pV4iltE60v/UyceLgfx7fFky/aAe2hhFdJRfmVRZHxPQzToPc6x2Pce nBJQ== 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=izyCxWPP5MIzPKSLH8pfshm9d5tChtDCeBhcYhIaLRg=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=GA/WlCCGgQqhCoYs9F/T1j4EflFA+gVWSkzTvwSQlY2+1e9c4gawLUYIS45jBNBz1D 3moa/s+Id57xdQrFGjGZGBRX57BHkSrx0Upf9uW4k44EUzmXEPgehAO8XKTv1YPKVsZ1 hfvSj/ZQZ9apWSv+Sjs+AmsvIsBenEeIFFMRAfD+VNDzL7pdQs9mwj4ono/IOQ85C2Tu FSFCa1DVIGZ7mdp9EldSJpEy6dn0OKBgn1ITy8zjVpuemeeiFGChuV8E617gGLR5kwKs SVNZXRxgRIVX550KtCVFcb+a+1J9zZL84DztFmJpmsWifZPKeG3s7z4NV2siYrzgMvc4 sz+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id mp7-20020a17090b190700b0026ce592a7absi2876030pjb.81.2023.09.13.19.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 19:58:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id CFE3281BEE91; Wed, 13 Sep 2023 09:39:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbjIMQjM (ORCPT + 35 others); Wed, 13 Sep 2023 12:39:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230363AbjIMQjF (ORCPT ); Wed, 13 Sep 2023 12:39:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4487C19BB; Wed, 13 Sep 2023 09:39:01 -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 43C2F1007; Wed, 13 Sep 2023 09:39:38 -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 493C83F5A1; Wed, 13 Sep 2023 09:38:59 -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 04/35] drivers: base: Move cpu_dev_init() after node_dev_init() Date: Wed, 13 Sep 2023 16:37:52 +0000 Message-Id: <20230913163823.7880-5-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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:39:13 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776980130967329328 X-GMAIL-MSGID: 1776980130967329328 NUMA systems require the node descriptions to be ready before CPUs are registered. This is so that the node symlinks can be created in sysfs. Currently no NUMA platform uses GENERIC_CPU_DEVICES, meaning that CPUs are registered by arch code, instead of cpu_dev_init(). Move cpu_dev_init() after node_dev_init() so that NUMA architectures can use GENERIC_CPU_DEVICES. Signed-off-by: James Morse Reviewed-by: Russell King (Oracle) --- drivers/base/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/init.c b/drivers/base/init.c index 397eb9880cec..c4954835128c 100644 --- a/drivers/base/init.c +++ b/drivers/base/init.c @@ -35,8 +35,8 @@ void __init driver_init(void) of_core_init(); platform_bus_init(); auxiliary_bus_init(); - cpu_dev_init(); memory_dev_init(); node_dev_init(); + cpu_dev_init(); container_dev_init(); } From patchwork Wed Sep 13 16:37:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 139262 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp73962vqi; Wed, 13 Sep 2023 19:58:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJoXTm7wpMjQrZfD4ZY/Qkf5HK74RM9xv+qOBdhOeUhIcCwLyGq0tWLYQpHO4+LNe4VCHS X-Received: by 2002:a17:902:ce82:b0:1bf:3378:6808 with SMTP id f2-20020a170902ce8200b001bf33786808mr5865891plg.56.1694660329958; Wed, 13 Sep 2023 19:58:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694660329; cv=none; d=google.com; s=arc-20160816; b=pOXnr+9h0OWkRO7dOCGdtSi7kItWl2sT7MOXCMNimwpbbcFpzi/hKt7Idj937nZmRc 2BqPLcZSnADqO/Ke+eyUTe2EbNRhx9bUoD1cLF8Vv6RcGvcRpnGHZjKSNxppfLTEv4II XUusG8NcPgAfiR5F/sTnHmy3wpVwOhc51kDCOvT96wgHHtj66F/e00fxu7SbP3aeTixp kvEPXyeul+3WirFg/5NLvJOh9xJCTrEO2cn6/zc6IShxCASRn+fuC7c4PrvWinCmxHB3 8eMy5sFSTOh5v9CveWzEnlINFWFkGqxkhpCwjiLbfs8ljvSmDNqyPETgnuMGEQyFJ+Fj oiIQ== 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=BkPaW2dUUg2OUXqQf5AHAQZwRwuBQlCdS9dHLWUFGK0=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=ISr58uvI6r8pUWuAS1RjQrv3ugGDIf9ylvilQH8vX54Zwp7Kv+K2qcufhjigz4qVwY AIcpyzeFxpd750eI++qtNfidZJc6Wc5ayaD2HpJkmoDcJGYy6+JRuzv9Ow029s4syBFU 8UEfJX+I2ArlLKOiY7y5fYkXlVYs7Z3j/Z4700x1gZ3ga769SiijqcMnKcYwmR99TKU5 6jzGH6bGNKCyL3gDeoU8kSv3cOQ40FD9TTt1fGKGYT45HrdMVcahPPc4cwYBIB1j/YsP o1RrdzzUmJDGDtF6EW2UPR1Xgw1qD563ebBwnI/S8KNQzx+rMq5v5AkZ8LKf4JvwN151 vp/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u17-20020a17090341d100b001c20e55153esi763776ple.496.2023.09.13.19.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 19:58:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 485C181D2D5A; Wed, 13 Sep 2023 09:39:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbjIMQjQ (ORCPT + 35 others); Wed, 13 Sep 2023 12:39:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbjIMQjH (ORCPT ); Wed, 13 Sep 2023 12:39:07 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4405E1BD0; Wed, 13 Sep 2023 09:39:03 -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 42F2DC15; Wed, 13 Sep 2023 09:39:40 -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 480883F5A1; Wed, 13 Sep 2023 09:39:01 -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 05/35] drivers: base: Print a warning instead of panic() when register_cpu() fails Date: Wed, 13 Sep 2023 16:37:53 +0000 Message-Id: <20230913163823.7880-6-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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:39:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776980149673963819 X-GMAIL-MSGID: 1776980149673963819 loongarch, mips, parisc, riscv and sh all print a warning if register_cpu() returns an error. Architectures that use GENERIC_CPU_DEVICES call panic() instead. Errors in this path indicate something is wrong with the firmware description of the platform, but the kernel is able to keep running. Downgrade this to a warning to make it easier to debug this issue. This will allow architectures that switching over to GENERIC_CPU_DEVICES to drop their warning, but keep the existing behaviour. Signed-off-by: James Morse Reviewed-by: Russell King (Oracle) --- drivers/base/cpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 579064fda97b..d31c936f0955 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -535,14 +535,15 @@ int __weak arch_register_cpu(int cpu) static void __init cpu_dev_register_generic(void) { - int i; + int i, ret; if (!IS_ENABLED(CONFIG_GENERIC_CPU_DEVICES)) return; for_each_present_cpu(i) { - if (arch_register_cpu(i)) - panic("Failed to register CPU device"); + ret = arch_register_cpu(i); + if (ret) + pr_warn("register_cpu %d failed (%d)\n", i, ret); } } From patchwork Wed Sep 13 16:37:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 139264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp74024vqi; Wed, 13 Sep 2023 19:59:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6vtCY9HqH4t42qvhLnQkl417FZo9U18t7f/JGoiGqH4/QI4YCSozEMEFn+ogpShs+BaIw X-Received: by 2002:a17:90a:9417:b0:26f:87d1:e48 with SMTP id r23-20020a17090a941700b0026f87d10e48mr862209pjo.20.1694660342909; Wed, 13 Sep 2023 19:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694660342; cv=none; d=google.com; s=arc-20160816; b=q9LbeQknYdtpGRQHqACVREFZsb5SULC1AirFC5cwk7zwNzQIOAN/dHXtJLQXU6VhJF 1cjLLTdZ84NJ/ojifBC3g+UD0kV6xzsS9JwfPRvexahbvIMYK+Efs5Il7bxeqq23Pfzs c+ldi1h6nWZw/sTkxWxo7L6HlKwnjw8MRUlBvtmxamVOhnI7NXgKsc55Sv0ud7WqWEjs CFMx5Of8wGsnZGUjMkbL35HkfWWsvh1/HJBir7RJ9roB+qcHLORNo54TOXdF2LiWZxyU wVW8coebpEr0xfbnr8fv9JDtE7G9RUy2hBD95/h0GglrJbMcvya2dnEQUqZyjqAVSeEa roqw== 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=jDAEm+yVMTd95B0G9tQuwSGx+8rybFj95oMdwyrSpxA=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=tqLFZOIpUCeumcvHfD66nyDDr1BjvmPSReM/h83jZjO3Lig/uDS0zh+//8o4gEuYkc Io5kiN4ohXnnk7D7wmGjAZfamuzvyHGErlHcCAgW4iFZ6fcZelIbV1HHB8FXJtVFtL29 hSbrndHJlWLmj5saKlmyyBMNyDrzTSRcRndfDGOLTw9rUag9haIe1Ez10CC5I+pRlzI3 tQQXQJOxs0k/bXuV/e2hExUBbpYRCDTnuhuCoafZHc+pbV4zvYLQuJBTlSpNn4wzdL2t n0qDnUkehiqvJqoJARfjeytNLaQR+VGk5x3uFy3uxDY0utmP4e8IIhM6z8GQH6zq454u 8UHQ== 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:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a21-20020a63e855000000b00563e9d3d78csi501967pgk.422.2023.09.13.19.59.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 19:59:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 9A69881C7AB7; Wed, 13 Sep 2023 09:39:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230458AbjIMQjR (ORCPT + 35 others); Wed, 13 Sep 2023 12:39:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230400AbjIMQjJ (ORCPT ); Wed, 13 Sep 2023 12:39:09 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7A964198B; Wed, 13 Sep 2023 09:39:05 -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 437381FB; Wed, 13 Sep 2023 09:39:42 -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 47F8C3F5A1; Wed, 13 Sep 2023 09:39:03 -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 06/35] arm64: setup: Switch over to GENERIC_CPU_DEVICES using arch_register_cpu() Date: Wed, 13 Sep 2023 16:37:54 +0000 Message-Id: <20230913163823.7880-7-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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:39:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776980164075555607 X-GMAIL-MSGID: 1776980164075555607 To allow ACPI's _STA value to hide CPUs that are present, but not available to online right now due to VMM or firmware policy, the register_cpu() call needs to be made by the ACPI machinery when ACPI is in use. This allows it to hide CPUs that are unavailable from sysfs. Switching to GENERIC_CPU_DEVICES is an intermediate step to allow all five ACPI architectures to be modified at once. Switch over to GENERIC_CPU_DEVICES, and provide an arch_register_cpu() that populates the hotpluggable flag. arch_register_cpu() is also the interface the ACPI machinery expects. The struct cpu in struct cpuinfo_arm64 is never used directly, remove it to use the one GENERIC_CPU_DEVICES provides. This changes the CPUs visible in sysfs from possible to present, but on arm64 smp_prepare_cpus() ensures these are the same. Signed-off-by: James Morse Reviewed-by: Russell King (Oracle) --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cpu.h | 1 - arch/arm64/kernel/setup.c | 13 ++++--------- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b10515c0200b..7b3990abf87a 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -132,6 +132,7 @@ config ARM64 select GENERIC_ARCH_TOPOLOGY select GENERIC_CLOCKEVENTS_BROADCAST select GENERIC_CPU_AUTOPROBE + select GENERIC_CPU_DEVICES select GENERIC_CPU_VULNERABILITIES select GENERIC_EARLY_IOREMAP select GENERIC_IDLE_POLL_SETUP diff --git a/arch/arm64/include/asm/cpu.h b/arch/arm64/include/asm/cpu.h index e749838b9c5d..887bd0d992bb 100644 --- a/arch/arm64/include/asm/cpu.h +++ b/arch/arm64/include/asm/cpu.h @@ -38,7 +38,6 @@ struct cpuinfo_32bit { }; struct cpuinfo_arm64 { - struct cpu cpu; struct kobject kobj; u64 reg_ctr; u64 reg_cntfrq; diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 417a8a86b2db..165bd2c0dd5a 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -402,19 +402,14 @@ static inline bool cpu_can_disable(unsigned int cpu) return false; } -static int __init topology_init(void) +int arch_register_cpu(int num) { - int i; + struct cpu *cpu = &per_cpu(cpu_devices, num); - for_each_possible_cpu(i) { - struct cpu *cpu = &per_cpu(cpu_data.cpu, i); - cpu->hotpluggable = cpu_can_disable(i); - register_cpu(cpu, i); - } + cpu->hotpluggable = cpu_can_disable(num); - return 0; + return register_cpu(cpu, num); } -subsys_initcall(topology_init); static void dump_kernel_offset(void) { From patchwork Wed Sep 13 16:37:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138960 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220837vqx; Wed, 13 Sep 2023 09:52:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8NdT1U0ZeHgmAOljQ1FZsWc3wnbeSkzIBnUpt4G7tWB1qa95gZ6o+q0yKzsMtef0u/v4x X-Received: by 2002:a05:6358:63a2:b0:135:4003:7849 with SMTP id k34-20020a05635863a200b0013540037849mr3252846rwh.4.1694623976566; Wed, 13 Sep 2023 09:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623976; cv=none; d=google.com; s=arc-20160816; b=s3pA30j/tCD8W3H8EA+Snpo4iZ+ZqxA8IHomEtHD8Ln16neYYKrVECbb8KEPfmXtOc oysLGb++tRn1/q1XbdbPBPXzlNb9qsaEaMd506lR5XFORC8VIQjAqDn+J9nrcd0a5Vhv AdU/+TrYgMLehLixCsgkYfHeOFYXXx309DPSumEM9Qev12KQJeRQDl4usK3e9PCH5zS+ a03d/cqALLyyyMUQsh0035uUUTCM93ESRmBvlLFmaYbfF55poSy3JZ+v661hC4FgG7LE mKq+fjDYjSHQ3G8LtDiafSYZP+TKfBlMZYPDKZYHfMRIdxJ7CQ3WVdgMYNn8LwMfBumJ YOiw== 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=VCWf3s5Lsd8r6Y8q0SB/0npjrt0ISnJGdBsvuDoxvK8=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=YtBepQ67X3UB8Q0M/Ow0p3xKV9rnpTB6BI0miE1GQ9jhHNFqBX73hxlCx1B19iiYa5 hZsjUA78IKhmU/2vgw8eKFZeKR4VbStDyxHbzZcxCQi1hNv6R8LmSnvAk5Zm+tl/cufJ qkV7Xm7Xazr7W1MFzspUOFKikvMPctILx7xMJi37Oei4PVNjUKSp5ztkFO56SCcWvi9g xmQ5SBoMN2gGomFtZaaPdWh5gKlABWHH8D7exsh225vvFkvynTkRSCJg4CWImzqE2Ctd lrEIPwfLIzmjKSkZLRwIWta4Xf1L6dMQs58P3apv/elJ5Uv82h3UJNDtkw3lsjfn2fLv AO8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id h64-20020a636c43000000b00565db8bec39si10554975pgc.173.2023.09.13.09.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:52:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 35EBE82B928C; Wed, 13 Sep 2023 09:39:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230442AbjIMQj1 (ORCPT + 35 others); Wed, 13 Sep 2023 12:39:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230441AbjIMQjL (ORCPT ); Wed, 13 Sep 2023 12:39:11 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 437541BCE; Wed, 13 Sep 2023 09:39:07 -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 43985C15; Wed, 13 Sep 2023 09:39:44 -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 4845B3F5A1; Wed, 13 Sep 2023 09:39:05 -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 07/35] x86: intel_epb: Don't rely on link order Date: Wed, 13 Sep 2023 16:37:55 +0000 Message-Id: <20230913163823.7880-8-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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:39:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776942030927513233 X-GMAIL-MSGID: 1776942030927513233 intel_epb_init() is called as a subsys_initcall() to register cpuhp callbacks. The callbacks make use of get_cpu_device() which will return NULL unless register_cpu() has been called. register_cpu() is called from topology_init(), which is also a subsys_initcall(). This is fragile. Moving the register_cpu() to a different subsys_initcall() leads to a NULL derefernce during boot. Make intel_epb_init() a late_initcall(), user-space can't provide a policy before this point anyway. Signed-off-by: James Morse --- subsys_initcall_sync() would be an option, but moving the register_cpu() calls into ACPI also means adding a safety net for CPUs that are online but not described properly by firmware. This lives in subsys_initcall_sync(). --- arch/x86/kernel/cpu/intel_epb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/intel_epb.c b/arch/x86/kernel/cpu/intel_epb.c index e4c3ba91321c..f18d35fe27a9 100644 --- a/arch/x86/kernel/cpu/intel_epb.c +++ b/arch/x86/kernel/cpu/intel_epb.c @@ -237,4 +237,4 @@ static __init int intel_epb_init(void) cpuhp_remove_state(CPUHP_AP_X86_INTEL_EPB_ONLINE); return ret; } -subsys_initcall(intel_epb_init); +late_initcall(intel_epb_init); From patchwork Wed Sep 13 16:37:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 139265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp74138vqi; Wed, 13 Sep 2023 19:59:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESglokldpazdN0KCiGxudq6pJqHc7qSR873Km4lx6PfuL24wPEL0l0ZZ2DT02QfhunGnJS X-Received: by 2002:a17:902:ab1e:b0:1b8:8702:1e7c with SMTP id ik30-20020a170902ab1e00b001b887021e7cmr785773plb.33.1694660370749; Wed, 13 Sep 2023 19:59:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694660370; cv=none; d=google.com; s=arc-20160816; b=aR14NveJQI1CUf/fgH15aQBQ/EGpAueWXgVtj+i5g6qSfm6C++xIqYk+h9TypgleoQ UddW/BDW4bJ0A1+6Eyj7Kp5+wzBbNn1eLTFPgVCqt8lObfYDPzhsKDPxNasTfBaQz6ss IXmSXAsWF2KP/U0ldeNBe2scwp2Q3yEbTtCQuaiAADW51rHXfN5z9+8pyq39ELaWt5vK JTr1sjl/bojXYYq6eyGLy1uSn+z1WvANNHZWLwxXAa2P5Hslw/SIQKuK/O2ZRV0aruHl LKlRHQj4AQnV1HjdiLY332Fi8zyBsOuq2V6XiexCcwx9bMQZQqZzZrEgxVoPBNuyyqbP slvQ== 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=9ek+nplbfDwxpAsQ1Ja4J48DdQa+1sowmJSgspWq1QE=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=UVtOh+cNr1qKa2vfnQV9zHI/bztx9nvw68kcn5GfbO7W51ibf+33KR7Vjw43nSAp8U g2DGXXRtj0+mumMXqF2m5dq7FKFHJMloKKAMfNSlhdRlqwgYEH7YhmUbCW6rFF8Tu/x5 AEkbXyoAbVkgGiaU0/j1qTkiVfCKT03LU7JHuFC1KFNhgr1gPMbQ4GUHO4xC7RDXKrWV tRwyXlVQfB8BSyc8//aJYsGyjG0ricEWPFuT4AFbYWUwoH5blM81SBkGj9VxpsKTvyZq 0tzFUJmC7sZSSFy5DhgnVbs9EJYrDhLIXj4ybvK5wYYCOdcjA/6PG+hJoJ3lHdyX5UeA c9kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b17-20020a170903229100b001b8c4021be9si756057plh.397.2023.09.13.19.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 19:59:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 6ACC681D6A8C; Wed, 13 Sep 2023 09:39:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231135AbjIMQjk (ORCPT + 35 others); Wed, 13 Sep 2023 12:39:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbjIMQjR (ORCPT ); Wed, 13 Sep 2023 12:39:17 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 42CD01BDD; Wed, 13 Sep 2023 09:39:09 -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 42417FEC; Wed, 13 Sep 2023 09:39:46 -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 47AE03F5A1; Wed, 13 Sep 2023 09:39:07 -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 08/35] x86/topology: Switch over to GENERIC_CPU_DEVICES Date: Wed, 13 Sep 2023 16:37:56 +0000 Message-Id: <20230913163823.7880-9-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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:39:39 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776980193057844502 X-GMAIL-MSGID: 1776980193057844502 Now that GENERIC_CPU_DEVICES calls arch_register_cpu(), which can be overridden by the arch code, switch over to this to allow common code to choose when the register_cpu() call is made. x86's struct cpus come from struct x86_cpu, which has no other members or users. Remove this and use the version defined by common code. This is an intermediate step to the logic being moved to drivers/acpi, where GENERIC_CPU_DEVICES will do the work when booting with acpi=off. Signed-off-by: James Morse ---- Changes since RFC: * Fixed the second copy of arch_register_cpu() used for non-hotplug --- arch/x86/Kconfig | 1 + arch/x86/include/asm/cpu.h | 4 ---- arch/x86/kernel/topology.c | 25 ++++++------------------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index a0100a1ab4a0..133ea5f561b5 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -148,6 +148,7 @@ config X86 select GENERIC_CLOCKEVENTS_MIN_ADJUST select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE + select GENERIC_CPU_DEVICES select GENERIC_CPU_VULNERABILITIES select GENERIC_EARLY_IOREMAP select GENERIC_ENTRY diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index 96dc4665e87d..f349c94510e8 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h @@ -23,10 +23,6 @@ static inline void prefill_possible_map(void) {} #endif /* CONFIG_SMP */ -struct x86_cpu { - struct cpu cpu; -}; - #ifdef CONFIG_HOTPLUG_CPU extern void arch_unregister_cpu(int); extern void soft_restart_cpu(void); diff --git a/arch/x86/kernel/topology.c b/arch/x86/kernel/topology.c index 0bab03130033..ca08a1d138f0 100644 --- a/arch/x86/kernel/topology.c +++ b/arch/x86/kernel/topology.c @@ -35,38 +35,25 @@ #include #include -static DEFINE_PER_CPU(struct x86_cpu, cpu_devices); - #ifdef CONFIG_HOTPLUG_CPU int arch_register_cpu(int cpu) { - struct x86_cpu *xc = per_cpu_ptr(&cpu_devices, cpu); + struct cpu *c = per_cpu_ptr(&cpu_devices, cpu); - xc->cpu.hotpluggable = cpu > 0; - return register_cpu(&xc->cpu, cpu); + c->hotpluggable = cpu > 0; + return register_cpu(c, cpu); } EXPORT_SYMBOL(arch_register_cpu); void arch_unregister_cpu(int num) { - unregister_cpu(&per_cpu(cpu_devices, num).cpu); + unregister_cpu(&per_cpu(cpu_devices, num)); } EXPORT_SYMBOL(arch_unregister_cpu); #else /* CONFIG_HOTPLUG_CPU */ -int __init arch_register_cpu(int num) +int arch_register_cpu(int num) { - return register_cpu(&per_cpu(cpu_devices, num).cpu, num); + return register_cpu(&per_cpu(cpu_devices, num), num); } #endif /* CONFIG_HOTPLUG_CPU */ - -static int __init topology_init(void) -{ - int i; - - for_each_present_cpu(i) - arch_register_cpu(i); - - return 0; -} -subsys_initcall(topology_init); From patchwork Wed Sep 13 16:37:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138935 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1213747vqx; Wed, 13 Sep 2023 09:41:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgjYdHklMFJ40y4JV/Q6uCV30jOOzq3bK82B5b8SEfPcuW/pbJik1o7fYJkQzYUQHkYUpK X-Received: by 2002:a17:902:e88a:b0:1c3:19d6:3559 with SMTP id w10-20020a170902e88a00b001c319d63559mr4631296plg.1.1694623268217; Wed, 13 Sep 2023 09:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623268; cv=none; d=google.com; s=arc-20160816; b=n4UX7Z1EpUXAK3Fuif9D2alM3j7gfpK8lztu5PeGWxW/cYX8ac3QCNOMBw+E3faasU HignPMJD05GFn2YN6WUSaZKovIAttaLCJKLtsForp04etY+zrlE/rjfJHp7lTpmaqPDm G2CPdonO/MVLBfjUNUIp+is0OYXIFO0q/rSq/dsI9kq9KsmhrsRprzq6jxOyg/tuNUfL 0rFkVR3KdRZjilKD/Xg2eUWnmMZCAwa4kfoVvreJBkoDzZXHiKaG/NJ7i1L3V5igNJWv DQWkH0VWe8txIFwSE5aQA6kPTkulQLCbOe8u4sUCo69ewWw3OXBFUzVOjqRYbwPnWx+S OdMw== 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=mU+w7afSVmVnsGgu6g5tMwxnhU9WQ4Lm3QzdVcBA0Qo=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=kGLU0TsgptvMH7Yj4QcrNK6YO/t1Iywnn7smzi9qJhIf1jSI0MvMYyI5Ygur6E3nya yd9/okTBdSQNkLU3OQqzAaVjYDpOnpdCW6dR7R8yheEfstTac49oYnIZ1ebmSHCupPT0 b37mXvtpYnb5DKLH0q9xvTVT8zijMzsE/cJh6Y3UVAP28lY5CoMRluLACN7PDPlFTIGh njh27AXQOs8rweP2I47xDMWO6tCBrrfu0jHFK8Bq8jPGxczJ93jxCsUfHk7hNMPFDSYm /+osEVnXKH9xAXIkI6YD1BmhkVLALcU3lCptQ+zUnbIs7qu55nyOMeCYmnJdiX0SIP+w MdeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id ix13-20020a170902f80d00b001bf0e15c0a9si10123853plb.269.2023.09.13.09.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:41:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 3541A81DE58F; Wed, 13 Sep 2023 09:40:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230235AbjIMQjm (ORCPT + 35 others); Wed, 13 Sep 2023 12:39:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230432AbjIMQjZ (ORCPT ); Wed, 13 Sep 2023 12:39:25 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3F6151BF0; Wed, 13 Sep 2023 09:39:11 -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 4008E1007; Wed, 13 Sep 2023 09:39:48 -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 459803F5A1; Wed, 13 Sep 2023 09:39:09 -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 09/35] LoongArch: Switch over to GENERIC_CPU_DEVICES Date: Wed, 13 Sep 2023 16:37:57 +0000 Message-Id: <20230913163823.7880-10-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 (fry.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:40:05 -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 fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941287782924046 X-GMAIL-MSGID: 1776941287782924046 Now that GENERIC_CPU_DEVICES calls arch_register_cpu(), which can be overridden by the arch code, switch over to this to allow common code to choose when the register_cpu() call is made. This allows topology_init() to be removed. This is an intermediate step to the logic being moved to drivers/acpi, where GENERIC_CPU_DEVICES will do the work when booting with acpi=off. Signed-off-by: James Morse --- arch/loongarch/Kconfig | 1 + arch/loongarch/kernel/topology.c | 29 ++--------------------------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index 2bddd202470e..5bed51adc68c 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -72,6 +72,7 @@ config LOONGARCH select GENERIC_CLOCKEVENTS select GENERIC_CMOS_UPDATE select GENERIC_CPU_AUTOPROBE + select GENERIC_CPU_DEVICES select GENERIC_ENTRY select GENERIC_GETTIMEOFDAY select GENERIC_IOREMAP if !ARCH_IOREMAP diff --git a/arch/loongarch/kernel/topology.c b/arch/loongarch/kernel/topology.c index caa7cd859078..8e4441c1ff39 100644 --- a/arch/loongarch/kernel/topology.c +++ b/arch/loongarch/kernel/topology.c @@ -7,20 +7,13 @@ #include #include -static DEFINE_PER_CPU(struct cpu, cpu_devices); - #ifdef CONFIG_HOTPLUG_CPU int arch_register_cpu(int cpu) { - int ret; struct cpu *c = &per_cpu(cpu_devices, cpu); - c->hotpluggable = 1; - ret = register_cpu(c, cpu); - if (ret < 0) - pr_warn("register_cpu %d failed (%d)\n", cpu, ret); - - return ret; + c->hotpluggable = !io_master(cpu); + return register_cpu(c, cpu); } EXPORT_SYMBOL(arch_register_cpu); @@ -33,21 +26,3 @@ void arch_unregister_cpu(int cpu) } EXPORT_SYMBOL(arch_unregister_cpu); #endif - -static int __init topology_init(void) -{ - int i, ret; - - for_each_present_cpu(i) { - struct cpu *c = &per_cpu(cpu_devices, i); - - c->hotpluggable = !io_master(i); - ret = register_cpu(c, i); - if (ret < 0) - pr_warn("topology_init: register_cpu %d failed (%d)\n", i, ret); - } - - return 0; -} - -subsys_initcall(topology_init); From patchwork Wed Sep 13 16:37:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1221183vqx; Wed, 13 Sep 2023 09:53:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAA1eRu/trRegvbUq/NKmoKApFFbEmUgvFYktHQr+LpZ17VtxhIC9VNFKw+heEQGmFQh22 X-Received: by 2002:a17:90b:4d85:b0:26c:f6d2:2694 with SMTP id oj5-20020a17090b4d8500b0026cf6d22694mr2832283pjb.12.1694624009404; Wed, 13 Sep 2023 09:53:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694624009; cv=none; d=google.com; s=arc-20160816; b=aeyfaGijZuCmq2q5a7XF8JzLysU+/9jFQdou5+Dhsm0UZTRzLI+oKlsPt1lfqKx8ep JUDD28HdW6XnExNfGA1zHw1xXrU9kbGfNq09lpDPjWyjrCAd8rOpT3FKG+79ZhCpfx0E 4uNpjROY7Kjzz/xYa3A3DkF6UTIVwDUaFKtH08HfF/BY6KpXS9XI4QyLjNt1udMJuY4T fdRlc7NuBL1bpb8mF/bptHQCuucgIApu6VCQSwVxz2zZTP3sa1l2YqaCSOJENECznuNH gv6gl9J/BIZeBVeY7QEzhUIrTF1KPVr9b+hb4eAhb/NiM/MS/bb/yktkF35E3CranGtc E2VQ== 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=VW5WlltlR8foCn+pFQMJn3CWM7LLlXzRjzye3rcEDXo=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=fMKHbRzDlYAE5RpZSlcdlegBVOw3ev5CD4SEH9CBwJ6+HnUDRBBS0p1QFdhXWT/6VS Loy9Tt8gicbYs8rjz6s7ZzFV0SHBuP4a4LPOZFJov55HL86R3I3D/BwmrFeuhfz3nL9A XorBwvA1cD8MsW9YwIiuEFbVeHwdokotMcqNx5fna/QVCYbXSxKTynlvzOsxgmT8tTUD d2xcBZOuOHEVxPteIr1Jo1jO+cAaFmzn0poV5zHtET6jpMKiOxjiXrFZoHoDH7rUq2ia jV6nW5J6zmhMPnIJzbIYvKrM9SaCxT5mLB2RxXc62Fh3ae571gIGvgy4ZLV5HlSVKPaR 1mIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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. [23.128.96.33]) by mx.google.com with ESMTPS id mr22-20020a17090b239600b00274001b10e8si1886999pjb.112.2023.09.13.09.53.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:53:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 AB7B6802644F; Wed, 13 Sep 2023 09:40:05 -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 S230397AbjIMQjv (ORCPT + 35 others); Wed, 13 Sep 2023 12:39:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230499AbjIMQj3 (ORCPT ); Wed, 13 Sep 2023 12:39:29 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3E66D1FCC; Wed, 13 Sep 2023 09:39:13 -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 3E2731FB; Wed, 13 Sep 2023 09:39:50 -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 436ED3F5A1; Wed, 13 Sep 2023 09:39:11 -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 10/35] riscv: Switch over to GENERIC_CPU_DEVICES Date: Wed, 13 Sep 2023 16:37:58 +0000 Message-Id: <20230913163823.7880-11-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:05 -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: 1776942065160693312 X-GMAIL-MSGID: 1776942065160693312 Now that GENERIC_CPU_DEVICES calls arch_register_cpu(), which can be overridden by the arch code, switch over to this to allow common code to choose when the register_cpu() call is made. This allows topology_init() to be removed. This is an intermediate step to the logic being moved to drivers/acpi, where GENERIC_CPU_DEVICES will do the work when booting with acpi=off. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron --- arch/riscv/Kconfig | 1 + arch/riscv/kernel/setup.c | 19 ++++--------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index d607ab0f7c6d..eeb80fb55acc 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -69,6 +69,7 @@ config RISCV select GENERIC_ARCH_TOPOLOGY select GENERIC_ATOMIC64 if !64BIT select GENERIC_CLOCKEVENTS_BROADCAST if SMP + select GENERIC_CPU_DEVICES select GENERIC_EARLY_IOREMAP select GENERIC_ENTRY select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c index e600aab116a4..f5bd6b8d0c52 100644 --- a/arch/riscv/kernel/setup.c +++ b/arch/riscv/kernel/setup.c @@ -62,7 +62,6 @@ atomic_t hart_lottery __section(".sdata") #endif ; unsigned long boot_cpu_hartid; -static DEFINE_PER_CPU(struct cpu, cpu_devices); /* * Place kernel memory regions on the resource tree so that @@ -320,23 +319,13 @@ void __init setup_arch(char **cmdline_p) riscv_set_dma_cache_alignment(); } -static int __init topology_init(void) +int arch_register_cpu(int cpu) { - int i, ret; + struct cpu *c = &per_cpu(cpu_devices, cpu); - for_each_possible_cpu(i) { - struct cpu *cpu = &per_cpu(cpu_devices, i); - - cpu->hotpluggable = cpu_has_hotplug(i); - ret = register_cpu(cpu, i); - if (unlikely(ret)) - pr_warn("Warning: %s: register_cpu %d failed (%d)\n", - __func__, i, ret); - } - - return 0; + c->hotpluggable = cpu_has_hotplug(cpu); + return register_cpu(c, cpu); } -subsys_initcall(topology_init); void free_initmem(void) { From patchwork Wed Sep 13 16:37:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138963 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220954vqx; Wed, 13 Sep 2023 09:53:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpDOAXp6oQxW6WlhZ/8+i9qHhhYEvNCAmV+lazZlvDKUAmiD6R3/Igd9QAtv8n/kF9LrmJ X-Received: by 2002:a17:902:7084:b0:1c0:d17a:bfe9 with SMTP id z4-20020a170902708400b001c0d17abfe9mr2359314plk.46.1694623988689; Wed, 13 Sep 2023 09:53:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623988; cv=none; d=google.com; s=arc-20160816; b=A8VUVgb1m0g+9oaeU/hWuZPylwtquDhHF+vrJprFEbo+UGN6sdbHYxkR7TKkhd1KCw AkJyalU60VrPa4gItwxPE+263zfvhkmy/lD286dllnJxf5POXR/iwbrZJABj+vyKBjLA 5hjhhbwhzjY+3op8my+7uc++7Tbjia9AM80L88DpMTIWe9VXpX4olAz06lNnlANMNjR6 dIzE6d/OTgitN16YjP/zvMXxXKERkxJwRKqCFuEspjijVxOasliEaUHltIxs0RPUWYEZ 8dtVar2I7J2gBfR3p9OepQE4Z37dxuQjFjWCqMEQRmhvejaQmoS8G+wpT+NHJeSSVjvq /3bQ== 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=qi0Pf5goCeCqPv40frmbcyEQJGVwlp02boYxSHsZLss=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=ky5sXMXJR47sFF5mVspPuqzDszWrbYvKU13UECTb2A7nTqrN1DG7vLdoNWkQVybTQy HO+U2U2SEKeCMxzZPBYVNAjMDr7nnGY3XQ6aO0XXM8YtcAm/IpkBCgK2Sc5gdTODaOi6 NdgMBNooTdv4LKclanDKTQ9BMDX/1XYOlKQ3cUewO5DhZnai4hiV6u1jdXm6qZb8ZTtI qbyIfNYogzIeuMqnn59Wa6BJUP5EQ3oLzuQkm9BX2qEs7USnWbyL3FhCvAz8JJ/sJJZl sma02z1ttQ+zf2MLnWTfNiYbJPS5hZ1iZJbVCJMueTo/+rfzDF4hZyUCqCNzlyNwkByX Whrg== 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:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id m17-20020a170902e41100b001b035ce0649si10239612ple.372.2023.09.13.09.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:53:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id D980A8452EF6; Wed, 13 Sep 2023 09:39:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbjIMQj7 (ORCPT + 35 others); Wed, 13 Sep 2023 12:39:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230387AbjIMQji (ORCPT ); Wed, 13 Sep 2023 12:39:38 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7B8E71FE5; Wed, 13 Sep 2023 09:39:15 -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 3C192C15; Wed, 13 Sep 2023 09:39:52 -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 416BC3F5A1; Wed, 13 Sep 2023 09:39:13 -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 11/35] arch_topology: Make register_cpu_capacity_sysctl() tolerant to late CPUs Date: Wed, 13 Sep 2023 16:37:59 +0000 Message-Id: <20230913163823.7880-12-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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:39:59 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776942043219437164 X-GMAIL-MSGID: 1776942043219437164 register_cpu_capacity_sysctl() adds a property to sysfs that describes the CPUs capacity. This is done from a subsys_initcall() that assumes all possible CPUs are registered. With CPU hotplug, possible CPUs aren't registered until they become present, (or for arm64 enabled). This leads to messages during boot: | register_cpu_capacity_sysctl: too early to get CPU1 device! and once these CPUs are added to the system, the file is missing. Move this to a cpuhp callback, so that the file is created once CPUs are brought online. This covers CPUs that are added late by mechanisms like hotplug. One observable difference is the file is now missing for offline CPUs. Signed-off-by: James Morse --- If the offline CPUs thing is a problem for the tools that consume this value, we'd need to move cpu_capacity to be part of cpu.c's common_cpu_attr_groups. --- drivers/base/arch_topology.c | 38 ++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index b741b5ba82bd..9ccb7daee78e 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -220,20 +220,34 @@ static DECLARE_WORK(update_topology_flags_work, update_topology_flags_workfn); static DEVICE_ATTR_RO(cpu_capacity); +static int cpu_capacity_sysctl_add(unsigned int cpu) +{ + struct device *cpu_dev = get_cpu_device(cpu); + + if (!cpu_dev) + return -ENOENT; + + device_create_file(cpu_dev, &dev_attr_cpu_capacity); + + return 0; +} + +static int cpu_capacity_sysctl_remove(unsigned int cpu) +{ + struct device *cpu_dev = get_cpu_device(cpu); + + if (!cpu_dev) + return -ENOENT; + + device_remove_file(cpu_dev, &dev_attr_cpu_capacity); + + return 0; +} + static int register_cpu_capacity_sysctl(void) { - int i; - struct device *cpu; - - for_each_possible_cpu(i) { - cpu = get_cpu_device(i); - if (!cpu) { - pr_err("%s: too early to get CPU%d device!\n", - __func__, i); - continue; - } - device_create_file(cpu, &dev_attr_cpu_capacity); - } + cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "topology/cpu-capacity", + cpu_capacity_sysctl_add, cpu_capacity_sysctl_remove); return 0; } From patchwork Wed Sep 13 16:38:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138968 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1221632vqx; Wed, 13 Sep 2023 09:54:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAbVopcTPVw3+Y1qH+4mkGz/y+URvJEwzpEZGVbDTSPvHF5Uuf7W/jQrrzS8Ld73HVk6ay X-Received: by 2002:a17:902:ea83:b0:1bb:84d4:5327 with SMTP id x3-20020a170902ea8300b001bb84d45327mr3174865plb.6.1694624056767; Wed, 13 Sep 2023 09:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694624056; cv=none; d=google.com; s=arc-20160816; b=q87rrVzbSqPXwdcNaZPJdaQXJJFZjCpXiKMUlMSEuXGuPFqmh5su4eOP1TbYbSeJ8u UDUqBGQaOVEsF0Uo+MuNRkxs8sV0j5lVwzdXJ5zc5wOjICbc1420Oiud3BT6eQrZhw2x xtGz8RNgcIe0H/2pQjJnUkAYftVRhmNSeWyqpazFGFLO5o8u+rqlVYrvGemsX0/m100O xkwZmDNS6TN60kUkxnrJ0SChG1IVOCwdrOnXYVe1sPHqIus8EbEd9DGq8q4MluTiE83e SZmVLCeO5+0RUgskxe5QgWUOLXO9aTz69kKL+aM5jC3M3RFxaVOj3ifUghGC4r/rWQGs UWFQ== 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=BcwuLlderQ1LBVmv8wRHIf7sf+opacJvUuxjf4oVs2g=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=ROeHZAb0/Bc4fJvjcBt7iouc7P8+xEJUMe4QCgF41i3qenz9I3R6mrWu/um7pWyhfr 3NBYSVWjfUYxBg1KtO2IOD4QG4lXKjyZF1wcHYNIxzR5YsMAqpTNHGq4/1zYR4mtLAuH Z3OWLxSDcU/3Kxzm6uH3ZksXXIc0cfV2/idaCW6wr/72A52/Jz/7Gx7rL2kPMPgppRfL 7oD+5T+ac2kOnsTplsdedZmNkTXPFLtLTzeEKOctBA34Hi/GVf8icHn7Vsz02hf2pa1v wxPeWnSqJSnLGO6E2UjlF6PZALSgQZvXKwTeYNLlP28dr272lbKKM3UpmnKAzYm6vU3u DRmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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. [23.128.96.33]) by mx.google.com with ESMTPS id o17-20020a170902d4d100b001b873b80747si11326728plg.39.2023.09.13.09.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:54:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 D7C268145974; Wed, 13 Sep 2023 09:40:08 -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 S230413AbjIMQkB (ORCPT + 35 others); Wed, 13 Sep 2023 12:40:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230523AbjIMQjj (ORCPT ); Wed, 13 Sep 2023 12:39:39 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3A0671FF5; Wed, 13 Sep 2023 09:39:17 -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 3A730FEC; Wed, 13 Sep 2023 09:39:54 -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 3F94B3F5A1; Wed, 13 Sep 2023 09:39:15 -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 12/35] ACPI: Use the acpi_device_is_present() helper in more places Date: Wed, 13 Sep 2023 16:38:00 +0000 Message-Id: <20230913163823.7880-13-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:08 -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: 1776942114660820540 X-GMAIL-MSGID: 1776942114660820540 acpi_device_is_present() checks the present or functional bits from the cached copy of _STA. A few places open-code this check. Use the helper instead to improve readability. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan --- drivers/acpi/scan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 691d4b7686ee..ed01e19514ef 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -304,7 +304,7 @@ static int acpi_scan_device_check(struct acpi_device *adev) int error; acpi_bus_get_status(adev); - if (adev->status.present || adev->status.functional) { + if (acpi_device_is_present(adev)) { /* * This function is only called for device objects for which * matching scan handlers exist. The only situation in which @@ -338,7 +338,7 @@ static int acpi_scan_bus_check(struct acpi_device *adev, void *not_used) int error; acpi_bus_get_status(adev); - if (!(adev->status.present || adev->status.functional)) { + if (!acpi_device_is_present(adev)) { acpi_scan_device_not_present(adev); return 0; } From patchwork Wed Sep 13 16:38:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138951 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220018vqx; Wed, 13 Sep 2023 09:51:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHo52ZH4FJHr7HNkFu0mQuE2A8Rtkuy4Nd/YgzgkNi/FcOaJVKc6anmQvjx/vDkYFWtiMi X-Received: by 2002:a05:6a00:851:b0:68e:2d59:b1f3 with SMTP id q17-20020a056a00085100b0068e2d59b1f3mr3814542pfk.13.1694623895884; Wed, 13 Sep 2023 09:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623895; cv=none; d=google.com; s=arc-20160816; b=XimZmnae+KG65lIPiBLHmgz8YP2MXVLeWoYk48vAjzpeH1/khktG2ifa5bM/nzWEGJ YB6boNEh/zRLUGpM4ePPOsW6fPYjCAKmukFe/Qns0eXGxh+E0JhqZ4nEHXIhdBolItdj /TGbcRScFINBKrvsuzygQyLpR225WaV22JPLLRwEN1m4QAFHPmPrYuBlPcMdnIO9nTte a1L1PzvN1KK4YHzYZzfhgmp35cyJ5Fh4es0UJD9vHZV6CNY9c/5GbBR4U4depP9L2CO2 Pp2QdaAazroTy+BDayiQVIO6yMhdSXPcjueV9RyDgFIJYVBxguotcIcnMKd4wamimQZA 17UQ== 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=joyA2RRgDbhuge5sGDyMojCf87Sw8Bpxtzby5XkXThk=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=Q/b2+3z31C+RcDFH+4RZ6obzWga8C9vd4BFs9z/fQweHAKPkSSHZQHlOERVifXsnPj ahCx+7Ex6PQWwVjjl5M/MhES2/RxnnIWMCrLCyF/PPN/6KJM2Olo96et7E03olFIzkdH Dwgo4IPVki4UilD0d05HiGHimdgPf7xNl8v3YeZTJHlHQRGc9YBmF3mW6LENXccxv9at FdZh3sJlmGeaBuA2QkdsOIsVeW22ev2L+D/ulEQpmy9eRtvTNw/Fx2Y7choRc/Ck5IX/ vCHmqe0DVQAB3BmWoX53qhgIzhT1N0v32XqIvR3WaqGLMzF3loK8WAR5fR9qLziorSEm Kqhg== 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:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id k189-20020a6384c6000000b00565f4fb0999si9939413pgd.610.2023.09.13.09.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:51:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id 2A21F81142C1; Wed, 13 Sep 2023 09:40:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230400AbjIMQkI (ORCPT + 35 others); Wed, 13 Sep 2023 12:40:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231136AbjIMQjk (ORCPT ); Wed, 13 Sep 2023 12:39:40 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3B1432106; Wed, 13 Sep 2023 09:39:19 -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 3A2C21FB; Wed, 13 Sep 2023 09:39:56 -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 3F3BD3F5A1; Wed, 13 Sep 2023 09:39:17 -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 13/35] ACPI: Rename acpi_scan_device_not_present() to be about enumeration Date: Wed, 13 Sep 2023 16:38:01 +0000 Message-Id: <20230913163823.7880-14-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 (groat.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:40:25 -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 groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941946267850529 X-GMAIL-MSGID: 1776941946267850529 acpi_scan_device_not_present() is called when a device in the hierarchy is not available for enumeration. Historically enumeration was only based on whether the device was present. To add support for only enumerating devices that are both present and enabled, this helper should be renamed. It was only ever about enumeration, rename it acpi_scan_device_not_enumerated(). No change in behaviour is intended. Signed-off-by: James Morse Reviewed-by: Gavin Shan --- drivers/acpi/scan.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index ed01e19514ef..17ab875a7d4e 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -289,10 +289,10 @@ static int acpi_scan_hot_remove(struct acpi_device *device) return 0; } -static int acpi_scan_device_not_present(struct acpi_device *adev) +static int acpi_scan_device_not_enumerated(struct acpi_device *adev) { if (!acpi_device_enumerated(adev)) { - dev_warn(&adev->dev, "Still not present\n"); + dev_warn(&adev->dev, "Still not enumerated\n"); return -EALREADY; } acpi_bus_trim(adev); @@ -327,7 +327,7 @@ static int acpi_scan_device_check(struct acpi_device *adev) error = -ENODEV; } } else { - error = acpi_scan_device_not_present(adev); + error = acpi_scan_device_not_enumerated(adev); } return error; } @@ -339,7 +339,7 @@ static int acpi_scan_bus_check(struct acpi_device *adev, void *not_used) acpi_bus_get_status(adev); if (!acpi_device_is_present(adev)) { - acpi_scan_device_not_present(adev); + acpi_scan_device_not_enumerated(adev); return 0; } if (handler && handler->hotplug.scan_dependent) From patchwork Wed Sep 13 16:38:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1213771vqx; Wed, 13 Sep 2023 09:41:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWAobPsCamV+UhV9687loCo/Zy/LlwmRoCt8DQnmu87P4lLJirV0Pm+a3oQsRuWMe7EKZI X-Received: by 2002:a05:6358:fac3:b0:12b:e47a:8191 with SMTP id ts3-20020a056358fac300b0012be47a8191mr2412542rwb.16.1694623271176; Wed, 13 Sep 2023 09:41:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623271; cv=none; d=google.com; s=arc-20160816; b=mko5JQpMv5nMYf/r564rSyRErDfemlnLjZNAo6nOWmGfIJvT9b8rPruxEum+4H1b2j V5KUyR4N4AYWBLJ/64B3wfU08Z3y2/x5iV8LYtF5FFg7feajJWqARUnQ26SPow2aAQp1 TSgSbyptlszcXLF2DCxgWMOOxCg5F6ks66J6wFghEVP9zKKhJL/6VgQB1BQOPVgSRTX5 ZEsb1rZZYQuqZxZ687iKKklxn8U8BtY8M7DspR20d29V1g+7uAOdcH0HQPLhQujhQIZS NdC6pMeP+sVIXJf/qFWF8g4Qws5haFT33GuCdldBND8w1QMXWiBo0qM9ql7aVn8qnM9M KVbQ== 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=o/NqhV95dBs4BZzEDZw1j825oiJngX0uNeKy194c6Wk=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=xQctaJet6qKRF1ixApndehEKk5KZutgiEIGx3/Nk6dNrfsRN6WWiAg+JQtxrLwg0eV DdHUKsCY+I/iCfWuYwFXCtwjfW/H2DY0fSD3Lqk9me9yUK0YhkJcB/IrM2wL6eXk/CCj lS/U+rbYdYdVrvdYaJjphYu5Q2uK3qdTyO+l6l0wEmGfM+yQor44lMmCpVr1p8fHm3oc eXjimEcrYRhbjWtFVyQpLVyrN6d2ISBEvENbtw9rsthYvGdlqF5eF/dMRMKyPwq8bIgD fDaASZxlZkDckepfZA6gteAm1CReWDu7rZen0avbBjPCDFAhkKpA9IIwrpo+NvEQjvag Z9Vw== 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:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id m27-20020a637d5b000000b00573e1eb9965si4133281pgn.663.2023.09.13.09.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:41:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 385F781DE59C; Wed, 13 Sep 2023 09:40:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbjIMQkL (ORCPT + 35 others); Wed, 13 Sep 2023 12:40:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231144AbjIMQjk (ORCPT ); Wed, 13 Sep 2023 12:39:40 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 381D1210B; Wed, 13 Sep 2023 09:39:21 -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 38273C15; Wed, 13 Sep 2023 09:39:58 -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 3DA263F5A1; Wed, 13 Sep 2023 09:39:19 -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 14/35] ACPI: Only enumerate enabled (or functional) devices Date: Wed, 13 Sep 2023 16:38:02 +0000 Message-Id: <20230913163823.7880-15-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 (fry.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:40:37 -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 fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941291334105185 X-GMAIL-MSGID: 1776941291334105185 Today the ACPI enumeration code 'visits' all devices that are present. This is a problem for arm64, where CPUs are always present, but not always enabled. When a device-check occurs because the firmware-policy has changed and a CPU is now enabled, the following error occurs: | acpi ACPI0007:48: Enumeration failure This is ultimately because acpi_dev_ready_for_enumeration() returns true for a device that is not enabled. The ACPI Processor driver will not register such CPUs as they are not 'decoding their resources'. Change acpi_dev_ready_for_enumeration() to also check the enabled bit. ACPI allows a device to be functional instead of maintaining the present and enabled bit. Make this behaviour an explicit check with a reference to the spec, and then check the present and enabled bits. This is needed to avoid enumerating present && functional devices that are not enabled. Signed-off-by: James Morse --- If this change causes problems on deployed hardware, I suggest an arch opt-in: ACPI_IGNORE_STA_ENABLED, that causes acpi_dev_ready_for_enumeration() to only check the present bit. --- drivers/acpi/device_pm.c | 2 +- drivers/acpi/device_sysfs.c | 2 +- drivers/acpi/internal.h | 1 - drivers/acpi/property.c | 2 +- drivers/acpi/scan.c | 23 +++++++++++++---------- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index f007116a8427..76c38478a502 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -313,7 +313,7 @@ int acpi_bus_init_power(struct acpi_device *device) return -EINVAL; device->power.state = ACPI_STATE_UNKNOWN; - if (!acpi_device_is_present(device)) { + if (!acpi_dev_ready_for_enumeration(device)) { device->flags.initialized = false; return -ENXIO; } diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c index b9bbf0746199..16e586d74aa2 100644 --- a/drivers/acpi/device_sysfs.c +++ b/drivers/acpi/device_sysfs.c @@ -141,7 +141,7 @@ static int create_pnp_modalias(const struct acpi_device *acpi_dev, char *modalia struct acpi_hardware_id *id; /* Avoid unnecessarily loading modules for non present devices. */ - if (!acpi_device_is_present(acpi_dev)) + if (!acpi_dev_ready_for_enumeration(acpi_dev)) return 0; /* diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h index 866c7c4ed233..a1b45e345bcc 100644 --- a/drivers/acpi/internal.h +++ b/drivers/acpi/internal.h @@ -107,7 +107,6 @@ int acpi_device_setup_files(struct acpi_device *dev); void acpi_device_remove_files(struct acpi_device *dev); void acpi_device_add_finalize(struct acpi_device *device); void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); -bool acpi_device_is_present(const struct acpi_device *adev); bool acpi_device_is_battery(struct acpi_device *adev); bool acpi_device_is_first_physical_node(struct acpi_device *adev, const struct device *dev); diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c index 413e4fcadcaf..e03f00b98701 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1418,7 +1418,7 @@ static bool acpi_fwnode_device_is_available(const struct fwnode_handle *fwnode) if (!is_acpi_device_node(fwnode)) return false; - return acpi_device_is_present(to_acpi_device_node(fwnode)); + return acpi_dev_ready_for_enumeration(to_acpi_device_node(fwnode)); } static const void * diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 17ab875a7d4e..f898591ce05f 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -304,7 +304,7 @@ static int acpi_scan_device_check(struct acpi_device *adev) int error; acpi_bus_get_status(adev); - if (acpi_device_is_present(adev)) { + if (acpi_dev_ready_for_enumeration(adev)) { /* * This function is only called for device objects for which * matching scan handlers exist. The only situation in which @@ -338,7 +338,7 @@ static int acpi_scan_bus_check(struct acpi_device *adev, void *not_used) int error; acpi_bus_get_status(adev); - if (!acpi_device_is_present(adev)) { + if (!acpi_dev_ready_for_enumeration(adev)) { acpi_scan_device_not_enumerated(adev); return 0; } @@ -1908,11 +1908,6 @@ static bool acpi_device_should_be_hidden(acpi_handle handle) return true; } -bool acpi_device_is_present(const struct acpi_device *adev) -{ - return adev->status.present || adev->status.functional; -} - static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler, const char *idstr, const struct acpi_device_id **matchid) @@ -2375,16 +2370,24 @@ EXPORT_SYMBOL_GPL(acpi_dev_clear_dependencies); * acpi_dev_ready_for_enumeration - Check if the ACPI device is ready for enumeration * @device: Pointer to the &struct acpi_device to check * - * Check if the device is present and has no unmet dependencies. + * Check if the device is functional or enabled and has no unmet dependencies. * - * Return true if the device is ready for enumeratino. Otherwise, return false. + * Return true if the device is ready for enumeration. Otherwise, return false. */ bool acpi_dev_ready_for_enumeration(const struct acpi_device *device) { if (device->flags.honor_deps && device->dep_unmet) return false; - return acpi_device_is_present(device); + /* + * ACPI 6.5's 6.3.7 "_STA (Device Status)" allows firmware to return + * (!present && functional) for certain types of devices that should be + * enumerated. + */ + if (!device->status.present && !device->status.enabled) + return device->status.functional; + + return device->status.present && device->status.enabled; } EXPORT_SYMBOL_GPL(acpi_dev_ready_for_enumeration); From patchwork Wed Sep 13 16:38:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138934 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1213516vqx; Wed, 13 Sep 2023 09:40:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHycE/b5bKmQvrL1/UId6NDR0N5Vk/tcyVTtyl0sCj1jyMqvyF61uF68DYbkYDD8uXK1zBN X-Received: by 2002:a05:6a20:1615:b0:159:b7dc:2295 with SMTP id l21-20020a056a20161500b00159b7dc2295mr679275pzj.9.1694623243925; Wed, 13 Sep 2023 09:40:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623243; cv=none; d=google.com; s=arc-20160816; b=u7VivKVVBO+KcECkdC1Gi5StNU50JA9E8NQbhUVBKRJioYIgtE8rsIXT8rXemtFQw5 8om064eJS1Dul7Av/WVfVFp2eqUmlGsjFmChq+WRwKHjwWTLYZhM4C6Wpiooij/sz5/G NADbuY5cRFzZidbcMvNJGqKmJM+UleM3KsFcVECDVBW95N7WIcVK3j2W8zTiVBmY+PZf o1TevEUToYZ2OGsQ2c68Xxteg6S/s683LJYMjLSz5XdPtfHI/BLNKwPVaWqanndn+AIi J2aVmnLDMHyYvrQ3lp+TcIAp6hJ0Qt+stIsAYxFZDLykHlpqU0X7iuRHAo5vsHktlyS8 Sgyg== 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=RTzee0Qx7a7uEcqAJMxv/nMw7O30YuR+udrjnvXPYxE=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=PLqNbBDN8eLOTub2zbNwG80z4+iM+8YSgQ+vAfMtpW9YcP8h7RNvtMYT36/95L4rjh /kYpWO7StSiCeqrTDIAnjTLSCmPyqoaPZZwH2YBgZF08E5BqCUlMMma638RPPtPwozKH 91AMVH2uEgl3gILH65frdbnlFr1e5gVbvwoKqhC4bgjHRtmUfODFNThx2A+r7AmrcJUd hVfOALi/4TKUdy77KeT2/aE7tGNQYZZYXM9ejBasRBnEB+pdt3qYmDFOxm63+QCD2GB/ Do1jU0bkpbGv4paF3/sgKXADva2OMO/twgRvL+IQn/WILwa7taXW5jUq4HoZ4/YF3t2e UgMA== 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:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id t23-20020a656097000000b0055b640a6b3csi7617781pgu.884.2023.09.13.09.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:40:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id D955C81EB0F6; Wed, 13 Sep 2023 09:40:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231313AbjIMQkP (ORCPT + 35 others); Wed, 13 Sep 2023 12:40:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231165AbjIMQjn (ORCPT ); Wed, 13 Sep 2023 12:39:43 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3695B2112; Wed, 13 Sep 2023 09:39:23 -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 36BFD1FB; Wed, 13 Sep 2023 09:40:00 -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 3BFF83F5A1; Wed, 13 Sep 2023 09:39:21 -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 15/35] ACPI: processor: Add support for processors described as container packages Date: Wed, 13 Sep 2023 16:38:03 +0000 Message-Id: <20230913163823.7880-16-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 (agentk.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:40:19 -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 agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941262872469983 X-GMAIL-MSGID: 1776941262872469983 ACPI has two ways of describing processors in the DSDT. Either as a device object with HID ACPI0007, or as a type 'C' package inside a Processor Container. The ACPI processor driver probes CPUs described as devices, but not those described as packages. Duplicate descriptions are not allowed, the ACPI processor driver already parses the UID from both devices and containers. acpi_processor_get_info() returns an error if the UID exists twice in the DSDT. The missing probe for CPUs described as packages creates a problem for moving the cpu_register() calls into the acpi_processor driver, as CPUs described like this don't get registered, leading to errors from other subsystems when they try to add new sysfs entries to the CPU node. (e.g. topology_sysfs_init()'s use of topology_add_dev() via cpuhp) To fix this, parse the processor container and call acpi_processor_add() for each processor that is discovered like this. The processor container handler is added with acpi_scan_add_handler(), so no detach call will arrive. Qemu TCG describes CPUs using packages in a processor container. Signed-off-by: James Morse --- drivers/acpi/acpi_processor.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index c0839bcf78c1..b4bde78121bb 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -625,9 +625,31 @@ static struct acpi_scan_handler processor_handler = { }, }; +static acpi_status acpi_processor_container_walk(acpi_handle handle, + u32 lvl, + void *context, + void **rv) +{ + struct acpi_device *adev; + acpi_status status; + + adev = acpi_get_acpi_dev(handle); + if (!adev) + return AE_ERROR; + + status = acpi_processor_add(adev, &processor_device_ids[0]); + acpi_put_acpi_dev(adev); + + return status; +} + static int acpi_processor_container_attach(struct acpi_device *dev, const struct acpi_device_id *id) { + acpi_walk_namespace(ACPI_TYPE_PROCESSOR, dev->handle, + ACPI_UINT32_MAX, acpi_processor_container_walk, + NULL, NULL, NULL); + return 1; } 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. From patchwork Wed Sep 13 16:38:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138964 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1221004vqx; Wed, 13 Sep 2023 09:53:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCD6JejrPoHOvahOzurmqMobQ4S1+UDTYLQy+jizEDUDqtdjr995MrtGwxaHmT8rgs5ehc X-Received: by 2002:a17:90a:4101:b0:26d:3e6a:cd93 with SMTP id u1-20020a17090a410100b0026d3e6acd93mr8529771pjf.17.1694623993636; Wed, 13 Sep 2023 09:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623993; cv=none; d=google.com; s=arc-20160816; b=feFsI0ThaucUTHUxjJt1ITf2M52TVr+MkBJID8CSpKsITwN/Pcs3ddfZbT85ySwnyl 02yjWqOrcavfltq078U2aXfq0/OwVbmNEz3qmQks1mGXBgZVmWPCwWj6qtnqCF5Gg3+t uG71FEtEiXYY7jzgp0BHGesDcMRotOEN1/bMT0n5mxU4uReqbdwJHl4jxKvE0eFUmRDI EXrzfKqN3AI1/TlK7tZsHPr5z5pC7tV8Dg0Zyequ3WXCzxKwVtKiFxk5RqfOiUQwoKYQ SxF5Jhmg0tMwHa1hvDKUZEGgWJZucN59TP3y3noViFjL5weOWqhxfj3MFfLbBXSdK4H+ rpbQ== 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=8Zw53qf70tlT158AshvZQHY21j9vTri8CUxJTblOQgE=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=eAdPA4EtzJTgdhHZXLNmEtP5lxUDQM7Zp8I4naJdFZ50wfi7DqeitjTv9u2ZKGVJI+ GlVauO1DgzxIliqiDRFYJh3jUoW07eaIZmR+hI+0C2lH9UmAz4c15XHVcElzAKloIaTr 41q2C98PX0udv5rNTAkigW73dojQ/ds0fvyB/FE7ixCP7IXMqjlLtGXoABYU6UvKVH17 45JqtIm8k8WuWqKFDZSJX8mTg53jaC2lpHwieinC+a15VulJeFXETWlTCNtfxamwe8MC olJwa79c5rVjgleiq/hvw0Fakq3gSVGDn8hohICDTjY7VHPp9gcCoIQ8UhmQqKA8BfAx TP8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id pc14-20020a17090b3b8e00b00263fa42fdcbsi2072578pjb.107.2023.09.13.09.53.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:53:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id EF5D384AC659; Wed, 13 Sep 2023 09:40:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231367AbjIMQkj (ORCPT + 35 others); Wed, 13 Sep 2023 12:40:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230526AbjIMQjw (ORCPT ); Wed, 13 Sep 2023 12:39:52 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 34AA1212A; Wed, 13 Sep 2023 09:39:27 -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 33FD11FB; Wed, 13 Sep 2023 09:40:04 -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 3895B3F5A1; Wed, 13 Sep 2023 09:39:25 -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 17/35] ACPI: processor: Register all CPUs from acpi_processor_get_info() Date: Wed, 13 Sep 2023 16:38:05 +0000 Message-Id: <20230913163823.7880-18-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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:40:45 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776942048571154547 X-GMAIL-MSGID: 1776942048571154547 To allow ACPI to skip the call to arch_register_cpu() when the _STA value indicates the CPU can't be brought online right now, move the arch_register_cpu() call into acpi_processor_get_info(). Systems can still be booted with 'acpi=off', or not include an ACPI description at all. For these, the CPUs continue to be registered by cpu_dev_register_generic(). This moves the CPU register logic back to a subsys_initcall(), while the memory nodes will have been registered earlier. Signed-off-by: James Morse Reviewed-by: Gavin Shan --- drivers/acpi/acpi_processor.c | 13 +++++++++++++ drivers/base/cpu.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index a01e315aa16a..867782bc50b0 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -313,6 +313,19 @@ static int acpi_processor_get_info(struct acpi_device *device) cpufreq_add_device("acpi-cpufreq"); } + /* + * Register CPUs that are present. + * Use get_cpu_device() to skip duplicate CPU descriptions from + * firmware. + */ + if (!invalid_logical_cpuid(pr->id) && cpu_present(pr->id) && + !get_cpu_device(pr->id)) { + int ret = arch_register_cpu(pr->id); + + if (ret) + return ret; + } + /* * Extra Processor objects may be enumerated on MP systems with * less than the max # of CPUs. They should be ignored _iff diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index d31c936f0955..677f963e02ce 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -537,7 +537,7 @@ static void __init cpu_dev_register_generic(void) { int i, ret; - if (!IS_ENABLED(CONFIG_GENERIC_CPU_DEVICES)) + if (!IS_ENABLED(CONFIG_GENERIC_CPU_DEVICES) || !acpi_disabled) return; for_each_present_cpu(i) { From patchwork Wed Sep 13 16:38:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138962 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220890vqx; Wed, 13 Sep 2023 09:53:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJc05oW/3Kihu7tDSZavmYoRRKTiHwz7GuwwdYjESX0rA4PYGZPTQ/RirO1s3F+9CCVH7V X-Received: by 2002:a17:903:110e:b0:1c3:dbad:52d4 with SMTP id n14-20020a170903110e00b001c3dbad52d4mr3538489plh.33.1694623983420; Wed, 13 Sep 2023 09:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623983; cv=none; d=google.com; s=arc-20160816; b=VMTHmLnyX/4v9brrTQP50s9AS/coWYfu/ubyYUDXXhBsHeVECd19zgyIblR+d7b9/2 SJiXCAcpiMl9l+bO5E+pH92I2fGvZmOabgNMmahxckL71xlX4Eh80X2Yu8TTnWmSvWOO Oym/pTix9NJgJEIzqfRkvzO2GGQztcfx1DCB8r+6lyjuv+HzjFtILEDVDe2hM5kOByLP dCIlJCsMILMP11Tc9DatJNLhe/SOZdxeYLjBMTVG8/eny8mvdKkW5qkasreIZezC39xp jcwiwITc0x1VL31iWZHnkKMRwDVDPW/nZ2UqXJxvqiu3B3SbREcykFWQ55HwC9nN4qYw Iuvg== 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=3E0Skv8OD4nqXop5xgGDziuzRSHOTcHPmYQaSMdk1+U=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=h593Ms4CflALIGDWWh6jSsepa1/kp8a69dO8Vtqj+DhErJ8mn00CFFcKYEgal8o4ar XOD/2LC1le/3kxalif+3EB/B8t8Qfc2QK1eMdbBBYHydreQE4clqGXdOd3UQVg8MB7sS uCYR2A2otthGpmwc077PVWKvmfyWB3a+h+BzUUq7PC3r1FOViY6rUH2RtNuqLhMMYV7F w16RGeirYmtRKGbbQPS5dV6NqS08kNh5K7Eshlp0AqW2xNWD+cUhODqmosO+5A61Lttt L+dbH2R1Hd0Ewl8mNV+ToaJ28+JiGMlApkFmNfHDilaHu1/ItCLeaKw2kuj+XpwX3ArI Q0oA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id n13-20020a170902e54d00b001c3a390ac9bsi7777914plf.150.2023.09.13.09.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:53:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id BDD6D84E5D77; Wed, 13 Sep 2023 09:40:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230444AbjIMQkm (ORCPT + 35 others); Wed, 13 Sep 2023 12:40:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231231AbjIMQjw (ORCPT ); Wed, 13 Sep 2023 12:39:52 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 58AE72134; Wed, 13 Sep 2023 09:39:29 -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 5612CC15; Wed, 13 Sep 2023 09:40:06 -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 37C573F5A1; Wed, 13 Sep 2023 09:39:27 -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 18/35] ACPI: Rename ACPI_HOTPLUG_CPU to include 'present' Date: Wed, 13 Sep 2023 16:38:06 +0000 Message-Id: <20230913163823.7880-19-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 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:40:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776942038094824885 X-GMAIL-MSGID: 1776942038094824885 The code behind ACPI_HOTPLUG_CPU allows a not-present CPU to become present. This isn't the only use of HOTPLUG_CPU. On arm64 and riscv CPUs can be taken offline as a power saving measure. On arm64 an offline CPU may be disabled by firmware, preventing it from being brought back online, but it remains present throughout. Adding code to prevent user-space trying to online these disabled CPUs needs some additional terminology. Rename the Kconfig symbol CONFIG_ACPI_HOTPLUG_PRESENT_CPU to reflect that it makes possible CPUs present. HOTPLUG_CPU is untouched as this is only about the ACPI mechanism. Signed-off-by: James Morse --- arch/ia64/Kconfig | 2 +- arch/ia64/include/asm/acpi.h | 2 +- arch/ia64/kernel/acpi.c | 6 +++--- arch/ia64/kernel/setup.c | 2 +- arch/loongarch/configs/loongson3_defconfig | 2 +- arch/loongarch/kernel/acpi.c | 4 ++-- arch/x86/Kconfig | 2 +- arch/x86/kernel/acpi/boot.c | 4 ++-- drivers/acpi/Kconfig | 4 ++-- drivers/acpi/acpi_processor.c | 10 +++++----- include/acpi/processor.h | 2 +- include/linux/acpi.h | 6 +++--- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index a3bfd42467ab..54972f9fe804 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -16,7 +16,7 @@ config IA64 select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_MIGHT_HAVE_PC_SERIO select ACPI - select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU + select ACPI_HOTPLUG_PRESENT_CPU if ACPI_PROCESSOR && HOTPLUG_CPU select ACPI_NUMA if NUMA select ARCH_ENABLE_MEMORY_HOTPLUG select ARCH_ENABLE_MEMORY_HOTREMOVE diff --git a/arch/ia64/include/asm/acpi.h b/arch/ia64/include/asm/acpi.h index 58500a964238..482ea994d1e1 100644 --- a/arch/ia64/include/asm/acpi.h +++ b/arch/ia64/include/asm/acpi.h @@ -52,7 +52,7 @@ extern unsigned int is_cpu_cpei_target(unsigned int cpu); extern void set_cpei_target_cpu(unsigned int cpu); extern unsigned int get_cpei_target_cpu(void); extern void prefill_possible_map(void); -#ifdef CONFIG_ACPI_HOTPLUG_CPU +#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU extern int additional_cpus; #else #define additional_cpus 0 diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index 15f6cfddcc08..35881bf4b016 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c @@ -194,7 +194,7 @@ acpi_parse_plat_int_src(union acpi_subtable_headers * header, return 0; } -#ifdef CONFIG_HOTPLUG_CPU +#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU unsigned int can_cpei_retarget(void) { extern int cpe_vector; @@ -711,7 +711,7 @@ int acpi_isa_irq_to_gsi(unsigned isa_irq, u32 *gsi) /* * ACPI based hotplug CPU support */ -#ifdef CONFIG_ACPI_HOTPLUG_CPU +#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) { #ifdef CONFIG_ACPI_NUMA @@ -820,7 +820,7 @@ int acpi_unmap_cpu(int cpu) return (0); } EXPORT_SYMBOL(acpi_unmap_cpu); -#endif /* CONFIG_ACPI_HOTPLUG_CPU */ +#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ #ifdef CONFIG_ACPI_NUMA static acpi_status acpi_map_iosapic(acpi_handle handle, u32 depth, diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index 5a55ac82c13a..44591716d07b 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -569,7 +569,7 @@ setup_arch (char **cmdline_p) #ifdef CONFIG_ACPI_NUMA acpi_numa_init(); acpi_numa_fixup(); -#ifdef CONFIG_ACPI_HOTPLUG_CPU +#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU prefill_possible_map(); #endif per_cpu_scan_finalize((cpumask_empty(&early_cpu_possible_map) ? diff --git a/arch/loongarch/configs/loongson3_defconfig b/arch/loongarch/configs/loongson3_defconfig index a3b52aaa83b3..ef3bc76313e4 100644 --- a/arch/loongarch/configs/loongson3_defconfig +++ b/arch/loongarch/configs/loongson3_defconfig @@ -59,7 +59,7 @@ CONFIG_ACPI_SPCR_TABLE=y CONFIG_ACPI_TAD=y CONFIG_ACPI_DOCK=y CONFIG_ACPI_IPMI=m -CONFIG_ACPI_HOTPLUG_CPU=y +CONFIG_ACPI_HOTPLUG_PRESENT_CPU=y CONFIG_ACPI_PCI_SLOT=y CONFIG_ACPI_HOTPLUG_MEMORY=y CONFIG_EFI_ZBOOT=y diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c index 9450e09073eb..b5153e395ad9 100644 --- a/arch/loongarch/kernel/acpi.c +++ b/arch/loongarch/kernel/acpi.c @@ -289,7 +289,7 @@ void __init arch_reserve_mem_area(acpi_physical_address addr, size_t size) memblock_reserve(addr, size); } -#ifdef CONFIG_ACPI_HOTPLUG_CPU +#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU #include @@ -341,4 +341,4 @@ int acpi_unmap_cpu(int cpu) } EXPORT_SYMBOL(acpi_unmap_cpu); -#endif /* CONFIG_ACPI_HOTPLUG_CPU */ +#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 133ea5f561b5..295a7a3debb6 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -60,7 +60,7 @@ config X86 # select ACPI_LEGACY_TABLES_LOOKUP if ACPI select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI - select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU + select ACPI_HOTPLUG_PRESENT_CPU if ACPI_PROCESSOR && HOTPLUG_CPU select ARCH_32BIT_OFF_T if X86_32 select ARCH_CLOCKSOURCE_INIT select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 2a0ea38955df..84dd4133754b 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -814,7 +814,7 @@ static void __init acpi_set_irq_model_ioapic(void) /* * ACPI based hotplug support for CPU */ -#ifdef CONFIG_ACPI_HOTPLUG_CPU +#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU #include static int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) @@ -863,7 +863,7 @@ int acpi_unmap_cpu(int cpu) return (0); } EXPORT_SYMBOL(acpi_unmap_cpu); -#endif /* CONFIG_ACPI_HOTPLUG_CPU */ +#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) { diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 8456d48ba702..417f9f3077d2 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -305,7 +305,7 @@ config ACPI_IPMI To compile this driver as a module, choose M here: the module will be called as acpi_ipmi. -config ACPI_HOTPLUG_CPU +config ACPI_HOTPLUG_PRESENT_CPU bool depends on ACPI_PROCESSOR && HOTPLUG_CPU select ACPI_CONTAINER @@ -399,7 +399,7 @@ config ACPI_PCI_SLOT config ACPI_CONTAINER bool "Container and Module Devices" - default (ACPI_HOTPLUG_MEMORY || ACPI_HOTPLUG_CPU) + default (ACPI_HOTPLUG_MEMORY || ACPI_HOTPLUG_PRESENT_CPU) help This driver supports ACPI Container and Module devices (IDs ACPI0004, PNP0A05, and PNP0A06). diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 867782bc50b0..75257fae10e7 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -182,7 +182,7 @@ static void __init acpi_pcc_cpufreq_init(void) {} #endif /* CONFIG_X86 */ /* Initialization */ -#ifdef CONFIG_ACPI_HOTPLUG_CPU +#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU static int acpi_processor_hotadd_init(struct acpi_processor *pr) { unsigned long long sta; @@ -227,7 +227,7 @@ static inline int acpi_processor_hotadd_init(struct acpi_processor *pr) { return -ENODEV; } -#endif /* CONFIG_ACPI_HOTPLUG_CPU */ +#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ static int acpi_processor_get_info(struct acpi_device *device) { @@ -461,7 +461,7 @@ static int acpi_processor_add(struct acpi_device *device, return result; } -#ifdef CONFIG_ACPI_HOTPLUG_CPU +#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU /* Removal */ static void acpi_processor_remove(struct acpi_device *device) { @@ -505,7 +505,7 @@ static void acpi_processor_remove(struct acpi_device *device) free_cpumask_var(pr->throttling.shared_cpu_map); kfree(pr); } -#endif /* CONFIG_ACPI_HOTPLUG_CPU */ +#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ #ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC bool __init processor_physically_present(acpi_handle handle) @@ -630,7 +630,7 @@ static const struct acpi_device_id processor_device_ids[] = { static struct acpi_scan_handler processor_handler = { .ids = processor_device_ids, .attach = acpi_processor_add, -#ifdef CONFIG_ACPI_HOTPLUG_CPU +#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU .detach = acpi_processor_remove, #endif .hotplug = { diff --git a/include/acpi/processor.h b/include/acpi/processor.h index 94181fe9780a..fd6913370c72 100644 --- a/include/acpi/processor.h +++ b/include/acpi/processor.h @@ -465,7 +465,7 @@ extern int acpi_processor_ffh_lpi_probe(unsigned int cpu); extern int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi); #endif -#ifdef CONFIG_ACPI_HOTPLUG_CPU +#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU extern int arch_register_cpu(int cpu); extern void arch_unregister_cpu(int cpu); #endif diff --git a/include/linux/acpi.h b/include/linux/acpi.h index a73246c3c35e..651dd43976a9 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -316,12 +316,12 @@ static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, } #endif -#ifdef CONFIG_ACPI_HOTPLUG_CPU +#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_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); @@ -644,7 +644,7 @@ static inline u32 acpi_osc_ctx_get_cxl_control(struct acpi_osc_context *context) #define ACPI_GSB_ACCESS_ATTRIB_RAW_PROCESS 0x0000000F /* Enable _OST when all relevant hotplug operations are enabled */ -#if defined(CONFIG_ACPI_HOTPLUG_CPU) && \ +#if defined(CONFIG_ACPI_HOTPLUG_PRESENT_CPU) && \ defined(CONFIG_ACPI_HOTPLUG_MEMORY) && \ defined(CONFIG_ACPI_CONTAINER) #define ACPI_HOTPLUG_OST From patchwork Wed Sep 13 16:38:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138965 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1221163vqx; Wed, 13 Sep 2023 09:53:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2EA4na98+EQzcKCW5OkVZNKAgxJQCtnDrtVoba/+rw1J90kHq6v25U1DNRgh4cX/wrK+n X-Received: by 2002:a05:6a20:3ca9:b0:145:47af:57d8 with SMTP id b41-20020a056a203ca900b0014547af57d8mr3340095pzj.2.1694624008034; Wed, 13 Sep 2023 09:53:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694624008; cv=none; d=google.com; s=arc-20160816; b=AbkcNcjVrdEi/wl0YeZpal07fgxvijIEFXAF+1/nYzCqkijJhO+/Dah33a/TyDdrUU tH0CtpVqdaU3twtrxjiEHmQljO1op/X90riMZF+Cg3PDOuxmMyix19bopCq1qEwnhmgx pUxjzMmuuhFobBFmjx+I1HHpT1Ozu4/vLP/6Ohk8ZFGf7Cht1jdmfjiI2TXG6fHL06Rh dNbIXh1V/MZsNQmcXLWjpGyOlU/shOD+2K22DaHu/VaCyKc3yRjN2JWyCbiVn3YeEj5h 3u48huZyxsK1ug7cFDWlg8GF28e62wfL/Q2qh8ERfQpBsb3Gl323PdvDJ3VIH3soyJo8 y07Q== 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=de5v9x9iadiqoW4TPC6MHibmdWSAPCAr+9qf694HfNo=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=fbOM+az37aChrs8VNRFpqvf/lwJCMoy2hD6Ow9F29N6yGPiBMmnRxiMT7C5w/mx1Y8 Zz7Js4E25rv5kcW+pFnakp1177EtKMBjWuW1L5Vco5UiLfrkM7uJOaz1W/ITou0mcM9M uo3dqQcukbNFxqNaNuhdzB7Ej3HC/E0NFJvDzqS/bstXks3/0yl63wbbRfzGWU3X/SrA PlcTZYoo3PdKCyQSySj7jdKB08p4U7LsZ3tjwF44e24BRtbxewNLfzhC8pmN0aSeDRje H9XIX2LEEVt8KHiW2LyjZIeh7+C1JiYUoypbV4qrE/ov7dxh4lzdj46XYZPxbGULGvTP s7Bw== 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 bk13-20020a056a02028d00b00564f934aabasi9809073pgb.112.2023.09.13.09.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:53:28 -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 CD12381DC60E; Wed, 13 Sep 2023 09:40:52 -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 S231187AbjIMQkp (ORCPT + 35 others); Wed, 13 Sep 2023 12:40:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230398AbjIMQjx (ORCPT ); Wed, 13 Sep 2023 12:39:53 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 53D51213D; Wed, 13 Sep 2023 09:39:31 -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 54724FEC; Wed, 13 Sep 2023 09:40:08 -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 596EB3F5A1; Wed, 13 Sep 2023 09:39:29 -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 19/35] ACPI: Move acpi_bus_trim_one() before acpi_scan_hot_remove() Date: Wed, 13 Sep 2023 16:38:07 +0000 Message-Id: <20230913163823.7880-20-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:52 -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: 1776942063879250124 X-GMAIL-MSGID: 1776942063879250124 A subsequent patch will change acpi_scan_hot_remove() to call acpi_bus_trim_one() instead of acpi_bus_trim(), meaning it can no longer rely on the prototype in the header file. Move these functions further up the file. No change in behaviour. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan --- drivers/acpi/scan.c | 76 ++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index f898591ce05f..a675333618ae 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -244,6 +244,44 @@ static int acpi_scan_try_to_offline(struct acpi_device *device) return 0; } +static int acpi_bus_trim_one(struct acpi_device *adev, void *not_used) +{ + struct acpi_scan_handler *handler = adev->handler; + + acpi_dev_for_each_child_reverse(adev, acpi_bus_trim_one, NULL); + + adev->flags.match_driver = false; + if (handler) { + if (handler->detach) + handler->detach(adev); + + adev->handler = NULL; + } else { + device_release_driver(&adev->dev); + } + /* + * Most likely, the device is going away, so put it into D3cold before + * that. + */ + acpi_device_set_power(adev, ACPI_STATE_D3_COLD); + adev->flags.initialized = false; + acpi_device_clear_enumerated(adev); + + return 0; +} + +/** + * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects. + * @adev: Root of the ACPI namespace scope to walk. + * + * Must be called under acpi_scan_lock. + */ +void acpi_bus_trim(struct acpi_device *adev) +{ + acpi_bus_trim_one(adev, NULL); +} +EXPORT_SYMBOL_GPL(acpi_bus_trim); + static int acpi_scan_hot_remove(struct acpi_device *device) { acpi_handle handle = device->handle; @@ -2506,44 +2544,6 @@ int acpi_bus_scan(acpi_handle handle) } EXPORT_SYMBOL(acpi_bus_scan); -static int acpi_bus_trim_one(struct acpi_device *adev, void *not_used) -{ - struct acpi_scan_handler *handler = adev->handler; - - acpi_dev_for_each_child_reverse(adev, acpi_bus_trim_one, NULL); - - adev->flags.match_driver = false; - if (handler) { - if (handler->detach) - handler->detach(adev); - - adev->handler = NULL; - } else { - device_release_driver(&adev->dev); - } - /* - * Most likely, the device is going away, so put it into D3cold before - * that. - */ - acpi_device_set_power(adev, ACPI_STATE_D3_COLD); - adev->flags.initialized = false; - acpi_device_clear_enumerated(adev); - - return 0; -} - -/** - * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects. - * @adev: Root of the ACPI namespace scope to walk. - * - * Must be called under acpi_scan_lock. - */ -void acpi_bus_trim(struct acpi_device *adev) -{ - acpi_bus_trim_one(adev, NULL); -} -EXPORT_SYMBOL_GPL(acpi_bus_trim); - int acpi_bus_register_early_device(int type) { struct acpi_device *device = NULL; From patchwork Wed Sep 13 16:38:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138944 Return-Path: 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 + 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 ); 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 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 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 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 (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 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 --- 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); -#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); From patchwork Wed Sep 13 16:38:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138955 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220640vqx; Wed, 13 Sep 2023 09:52:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgJ/sp4CcOqOt/UKJJ6gU4I3/digrS27mX4Mm+mqIT2LWrhoOERSDlZ/7/sVgSxWAhB63h X-Received: by 2002:a05:6359:620b:b0:140:f08b:4f35 with SMTP id sc11-20020a056359620b00b00140f08b4f35mr2553742rwb.21.1694623956262; Wed, 13 Sep 2023 09:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623956; cv=none; d=google.com; s=arc-20160816; b=L4u/US1gibZdST5bKbYKFQjf6AknmAIVw4Reg5emyQXqRCjbhvbHyikDH/lF7SX/8P r1G8tkRyJuPbSy3AiyN1Y9B3RR2QRIBcJgE5/iKz9Yuo+rfnib3O3/abgT1rjQiRv4oO ayGP/7ow5gEGBq2EpgXwxDx97L896G5bMV0UxunkEcDUPkpS7kZohi6g59JrFD/38SJu IFBeYYZFtVTcEXY9Zo3vbZ21UslFY90TLv5APXduh7k5/Za2abAPJ6SEQCW60pmgLwpj 6EfrUDzUOf4mPHs1HbiToykA+HlPID4UF6goXMICXC//h+1tt6AydFCR7r78xoHijuoM e72w== 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=dy6yToBw26UXWWsvMKGxgNo8n8OUi0/8ZpFNco1yzUs=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=PC98RDgG9qtbzt808zSmhM/spsTfDlohlQ8VQOBgme8faBnU2uKHZuxKVopyw+LTiR UvvPaom9W5QUCVlkfdBPphjN4WNHjJ/UFrNui+Ul+Arf4k1eQHPgHa4TONzVjS46SGIR 6uMGWHjNvvOLF3e8YZhryA0SbHJ2wOfUpFovhvuvrn99skTyZX49wXg0xCGl6/lk9mXo wvxf/hsLJB5oJVBycOBvzkN8EfzTrh/CFv54A7TB+8tOHuHgXVmsfNN8pRv3KvjE5OV5 DNufnkaXCe9zCjCpbFA76y3YPKjJYDD3LvL9TCB0SUGztXqt+uXCn/O02n1mLhuo+Era MK7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id s13-20020a632c0d000000b0056679c8e70csi2148882pgs.272.2023.09.13.09.52.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:52:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 2EAD581142DC; Wed, 13 Sep 2023 09:41:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231274AbjIMQlE (ORCPT + 35 others); Wed, 13 Sep 2023 12:41:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231266AbjIMQj5 (ORCPT ); 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 827F61BE1; Wed, 13 Sep 2023 09:39:35 -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 758D8C15; Wed, 13 Sep 2023 09:40:12 -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 6006F3F5A1; Wed, 13 Sep 2023 09:39:33 -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 21/35] ACPI: Add post_eject to struct acpi_scan_handler for cpu hotplug Date: Wed, 13 Sep 2023 16:38:09 +0000 Message-Id: <20230913163823.7880-22-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 (groat.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:41:14 -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 groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776942009296277969 X-GMAIL-MSGID: 1776942009296277969 struct acpi_scan_handler has a detach callback that is used to remove a driver when a bus is changed. When interacting with an eject-request, the detach callback is called before _EJ0. This means the ACPI processor driver can't use _STA to determine if a CPU has been made not-present, or some of the other _STA bits have been changed. acpi_processor_remove() needs to know the value of _STA after _EJ0 has been called. Add a post_eject callback to struct acpi_scan_handler. This is called after acpi_scan_hot_remove() has successfully called _EJ0. Because acpi_bus_trim_one() also clears the handler pointer, it needs to be told if the caller will go on to call acpi_bus_post_eject(), so that acpi_device_clear_enumerated() and clearing the handler pointer can be deferred. The existing not-used pointer is used for this. Signed-off-by: James Morse Reviewed-by: Joanthan Cameron Reviewed-by: Gavin Shan --- drivers/acpi/acpi_processor.c | 4 +-- drivers/acpi/scan.c | 52 ++++++++++++++++++++++++++++++----- include/acpi/acpi_bus.h | 1 + 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 22a15a614f95..00dcc23d49a8 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -459,7 +459,7 @@ static int acpi_processor_add(struct acpi_device *device, #ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU /* Removal */ -static void acpi_processor_remove(struct acpi_device *device) +static void acpi_processor_post_eject(struct acpi_device *device) { struct acpi_processor *pr; @@ -627,7 +627,7 @@ static struct acpi_scan_handler processor_handler = { .ids = processor_device_ids, .attach = acpi_processor_add, #ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU - .detach = acpi_processor_remove, + .post_eject = acpi_processor_post_eject, #endif .hotplug = { .enabled = true, diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index a675333618ae..b6d2f01640a9 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -244,18 +244,28 @@ static int acpi_scan_try_to_offline(struct acpi_device *device) return 0; } -static int acpi_bus_trim_one(struct acpi_device *adev, void *not_used) +/** + * acpi_bus_trim_one() - Detach scan handlers and drivers from ACPI device + * objects. + * @adev: Root of the ACPI namespace scope to walk. + * @eject: Pointer to a bool that indicates if this was due to an + * eject-request. + * + * Must be called under acpi_scan_lock. + * If @eject points to true, clearing the device enumeration is deferred until + * acpi_bus_post_eject() is called. + */ +static int acpi_bus_trim_one(struct acpi_device *adev, void *eject) { struct acpi_scan_handler *handler = adev->handler; + bool is_eject = *(bool *)eject; - acpi_dev_for_each_child_reverse(adev, acpi_bus_trim_one, NULL); + acpi_dev_for_each_child_reverse(adev, acpi_bus_trim_one, eject); adev->flags.match_driver = false; if (handler) { if (handler->detach) handler->detach(adev); - - adev->handler = NULL; } else { device_release_driver(&adev->dev); } @@ -265,7 +275,12 @@ static int acpi_bus_trim_one(struct acpi_device *adev, void *not_used) */ acpi_device_set_power(adev, ACPI_STATE_D3_COLD); adev->flags.initialized = false; - acpi_device_clear_enumerated(adev); + + /* For eject this is deferred to acpi_bus_post_eject() */ + if (!is_eject) { + adev->handler = NULL; + acpi_device_clear_enumerated(adev); + } return 0; } @@ -278,15 +293,36 @@ static int acpi_bus_trim_one(struct acpi_device *adev, void *not_used) */ void acpi_bus_trim(struct acpi_device *adev) { - acpi_bus_trim_one(adev, NULL); + bool eject = false; + + acpi_bus_trim_one(adev, &eject); } EXPORT_SYMBOL_GPL(acpi_bus_trim); +static int acpi_bus_post_eject(struct acpi_device *adev, void *not_used) +{ + struct acpi_scan_handler *handler = adev->handler; + + acpi_dev_for_each_child_reverse(adev, acpi_bus_post_eject, NULL); + + if (handler) { + if (handler->post_eject) + handler->post_eject(adev); + + adev->handler = NULL; + } + + acpi_device_clear_enumerated(adev); + + return 0; +} + static int acpi_scan_hot_remove(struct acpi_device *device) { acpi_handle handle = device->handle; unsigned long long sta; acpi_status status; + bool eject = true; if (device->handler && device->handler->hotplug.demand_offline) { if (!acpi_scan_is_offline(device, true)) @@ -299,7 +335,7 @@ static int acpi_scan_hot_remove(struct acpi_device *device) acpi_handle_debug(handle, "Ejecting\n"); - acpi_bus_trim(device); + acpi_bus_trim_one(device, &eject); acpi_evaluate_lck(handle, 0); /* @@ -322,6 +358,8 @@ static int acpi_scan_hot_remove(struct acpi_device *device) } else if (sta & ACPI_STA_DEVICE_ENABLED) { acpi_handle_warn(handle, "Eject incomplete - status 0x%llx\n", sta); + } else { + acpi_bus_post_eject(device, NULL); } return 0; diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 254685085c82..1b7e1acf925b 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -127,6 +127,7 @@ struct acpi_scan_handler { bool (*match)(const char *idstr, const struct acpi_device_id **matchid); int (*attach)(struct acpi_device *dev, const struct acpi_device_id *id); void (*detach)(struct acpi_device *dev); + void (*post_eject)(struct acpi_device *dev); void (*bind)(struct device *phys_dev); void (*unbind)(struct device *phys_dev); struct acpi_hotplug_profile hotplug; From patchwork Wed Sep 13 16:38:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138946 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1219652vqx; Wed, 13 Sep 2023 09:50:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHMcTQe+lOv9OI4Tg6AUnSQNCsAb4w8GjaLevDpX0yAaJOtRSWx0Be+YR28yNXMfw4MNgut X-Received: by 2002:a17:902:7892:b0:1c0:e6e1:4a11 with SMTP id q18-20020a170902789200b001c0e6e14a11mr2798480pll.54.1694623856249; Wed, 13 Sep 2023 09:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623856; cv=none; d=google.com; s=arc-20160816; b=KJWfSTHWFzHK5REqv8fPn3MlfH4sLk475YtEYjkoI0klpj2tkYuZSjxC3yCOEHKzm4 d/Ba4DbknHDLCbGVjSJ/3qRkMMHWpTpznxlmgKEi/BmjbpKwMZ32NoIQTfsO/u20Dg/9 XVHzHKbPPwhJaTMJ/H1KZYiTGLMZBGTfipcHdy4Yqg8bYckQ1eT59SsHJYDDhgQMIuLp tW1f/AJ6bFDiM5G3lX5XtbUc7Nr8j8VI6zD01pbbt/X2gHDGb0SSgvcip1m7dSi8tFCS SAOSvf6SEHLio9pF5teWxdV8QhQmAyPqMZktVPk1XrJjZQz8AOqpomCVySYSrYwIYhRc wcmA== 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=D7Fwj9qY3mLo8YgU5ROdUqQwH6WDt9GRbLRoKtLliQ8=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=zOuw0mB9v9hgwud0WtK3AYofCv0jSj32a1JCB79BqvrgBXSMdEmpbU2DSC5OaOvXzd sysJzuHc2Mmusvv1KcrlGEfiajC3kDRSKhIg5SeH54WpDE7xVoR9vxDGi88d4sufa3IN csWvi0cEQJmdXXKmyMgGzsaAho+M+53vXRsTg3Jt/ormpRDG1xRyf/yitgpm5FSCdhuu P2RO2urmmuARY8GGxEnP5MmMeoSx7iuhz0VzYe5xp5IA+y2hpWiPzOzavXyPwehaEIof iGhO3QAXOJMKN49jiXcAAxgqk9Y6uDMQVX4hhsS2g/5GWP/K2mfALTYLPRZZtM9tIbl2 7sZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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. [23.128.96.36]) by mx.google.com with ESMTPS id m10-20020a170902c44a00b001bba8f79ad0si10024172plm.109.2023.09.13.09.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:50:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 B52A980BC3FA; Wed, 13 Sep 2023 09:42:53 -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 S230515AbjIMQlH (ORCPT + 35 others); Wed, 13 Sep 2023 12:41:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231127AbjIMQj7 (ORCPT ); Wed, 13 Sep 2023 12:39:59 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 657731BEC; Wed, 13 Sep 2023 09:39:37 -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 5B6AA1FB; Wed, 13 Sep 2023 09:40:14 -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 60F763F5A1; Wed, 13 Sep 2023 09:39:35 -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 22/35] ACPI: Check _STA present bit before making CPUs not present Date: Wed, 13 Sep 2023 16:38:10 +0000 Message-Id: <20230913163823.7880-23-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 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:42:53 -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: 1776941904794347179 X-GMAIL-MSGID: 1776941904794347179 When called acpi_processor_post_eject() unconditionally make a CPU not-present and unregisters it. To add support for AML events where the CPU has become disabled, but remains present, the _STA method should be checked before calling acpi_processor_remove(). Rename acpi_processor_post_eject() acpi_processor_remove_possible(), and check the _STA before calling. Adding the function prototype for arch_unregister_cpu() allows the preprocessor guards to be removed. After this change CPUs will remain registered and visible to user-space as offline if buggy firmware triggers an eject-request, but doesn't clear the corresponding _STA bits after _EJ0 has been called. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron --- drivers/acpi/acpi_processor.c | 31 +++++++++++++++++++++++++------ include/linux/cpu.h | 1 + 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 00dcc23d49a8..2cafea1edc24 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -457,13 +457,12 @@ static int acpi_processor_add(struct acpi_device *device, return result; } -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU /* Removal */ -static void acpi_processor_post_eject(struct acpi_device *device) +static void acpi_processor_make_not_present(struct acpi_device *device) { struct acpi_processor *pr; - if (!device || !acpi_driver_data(device)) + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) return; pr = acpi_driver_data(device); @@ -501,7 +500,29 @@ static void acpi_processor_post_eject(struct acpi_device *device) free_cpumask_var(pr->throttling.shared_cpu_map); kfree(pr); } -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ + +static void acpi_processor_post_eject(struct acpi_device *device) +{ + struct acpi_processor *pr; + unsigned long long sta; + acpi_status status; + + if (!device) + return; + + pr = acpi_driver_data(device); + if (!pr || pr->id >= nr_cpu_ids || invalid_phys_cpuid(pr->phys_id)) + return; + + status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); + if (ACPI_FAILURE(status)) + return; + + if (cpu_present(pr->id) && !(sta & ACPI_STA_DEVICE_PRESENT)) { + acpi_processor_make_not_present(device); + return; + } +} #ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC bool __init processor_physically_present(acpi_handle handle) @@ -626,9 +647,7 @@ static const struct acpi_device_id processor_device_ids[] = { static struct acpi_scan_handler processor_handler = { .ids = processor_device_ids, .attach = acpi_processor_add, -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU .post_eject = acpi_processor_post_eject, -#endif .hotplug = { .enabled = true, }, diff --git a/include/linux/cpu.h b/include/linux/cpu.h index a71691d7c2ca..e117c06e0c6b 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -81,6 +81,7 @@ struct device *cpu_device_create(struct device *parent, void *drvdata, const struct attribute_group **groups, const char *fmt, ...); extern int arch_register_cpu(int cpu); +extern void arch_unregister_cpu(int cpu); #ifdef CONFIG_HOTPLUG_CPU extern void unregister_cpu(struct cpu *cpu); extern ssize_t arch_cpu_probe(const char *, size_t); From patchwork Wed Sep 13 16:38:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138947 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1219671vqx; Wed, 13 Sep 2023 09:50:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG9LInzwEXNKN33XILRklqKJrNkMgG5T0aOD02A5dRVD/E5Nfbua+ZfGA9HWv68+nUIS++3 X-Received: by 2002:a05:6a20:9190:b0:153:63b9:8bf9 with SMTP id v16-20020a056a20919000b0015363b98bf9mr3307296pzd.0.1694623858102; Wed, 13 Sep 2023 09:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623858; cv=none; d=google.com; s=arc-20160816; b=xU5C8x137vp5RLP+RH0HJwWJ2uDQ5JK0elvj1zcj0okzsKHEvpQjRoH982aEXBk3XM X8cBfQkkg4l+fd/BhnTRBGvp1kBXPgNJ++XHPzQxgrRGcf0nHjuRFGBROPrwb03IcaPt p6ODE+sp8VoGNsTRdVaCsdlVEafEGVEnQ6/Ni0b8LWwFy8k+n73V/nsqDiaJc+fHw2Re Pnjv2sS4RqFFjXk4C1QrE0nmcT9K4IZW2hHBlh1bAv/y5za+Wtlo+fgbtMaaFUW1NnNt xOy2IrYYijaFMT4J5FjJS4cpgWYhEfsYkA39ZkDNPStyEguP5exr5LKBbXSE1bBm4MfX q/Gg== 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=8b9OKbbi306y0VODM5Qwet8D0FL/dH8H7cuVvxAuP1g=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=TiV8sskNlscJFlbDuS44kEL5R8SaJ9ewDrfaPvscfrtGh+68sQi9Q7dXBGWd3cNtpI /3834UPiIe8v4Gawxz2IfvO5Pw0emtTEpAaZKujweULETi3kZpXqQn8mERiq2RXm6IJK Jd+zG1it1zNLWctrT31bwr3laeColrxOHYePXeqfPdtxOEcsAa4dsfoQllcMK6+75z2l N0d6aS2sOy28z9bbDF585OGUh7Ovc25J1PZcrS7kSSpXEj+v85/SOdTdHYA+wpCHgWQ0 a4D25Udrwp19EX1ZZ9iR1O6Nnt0csr5PAaqdrDEzhIz7H6ucAn1rd2zpho+w6MwNWLwe fpeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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. [23.128.96.36]) by mx.google.com with ESMTPS id h188-20020a636cc5000000b00565403bf2d2si10438472pgc.645.2023.09.13.09.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:50:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 329ED80763E8; Wed, 13 Sep 2023 09:42:21 -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 S230451AbjIMQlV (ORCPT + 35 others); Wed, 13 Sep 2023 12:41:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230437AbjIMQkO (ORCPT ); Wed, 13 Sep 2023 12:40:14 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7F2B126A4; Wed, 13 Sep 2023 09:39:39 -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 59BDAFEC; Wed, 13 Sep 2023 09:40:16 -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 5ED3D3F5A1; Wed, 13 Sep 2023 09:39:37 -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 23/35] ACPI: Warn when the present bit changes but the feature is not enabled Date: Wed, 13 Sep 2023 16:38:11 +0000 Message-Id: <20230913163823.7880-24-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 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:42:21 -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: 1776941906645571292 X-GMAIL-MSGID: 1776941906645571292 ACPI firmware can trigger the events to add and remove CPUs, but the OS may not support this. Print a warning when this happens. This gives early warning on arm64 systems that don't support CONFIG_ACPI_HOTPLUG_PRESENT_CPU, as making CPUs not present has side effects for other parts of the system. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan --- drivers/acpi/acpi_processor.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 2cafea1edc24..b67616079751 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -188,8 +188,10 @@ static int acpi_processor_make_present(struct acpi_processor *pr) acpi_status status; int ret; - if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) { + pr_err_once("Changing CPU present bit is not supported\n"); return -ENODEV; + } if (invalid_phys_cpuid(pr->phys_id)) return -ENODEV; @@ -462,8 +464,10 @@ static void acpi_processor_make_not_present(struct acpi_device *device) { struct acpi_processor *pr; - if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) { + pr_err_once("Changing CPU present bit is not supported"); return; + } pr = acpi_driver_data(device); if (pr->id >= nr_cpu_ids) From patchwork Wed Sep 13 16:38:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1214081vqx; Wed, 13 Sep 2023 09:41:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJ3X6Max+jxeqHjEBQtJ2/6o6ozZjmJ6mp1OLl3mDkJ1k99W820uvoh2n6dTXhhXE1jy8K X-Received: by 2002:a05:6a00:1819:b0:68f:d554:a299 with SMTP id y25-20020a056a00181900b0068fd554a299mr3785026pfa.10.1694623303284; Wed, 13 Sep 2023 09:41:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623303; cv=none; d=google.com; s=arc-20160816; b=npf/JJur6OmHN6j9CxQbHRhwrl9N6vTS/CGQVN+zyOQ/T1mdEc3qY3nfMp8YmDGYIU 1tfn7TJRoYOKNmxRN1r9Vnsmc/KaKA5sCkR0HGHt4ki4utRpG8QwGZTr9VD+Em9vv1EU eozFQC0rF8YDvG8G3bXxccJUgrX6cvNntGpvYQXp7SxKC9BpspitPfIbiMnwj/4hruz6 oZLl8lL1QTnKv/Xhj+hnSK4KUcx+Di5etf0RV9vSCJZkGauCq+yQrSQOeXLLivhmAI22 2IkRwMyOBDdEkK2lXzt3CiLQP9NjQGZFK5gMNoUdI1fNma6kMIjDy1IAjJELDZ431ips d8Fw== 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=5XUwq6cWSioemH6X3uwmt5P5O1VCxxq8pzs8XEfSEik=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=uVOa5fhHytjXgGHjTt9VsLzr+qCGI85IprzneqEdRPxcan+YNTmu4chhdJn084S2kB TyNOBl9Bedg09q+yoP0ui4UVxI2EluhWWktlM7tyLdsmGNiR+9EYDITzbv6M49a+fkfv C5OfIhwacDfqsOZGk3kHE3VY91gnASWztyONvBi66l21c8d/uSgh/vytakAKahRdSn5q EXY5xlB3y6D8KkW7hB18fyfZNaoIkcwNrNit3YMZ03M4NLUFZ98ZGfAL+7/cjpBzmd7t eOC79H74R6Zqu7MvAKU8i6za1Ti7D0VZ6B+2ifbjuSuc/f1pwXadeTrlfbkoIkQB6+9r o2wA== 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:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id cg19-20020a056a00291300b0068e35157c22si10359474pfb.119.2023.09.13.09.41.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:41:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 3DBAC81ECCED; Wed, 13 Sep 2023 09:41:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231230AbjIMQl0 (ORCPT + 35 others); Wed, 13 Sep 2023 12:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbjIMQka (ORCPT ); Wed, 13 Sep 2023 12:40:30 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 78EA226B3; Wed, 13 Sep 2023 09:39:41 -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 586F01007; Wed, 13 Sep 2023 09:40:18 -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 5DDC13F5A1; Wed, 13 Sep 2023 09:39:39 -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 24/35] drivers: base: Implement weak arch_unregister_cpu() Date: Wed, 13 Sep 2023 16:38:12 +0000 Message-Id: <20230913163823.7880-25-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 (agentk.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:41:38 -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 agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941324841205683 X-GMAIL-MSGID: 1776941324841205683 Add arch_unregister_cpu() to allow the ACPI machinery to call unregister_cpu(). This is enough for arm64, riscv and loongarch, but needs to be overridden by x86 and ia64 who need to do more work. CC: Jean-Philippe Brucker Signed-off-by: James Morse Reviewed-by: Jonathan Cameron --- Changes since v1: * Added CONFIG_HOTPLUG_CPU ifdeffery around unregister_cpu --- arch/ia64/include/asm/cpu.h | 4 ---- arch/loongarch/include/asm/cpu.h | 6 ------ arch/x86/include/asm/cpu.h | 1 - drivers/base/cpu.c | 9 ++++++++- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/arch/ia64/include/asm/cpu.h b/arch/ia64/include/asm/cpu.h index a3e690e685e5..642d71675ddb 100644 --- a/arch/ia64/include/asm/cpu.h +++ b/arch/ia64/include/asm/cpu.h @@ -15,8 +15,4 @@ DECLARE_PER_CPU(struct ia64_cpu, cpu_devices); DECLARE_PER_CPU(int, cpu_state); -#ifdef CONFIG_HOTPLUG_CPU -extern void arch_unregister_cpu(int); -#endif - #endif /* _ASM_IA64_CPU_H_ */ diff --git a/arch/loongarch/include/asm/cpu.h b/arch/loongarch/include/asm/cpu.h index b8568e637420..48b9f7168bcc 100644 --- a/arch/loongarch/include/asm/cpu.h +++ b/arch/loongarch/include/asm/cpu.h @@ -128,10 +128,4 @@ enum cpu_type_enum { #define LOONGARCH_CPU_HYPERVISOR BIT_ULL(CPU_FEATURE_HYPERVISOR) #define LOONGARCH_CPU_PTW BIT_ULL(CPU_FEATURE_PTW) -#if !defined(__ASSEMBLY__) -#ifdef CONFIG_HOTPLUG_CPU -void arch_unregister_cpu(int cpu); -#endif -#endif /* ! __ASSEMBLY__ */ - #endif /* _ASM_CPU_H */ diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index f349c94510e8..91867a6a9f8e 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h @@ -24,7 +24,6 @@ static inline void prefill_possible_map(void) {} #endif /* CONFIG_SMP */ #ifdef CONFIG_HOTPLUG_CPU -extern void arch_unregister_cpu(int); extern void soft_restart_cpu(void); #endif diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 677f963e02ce..c709747c4a18 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -531,7 +531,14 @@ int __weak arch_register_cpu(int cpu) { return register_cpu(&per_cpu(cpu_devices, cpu), cpu); } -#endif + +#ifdef CONFIG_HOTPLUG_CPU +void __weak arch_unregister_cpu(int num) +{ + unregister_cpu(&per_cpu(cpu_devices, num)); +} +#endif /* CONFIG_HOTPLUG_CPU */ +#endif /* CONFIG_GENERIC_CPU_DEVICES */ static void __init cpu_dev_register_generic(void) { From patchwork Wed Sep 13 16:38:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138940 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1216385vqx; Wed, 13 Sep 2023 09:45:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3HirM+AeonT0GFT0ptZ5+c9P4HVbOvWcfBoVLcbOr/kHudnkwclKEhLDv5jVud2WV4xwW X-Received: by 2002:a05:6358:99a0:b0:135:acfd:8786 with SMTP id j32-20020a05635899a000b00135acfd8786mr3448630rwb.3.1694623526161; Wed, 13 Sep 2023 09:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623526; cv=none; d=google.com; s=arc-20160816; b=SeQVPr/P5ZrzXzaJTw87a5inSYqKLp1m+kyfuwi9TZOLBBzW+OCXz8yZa4q9lIk2zf Vr9iPW2wGXwWuIkdsFXg6GfRNH+5czsqCRxAymeCkXlLa9JQj+F4x/yjyt+VbE8hH+ss slU7bIKkMjFwedqnPsAXakIW2hQfJB9aJkdj7bS3qoQTnb487NABVWcm57VVDjg+8Q1F vOWIhKIHV9XKQbyJKGmGFdQbcivrsy7AS0m4r1WSNsTHKS0tRFwWCJYeqO2M6RRmRCOy RH/OytGiygOLh8y4E1MSId4A7TEeANaoRT8tMmPdfpfe/Qf4GBUankscCY4Bwrp0SF4r K1ag== 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=p0QGy4Oj5aMzY+SoJ+ZbElJmr1QMj/WdF5qjVHzyVcI=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=F/de04Ha0MT0kqFfoqEfOTy6khwwzVrv63an0LQJgjUMA6CRIWX71LXiA0EWcE1dNa wTBm5adyXlwobjI30yuj34wAHgQ9JDcaTSfrJneCHQGAN0nfkUMbXaXxpmOU084Xx3w1 ORJdVonvkmx6T+shKh4k1iB00fGCpt91XRqReiWtvhsI+9rc6pN5GXMY4wOZB7ipAGPu IZx+Oo72mDCvPhTCEOrCkhqlm3DdEBo7d/79jK//NEdgj0GP8r5Rf4FkzH45rgOsKKDD 1Q9g5UqGINPdK5ziiq5+OyOaVx2jtV+G9Q4TZJVMLkwvGsd7w8YEDc4JO4JtD+3W3iix 2zuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id v202-20020a6361d3000000b0057777451a91si5871004pgb.581.2023.09.13.09.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:45:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 8AD4F827D0F2; Wed, 13 Sep 2023 09:41:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231222AbjIMQlX (ORCPT + 35 others); Wed, 13 Sep 2023 12:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbjIMQki (ORCPT ); Wed, 13 Sep 2023 12:40:38 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 76661270B; Wed, 13 Sep 2023 09:39:43 -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 6EFCDC15; Wed, 13 Sep 2023 09:40:20 -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 5C0403F5A1; Wed, 13 Sep 2023 09:39:41 -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 25/35] LoongArch: Use the __weak version of arch_unregister_cpu() Date: Wed, 13 Sep 2023 16:38:13 +0000 Message-Id: <20230913163823.7880-26-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 (morse.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:41:27 -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 morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941558694031470 X-GMAIL-MSGID: 1776941558694031470 LoongArch provides its own arch_unregister_cpu(). This clears the hotpluggable flag, then unregisters the CPU. It isn't necessary to clear the hotpluggable flag when unregistering a cpu. unregister_cpu() writes NULL to the percpu cpu_sys_devices pointer, meaning cpu_is_hotpluggable() will return false, as get_cpu_device() has returned NULL. Remove arch_unregister_cpu() and use the __weak version. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan --- arch/loongarch/kernel/topology.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/arch/loongarch/kernel/topology.c b/arch/loongarch/kernel/topology.c index 8e4441c1ff39..5a75e2cc0848 100644 --- a/arch/loongarch/kernel/topology.c +++ b/arch/loongarch/kernel/topology.c @@ -16,13 +16,4 @@ int arch_register_cpu(int cpu) return register_cpu(c, cpu); } EXPORT_SYMBOL(arch_register_cpu); - -void arch_unregister_cpu(int cpu) -{ - struct cpu *c = &per_cpu(cpu_devices, cpu); - - c->hotpluggable = 0; - unregister_cpu(c); -} -EXPORT_SYMBOL(arch_unregister_cpu); #endif From patchwork Wed Sep 13 16:38:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138942 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1216533vqx; Wed, 13 Sep 2023 09:45:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1wYQKONIrfmzhzskGjz6xkjxm+8eBxHfWzlqWY8TvSEqXjJso6pcLdzUqo58A/CjiRo0k X-Received: by 2002:a17:902:eb46:b0:1bd:d15f:bdfa with SMTP id i6-20020a170902eb4600b001bdd15fbdfamr3163662pli.68.1694623537917; Wed, 13 Sep 2023 09:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623537; cv=none; d=google.com; s=arc-20160816; b=hOeJ0tAVtqVxTAHa/V4hXv8gIKpTaqdrmke4i30Vgi9vcGcOv8EsdPXu330ogQVjI5 F69UodllLbZOqTOialCd6VGsjQdZr40i5bX6MTC/nlRTjJgc0rK3SNXdW2yOr+6Rjc6e cUykzdsV9j7U8j/ewFxsb6+rfptFtTw1pQrtaohH3rdJwWSzuoAWw8SbVbx7FP9dSW0b aZgFOHRMhyCALos+gPUslr3187xM6LUtdHDKEj5UFyGCEzqjqnJzLqV4qe8RoBMw5MW9 XZPcKI1E7gqyDTExcAwOobcdqKs0bwpXHBCWYAvrYxhb0RH+tQ87fua1ipyNmb5DB6xJ O5Eg== 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=KLugWriGX6zqaFgxpxKzTY3Tax57oIOyzp2E96kFWQ4=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=sWOAGAVrAEjfJBpJqAm7hqItQ+xAiY/fQlK6aRSjvYxMZLvERuDgPUPSw1C/Htbhg0 AeSFUahUNFWwZr5KD0PpWwT728IknXwp5RBeMpDsrZlTwNTiE6FPZtHMKOJSBW5zknQ3 S/O95I4TxIcf1Nlli4ClwqTlPFrL3Jz9h5RKpayZvPhHqpDHsa7jvMxt4Nk6PmzbeFGk nyn2gxwLMdnNdVYSxc0PT2kYHk6P2W00HIFlf/2jFQI8PZNodbq1VH8wGUVECRx+P7uS X2vZl8y8oOsrAbFQW8DEbu+1EtWfhpGMTgnFSyS4geJMjE7AEA2qxMi2KTWxwSMJ/qNR L4sw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ku3-20020a170903288300b001bbb8a61d3dsi10165386plb.562.2023.09.13.09.45.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:45:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 87ACC826EDB4; Wed, 13 Sep 2023 09:41:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231241AbjIMQl2 (ORCPT + 35 others); Wed, 13 Sep 2023 12:41:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231343AbjIMQki (ORCPT ); Wed, 13 Sep 2023 12:40:38 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 76A151FC2; Wed, 13 Sep 2023 09:39:45 -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 54D001FB; Wed, 13 Sep 2023 09:40:22 -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 5A1BB3F5A1; Wed, 13 Sep 2023 09:39:43 -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 26/35] arm64: acpi: Move get_cpu_for_acpi_id() to a header Date: Wed, 13 Sep 2023 16:38:14 +0000 Message-Id: <20230913163823.7880-27-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 (morse.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:41:44 -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 morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941570955236380 X-GMAIL-MSGID: 1776941570955236380 ACPI identifies CPUs by UID. get_cpu_for_acpi_id() maps the ACPI UID to the linux CPU number. The helper to retrieve this mapping is only available in arm64's numa code. Move it to live next to get_acpi_id_for_cpu(). Signed-off-by: James Morse Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan --- arch/arm64/include/asm/acpi.h | 11 +++++++++++ arch/arm64/kernel/acpi_numa.c | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index 4d537d56eb84..ce5045038e87 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -100,6 +100,17 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu) return acpi_cpu_get_madt_gicc(cpu)->uid; } +static inline int get_cpu_for_acpi_id(u32 uid) +{ + int cpu; + + for (cpu = 0; cpu < nr_cpu_ids; cpu++) + if (uid == get_acpi_id_for_cpu(cpu)) + return cpu; + + return -EINVAL; +} + static inline void arch_fix_phys_package_id(int num, u32 slot) { } void __init acpi_init_cpus(void); int apei_claim_sea(struct pt_regs *regs); diff --git a/arch/arm64/kernel/acpi_numa.c b/arch/arm64/kernel/acpi_numa.c index e51535a5f939..0c036a9a3c33 100644 --- a/arch/arm64/kernel/acpi_numa.c +++ b/arch/arm64/kernel/acpi_numa.c @@ -34,17 +34,6 @@ int __init acpi_numa_get_nid(unsigned int cpu) return acpi_early_node_map[cpu]; } -static inline int get_cpu_for_acpi_id(u32 uid) -{ - int cpu; - - for (cpu = 0; cpu < nr_cpu_ids; cpu++) - if (uid == get_acpi_id_for_cpu(cpu)) - return cpu; - - return -EINVAL; -} - static int __init acpi_parse_gicc_pxm(union acpi_subtable_headers *header, const unsigned long end) { From patchwork Wed Sep 13 16:38:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138959 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220781vqx; Wed, 13 Sep 2023 09:52:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2ePGgJmYhL3blS1NqSIGyp0jnTeZi39Zi1yZ7horpJHLI8b7G6SYu9OjtOUocF9xXEcbh X-Received: by 2002:a05:6870:ac1f:b0:1bf:16f7:c901 with SMTP id kw31-20020a056870ac1f00b001bf16f7c901mr3372994oab.49.1694623970324; Wed, 13 Sep 2023 09:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623970; cv=none; d=google.com; s=arc-20160816; b=nqOskedfPeb0TgnY1BlB3qohqoov4KAVVxOv/i5GJnoqBzkB6O4hx1af4tZYso69U7 ukNYEDZ+KNksJ5ot54TKXo9XrkZRXtOwA2zE0hj0Zw4Wj8I5TVwk7iSQvA0CFPHoSzRs fb1ch3Z7r7Ncw0J8j4BiA9dJeR2dlqKu1e6zGf88v2U2JIRcnxAZzuHgUmBqs4dg+Vex aCJHOjOusQlVuHfDZQtOGXV30zPwHs8Q2MH4hAiU+K1w65TLZE93M/ED27Kw5CuYv3pF laHAJF4YcYeRuyOuTFm+HRbhei2AXk3tc0OrCHA8OYVXEidwuheREe3Z9p5EL3BhPQQJ y3Sw== 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=0IaUdsZYMwZODNM6RHkcy8yl9XjtDnRmanHVV7mMIjc=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=ut3EHS3XCSJ1sOSF8/AWxYehX4ASoYIBXmlFO8ZB16eKOTP4hiodSk8U2X7pJZbRm0 EmHnssVdEcbDRh5PMmIv/RpY8PLpjJn8xW5xVfCkpHXRPZloFceMsPHfcXIKJ+Mi46/i T6JBEplQ9NRyw2Hq1/QLLkLH/F7BCx5i4GXl+9u6rqiyhR6tiE1Sp+GfytJfs2XrP/PP NlQAFeqDpNEErqC2eZoA6eRodU4ArCImC6nj2TLBt76VFrBcnAJpa6TWRqDlRcgQ/UvA m+iGYiSSMsXhdvm9I0nQjVIRxgXxj0n+X985KO2kIOQlCcPr7vu6wXyUpI8uCKCtQO3r oSOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id r1-20020a63d901000000b005740eeadb59si10136412pgg.518.2023.09.13.09.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:52:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 26F698229F04; Wed, 13 Sep 2023 09:41:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231265AbjIMQlb (ORCPT + 35 others); Wed, 13 Sep 2023 12:41:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbjIMQkk (ORCPT ); Wed, 13 Sep 2023 12:40:40 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 53CC12722; Wed, 13 Sep 2023 09:39:47 -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 5359111FB; Wed, 13 Sep 2023 09:40:24 -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 585FC3F5A1; Wed, 13 Sep 2023 09:39:45 -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 27/35] ACPICA: Add new MADT GICC flags fields [code first?] Date: Wed, 13 Sep 2023 16:38:15 +0000 Message-Id: <20230913163823.7880-28-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 (groat.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:41:41 -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 groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776942024258060337 X-GMAIL-MSGID: 1776942024258060337 Add the new flag field to the MADT's GICC structure. 'Online Capable' indicates a disabled CPU can be enabled later. Signed-off-by: James Morse --- This patch probably needs to go via the upstream acpica project, but is included here so the feature can be testd. --- include/acpi/actbl2.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/acpi/actbl2.h b/include/acpi/actbl2.h index 3751ae69432f..c433a079d8e1 100644 --- a/include/acpi/actbl2.h +++ b/include/acpi/actbl2.h @@ -1046,6 +1046,7 @@ struct acpi_madt_generic_interrupt { /* ACPI_MADT_ENABLED (1) Processor is usable if set */ #define ACPI_MADT_PERFORMANCE_IRQ_MODE (1<<1) /* 01: Performance Interrupt Mode */ #define ACPI_MADT_VGIC_IRQ_MODE (1<<2) /* 02: VGIC Maintenance Interrupt mode */ +#define ACPI_MADT_GICC_CPU_CAPABLE (1<<3) /* 03: CPU is online capable */ /* 12: Generic Distributor (ACPI 5.0 + ACPI 6.0 changes) */ From patchwork Wed Sep 13 16:38:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138961 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220846vqx; Wed, 13 Sep 2023 09:52:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3/nssuP3Om8f42or08ED7HiC2jTcP/extOTklyYg3xYUUqB92KDzwNcOX02rnmQpRV0If X-Received: by 2002:a17:903:2445:b0:1c0:774d:9342 with SMTP id l5-20020a170903244500b001c0774d9342mr3386502pls.25.1694623977637; Wed, 13 Sep 2023 09:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623977; cv=none; d=google.com; s=arc-20160816; b=DSnJPdFrXSyJMlQe+j4V7BU48mnPeYO5VX+KYTMb7yuniwmkLjT9k9mEeHrgTWdOYW UGfupCwb0K5F2e/QHyW8V5bejyWXspWHDiQx072ic64ue1P7ZOh8C2xDX9AAB3e1jJQj zcDC8DVE1E1ZSe62O+ra5U57gVRxc39z1A9ulrq2Yw5QNXd/4coq0FMZXgwURqrlEQAV 0SiTi7Clm3ENnTZEphESukokacx+bUDUUddJ8hrhjw295nAI1ps1o7sWLhU+vreLDHQ6 tSUn6Nda2qKkMO4PnosIdUkv0TWBURCKbvieZgGHtgeBkYrSMJeykHWAI9R8bBwgwpaZ IG4Q== 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=lXcEg6uaqnAxzE8bTHushhr4hVkfEwYocSSm2dUQnvI=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=k5CKEenYbcimx5MCdnBOAvkOM4WfeQu8GH/0DXjyqTDro5/zSa/5J5jeqisjRUVBtK WFpORatB9YeT6RuA/ydeYzE8brGeOfr0LSu8kqbFIL7Mk9+2NuePx2lA74o0qEUeLVcc QnTsl6OlNVOq2NvttoDYfAtn3Sx/MYylAIl7fk6n3AX6mOy4MRsrEOISRduwJHKmI623 LfinmQIGuGZ/4Q7NOeo1fpF9dtdekvFsdIyczET9dMP8PlVPqXRUR29s1dMNueRaEs00 ZXZ7N4sq20sSJy1UGyjEVRQ3CMpsiXkOv+xDRi7UucXWXpgOtF4diHBth0SoCib+Xq+G 324A== 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:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id b21-20020a170902ed1500b001b55070e154si10508771pld.96.2023.09.13.09.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:52:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id A9D4880707E5; Wed, 13 Sep 2023 09:41:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231357AbjIMQlf (ORCPT + 35 others); Wed, 13 Sep 2023 12:41:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbjIMQlD (ORCPT ); Wed, 13 Sep 2023 12:41:03 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 649781FE0; Wed, 13 Sep 2023 09:39:49 -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 52D1812FC; Wed, 13 Sep 2023 09:40:26 -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 57D4F3F5A1; Wed, 13 Sep 2023 09:39:47 -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 28/35] arm64, irqchip/gic-v3, ACPI: Move MADT GICC enabled check into a helper Date: Wed, 13 Sep 2023 16:38:16 +0000 Message-Id: <20230913163823.7880-29-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 (groat.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:41:54 -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 groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776942031831584983 X-GMAIL-MSGID: 1776942031831584983 ACPI, irqchip and the architecture code all inspect the MADT enabled bit for a GICC entry in the MADT. The addition of an 'online capable' bit means all these sites need updating. Move the current checks behind a helper to make future updates easier. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan --- arch/arm64/kernel/smp.c | 2 +- drivers/acpi/processor_core.c | 2 +- drivers/irqchip/irq-gic-v3.c | 10 ++++------ include/linux/acpi.h | 5 +++++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 960b98b43506..8c8f55721786 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -520,7 +520,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor) { u64 hwid = processor->arm_mpidr; - if (!(processor->flags & ACPI_MADT_ENABLED)) { + if (!acpi_gicc_is_usable(processor)) { pr_debug("skipping disabled CPU entry with 0x%llx MPIDR\n", hwid); return; } diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 7dd6dbaa98c3..b203cfe28550 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c @@ -90,7 +90,7 @@ static int map_gicc_mpidr(struct acpi_subtable_header *entry, struct acpi_madt_generic_interrupt *gicc = container_of(entry, struct acpi_madt_generic_interrupt, header); - if (!(gicc->flags & ACPI_MADT_ENABLED)) + if (!acpi_gicc_is_usable(gicc)) return -ENODEV; /* device_declaration means Device object in DSDT, in the diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index eedfa8e9f077..72d3cdebdad1 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -2367,8 +2367,7 @@ gic_acpi_parse_madt_gicc(union acpi_subtable_headers *header, u32 size = reg == GIC_PIDR2_ARCH_GICv4 ? SZ_64K * 4 : SZ_64K * 2; void __iomem *redist_base; - /* GICC entry which has !ACPI_MADT_ENABLED is not unusable so skip */ - if (!(gicc->flags & ACPI_MADT_ENABLED)) + if (!acpi_gicc_is_usable(gicc)) return 0; redist_base = ioremap(gicc->gicr_base_address, size); @@ -2418,7 +2417,7 @@ static int __init gic_acpi_match_gicc(union acpi_subtable_headers *header, * If GICC is enabled and has valid gicr base address, then it means * GICR base is presented via GICC */ - if ((gicc->flags & ACPI_MADT_ENABLED) && gicc->gicr_base_address) { + if (acpi_gicc_is_usable(gicc) && gicc->gicr_base_address) { acpi_data.enabled_rdists++; return 0; } @@ -2427,7 +2426,7 @@ static int __init gic_acpi_match_gicc(union acpi_subtable_headers *header, * It's perfectly valid firmware can pass disabled GICC entry, driver * should not treat as errors, skip the entry instead of probe fail. */ - if (!(gicc->flags & ACPI_MADT_ENABLED)) + if (!acpi_gicc_is_usable(gicc)) return 0; return -ENODEV; @@ -2486,8 +2485,7 @@ static int __init gic_acpi_parse_virt_madt_gicc(union acpi_subtable_headers *hea int maint_irq_mode; static int first_madt = true; - /* Skip unusable CPUs */ - if (!(gicc->flags & ACPI_MADT_ENABLED)) + if (!acpi_gicc_is_usable(gicc)) return 0; maint_irq_mode = (gicc->flags & ACPI_MADT_VGIC_IRQ_MODE) ? diff --git a/include/linux/acpi.h b/include/linux/acpi.h index b7ab85857bb7..e3265a9eafae 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -256,6 +256,11 @@ acpi_table_parse_cedt(enum acpi_cedt_type id, int acpi_parse_mcfg (struct acpi_table_header *header); void acpi_table_print_madt_entry (struct acpi_subtable_header *madt); +static inline bool acpi_gicc_is_usable(struct acpi_madt_generic_interrupt *gicc) +{ + return (gicc->flags & ACPI_MADT_ENABLED); +} + /* the following numa functions are architecture-dependent */ void acpi_numa_slit_init (struct acpi_table_slit *slit); From patchwork Wed Sep 13 16:38:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138953 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220146vqx; Wed, 13 Sep 2023 09:51:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE6v31tH40ChOFvppWXpU/+Zl4Tnhxt7Tl3QWC4N6ncWWB+j0leXbkvQzUu7GzK1cihRwvG X-Received: by 2002:a17:902:f542:b0:1bd:dbec:8673 with SMTP id h2-20020a170902f54200b001bddbec8673mr9297133plf.11.1694623907598; Wed, 13 Sep 2023 09:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623907; cv=none; d=google.com; s=arc-20160816; b=JSQeWW752TaZAZFyfFJDeitHo/BvtLi5Bg5kYP+Fm04uE+iHYDVskp0nLXOjawTgh9 eUC5bQKMTyT5BXZNed0WUVCV1ck4qu4SW/MJrJO/uhnmgOspKuHjMlwRbgnlsdqRtqvp VueoWQd6tjDbz2LbzwEELgGcEZZRc0nDbYbCgHCOh3krCy40b5ufUWuggUXPcP3QssIY nbxn0nVchFKS1WQxSC8NxRfhqglwLShi20iDHFkZrrJewX+HTrNu1jZjvWMIstAJaewq 0MX+YCJgXN2qWU600CJHsgKGqM/0X3rG2asU2E8USosvrecArb65/fG9SPdLhqTenIfg 1TVQ== 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=smaW/o8bd+rKbnDSaMbVWU9xJol1PXqasCCdXHQGEUg=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=q3I5xKQZQrylkDIjTx8gXNPENoFrJhzsrWNpuNMYIU6TaPudDQYWYIGbiKvUkwLpoC yB2SWfoDCSZXe4Dq/PPO1wRbtM6pv65W3D0HWMZhy6bjkbYNlnZDEcuH7pnatDRkpVG9 EF1+gXuelH2kKxlowfm2uGWWGjn2emBSV/LrbAVpFMhW1yi9DCujlJlCXYCUSvm9aH/f 9KMyX+4GotUW8TGKAS1TBMfCFZMZpvXVcVFbHy5Ii+8YphvnKzCtygPVCGJFBSQFqC7r HYfuCG35uvv3A1YeL5GNJ6sbUaerN+ngMplYFkyiirWpfXlTSPser7LRovior4lrBwa/ /GUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id u2-20020a170902714200b001bee6def27dsi10126725plm.235.2023.09.13.09.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:51:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id C405C8057E5D; Wed, 13 Sep 2023 09:41:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231142AbjIMQlx (ORCPT + 35 others); Wed, 13 Sep 2023 12:41:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231273AbjIMQlE (ORCPT ); Wed, 13 Sep 2023 12:41:04 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6477A2733; Wed, 13 Sep 2023 09:39:51 -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 505AE139F; Wed, 13 Sep 2023 09:40:28 -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 55C453F5A1; Wed, 13 Sep 2023 09:39:49 -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 29/35] irqchip/gic-v3: Don't return errors from gic_acpi_match_gicc() Date: Wed, 13 Sep 2023 16:38:17 +0000 Message-Id: <20230913163823.7880-30-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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:41:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941958425613046 X-GMAIL-MSGID: 1776941958425613046 gic_acpi_match_gicc() is only called via gic_acpi_count_gicr_regions(). It should only count the number of enabled redistributors, but it also tries to sanity check the GICC entry, currently returning an error if the Enabled bit is set, but the gicr_base_address is zero. Adding support for the online-capable bit to the sanity check complicates it, for no benefit. The existing check implicitly depends on gic_acpi_count_gicr_regions() previous failing to find any GICR regions (as it is valid to have gicr_base_address of zero if the redistributors are described via a GICR entry). Instead of complicating the check, remove it. Failures that happen at this point cause the irqchip not to register, meaning no irqs can be requested. The kernel grinds to a panic() pretty quickly. Without the check, MADT tables that exhibit this problem are still caught by gic_populate_rdist(), which helpfully also prints what went wrong: | CPU4: mpidr 100 has no re-distributor! Signed-off-by: James Morse Reviewed-by: Gavin Shan --- drivers/irqchip/irq-gic-v3.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 72d3cdebdad1..0f54811262eb 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -2415,21 +2415,15 @@ static int __init gic_acpi_match_gicc(union acpi_subtable_headers *header, /* * If GICC is enabled and has valid gicr base address, then it means - * GICR base is presented via GICC + * GICR base is presented via GICC. The redistributor is only known to + * be accessible if the GICC is marked as enabled. If this bit is not + * set, we'd need to add the redistributor at runtime, which isn't + * supported. */ - if (acpi_gicc_is_usable(gicc) && gicc->gicr_base_address) { + if (gicc->flags & ACPI_MADT_ENABLED && gicc->gicr_base_address) acpi_data.enabled_rdists++; - return 0; - } - /* - * It's perfectly valid firmware can pass disabled GICC entry, driver - * should not treat as errors, skip the entry instead of probe fail. - */ - if (!acpi_gicc_is_usable(gicc)) - return 0; - - return -ENODEV; + return 0; } static int __init gic_acpi_count_gicr_regions(void) From patchwork Wed Sep 13 16:38:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138958 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220732vqx; Wed, 13 Sep 2023 09:52:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHiIsr23yFKTBeGCK2PoPNFwMwmZNlHG2pgX6Bq2HZUEuH2dv6ZgNcWkMOmqLgAmgiD05jX X-Received: by 2002:a05:6a21:196:b0:154:e7e6:85c8 with SMTP id le22-20020a056a21019600b00154e7e685c8mr3381078pzb.31.1694623965383; Wed, 13 Sep 2023 09:52:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623965; cv=none; d=google.com; s=arc-20160816; b=U2IpQsETKfF76nHMYs+CC9C8EjyMqRdgsuXyFWZ49KjGmzIsa5IartA5ZH+c0pl1p5 v/wlyFs9f3geUYbZGW3m52o4rhwubloZJNyiE8wHbBdkMAwHPgV5f5JA2IWn/S4H6Pnt BBqLkpaUO8NbxxgBiiuek4SBFdI5FGBh5tz5mNg7fEZdxiHuPfKpdSxVacv5r7SA9rvV U29TBnoR00cDhUJAeCRLubdxTsn03rFzQ2JkNBV1nGS0wia+PPN67+p3+AHfk5BpTVN5 5Up334GI3e9rBzvz453LSGcAzSPeZAsVGDlIKhr4kWKEPcjwo9dgAH2a0t5/ZhBDZeyx aFeg== 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=1mFMZNPY6FPZDVDfRwDpDHNkr7NUFr3wlN3mFPbZfyY=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=mOmqJj7nBEH+0furdm88VLkhMNbQD68JjEq2GmSXpSx0HC0iIPV7RCUQikw3DTCfUX 5gPC5ae+UIs23Br5y6R3BdIIsvTYWdgbHMpJZRLZneXiOZQqyb3WemdmnarKGyPW8Crd +MR6W0filCFvhQSVNhytUDZIWL4zuie5GE1EY5M23Pp9s9EW2OQdFP+XfD1e/yElup6h W4FWGB06uetCnvKbWl3eE+xFQifK2WhI93wYZHx3pO5gCwrs871n39F0cxWXw6HDUHTS lZ/pIuPPwBqVaQDCYfzFLmP2iR16TZ+hdOu0IFWh5p5ipf+sOlTQCXsGwf+4vnTN/jBO foIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id kg6-20020a170903060600b001b3d6c68bd1si10141493plb.643.2023.09.13.09.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:52:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id D58638075B39; Wed, 13 Sep 2023 09:42:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231300AbjIMQlz (ORCPT + 35 others); Wed, 13 Sep 2023 12:41:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231409AbjIMQlF (ORCPT ); Wed, 13 Sep 2023 12:41:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5838219BF; Wed, 13 Sep 2023 09:39:53 -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 4ED1DFEC; Wed, 13 Sep 2023 09:40:30 -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 53E593F5A1; Wed, 13 Sep 2023 09:39:51 -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 30/35] irqchip/gic-v3: Add support for ACPI's disabled but 'online capable' CPUs Date: Wed, 13 Sep 2023 16:38:18 +0000 Message-Id: <20230913163823.7880-31-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 (groat.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:42: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 groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776942019416474878 X-GMAIL-MSGID: 1776942019416474878 To support virtual CPU hotplug, ACPI has added an 'online capable' bit to the MADT GICC entries. This indicates a disabled CPU entry may not be possible to online via PSCI until firmware has set enabled bit in _STA. What about the redistributor in the GICC entry? ACPI doesn't want to say. Assume the worst: When a redistributor is described in the GICC entry, but the entry is marked as disabled at boot, assume the redistributor is inaccessible. The GICv3 driver doesn't support late online of redistributors, so this means the corresponding CPU can't be brought online either. Clear the possible and present bits. Systems that want CPU hotplug in a VM can ensure their redistributors are always-on, and describe them that way with a GICR entry in the MADT. When mapping redistributors found via GICC entries, handle the case where the arch code believes the CPU is present and possible, but it does not have an accessible redistributor. Print a warning and clear the present and possible bits. Signed-off-by: James Morse ---- Disabled but online-capable CPUs cause this message to be printed if their redistributors are described via GICC: | GICv3: CPU 3's redistributor is inaccessible: this CPU can't be brought online If ACPI's _STA tries to make the cpu present later, this message is printed: | Changing CPU present bit is not supported --- drivers/irqchip/irq-gic-v3.c | 14 ++++++++++++++ include/linux/acpi.h | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 0f54811262eb..f56d064f4aa9 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -2365,11 +2365,25 @@ gic_acpi_parse_madt_gicc(union acpi_subtable_headers *header, (struct acpi_madt_generic_interrupt *)header; u32 reg = readl_relaxed(acpi_data.dist_base + GICD_PIDR2) & GIC_PIDR2_ARCH_MASK; u32 size = reg == GIC_PIDR2_ARCH_GICv4 ? SZ_64K * 4 : SZ_64K * 2; + int cpu = get_cpu_for_acpi_id(gicc->uid); void __iomem *redist_base; if (!acpi_gicc_is_usable(gicc)) return 0; + /* + * Capable but disabled CPUs can be brought online later. What about + * the redistributor? ACPI doesn't want to say! + * Virtual hotplug systems can use the MADT's "always-on" GICR entries. + * Otherwise, prevent such CPUs from being brought online. + */ + if (!(gicc->flags & ACPI_MADT_ENABLED)) { + pr_warn_once("CPU %u's redistributor is inaccessible: this CPU can't be brought online\n", cpu); + set_cpu_present(cpu, false); + set_cpu_possible(cpu, false); + return 0; + } + redist_base = ioremap(gicc->gicr_base_address, size); if (!redist_base) return -ENOMEM; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index e3265a9eafae..92cb25349a18 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -258,7 +258,8 @@ void acpi_table_print_madt_entry (struct acpi_subtable_header *madt); static inline bool acpi_gicc_is_usable(struct acpi_madt_generic_interrupt *gicc) { - return (gicc->flags & ACPI_MADT_ENABLED); + return ((gicc->flags & ACPI_MADT_ENABLED || + gicc->flags & ACPI_MADT_GICC_CPU_CAPABLE)); } /* the following numa functions are architecture-dependent */ From patchwork Wed Sep 13 16:38:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138956 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220672vqx; Wed, 13 Sep 2023 09:52:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrYB/RRry30tJVDQrk1xhaDJk1ancLG/+0wcVa+j2M2rGVL7+6iO/0OSAzQ/oiu0kQXXKv X-Received: by 2002:a05:6a00:b93:b0:68f:d35d:217e with SMTP id g19-20020a056a000b9300b0068fd35d217emr3696098pfj.2.1694623959495; Wed, 13 Sep 2023 09:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623959; cv=none; d=google.com; s=arc-20160816; b=ZTUiS8i4jA9J6JCEUQieSBUO/ummc3BO0NQ7X2JkawqD+6LSQw3e2fIGSaU2KL7qLw j7WUZbgqBej9xfFvdmdN1X1Cz5oIhhooq2x53wnCmxdb1pOGi+STzstY/OHR13rQJYZL /6CEJx0zxY0WQSoR5xoTN23BL5G1rLszBczbpP07VOSpKZP+h9B7XBGLAuahahlwGgh9 wZJL09kFjBpnMhiVB4vPff/HHiyIyF7RX3FAKZtrF/jnTfMTq2CbtE0B63wT6FvcAu3D jBfagBk3/HfU85nSkxpDN/HXW4wfyYnI7ffTZs0obnKikSVQ/iBiMSJ+bib4dXmd+Grm DGuA== 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=IvnqDn4icDlfnv3u50enCSsoirJyRF6d/xs/RkITuSo=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=l/GYNjom3MlwR66mRJidDwGjFYvr8oZqR2BL4VmH838WUEvrT0u2iZRIxX0qHEM5oT jj1kzuEJbChxvD3fmwY1tnsmonWzXdAm7bEVwmXfpWlpYmoXFno9yfLu9ajte0UEBhIB duPYIdHQL8ikQtuio3HsIwqh+hHrdIgk2L+u/01VpH8jTZIHycJD+ZEfJ5pCfjdcVmIt s3miaETJK3Z2YXgfMkx+y0ZNh4tgxUp9nHQW13OcNkxnvUQOftP4tVyLnUawhv8QXn24 LCNBx3VpH7O5cVBEBBKz2DkhqQcDhIZogMejaoRrNczaH4V3LLMffCFCYB8iw1YctmCe 0HUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id p16-20020a056a000b5000b0069026fd5a29si59234pfo.19.2023.09.13.09.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:52:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 7913E8034173; Wed, 13 Sep 2023 09:42:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231426AbjIMQmD (ORCPT + 35 others); Wed, 13 Sep 2023 12:42:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231434AbjIMQlP (ORCPT ); Wed, 13 Sep 2023 12:41:15 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 95E821FF6; Wed, 13 Sep 2023 09:39:55 -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 4D1701007; Wed, 13 Sep 2023 09:40:32 -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 5292E3F5A1; Wed, 13 Sep 2023 09:39:53 -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 31/35] arm64: psci: Ignore DENIED CPUs Date: Wed, 13 Sep 2023 16:38:19 +0000 Message-Id: <20230913163823.7880-32-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 (groat.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:42:10 -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 groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776942012855209330 X-GMAIL-MSGID: 1776942012855209330 From: Jean-Philippe Brucker When a CPU is marked as disabled, but online capable in the MADT, PSCI applies some firmware policy to control when it can be brought online. PSCI returns DENIED to a CPU_ON request if this is not currently permitted. The OS can learn the current policy from the _STA enabled bit. Handle the PSCI DENIED return code gracefully instead of printing an error. Signed-off-by: Jean-Philippe Brucker [ morse: Rewrote commit message ] Signed-off-by: James Morse --- arch/arm64/kernel/psci.c | 2 +- arch/arm64/kernel/smp.c | 3 ++- drivers/firmware/psci/psci.c | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c index 29a8e444db83..4fcc0cdd757b 100644 --- a/arch/arm64/kernel/psci.c +++ b/arch/arm64/kernel/psci.c @@ -40,7 +40,7 @@ static int cpu_psci_cpu_boot(unsigned int cpu) { phys_addr_t pa_secondary_entry = __pa_symbol(secondary_entry); int err = psci_ops.cpu_on(cpu_logical_map(cpu), pa_secondary_entry); - if (err) + if (err && err != -EPROBE_DEFER) pr_err("failed to boot CPU%d (%d)\n", cpu, err); return err; diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 8c8f55721786..e958db987665 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -124,7 +124,8 @@ int __cpu_up(unsigned int cpu, struct task_struct *idle) /* Now bring the CPU into our world */ ret = boot_secondary(cpu, idle); if (ret) { - pr_err("CPU%u: failed to boot: %d\n", cpu, ret); + if (ret != -EPROBE_DEFER) + pr_err("CPU%u: failed to boot: %d\n", cpu, ret); return ret; } diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index d9629ff87861..f7ab3fed3528 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -218,6 +218,8 @@ static int __psci_cpu_on(u32 fn, unsigned long cpuid, unsigned long entry_point) int err; err = invoke_psci_fn(fn, cpuid, entry_point, 0); + if (err == PSCI_RET_DENIED) + return -EPROBE_DEFER; return psci_to_linux_errno(err); } From patchwork Wed Sep 13 16:38:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138948 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1219737vqx; Wed, 13 Sep 2023 09:51:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwYc2k/RaeVhJon/7bBgnijlxK1Wn9D9dKGIxIW/hDijX24TFnJGPWiBjk1tmtFOY5LpR7 X-Received: by 2002:a17:902:b718:b0:1c2:1068:1f4f with SMTP id d24-20020a170902b71800b001c210681f4fmr2806302pls.17.1694623864041; Wed, 13 Sep 2023 09:51:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623864; cv=none; d=google.com; s=arc-20160816; b=zxcgVceTTTXfZyHVmJ11VMcPK7GCXhO60DImnZa0sM4CtD2jrpQHT7uQZh9r9BGfTu YW4FW3XW8NxoHtgsHtwIlLPdP+CHHmWLAEMl+7oX6BZypwwpSihLL9hN7P1iR7IOynzR x0zklQ5dNcBqPwmwdNDZnAo5Gc4hFSqriSlACRjVHDenmMtYD366Og1GxWLgTBMeT1S7 09MahhyGACQK28QHCkpTUIZSIxsORhaxAfM+qDaASKxgQb6lUa0EPHZJToIi4kfKuSZb UEmXVrbCfj30ihnuojtpy6he7z/BhBHYgDdpizBOwUgoR8uRd3J86fDHpJ75Ca+q2Acx J24Q== 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=4nts9Z5V79ffHKEfbTuPKMkI7gmykrCBAlzYIqy0Ih0=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=E1Vdb9OzDbMfRpIoSogSyYYHgo+bcOGWkwCAllgUrePeB1JF3UfZo6yeP1cU/SWb3y T0wDlKx36gIzaiGVZq7jxxuST/dRulpcnuuYz7bZDi8izX4uY10VrT2KHyi6h/gy6pB3 sqTLVafxMHJF1kmrev/zH69p8e9Umh8ukqb3b9Jr+oFXkMhOdDoTyNUSzZN/DOMu9Tm8 9teOxqQC0cWBvoqoOKb/6XO7DSx+VG9FLUB+cKxyJN73f/ovDjbxGiZgQO9OH0jyZkqQ 2S4zbbVuV0v+Vgw+oGANizPbPzUWYwDggcFjlTie7trulp352qvOA1Ftn9z2fytv/Zp9 UVCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ay6-20020a1709028b8600b001b89bab468esi10271704plb.107.2023.09.13.09.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:51:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 906D682B1E4B; Wed, 13 Sep 2023 09:42:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231490AbjIMQmN (ORCPT + 35 others); Wed, 13 Sep 2023 12:42:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231478AbjIMQlR (ORCPT ); Wed, 13 Sep 2023 12:41:17 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4D7FE2D41; Wed, 13 Sep 2023 09:39:57 -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 4B8EB13D5; Wed, 13 Sep 2023 09:40:34 -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 50C7C3F5A1; Wed, 13 Sep 2023 09:39:55 -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 32/35] ACPI: add support to register CPUs based on the _STA enabled bit Date: Wed, 13 Sep 2023 16:38:20 +0000 Message-Id: <20230913163823.7880-33-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 (morse.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:42:34 -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 morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941913072739156 X-GMAIL-MSGID: 1776941913072739156 acpi_processor_get_info() registers all present CPUs. Registering a CPU is what creates the sysfs entries and triggers the udev notifications. arm64 virtual machines that support 'virtual cpu hotplug' use the enabled bit to indicate whether the CPU can be brought online, as the existing ACPI tables require all hardware to be described and present. If firmware describes a CPU as present, but disabled, skip the registration. Such CPUs are present, but can't be brought online for whatever reason. (e.g. firmware/hypervisor policy). Once firmware sets the enabled bit, the CPU can be registered and brought online by user-space. Online CPUs, or CPUs that are missing an _STA method must always be registered. Signed-off-by: James Morse Reviewed-by: Jonathan Cameron Reviewed-by: Gavin Shan --- drivers/acpi/acpi_processor.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index b67616079751..b49859eab01a 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -227,6 +227,32 @@ static int acpi_processor_make_present(struct acpi_processor *pr) return ret; } +static int acpi_processor_make_enabled(struct acpi_processor *pr) +{ + unsigned long long sta; + acpi_status status; + bool present, enabled; + + if (!acpi_has_method(pr->handle, "_STA")) + return arch_register_cpu(pr->id); + + status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); + if (ACPI_FAILURE(status)) + return -ENODEV; + + present = sta & ACPI_STA_DEVICE_PRESENT; + enabled = sta & ACPI_STA_DEVICE_ENABLED; + + if (cpu_online(pr->id) && (!present || !enabled)) { + pr_err_once(FW_BUG "CPU %u is online, but described as not present or disabled!\n", pr->id); + add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK); + } else if (!present || !enabled) { + return -ENODEV; + } + + return arch_register_cpu(pr->id); +} + static int acpi_processor_get_info(struct acpi_device *device) { union acpi_object object = { 0 }; @@ -318,7 +344,7 @@ static int acpi_processor_get_info(struct acpi_device *device) */ if (!invalid_logical_cpuid(pr->id) && cpu_present(pr->id) && !get_cpu_device(pr->id)) { - int ret = arch_register_cpu(pr->id); + int ret = acpi_processor_make_enabled(pr); if (ret) return ret; @@ -526,6 +552,9 @@ static void acpi_processor_post_eject(struct acpi_device *device) acpi_processor_make_not_present(device); return; } + + if (cpu_present(pr->id) && !(sta & ACPI_STA_DEVICE_ENABLED)) + arch_unregister_cpu(pr->id); } #ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC From patchwork Wed Sep 13 16:38:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138952 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220130vqx; Wed, 13 Sep 2023 09:51:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGF7NLUfqAbLjqCMg/JF9vOsaG6wjFEfe2+6iMJSCh10Sp1OpsxKVIJy922+WA3XPjslVHi X-Received: by 2002:a17:903:1c5:b0:1bb:55be:e198 with SMTP id e5-20020a17090301c500b001bb55bee198mr4303162plh.0.1694623906671; Wed, 13 Sep 2023 09:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623906; cv=none; d=google.com; s=arc-20160816; b=R7HckMVD9oNMzsuqPt4XZRUUfLvveDk3LR21cErON6+0yO3GeNlSVcGXZlrmGiZ0B0 4KA+/ahYdXmBuiu7N7jXujvSuCQNVRUzUDmK4vKhyfN1a8w5CZ0jclPn5zzmTY4Dllvt iEm9Ax4qKIbjCbrtkBwTcK+CfrvkKghnp4dfa5Jnb0EavyV2Ba7AgVDbA5NKvolhUDqs Mr4rcCS5ol4DSP4zpcAxHBN16UqKi5WNPfEnh4zvM6Wuamiq8vXESCrBah2Vrj8pslU1 Ipv5r1n2Gm6UmWg1FGqzGi1M/llxbcrWuYqKzKqAQqQV6yFegU9nxKVc8P2lPGwCYq0D ZJnQ== 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=gmOOVsUHShEFyy3AIWRUifoV/OnwIkjCXKKKzSV+70o=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=yDYBNU6uF0nQkJt08l+xG4n0NevMxjM86vSZfhZw5Brkzk5FtZNUkXXMdSU0044BY5 wJgpyqFDoX5B1y9w3DVS5AQvSc8tfn8wiC+IXpSXrhtkSUWwk5b5fpWcPLSVVM/U/Wcq SYx6zDmbHVSk015PaJLrKqRqf7IvEI23WKkMY1aRmTEMnFKXB07iCwg6RNl3VaJ2ajxe 94kT+JzdrXNxvjtt61Q+TwjM40WgCDstZFPnfNrVBNg/vYv1xFqU3u4QiGbG0waaCEbK cY0NyH8kv4Pg7cCTmBdDdP5GfRTtiA/I7f76SUQgyb/5ANpE3m5IR1O/QKtEdDFX68zU BMGQ== 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:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id kv4-20020a17090328c400b001c1e1fe16bcsi10274383plb.252.2023.09.13.09.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:51:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 45EAB81E64BB; Wed, 13 Sep 2023 09:42:22 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231545AbjIMQmQ (ORCPT + 35 others); Wed, 13 Sep 2023 12:42:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231504AbjIMQlT (ORCPT ); Wed, 13 Sep 2023 12:41:19 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4D2652D4E; Wed, 13 Sep 2023 09:39:59 -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 4DC6DFEC; Wed, 13 Sep 2023 09:40:36 -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 4F3433F5A1; Wed, 13 Sep 2023 09:39:57 -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 33/35] arm64: document virtual CPU hotplug's expectations Date: Wed, 13 Sep 2023 16:38:21 +0000 Message-Id: <20230913163823.7880-34-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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:42:22 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941957612454801 X-GMAIL-MSGID: 1776941957612454801 Add a description of physical and virtual CPU hotplug, explain the differences and elaborate on what is required in ACPI for a working virtual hotplug system. Signed-off-by: James Morse --- Documentation/arch/arm64/cpu-hotplug.rst | 79 ++++++++++++++++++++++++ Documentation/arch/arm64/index.rst | 1 + 2 files changed, 80 insertions(+) create mode 100644 Documentation/arch/arm64/cpu-hotplug.rst diff --git a/Documentation/arch/arm64/cpu-hotplug.rst b/Documentation/arch/arm64/cpu-hotplug.rst new file mode 100644 index 000000000000..76ba8d932c72 --- /dev/null +++ b/Documentation/arch/arm64/cpu-hotplug.rst @@ -0,0 +1,79 @@ +.. SPDX-License-Identifier: GPL-2.0 +.. _cpuhp_index: + +==================== +CPU Hotplug and ACPI +==================== + +CPU hotplug in the arm64 world is commonly used to describe the kernel taking +CPUs online/offline using PSCI. This document is about ACPI firmware allowing +CPUs that were not available during boot to be added to the system later. + +``possible`` and ``present`` refer to the state of the CPU as seen by linux. + + +CPU Hotplug on physical systems - CPUs not present at boot +---------------------------------------------------------- + +Physical systems need to mark a CPU that is ``possible`` but not ``present`` as +being ``present``. An example would be a dual socket machine, where the package +in one of the sockets can be replaced while the system is running. + +This is not supported. + +In the arm64 world CPUs are not a single device but a slice of the system. +There are no systems that support the physical addition (or removal) of CPUs +while the system is running, and ACPI is not able to sufficiently describe +them. + +e.g. New CPUs come with new caches, but the platform's cache toplogy is +described in a static table, the PPTT. How caches are shared between CPUs is +not discoverable, and must be described by firmware. + +e.g. The GIC redistributor for each CPU must be accessed by the driver during +boot to discover the system wide supported features. ACPI's MADT GICC +structures can describe a redistributor associated with a disabled CPU, but +can't describe whether the redistributor is accessible, only that it is not +'always on'. + +arm64's ACPI tables assume that everything described is ``present``. + + +CPU Hotplug on virtual systems - CPUs not enabled at boot +--------------------------------------------------------- + +Virtual systems have the advantage that all the properties the system will +ever have can be described at boot. There are no power-domain considerations +as such devices are emulated. + +CPU Hotplug on virtual systems is supported. It is distinct from physical +CPU Hotplug as all resources are described as ``present``, but CPUs may be +marked as disabled by firmware. Only the CPU's online/offline behaviour is +influenced by firmware. An example is where a virtual machine boots with a +single CPU, and additional CPUs are added once a cloud orchestrator deploys +the workload. + +For a virtual machine, the VMM (e.g. Qemu) plays the part of firmware. + +Virtual hotplug is implemented as a firmware policy affecting which CPUs can be +brought online. Firmware can enforce its policy via PSCI's return codes. e.g. +``DENIED``. + +The ACPI tables must describe all the resources of the virtual machine. CPUs +that firmware wishes to disable either from boot (or later) should not be +``enabled`` in the MADT GICC structures, but should have the ``online capable`` +bit set, to indicate they can be enabled later. The boot CPU must be marked as +``enabled``. The 'always on' GICR structure must be used to describe the +redistributors. + +CPUs described as ``online capable`` but not ``enabled`` can be set to enabled +by the DSDT's Processor object's _STA method. On virtual systems the _STA method +must always report the CPU as ``present``. Changes to the firmware policy can +be notified to the OS via device-check or eject-request. + +CPUs described as ``enabled`` in the static table, should not have their _STA +modified dynamically by firmware. Soft-restart features such as kexec will +re-read the static properties of the system from these static tables, and +may malfunction if these no longer describe the running system. Linux will +re-discover the dynamic properties of the system from the _STA method later +during boot. diff --git a/Documentation/arch/arm64/index.rst b/Documentation/arch/arm64/index.rst index d08e924204bf..78544de0a8a9 100644 --- a/Documentation/arch/arm64/index.rst +++ b/Documentation/arch/arm64/index.rst @@ -13,6 +13,7 @@ ARM64 Architecture asymmetric-32bit booting cpu-feature-registers + cpu-hotplug elf_hwcaps hugetlbpage kdump From patchwork Wed Sep 13 16:38:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138954 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1220161vqx; Wed, 13 Sep 2023 09:51:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGjEzJpeaXYrwCo7tQ4xIKExY/LmJfNHpcVTvNbIIDPkNe5KJeM/dO8U4zOsMtkHV0KgMf+ X-Received: by 2002:a17:902:c106:b0:1bd:c6ca:e0db with SMTP id 6-20020a170902c10600b001bdc6cae0dbmr3170262pli.37.1694623909514; Wed, 13 Sep 2023 09:51:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623909; cv=none; d=google.com; s=arc-20160816; b=X+hcIahKhRfrFus9G52pGOlv4D6STB3dYF19XeLxMDXKGUm2TA/0v8cirnLomRgEAv gn28gvIpPhGl+HgAyl0qI6DdHcTj7FqSFV3Atc7ESoLjxUtjgWTZ03SNWmHogAuXE1+k IjCCLHAPetzooaXsWQvTf9H8NyOxDYybEc3gnEqSLvjGWZT77F9UmLXSOQcR/2AUU3x5 FbZEDVha7mZlkTHwj9UYsMrv74BEmwNA0T3HZmgJAp/05wol8LE89r0dkiECWZrfC/wf gWMWwWbIAysssUhO5SMbnsnNZae2QWQOLCHxX+E7dCqDhGDcKX9ZBBvRul/q3qrNqM8P x20Q== 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=SMxueuCU9CFNun2wDXS2vOCv++sG20sZUpK1kL9KaAw=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=ZwkThXIydbWbGhXS8f592QTdylUWq9XmRjWlbGMAy8ufaaQpGLxKDsfosDTvVlLBph bO8H74i3dXooB9Bq9RZKiseOGnNob0OAxqQgOj7Aba+niwCdU012a1MLg8oMVpCE8lI+ hBK0+5TAFGRgkt0LBSzGjNBymDN83VwtbmIYOYCx/Ngrn8ItEllu0pKsbre73tOclYoI QI88Qo2dblhLmVcc84eDIDREJP40sPWg7L8ZYRJgYnlZAyJEhgIGSoAZ8Re3qTrXBgvr FtX3cAex5Gp1y8M7HhwqjSi2wZ30rKGFoo77/QplDQdLBL1628ttAS5oV6fWpdjzPyBL b6nQ== 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:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id n2-20020a170902d2c200b001bb6d711625si7493920plc.279.2023.09.13.09.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:51:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 9049D81E725F; Wed, 13 Sep 2023 09:42:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230432AbjIMQmU (ORCPT + 35 others); Wed, 13 Sep 2023 12:42:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230355AbjIMQlU (ORCPT ); Wed, 13 Sep 2023 12:41:20 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 54B932D64; Wed, 13 Sep 2023 09:40:01 -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 4CEEB1FB; Wed, 13 Sep 2023 09:40:38 -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 516783F5A1; Wed, 13 Sep 2023 09:39:59 -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 34/35] ACPI: Add _OSC bits to advertise OS support for toggling CPU present/enabled Date: Wed, 13 Sep 2023 16:38:22 +0000 Message-Id: <20230913163823.7880-35-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 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:42:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941960441901288 X-GMAIL-MSGID: 1776941960441901288 Platform firmware can disabled a CPU, or make it not-present by making an eject-request notification, then waiting for the os to make it offline and call _EJx. After the firmware updates _STA with the new status. Not all operating systems support this. For arm64 making CPUs not-present has never been supported. For all ACPI architectures, making CPUs disabled has recently been added. Firmware can't know what the OS has support for. Add two new _OSC bits to advertise whether the OS supports the _STA enabled or present bits being toggled for CPUs. This will be important for arm64 if systems that support physical CPU hotplug ever appear as arm64 linux doesn't currently support this, so firmware shouldn't try. Advertising this support to firmware is useful for cloud orchestrators to know whether they can scale a particular VM by adding CPUs. Signed-off-by: James Morse --- I'm assuming ia64 with physical hotplug machines once existed, and that Loongarch machines with support for this don't. --- arch/ia64/Kconfig | 1 + arch/x86/Kconfig | 1 + drivers/acpi/Kconfig | 9 +++++++++ drivers/acpi/acpi_processor.c | 14 +++++++++++++- drivers/acpi/bus.c | 16 ++++++++++++++++ include/linux/acpi.h | 4 ++++ 6 files changed, 44 insertions(+), 1 deletion(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 54972f9fe804..13df676bad67 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -17,6 +17,7 @@ config IA64 select ARCH_MIGHT_HAVE_PC_SERIO select ACPI select ACPI_HOTPLUG_PRESENT_CPU if ACPI_PROCESSOR && HOTPLUG_CPU + select ACPI_HOTPLUG_IGNORE_OSC if ACPI select ACPI_NUMA if NUMA select ARCH_ENABLE_MEMORY_HOTPLUG select ARCH_ENABLE_MEMORY_HOTREMOVE diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 295a7a3debb6..5fea3ce9594e 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -61,6 +61,7 @@ config X86 select ACPI_LEGACY_TABLES_LOOKUP if ACPI select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI select ACPI_HOTPLUG_PRESENT_CPU if ACPI_PROCESSOR && HOTPLUG_CPU + select ACPI_HOTPLUG_IGNORE_OSC if ACPI && HOTPLUG_CPU select ARCH_32BIT_OFF_T if X86_32 select ARCH_CLOCKSOURCE_INIT select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 417f9f3077d2..c49978b4b11f 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -310,6 +310,15 @@ config ACPI_HOTPLUG_PRESENT_CPU depends on ACPI_PROCESSOR && HOTPLUG_CPU select ACPI_CONTAINER +config ACPI_HOTPLUG_IGNORE_OSC + bool + depends on ACPI_HOTPLUG_PRESENT_CPU + help + Ignore whether firmware acknowledged support for toggling the CPU + present bit in _STA. Some architectures predate the _OSC bits, so + firmware doesn't know to do this. + + config ACPI_PROCESSOR_AGGREGATOR tristate "Processor Aggregator" depends on ACPI_PROCESSOR diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index b49859eab01a..87926f22c857 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -181,6 +181,18 @@ static void __init acpi_pcc_cpufreq_init(void) static void __init acpi_pcc_cpufreq_init(void) {} #endif /* CONFIG_X86 */ +static bool acpi_processor_hotplug_present_supported(void) +{ + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) + return false; + + /* x86 systems pre-date the _OSC bit */ + if (IS_ENABLED(CONFIG_ACPI_HOTPLUG_IGNORE_OSC)) + return true; + + return osc_sb_hotplug_present_support_acked; +} + /* Initialization */ static int acpi_processor_make_present(struct acpi_processor *pr) { @@ -188,7 +200,7 @@ static int acpi_processor_make_present(struct acpi_processor *pr) acpi_status status; int ret; - if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) { + if (!acpi_processor_hotplug_present_supported()) { pr_err_once("Changing CPU present bit is not supported\n"); return -ENODEV; } diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index f41dda2d3493..123c28c2eda3 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -298,6 +298,13 @@ EXPORT_SYMBOL_GPL(osc_sb_native_usb4_support_confirmed); bool osc_sb_cppc2_support_acked; +/* + * ACPI 6.? Proposed Operating System Capabilities for modifying CPU + * present/enable. + */ +bool osc_sb_hotplug_enabled_support_acked; +bool osc_sb_hotplug_present_support_acked; + static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48"; static void acpi_bus_osc_negotiate_platform_control(void) { @@ -346,6 +353,11 @@ static void acpi_bus_osc_negotiate_platform_control(void) if (!ghes_disable) capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_APEI_SUPPORT; + + capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_HOTPLUG_ENABLED_SUPPORT; + if (IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) + capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_HOTPLUG_PRESENT_SUPPORT; + if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle))) return; @@ -383,6 +395,10 @@ static void acpi_bus_osc_negotiate_platform_control(void) capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT; osc_cpc_flexible_adr_space_confirmed = capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_CPC_FLEXIBLE_ADR_SPACE; + osc_sb_hotplug_enabled_support_acked = + capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_HOTPLUG_ENABLED_SUPPORT; + osc_sb_hotplug_present_support_acked = + capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_HOTPLUG_PRESENT_SUPPORT; } kfree(context.ret.pointer); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 92cb25349a18..2ba7e0b10bcf 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -580,12 +580,16 @@ acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context); #define OSC_SB_NATIVE_USB4_SUPPORT 0x00040000 #define OSC_SB_PRM_SUPPORT 0x00200000 #define OSC_SB_FFH_OPR_SUPPORT 0x00400000 +#define OSC_SB_HOTPLUG_ENABLED_SUPPORT 0x00800000 +#define OSC_SB_HOTPLUG_PRESENT_SUPPORT 0x01000000 extern bool osc_sb_apei_support_acked; extern bool osc_pc_lpi_support_confirmed; extern bool osc_sb_native_usb4_support_confirmed; extern bool osc_sb_cppc2_support_acked; extern bool osc_cpc_flexible_adr_space_confirmed; +extern bool osc_sb_hotplug_enabled_support_acked; +extern bool osc_sb_hotplug_present_support_acked; /* USB4 Capabilities */ #define OSC_USB_USB3_TUNNELING 0x00000001 From patchwork Wed Sep 13 16:38:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 138949 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp1219802vqx; Wed, 13 Sep 2023 09:51:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3W1KDvh8PA3ey3oRNQVeH3rDBmuOT+SyWAQemwslTTTZu7MgQrHQeVCvAhA8WJJiXu2NJ X-Received: by 2002:a17:903:32c7:b0:1b9:c68f:91a5 with SMTP id i7-20020a17090332c700b001b9c68f91a5mr4320834plr.6.1694623870379; Wed, 13 Sep 2023 09:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694623870; cv=none; d=google.com; s=arc-20160816; b=bwqt0H2ZE+1YTwcFS0SmxzTU6dkMMiTz2SooE04R/R22m8Jmdhaug5S7fA/zLaGUul TQ0XTEC5mifsap+5OdsFq2Q4rY4eFGekg45EIP3QTtForQ2NGL83DiUFx3oizSEvhz+C /IJp2+cya73KdblgMSjUY1wLLPVLNBNgQnmV3aprJEgV8sSNELb3LSkQ7Nt2QHUeUuwC jpTjUVTwoqKtiSepDLDAwkoT1tEM+PJzlpFsCJpcSFQpAwNuwwrkO6cGuJZrbfo1oJ4u wDPWA0BjqJBQuH8IcLKH8NiGEL25pfTSQN0xeCx1WSWfCwqMaEnu5fTb18ts8eJRcqeN V6og== 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=JVc8Cg78qYl3O4MG61n7JjxtNw4p/IiOh9HK2srEy5s=; fh=2nhVWB0fZ+8YH0lLFpnF/Mo8eq+n1VMLe+b+IpvS0g0=; b=CNXy+RN7iRaYqzbf9LCJ3CB6UVhG6rAQiiFReDOLU500Gvj3otdBZJY4+HVjJfvEso Vrfy23VuqenMWN3uFOAvqJS7adcYZ87hDfwQB2vy4ym4YkEHhxqVbplLNjaELLkcG19w UxgRRAwgmyzCIcbvpl3atTekK7RhwtKTv3klH7EKbC+fQyKJ1MN5g4lUSXv2IttPBvxk JVcdgiJ77ofNRk8qeQTJaCBauZRMyOw50f+PqJUjYCapgrTQFvGImypf68YdHmLoP9mn t3nQrGjuRBskDMcvj9A1ftbOvnjf4U2rF/bH76P8fazEwD31ohKEuZIUJrv233Mj6Jen 4xUg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id j6-20020a170902da8600b001b222cd9826si11026700plx.349.2023.09.13.09.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:51:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 51B8F8113409; Wed, 13 Sep 2023 09:43:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230523AbjIMQmj (ORCPT + 35 others); Wed, 13 Sep 2023 12:42:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbjIMQlo (ORCPT ); Wed, 13 Sep 2023 12:41:44 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 960DA2D7E; Wed, 13 Sep 2023 09:40:03 -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 4D35AC15; Wed, 13 Sep 2023 09:40:40 -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 51B823F5A1; Wed, 13 Sep 2023 09:40:01 -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 35/35] cpumask: Add enabled cpumask for present CPUs that can be brought online Date: Wed, 13 Sep 2023 16:38:23 +0000 Message-Id: <20230913163823.7880-36-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 (morse.vger.email [0.0.0.0]); Wed, 13 Sep 2023 09:43:16 -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 morse.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776941919492401954 X-GMAIL-MSGID: 1776941919492401954 The 'offline' file in sysfs shows all offline CPUs, including those that aren't present. User-space is expected to remove not-present CPUs from this list to learn which CPUs could be brought online. CPUs can be present but not-enabled. These CPUs can't be brought online until the firmware policy changes, which comes with an ACPI notification that will register the CPUs. With only the offline and present files, user-space is unable to determine which CPUs it can try to bring online. Add a new CPU mask that shows this based on all the registered CPUs. Signed-off-by: James Morse --- drivers/base/cpu.c | 10 ++++++++++ include/linux/cpumask.h | 25 +++++++++++++++++++++++++ kernel/cpu.c | 3 +++ 3 files changed, 38 insertions(+) diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index c709747c4a18..a19a8be93102 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -95,6 +95,7 @@ void unregister_cpu(struct cpu *cpu) { int logical_cpu = cpu->dev.id; + set_cpu_enabled(logical_cpu, false); unregister_cpu_under_node(logical_cpu, cpu_to_node(logical_cpu)); device_unregister(&cpu->dev); @@ -273,6 +274,13 @@ static ssize_t print_cpus_offline(struct device *dev, } static DEVICE_ATTR(offline, 0444, print_cpus_offline, NULL); +static ssize_t print_cpus_enabled(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(cpu_enabled_mask)); +} +static DEVICE_ATTR(enabled, 0444, print_cpus_enabled, NULL); + static ssize_t print_cpus_isolated(struct device *dev, struct device_attribute *attr, char *buf) { @@ -413,6 +421,7 @@ int register_cpu(struct cpu *cpu, int num) register_cpu_under_node(num, cpu_to_node(num)); dev_pm_qos_expose_latency_limit(&cpu->dev, PM_QOS_RESUME_LATENCY_NO_CONSTRAINT); + set_cpu_enabled(num, true); return 0; } @@ -494,6 +503,7 @@ static struct attribute *cpu_root_attrs[] = { &cpu_attrs[2].attr.attr, &dev_attr_kernel_max.attr, &dev_attr_offline.attr, + &dev_attr_enabled.attr, &dev_attr_isolated.attr, #ifdef CONFIG_NO_HZ_FULL &dev_attr_nohz_full.attr, diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index f10fb87d49db..a29ee03f13ff 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -92,6 +92,7 @@ static inline void set_nr_cpu_ids(unsigned int nr) * * cpu_possible_mask- has bit 'cpu' set iff cpu is populatable * cpu_present_mask - has bit 'cpu' set iff cpu is populated + * cpu_enabled_mask - has bit 'cpu' set iff cpu can be brought online * cpu_online_mask - has bit 'cpu' set iff cpu available to scheduler * cpu_active_mask - has bit 'cpu' set iff cpu available to migration * @@ -124,11 +125,13 @@ static inline void set_nr_cpu_ids(unsigned int nr) extern struct cpumask __cpu_possible_mask; extern struct cpumask __cpu_online_mask; +extern struct cpumask __cpu_enabled_mask; extern struct cpumask __cpu_present_mask; extern struct cpumask __cpu_active_mask; extern struct cpumask __cpu_dying_mask; #define cpu_possible_mask ((const struct cpumask *)&__cpu_possible_mask) #define cpu_online_mask ((const struct cpumask *)&__cpu_online_mask) +#define cpu_enabled_mask ((const struct cpumask *)&__cpu_enabled_mask) #define cpu_present_mask ((const struct cpumask *)&__cpu_present_mask) #define cpu_active_mask ((const struct cpumask *)&__cpu_active_mask) #define cpu_dying_mask ((const struct cpumask *)&__cpu_dying_mask) @@ -973,6 +976,7 @@ extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS); #else #define for_each_possible_cpu(cpu) for_each_cpu((cpu), cpu_possible_mask) #define for_each_online_cpu(cpu) for_each_cpu((cpu), cpu_online_mask) +#define for_each_enabled_cpu(cpu) for_each_cpu((cpu), cpu_enabled_mask) #define for_each_present_cpu(cpu) for_each_cpu((cpu), cpu_present_mask) #endif @@ -995,6 +999,15 @@ set_cpu_possible(unsigned int cpu, bool possible) cpumask_clear_cpu(cpu, &__cpu_possible_mask); } +static inline void +set_cpu_enabled(unsigned int cpu, bool can_be_onlined) +{ + if (can_be_onlined) + cpumask_set_cpu(cpu, &__cpu_enabled_mask); + else + cpumask_clear_cpu(cpu, &__cpu_enabled_mask); +} + static inline void set_cpu_present(unsigned int cpu, bool present) { @@ -1074,6 +1087,7 @@ static __always_inline unsigned int num_online_cpus(void) return raw_atomic_read(&__num_online_cpus); } #define num_possible_cpus() cpumask_weight(cpu_possible_mask) +#define num_enabled_cpus() cpumask_weight(cpu_enabled_mask) #define num_present_cpus() cpumask_weight(cpu_present_mask) #define num_active_cpus() cpumask_weight(cpu_active_mask) @@ -1082,6 +1096,11 @@ static inline bool cpu_online(unsigned int cpu) return cpumask_test_cpu(cpu, cpu_online_mask); } +static inline bool cpu_enabled(unsigned int cpu) +{ + return cpumask_test_cpu(cpu, cpu_enabled_mask); +} + static inline bool cpu_possible(unsigned int cpu) { return cpumask_test_cpu(cpu, cpu_possible_mask); @@ -1106,6 +1125,7 @@ static inline bool cpu_dying(unsigned int cpu) #define num_online_cpus() 1U #define num_possible_cpus() 1U +#define num_enabled_cpus() 1U #define num_present_cpus() 1U #define num_active_cpus() 1U @@ -1119,6 +1139,11 @@ static inline bool cpu_possible(unsigned int cpu) return cpu == 0; } +static inline bool cpu_enabled(unsigned int cpu) +{ + return cpu == 0; +} + static inline bool cpu_present(unsigned int cpu) { return cpu == 0; diff --git a/kernel/cpu.c b/kernel/cpu.c index 6de7c6bb74ee..2201a6a449b5 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -3101,6 +3101,9 @@ EXPORT_SYMBOL(__cpu_possible_mask); struct cpumask __cpu_online_mask __read_mostly; EXPORT_SYMBOL(__cpu_online_mask); +struct cpumask __cpu_enabled_mask __read_mostly; +EXPORT_SYMBOL(__cpu_enabled_mask); + struct cpumask __cpu_present_mask __read_mostly; EXPORT_SYMBOL(__cpu_present_mask);