From patchwork Wed Dec 13 12:49:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5BD07C4332F for ; Wed, 13 Dec 2023 12:52:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jMyH0SdRBT1b10bLAyzABYI4kUzt+Q1lunQYrZCZ7Pk=; b=HflZF1qbcA5iy+ I9vjTvu49EeuZkV4GJiHnHO+WOsol+PCdr9A+yLN5JFwB+BkhXwSjpy9MPgaDL5khC4jkdY9dRIJk D3csSWJBIjmQr+Te+j0R1zb55Fn9d/jRmBl0qsQ0Gk4E7v1/nClfy/FXStChHHKmU7hs+71RDcczR wb0X8WHQUv4/FAXbmwEFEqlpUo0yAU0BEB4xhYTqZC0M3M4Pd2yh3EETeazMqrTJMAs1qYcEnmJ6s FQ49tZZZfJOkMzVjjWDbwOFxYl6/2echE0AF4ZDgHOsTDTW8vcS6WBdx6TsQdFoB645lax1jqq1oZ 6sHQ8GNr20PLmv6aqLPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOiD-00Efu5-0o; Wed, 13 Dec 2023 12:51:41 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOi3-00Eduz-0b; Wed, 13 Dec 2023 12:51:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7Aiu0hOT23ckQkcqYvFjFK3dZgn3o0k6iEaEs/f0wM4=; b=R6N7nL3Hj7r6PGZF3AQxR9xYGp hz3VIljNGb8hg0+7xDjuT8525pBUgeBD+UIlhqsF/zdkVX1vEA4PMefDHWLw6eESWX/1AaRvJ2xvp drQL6SkAjAlAaI2V+skWX+NQheiaNGiyFmbcghDlNq53IdbfD3RGfOI0sr2M81PLbH2+OjiOQSuF6 /Gyjb/SKH6KmE2xRrQzd43ITzOIHYT2giKcTbiBo+f70SVHRLq3gSmUv6s13SFY3S3PO1NASAJuRf 0QsynTB3Sjo9SskZetDQ+UgL519HLUw4PT5wxDx035hqiXN3EfAgIHCFhMU5KolSLXbJDE1D9hsuC deJdumJQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:36776 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOfq-0008Cl-1H; Wed, 13 Dec 2023 12:49:14 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOfs-00DvjY-HQ; Wed, 13 Dec 2023 12:49:16 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 01/21] ACPI: Only enumerate enabled (or functional) devices MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:49:16 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_045131_398620_751E52F7 X-CRM114-Status: GOOD ( 21.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) Reviewed-by: Jonathan Cameron Signed-off-by: James Morse Signed-off-by: Russell King (Oracle) Tested-by: Jonathan Cameron Reviewed-by: Jonathan Cameron --- 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. Changes since RFC v2: * Incorporate comment suggestion by Gavin Shan. Other review comments from Jonathan Cameron not yet addressed. --- 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 | 24 ++++++++++++++---------- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 3b4d048c4941..e3c80f3b3b57 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 23373faa35ec..a0256d2493a7 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 6979a3f9f90a..14d6948fd88a 100644 --- a/drivers/acpi/property.c +++ b/drivers/acpi/property.c @@ -1420,7 +1420,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 02bb2cce423f..728649a2a251 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; } @@ -1913,11 +1913,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) @@ -2381,16 +2376,25 @@ 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. Note that the enabled bit can't be sert until the present + * bit is set. + */ + if (device->status.present) + return device->status.enabled; + else + return device->status.functional; } EXPORT_SYMBOL_GPL(acpi_dev_ready_for_enumeration); From patchwork Wed Dec 13 12:49:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490928 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 097FAC4332F for ; Wed, 13 Dec 2023 12:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=I8VGonz99ziONNdUFMZGhxawnqyHjmBPZBs0tX8IDfQ=; b=4F9IGazG117gLR MfIFjp7Ms3B0yahT+7ubnUDQqKtEKY+C8oCG9uMUvcwAqCgbprTX39vROnMfuXAFnM5BLu0fMOsPR 8BPQt24M07mZrv63yrRdzUXtKz0cfPr9kOA/vEqZ7XNGpwJL8lQOLfDceyZC81+NHI1OLhwkWwjMy YkfPEV9cspoznUFHaCdbqH+Nss5joszynXQUsbith+xwZLjgSOkYb0FENjqaSGHr388VfWRcXoegi glJVBZdcLwWfWrn0nxFVA3ngpoeNNbYZxvUzRAbD10JZ6zxp2GWqmibYa18YuG35vrga7QE8mCztb Hvy2W8PMJkrozLD1u7yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOiM-00Eg6J-39; Wed, 13 Dec 2023 12:51:50 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOi6-00EdvI-1V; Wed, 13 Dec 2023 12:51:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+X6RbS8+FdE0yTZKPB4LhEuZYWtnagnPlrAoFbcwPjQ=; b=cohuG+LDvNgpd64HbLmHbpKUXp wxNPAKD5TR46g/lZehPoGpq7YgfCZwNooh/ByyYfKpefpXR22aovnRqW+RA5WU39sX1qqLVh8BcUU 5Oyp825+gDNk6o9i4bApxpmqhlprYwzRvHWBe1G4qqjNvgDLrXmVxXNuL7tARCig7gykj6zvJRS3T iY72a4kgPGGJk4roa71Dwqclee4H33OSkqc8KZf4fj1ho/agpVWByd5HmSjd90KLhZYN00hAE7TWu qEDie8YSn6l6pEn0A/i2aDLiTck5BDTRfVj78USvT8+8H0wMV+gtHVoMS/AKx3eMft/2tK3i6xdSM 4U/yXaAg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:36780 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOfv-0008Cu-1l; Wed, 13 Dec 2023 12:49:19 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOfx-00Dvje-MS; Wed, 13 Dec 2023 12:49:21 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 02/21] ACPI: processor: Add support for processors described as container packages MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:49:21 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_045134_527742_37FA7791 X-CRM114-Status: GOOD ( 15.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse ACPI has two ways of describing processors in the DSDT. From ACPI v6.5, 5.2.12: "Starting with ACPI Specification 6.3, the use of the Processor() object was deprecated. Only legacy systems should continue with this usage. On the Itanium architecture only, a _UID is provided for the Processor() that is a string object. This usage of _UID is also deprecated since it can preclude an OSPM from being able to match a processor to a non-enumerable device, such as those defined in the MADT. From ACPI Specification 6.3 onward, all processor objects for all architectures except Itanium must now use Device() objects with an _HID of ACPI0007, and use only integer _UID values." Also see https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html#declaring-processors 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 processor devices in a processor container. For more information, see build_cpus_aml() in Qemu hw/acpi/cpu.c and https://uefi.org/specs/ACPI/6.5/08_Processor_Configuration_and_Control.html#processor-container-device Signed-off-by: James Morse Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Reviewed-by: Jonathan Cameron --- Outstanding comments: https://lore.kernel.org/r/20230914145353.000072e2@Huawei.com https://lore.kernel.org/r/50571c2f-aa3c-baeb-3add-cd59e0eddc02@redhat.com --- 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 4fe2ef54088c..6a542e0ce396 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -626,9 +626,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 Dec 13 12:49:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E1948C4167D for ; Wed, 13 Dec 2023 12:52:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AJ1lvMiMzIpnhYu0A4aJgFPlBENO9jxub8DY6UfgSJE=; b=rSI2zBJP5Cxy9Z hu1EYJcaE+lHy7cumw+rH9Z5Va27rxQMO4qs8wVbU4HICkb5YzrKzLcryPRTAtiWQDK0L0f6ocyPO ME45aU9EQ5fpZLt+wzZIdRafiM3igbfFMWI2wJHfmQiwUO8bgRSb0hTgI4sTcMiDq5850fmINoc1M j6vOVvNeoq5oDDXIV3CZC6otUvUF2xzebICxnD0alcyC4aAV9qQlVEeakak8C3H/PRJH/S6TOIx20 2/Oc2oyjKNl+RVZDV5Uce4e5/+CyrLi2Cl31k2ZF/3hAaqGcbhYbbvve+C7PnCCb/LBpyhFdwZn9d OO62MtW3Qrg/BBqVTRzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOiR-00EgAH-08; Wed, 13 Dec 2023 12:51:55 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOi8-00Edvj-3C; Wed, 13 Dec 2023 12:51:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=TBP+R/WnvXUfMyTGAeqg+zDZHJCc+YgTDDU9BjPnE9g=; b=ksm1NKE0scGCsyGD98yGeYXubr hB68rislLCulb5Vrhre3UZbE0fxzcZ56LCzd5+Jx/UWiG25ops81IW195eVeI8hCQ5EANLwLRWDLA BmC4J9EmHzrINYzT6DlHEOYKjkDSM0BA4JczIJo4NcTNxODYtV4qUZxAeg1J7TH+VUw4KpKxTHLPz mpmzh+ajIEmyMMSsM4T56yj66lxMZNRqG8qaewbcE/l7g7lRVI3rtAua0Mp747FPjrkKFWvOHFqFD 2bv0xOQ5zwDWdKfZo9UeZUjaRSQLgY0cl+j0aJ56oPkOTkQW4csde5cwMAKUOpa9x8rBSwoAiid2c Df8GEnuA==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:43366 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOg0-0008D5-24; Wed, 13 Dec 2023 12:49:24 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOg2-00Dvjk-RI; Wed, 13 Dec 2023 12:49:26 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 03/21] ACPI: processor: Register CPUs that are online, but not described in the DSDT MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:49:26 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_045137_061466_F862E4F5 X-CRM114-Status: GOOD ( 12.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) --- 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 6a542e0ce396..0511f2bc10bc 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -791,6 +791,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 Dec 13 12:49:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0458DC4167B for ; Wed, 13 Dec 2023 12:50:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Zex2IBQFqv7mhVra89AWLO5nfGFrncXSqCRMuEWlRoI=; b=0N49TOJral6u2I Qs+hx6jV4eH+EokYbdollncDAcXbtGg2/2/fzYHHw+4otRa5owP/PcpaWNHgeaNtJiyzuqeroTE28 gKD3LvqbZSqyq3kuy3e5nBU/GhfVoppckgJbZQwB1MN7AIez9QFK/3scOs7xkeZ/1omAwjPq6RdwT ERHm3dv4Ult+4mr9v1qtRLedKEWjmwPqwWTwk2bU6a2Q+mfbX6Vd6HoIVZZEbi59RzU9ZBV3KXbOX 5Q3XXr7dW0BbM6ievT2MMXCNPI6rs2KQyyikt3chcku3mkm+wqYiBFN6AEyyVW0ah7O8jZ86e5L+G 9eFd6aAszAazIqtqGmMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOgQ-00Ee56-1l; Wed, 13 Dec 2023 12:49:50 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOgK-00Ee02-2e; Wed, 13 Dec 2023 12:49:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZKS6pxC2YYfNhWwg82WjEwf9+rWwSBqqkCpc9wbmrvU=; b=Jf/e7+SMOBjpGIMb6Uk/wbjene LjN9KE/FW0snbFyWyMg6pDKsB+5IvmUU5qN5LnEIjVwaaA5a9S9TaSUdqA0JE4nxCdtkeW6f6yJHb Hpc+dvKih6ImW7DLJIuhosO/yJrIojS6z7MetDq6D4qLRtlFNRtkyCLtoH/8s7HGj46i9aqItRpnM jIgdW7rw8xlYZl80cDI26htD87Prb0hKAY5Up92iSfUG3f3NoIX5VHMpIzaLyhydFkSMyyeXzsocJ lgGarR0gEODrCWvRZO4uKb4MDZSwGZabqarJ6yQTqSXPxUFiSDdq2FTl2Zlz/IElIPZUXQQy49IWc Ci+FbtPw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:43378 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOg5-0008DO-2J; Wed, 13 Dec 2023 12:49:30 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOg7-00Dvjq-VZ; Wed, 13 Dec 2023 12:49:32 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 04/21] ACPI: processor: Register all CPUs from acpi_processor_get_info() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:49:31 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_044944_864915_0BA63A12 X-CRM114-Status: GOOD ( 15.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) Reviewed-by: Jonathan Cameron --- Changes since RFC v2: * Fixup comment in acpi_processor_get_info() (Gavin Shan) * Add comment in cpu_dev_register_generic() (Gavin Shan) --- drivers/acpi/acpi_processor.c | 12 ++++++++++++ drivers/base/cpu.c | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 0511f2bc10bc..e7ed4730cbbe 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -314,6 +314,18 @@ static int acpi_processor_get_info(struct acpi_device *device) cpufreq_add_device("acpi-cpufreq"); } + /* + * Register CPUs that are present. get_cpu_device() is used 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 47de0f140ba6..13d052bf13f4 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -553,7 +553,11 @@ static void __init cpu_dev_register_generic(void) { int i, ret; - if (!IS_ENABLED(CONFIG_GENERIC_CPU_DEVICES)) + /* + * When ACPI is enabled, CPUs are registered via + * acpi_processor_get_info(). + */ + if (!IS_ENABLED(CONFIG_GENERIC_CPU_DEVICES) || !acpi_disabled) return; for_each_present_cpu(i) { From patchwork Wed Dec 13 12:49:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B5CFC4332F for ; Wed, 13 Dec 2023 12:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vUL/Mr7KdcyZjURy12TIOcWZHTpf/85jyr3h+yEKavc=; b=FPiuLLdskDBkGE fNLDtciMJCk08oZPAefExBMZXn+37kHGu9vGf6oz/V76COgmSqLfaF9c8EbrDYabs83hABcdwgv9e 597ukA8CM9duphuS4+mB0T6RYX3XVOV3u2xkjXLLlK0DkEABefucR6/ti87JyMWyMjUDc8MBQDf1K lh6UfM+nHRqGZ0X4jAsZqLLuEQHLmcml0C9RyjV9EzBSC+vNhj7SXAvSHKalR/vccyd8fFRxnmQ5t rKSu74mA+GHZhA4g2NY+PSOec5lruEkEVXqg4lQNHtYetYJlYkTtHfJNvCROZI6iFAZzi36iUOekx fcJsmsF45np3u8aZ++CQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOic-00EgMj-0v; Wed, 13 Dec 2023 12:52:06 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOiI-00Ee0b-35; Wed, 13 Dec 2023 12:51:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=DDcdVazneM/u7wMj0E+j+LVt0/sG+/pUc+Ol6c0oUAM=; b=o2knhIkwo9iXzfmsPtqSYX3GtZ 82mkAYgR4tZL2XDDxQhWg2TXvFkydzxSO+QtMU6aght4+jecATwSJPaT6MOwZeS2Ar+iELpliTHfp fCdlENl4Al65j5dZUj6eh5X8CVOib3wPeL8+uRxbxXBGCLYKKhg4H1igrdD98NeZssawKNbd44Y2Z SL6LFSQIHbW0euxInaGWgMRpmE7cVcBK4FS/cpANOuJLiiRfLAbQJenZVhnVlS5Ce7og2+qK0NJpx VrHNwjSHqRrWUHXwJj3/H/VjCIzjKpqQvhqJJPgpkfimj1TGxDLx4y3VzkfdM21OZAwUSFU/cnnPj LT9Gj5Fg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:58164 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOgA-0008Db-38; Wed, 13 Dec 2023 12:49:35 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOgD-00Dvk2-3h; Wed, 13 Dec 2023 12:49:37 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 05/21] ACPI: Rename ACPI_HOTPLUG_CPU to include 'present' MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:49:37 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_045147_200495_C51791B8 X-CRM114-Status: GOOD ( 17.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) Reviewed-by: Jonathan Cameron --- Changes since RFC v2: * Add Loongarch update Changes since RFC v3: * Dropped ia64 changes --- arch/loongarch/Kconfig | 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/linux/acpi.h | 6 +++--- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig index 15d05dd2b7f3..b1e87b90468d 100644 --- a/arch/loongarch/Kconfig +++ b/arch/loongarch/Kconfig @@ -5,7 +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_HOTPLUG_PRESENT_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/configs/loongson3_defconfig b/arch/loongarch/configs/loongson3_defconfig index 33795e4a5bd6..85d37b143077 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 8e00a754e548..dfa56119b56f 100644 --- a/arch/loongarch/kernel/acpi.c +++ b/arch/loongarch/kernel/acpi.c @@ -288,7 +288,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 @@ -340,4 +340,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 8330c4ac26b3..64fc7c475ab0 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -59,7 +59,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 1a0dd80d81ac..33d259ddd188 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -826,7 +826,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) @@ -875,7 +875,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 a3acfc750fce..9c5a43d0aff4 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -306,7 +306,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 @@ -400,7 +400,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 e7ed4730cbbe..c8e960ff0aca 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -183,7 +183,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; @@ -228,7 +228,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/linux/acpi.h b/include/linux/acpi.h index 4db54e928b36..36071bc11acd 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -301,12 +301,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); @@ -629,7 +629,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 Dec 13 12:49:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67B75C4332F for ; Wed, 13 Dec 2023 12:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=82OeWpqxSnTdk3GTtJnlMK2sPjRlcPF/e2PNE3rj7g8=; b=GD5CVDRb0r8Du4 pQD44O3JpaLSDfMriyQ6SttPRKfF7DzbOzdj1aNrt5CpQvOcbXwcpWc8SHjPNRUyz9yC/GiUg8zdJ N7ke5kBx2BEVzut+PuIiKMqfrZOhsD4BDkSkrhw/g0AlmM7IuSWtEiF6j7FwIk0nwFe7m0W2sRVKz zPfkhvBzM/5mWYedalYhd/4Gt5w69V8jAjU7RmCIw49flWcFdj9uqthqnXe3GXtwLBNE4foFUXt3Z viCa+2poN6GOjgNQNDKrqcj0euFcOCYuWozPqqmeSDO0ODPobA1jK3BCp5xY2/DUEV5B+V9ZBpEiL 3RvisISOkWtss9Jn+cKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOge-00EeGs-0f; Wed, 13 Dec 2023 12:50:04 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOgR-00Ee5R-2W; Wed, 13 Dec 2023 12:49:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FKb6Tx3YWEOt6/qzVEvWhIjmqk2GL+umifX9jwivsXw=; b=iPvbSxdOfLSl0br81MW2NrQMOg 4nPsPkQ6ioYh+vwRKIq9OpJY4QNbTdAEf6GB7UFRf+0gTRk5MUgucEOiziY+kSkHDBeecdmVC8B0L c6iQFU3lqZGH+FhOPFH5DIaUTmxXQHAr+0C3VAy4iaYAOkdkF3rqAzn+IC0fTLIgt6WA0V/3sq4ab IYsKHfp8ZW0yK2+ANMrXtips/qJLG7k66jsh+v5euH+fL4b+DIbk9dCwEb4CwhL4VF0uIc6EOdVbg LPmQFlHnNCj8LzfaBO/834r6i5eLm1HnJTfNpwNo+FvjLtsHdn03Q7KZZmRTnOyrzs9wvIsgJcGfd 3rh7MbNg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:58180 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOgG-0008Dp-10; Wed, 13 Dec 2023 12:49:40 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOgI-00Dvk8-8X; Wed, 13 Dec 2023 12:49:42 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 06/21] ACPI: Move acpi_bus_trim_one() before acpi_scan_hot_remove() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:49:42 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_044951_854206_580F2A0D X-CRM114-Status: GOOD ( 13.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) --- 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 728649a2a251..ec42fe9d0611 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; @@ -2513,44 +2551,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 Dec 13 12:49:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 118B5C4167D for ; Wed, 13 Dec 2023 12:50:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QuyeSYiZJ0491NwnoZ5m4IE1pyIPtbl5fCU7wtXrZ7M=; b=2/+R5j6SuOb8l2 X/oeCl4TKGmGwX3nlbLNIhJpOsTagEFsFVRfuxRMXmyU+XSZrODILRMcFol4Fo4E4zlKuPD/WWnlh tz9O7JbbciR4Q0tiCXd0PKrXFmFaWAhd9JDP369Z4N+qTApNmM+Hr+qFsUVUCg3W3xREM1J+ibsTc Y/LHfaLt5kJ6Q5HBn5KpmTU83X9iaIRYk21K8oYET6671Z+GFyo7Pd7c2LzFEuYdc/nW2QIdCnpFw ls1PX9Yf3+4tbAeK3WBUdMiZTiIxxz3Brq46hH0ddQB0hosxRv7KR5U38ATo/QJc2ZZFHsAeOYM9o 8q4eJ/kN47jbNz0jLA1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOgn-00EeQi-2o; Wed, 13 Dec 2023 12:50:13 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOgV-00Ee8d-22; Wed, 13 Dec 2023 12:49:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kQ4xjAWUxEG0ANx7LMdmdHmPUnFC4tC8apeLWjcG8Og=; b=X90FTAwQnBfHmSIKYLsWfRlpia 375dpkt1T6mkAwKyEadpQymyIe0dg3/p2GwJurKcYd8p3XZRGklvmexrzgscGSrA+E2Yv6aoT86MB ijJOedBgttvzTKBfT9eUkiHEXrz2WuPlFfeI4lj+ac0nHIA6yBoKCgnau1V8tzQjrNKo+vgA5IvnG HYzMibJAtMCmVnc6CLNbKTEpSs0Y0S0suWGF9Ss1Gsl3tCiP/+CHBou3NEzC+Zl6kwj+tV2mTQjT5 04I/JuGQif9ZoTv4TXeya3FEre5X/d4oNidSnw0HnoEtJPLc0iw3ZdEBkG4oHPQUXpWCCbPO2kXKc nDBjPYQw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:34582 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOgL-0008E5-0Y; Wed, 13 Dec 2023 12:49:45 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOgN-00DvkE-D8; Wed, 13 Dec 2023 12:49:47 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 07/21] ACPI: Rename acpi_processor_hotadd_init and remove pre-processor guards MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:49:47 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_044955_675196_7646A0EB X-CRM114-Status: GOOD ( 16.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Reviewed-by: Jonathan Cameron --- Outstanding comments: https://lore.kernel.org/r/20230914151720.00007105@Huawei.com https://lore.kernel.org/r/b8f430c1-c30f-191f-18c6-f750fa6ba476@redhat.com For this comment, we use IS_ENABLED() in multiple places in the kernel in this way, and it isn't a problem. --- 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 c8e960ff0aca..26e3efb74614 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -183,13 +183,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; @@ -223,12 +225,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 36071bc11acd..19d009ca9e7a 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -301,12 +301,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 Dec 13 12:49:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC986C4332F for ; Wed, 13 Dec 2023 12:50:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3kNzgRZ5R155rHu5MpP3LRaXEHGkPrpi10/fS4KTNFs=; b=Jdsy+j3zxAfrC8 LIwP1sbvrfmjBVGjd4kZvlA9ZapNCc02G7y393uBCtTK7O1ypSx02+iSNF70gOiUhK7L+uAahPujC c6SHqHp8nLYthMollb4vjFLLagJkKYWAKajoDqxQ52AvldXr9wWUVSIziuyH3pGNxvg3/reFcWBqM Nvfr3iD/GCsVSQUWk8LpMTNRk54MfioUnAS1Cfj/Ru07eHDKb7on/L373rw0YYLnXpp2vFsmePvW2 7hq/ZxyePOdDBRrbcal2piMc/qX6oaBwhhGGMsnZyu4FnPgdLNshQa9xnSUnl440/2Vl3UTc042Ga s5vDpNn3PQzU2jDiSWaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOgu-00EeXr-1u; Wed, 13 Dec 2023 12:50:20 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOgZ-00EeBO-0v; Wed, 13 Dec 2023 12:50:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jXw7/CfCQVwnxBpa8i2NRb554kmnX61q77srRq2J1d4=; b=p1cs2dYFtYjWzhMUHafGMe3bf1 IBGszah/noeMODL/i7ZYeX2VOMc7FXiwBSG7pcxRGnZhOfoDCxI20cu4EHlTIn9RlDwgMDixZ3m/W rwugQO7CMEQOecDyhn/CJ/MLXhg800KnpCVEEGx9zbp7n6zUXRoD6JGkWIMi9pMjNlamBA+U1Gzri Gb11IzoqcZb92O1w4McqB0jgsqoWOnqFEU2kuXTihTAJc2BgJdlp7fs1GqcH2PMD9FCkg2tIrQ6+t siJvKs6TtiZMyskwe5oUUlQchHlfQghNqUo6mUQ1QXTbOGkS085OMTQBpEk+MrajgHTszve/RkHDM QnuC3dTQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:34594 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOgQ-0008EN-15; Wed, 13 Dec 2023 12:49:50 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOgS-00DvkK-HR; Wed, 13 Dec 2023 12:49:52 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 08/21] ACPI: Add post_eject to struct acpi_scan_handler for cpu hotplug MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:49:52 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_045000_406556_29BCA160 X-CRM114-Status: GOOD ( 20.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu --- Outstanding comments: https://lore.kernel.org/r/20230914152809.00003152@Huawei.com https://lore.kernel.org/r/c3ef8123-1fcc-7289-c475-c753de44d564@redhat.com --- 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 26e3efb74614..b6f5005985c3 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 ec42fe9d0611..6ffd65e9e512 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 1216d72c650f..c887c2dfc5b5 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -130,6 +130,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 Dec 13 12:49:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490916 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D53AC4167B for ; Wed, 13 Dec 2023 12:50:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=q7aZ2bcXChzj+UYJMHI76bZ0eUmxnoPBcommxyQCi5M=; b=wUGP9CDJtZJGXS NMUMhyjo6/0svlGODBslo4+y82In8pDPBF77JwobBr1jccbmY5WMRFRW8jOO6HyxECEcf75hlkYau zh8CzaPO9ocPHn4EgkA91zCBofohq0zVzo4/XLJ04/xCCqrV8H1Iubpc/roxemADgEvR6wIg+dXyr e1rDmtBZEqvUKiXdhn6likf1Yb0sZSeA6EYqbjuoAm7zUwhLWnhx3utrP6YXiepl6m1XQ7fUDerGb twU3l5hRMn2+syrMSr/QKyZ6D4ZK4ppDkM38Llwo/EzG/5NI3Ma0DYJXAwfPUUk735YxJUJHaPKcR kEJM/WXo3ZXmSVEpnAUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOgw-00EeaN-2l; Wed, 13 Dec 2023 12:50:22 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOgi-00EeKi-2F; Wed, 13 Dec 2023 12:50:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oPeme1Idl7Or3jdMYkiOWAf3GphaNVmJTG+4LYE0TBg=; b=AGYycIJJ1HK/RXsJpD4nE7Zosg WJHYKYmLu98XkzqmJxjN/Ejtq/87JEgiJq/3fsU9u2Vd0hVEkWMPHhvaTrGlWOQ+97ar8oNzGWutu zwVgUDd3oP50s85O+DSifKJCgZ0JIs8pUWOFCFqGeW6fnNa89FFJLrhiU78AxYABi2PgZ7OnVC5c0 mPqNLJhbC8p01YDBwk8YMbQ1VHZo97tq6RvwJNYezmZ++MFgEFBeOtxkMaRAL3gitdNMUh43SuFR0 nzuNl8YomZk5pxXIBUm73pO8DiZslIc/orjfmoZgpp64FReJp0wHLUanvPkpT2mDNEgsjhJ+AqeOb RDyeENMw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:50920 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOgV-0008Ei-1G; Wed, 13 Dec 2023 12:49:55 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOgX-00DvkQ-Lg; Wed, 13 Dec 2023 12:49:57 +0000 In-Reply-To: References: From: "Russell King (Oracle)" 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 09/21] ACPI: convert acpi_processor_post_eject() to use IS_ENABLED() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:49:57 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_045008_742978_4B12FA37 X-CRM114-Status: UNSURE ( 9.28 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Rather than ifdef'ing acpi_processor_post_eject() and its use site, use IS_ENABLED() to increase compile coverage. Signed-off-by: Russell King (Oracle) Reviewed-by: Jonathan Cameron --- drivers/acpi/acpi_processor.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index b6f5005985c3..01c460881662 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -457,12 +457,14 @@ 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) { struct acpi_processor *pr; + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) + return; + if (!device || !acpi_driver_data(device)) return; @@ -501,7 +503,6 @@ 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 */ #ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC bool __init processor_physically_present(acpi_handle handle) @@ -626,9 +627,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, }, From patchwork Wed Dec 13 12:50:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 840CBC4167D for ; Wed, 13 Dec 2023 12:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zLsO7eaAO7UgBWK/QLDRmXEzfyGMeO/zwDyYkLrYCDY=; b=jRfXCgmy5IHQGz ibck3yiLTBV4u4XSZfR8WrLpNUliAsfcqC/e09DB/evQ83v2DxZZObJZRcL0ApIXdKpksW5B73vNe v/UXmnH+MWNbA/LeeJ86fp6yH3T0cDeLmKMNnUKWpeKTgJRrC75zSBXXl44JVxNk0t/44DqfspJiP oWp1D69uL6YjAzNR+MvRmOehLlbAAOJcjKQj5jNscm8O/unzuvKiF7DCgHrZF0RWDVMDKjY2GrPLq NEfHPNTlJpwq/o8JwlUB3CbfaVRM/Jy/qmHyrTscsgLdOdp4PUak/SxdHD2etx7xPQX2JWDBD9SmV y6jAulJlh4seszFbXTZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOgz-00EedE-1g; Wed, 13 Dec 2023 12:50:25 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOgl-00EeMt-01; Wed, 13 Dec 2023 12:50:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+T8kn3k9b5NRBjWSUweuCxqkK4fxT1FVGeJHMIqvr6c=; b=rkyEttm/kwtrIQTS1tSEUUuy10 b9f4MBsDpOC7fICaT9EKK+Erd3u3912ckPVBYTTp9qSDOl75HckFt2qX6y4YCvnlnnFH14GeyAlCD Li+m9IPqogcUFaNQ7kQHxE4OpBhAZYtFI73RMlMLVN/fOwXSoM636lHWmCwWwcFfIS24kketvfMg0 EU7oxLVMKZRpauGDtcKWJQe8L2+C4eMsQ9rGXcJRTKtsWv+vOvGMNbx0tW/5qZx4LHU0G5Ov/QN7B +CzbJp4H7r/dgAdh7yyBwxBVH4y/8nMxcj74KZ3bUuRotM59px0g35yT9z1oC88KgqotI5CkI10kd HXtcF17Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:50928 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOga-0008F6-2I; Wed, 13 Dec 2023 12:50:01 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOgc-00DvkW-PZ; Wed, 13 Dec 2023 12:50:02 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 10/21] ACPI: Check _STA present bit before making CPUs not present MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:50:02 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_045011_133861_F1817ED3 X-CRM114-Status: GOOD ( 13.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Reviewed-by: Jonathan Cameron --- Changes since RFC v3: * Move IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU) into separate patch. Outstanding comments: https://lore.kernel.org/r/20230914153110.00003e38@Huawei.com https://lore.kernel.org/r/518859b1-64a9-d723-963c-56c7f6fc2da1@redhat.com This contains a repeat of the IS_ENABLED() issue which we don't think is a problem - but there is another issue mentioned in that comment. --- drivers/acpi/acpi_processor.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 01c460881662..19fceb3ec4e2 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -458,16 +458,13 @@ static int acpi_processor_add(struct acpi_device *device, } /* 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 (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) return; - if (!device || !acpi_driver_data(device)) - return; - pr = acpi_driver_data(device); if (pr->id >= nr_cpu_ids) goto out; @@ -504,6 +501,29 @@ static void acpi_processor_post_eject(struct acpi_device *device) kfree(pr); } +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) { From patchwork Wed Dec 13 12:50:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 88721C4332F for ; Wed, 13 Dec 2023 12:53:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=S1OzWEyPem3I0fq+10Hv6Ro1SmJ05Qh+wd+KIO3IRuo=; b=0X07NtmUTdYwA9 lmVRb80LHcgEyysnM4ci8mySfDHjyi0Z4ctsTse2ZCxdECx9T6qvug6CtGjYU//GUN9TRxxuiJ1Sn ki0/0eKvpQyNuHvSmhPBdBi2hlTBFj1cYONbi6kSGl0J5z6ynYMndUXf2Gt+a2HtXcSOPPz4eghny OBcwp6LuBUYdCostnuP7biU7cKnflkK3aTEcVrVtvrUDBNB07A3B/W131wIHqYO0R2ENvcTGk94a+ s/1gknv3kutSxuHHwbpAo+8QeqcttwD5zw0bxWpSku//7Te7unRB8PbIMwjG0skP1YpQwB4LP+RhC KBnYqozhrGflJgLiVAOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOj8-00EgsH-2U; Wed, 13 Dec 2023 12:52:38 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOj7-00EgqQ-0G; Wed, 13 Dec 2023 12:52:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description; bh=xRMKGWwlt+tDnJgmpjIjTzFwGAKGxwsQWsjqqxoBgt4=; b=RAylBw/g8Cf5WlazP1RjbjBu+r im54Kwi9lVQRRG9JSaGf5NFrFqcNdqag2k1RsqNLjsLcwdup0o+oLRDD6aF3GCTf1dXW3BKq3JWOL xd8Ul2RR8XPN8tD36O1GOqmbzdCNv0f07DKLrCHUgHlAYk1T31NdKuNJbWEf0MtLJqcIibuOj2Xgu nXem9nHgN9YdhLd5TK+TK+BQT6lDDmu6wcI6PT+1BzCQmaMpsDoGyCp1JJChgz4OD9MnlWj+yXKWM OkSuh5EdcJWhtzmdOoM10BSnbD+7Cuj2ogIW56U28LH4sB3kGjCe9SgB6nGh1YlvdSsTiMSSiX4S1 sFmOyShQ==; Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOj3-00963n-3B; Wed, 13 Dec 2023 12:52:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xRMKGWwlt+tDnJgmpjIjTzFwGAKGxwsQWsjqqxoBgt4=; b=sAvIu/KfdRhiVQLQAzi1pftBLD AZtA0Hs5SOUW3Khxxl6f/hWMpFepsEJgQyGqVCXf2J6iqPGh1irYe61lsvzQauQCuuk+uH3FyHaw7 AvzGgWM+IPItC0K7GAs/xGD92ORf6Skc8i2iWAeY2h5KaO3CYUXJv5yEt7Urk6M+uQaQNv9JbUQDV WhUE9WkIHa4o1Mu0hFaS70ASAxlzFvPz/G7aA7qW+OsLl7PvjXZFeIE6zhxGyqU2kqJAojzd1G5ES +rzSzq86l+CfY2K8inR1g8Pu6l9z/cbz6RWLKJk+7kIqPgRBox16Ks375iUFf7Q9Q5zjcipcX2OP+ dwCo2UTw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:57402 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOgf-0008FI-2J; Wed, 13 Dec 2023 12:50:06 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOgh-00Dvkc-U3; Wed, 13 Dec 2023 12:50:07 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 11/21] ACPI: Warn when the present bit changes but the feature is not enabled MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:50:07 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_125234_232655_565617EA X-CRM114-Status: GOOD ( 12.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse ACPI firmware can trigger the events to add and remove CPUs, but the OS may not support this. Print an error message 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) --- Changes since RFC v2: * Update commit message with suggestion from 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 19fceb3ec4e2..b7a94c1348b0 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -189,8 +189,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 Dec 13 12:50:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13491057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 22927C4332F for ; Wed, 13 Dec 2023 14:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=M36hRbGPqDFWClKoe4kmsU40hotaC69XJqY5sTNnPuU=; b=Le7+HURf2XDO1m Vdy21C6lAn9yjAaRLc8er/pPm1y/Qo3WsEBp28x4H0WDqEBCsx0ZjBNByTbvL8G1bAtt2db05O/By vkseIvNW2XinfDaJ/glNSAJA6SV7AJlwifpGJlAFkuHxrW0KNnSHgseKJpz+lonNrdkGVZRoKvtd6 SLPq1HArjpu1tHf4AFBLGwDyv4kzUg0X5YWVWLaIFvujJkj6I29ozUW/6wwOrXDVWtKH98M31vO5U G/GHASuATMlILh41EISog4h43c5QfgGpRd2G5infHXTAfKwvZndTvTQ7z8oWchhf3oJ4Cdxvr0JeM TzWjtB8l4217c1zKpXLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDPnk-00Evzp-2x; Wed, 13 Dec 2023 14:01:28 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOgy-00EebP-26; Wed, 13 Dec 2023 12:50:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=VN1zuZPFpZjLLP0E5DaIC2d1rUW/6DV9Td+xG3o2+qg=; b=D1oe/wUW347yc1kOtGSkPh+NwF pSCntHs+gy+no5ciu7dgJn8Dwp7ORYjROsmBGp2LxhmqGuGHNBP1aZV4OFlEC9LS/kkNb5k/WLv0D mh8mN34J76pSZrqKTu/t/Yy4YAK2i6WxDzVJVCIEvI90776a9cz/NI1sAPKu3ritagRuRdxGFqiRV EFDmKmn1xkbQg+qk0w/J584QQZcCvychU5lpTdyK4uDeS0SBGUzA+NMnOOnzXzgm4BLxaVVcBbXvT RRU7paUGEeifLGjZXvZ7Z68W8gZPslrofMMxzTl+WLoI4SZHMi25yNHGhFi/ON2jM6106rGDwHUeH GzKOJ5ww==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:57410 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOgk-0008Ff-2y; Wed, 13 Dec 2023 12:50:11 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOgn-00Dvki-2N; Wed, 13 Dec 2023 12:50:13 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 12/21] arm64: acpi: Move get_cpu_for_acpi_id() to a header MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:50:13 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_045024_715027_24F13482 X-CRM114-Status: GOOD ( 11.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) --- 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 6792a1f83f2a..bc9a6656fc0c 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -119,6 +119,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 Dec 13 12:50:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A32EFC4332F for ; Wed, 13 Dec 2023 12:51:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Us/OWgf6x3MfUjQf3trpirxjxyOTogGg9pLY/mcvwl4=; b=kGxDTKyKfdrReQ Mtxp3iISmcoRNNvVD0SV90n6kuyUTvadvNiuEXTosQB4J28ofufcffJ9deHSpalJP0QdcdaR1rrKr L3pFWnWpzdKLzS1pgvwk8fhFIvlIWMRrshbSOctXP0ClJSOq0r4IQpt+scjrcR+cGXbZo/xVb3xsA WtWChC7DVLSPlPvtKL+wUyTxc7jCRcSUs6oQk4EqHdEWRngWnA3LYhpLwonGZZ15awWYpbyoWsmjU MUhIJC7pyG+PQOda1IZ+7yvJNA+U/y4hDMLjqtSIjOx2xHYt/I6vKj/gNaed67WoMZ7VIfNwrHBDH kxjkWSc1CdAFoB8kzrJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhJ-00Eev9-18; Wed, 13 Dec 2023 12:50:45 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhF-00Eeqm-0C; Wed, 13 Dec 2023 12:50:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description; bh=DnFY2Lrn3laRjR0dFD9DsIQAz620A4pU6zpNT78Use8=; b=Z/YHxhjFjIG628REu/2ZHWz5OM XYctAIdQAfk9oDirh95kcT6IUgxAKejLNwwY+6Jp5QGF+n8puhSz7zwE2AZ7PmF0REVZJba5LL3gq VwCPd1LfLFf4UaABjGnSIomoCRgqmMLajBDo5f9YSR7fl1kfqZvnPEr1BhKyb0XOGrCTZr1p/rS1T da/nA31XJJWBcHftJvUSJE9Cue3PNY5f7auUUwpRgb1JnT4qawe4AHtQqFmlq8KeNKtx6tdU1vt2q R2uMx3xxt7W0PtKP1WiFhCJjxcQdSUuv/zHTOLZmfz35ofouoLKLbdEpxwAOI5ZKBFgV5ImEwax7T kXbERvJg==; Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOh9-00964K-1m; Wed, 13 Dec 2023 12:50:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=DnFY2Lrn3laRjR0dFD9DsIQAz620A4pU6zpNT78Use8=; b=AsjeyEgF6qrzJzab3wkGeZcEwz rQbT8Tw9ttXnjWwBGSCpduVsdyCslNTtuX0uB4lOWLn2A4DQGf8kQ54y0eQssun1EYJVaEjWIl9+m pSqtSsZYzlpMk6x1cEk4OonnO/nvQhZCTzAnt6bk8eG11xPN/bKHuFd3QTGhNZKj9fdYNDgvvT6j5 KjXoS4SJ3GKYkLPAF7X0EkDMoJdVgIbwj0bsR13/aGe4cetcTaI0cBPZMSGQ+V25Klu4Ppx6urvC/ eKcbFBSHX4L8zY9q6CIQ36XIHBJPW92Q1bOt1cleQ9a1mRdmlhqi3jF3ZqX8pqXPmBYM0zM3WXTb5 2ou+awpw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:33732 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOgp-0008Fs-39; Wed, 13 Dec 2023 12:50:16 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOgs-00Dvko-6t; Wed, 13 Dec 2023 12:50:18 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 13/21] ACPICA: Add new MADT GICC flags fields MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:50:18 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_125035_789042_E8556319 X-CRM114-Status: GOOD ( 10.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse Add the new flag field to the MADT's GICC structure. 'Online Capable' indicates a disabled CPU can be enabled later. See ACPI specification 6.5 Tabel 5.37: GICC CPU Interface Flags. Signed-off-by: James Morse Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) --- This patch probably needs to go via the upstream acpica project, but is included here so the feature can be tested. If the ACPICA header files are updated before merging this patch set, this patch will need to be dropped. Changes since RFC v2: * Add ACPI specification reference. --- 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 Dec 13 12:50:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490918 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36637C4332F for ; Wed, 13 Dec 2023 12:51:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=aYqP1Amuxi/tpEZb7dfd/NrgQTmSJNB1S/zjMVyLmvU=; b=mBr3RNAUgWtONP RPSPtk83CE1Jcd1WpbB50pRmULKDwU8rSeNTsH8Y4WKYXxJpJdUdyS8oQaYSAF4/jiKPXV3ucFnPL h+XzvVTESDPuX3gTpzuUlX3um+zMBQba/cIKHEsKPUKESXB8zxrq3DPzMl0e9j5f3vIg+YC+x+w28 0gV1JI5CXDC/NjglDL21Cxuq+KtKSlScgp5sNVoPPH3Km+ct+BlCcwN+P/IS/bDJdde9eAzlM5WAR rfJ8DRpQ30rvVzozg1NrTwmkO5NV/K2abVQP4VQRhnbnI90D0k6ckHTSCFI32lqBWFJZh6h9pcfK/ T+fEP2WVxRpBy2yfKcsQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhL-00Eews-0S; Wed, 13 Dec 2023 12:50:47 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhF-00Eeqr-0s; Wed, 13 Dec 2023 12:50:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description; bh=nlbHQpsJ2mXYVNzTjHiHy20VvNm+xTIYOL47lOBS/vU=; b=V+/1wo36KSWGuHKziqfgXpxqXI Yvo+UQWnwjFLGWUJ9zb3hAb/fX7FWU0KkdwNVdfUcX23PBR6hdcS7TN7NJPJesc2dH1uNdUF79Imo VzU9ep7PdVQxXAtApHa3H/0d1V31J1riceE8KkUEeXT57hr9GR4K3FjIV91pHwUsavKV0iZV/nHH2 ix1D7rRvBVhMfZhIl7RyWZkRWKYxtjGdeoRN+4Ra1Hz848ix40gYCkdkbUl8MYOTBWsNG75n9GoRY JPfHzT9dg12UjrKLzAFTsGGjsUHlmbX2zrcBzoKQ/Tcs4cX0M7StISLi5IlEzDr9X0meYRUC6AfBp 1V4vx/oQ==; Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOh9-00964c-1m; Wed, 13 Dec 2023 12:50:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nlbHQpsJ2mXYVNzTjHiHy20VvNm+xTIYOL47lOBS/vU=; b=NxjT/a9log1Qg2/QyYTC28lXRw Nb9PdozexRLxTReLoLYO2nPm/U2CtaDlf+9iRFgmUhORHcWBDVCDEmOfIsZ/HBQqtNBv2syvGX9sV vSB+ayP6h5pwY6jETJUNe3RmtaiNKcx8QfBN2h/Xh1IM03S0O5bhesS3qtkU2C567Y0tXYCzHjnoz SKnotxGSCp10T9ulrc6Xvm96pwTBhdssvD2Zwqyl9X62ZMKA2SXgWyqpWB2ifAuwftFu6/bsM3ibG Su6rLni7+lTJqAXf41O4K0yuwixYKidf/YEBvSwcuWzVz/QMW5sTleuqzkZF+ksNmUAYp2bFDclj4 OQBX60Zg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:33740 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOgv-0008G4-0b; Wed, 13 Dec 2023 12:50:21 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOgx-00Dvkv-Bb; Wed, 13 Dec 2023 12:50:23 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 14/21] irqchip/gic-v3: Don't return errors from gic_acpi_match_gicc() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:50:23 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_125035_907082_DC4E0AF8 X-CRM114-Status: GOOD ( 15.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) --- 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 98b0329b7154..ebecd4546830 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -2420,21 +2420,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 Dec 13 12:50:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490921 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA718C4332F for ; Wed, 13 Dec 2023 12:51:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=q3LK+7Oq3/vyzSQFCC3Wio8ArXk36yxtYedqybntcRE=; b=HWxScPGWj9w2VG NpdDoX/duUJKGzUOi4zjJ3Nbv6sDVXcYFl9G3sYEmgsrMvAzVDlo44f+B2i+Ox378Z9uegnOoYYVU eqt1mOY199fGsHocENMOYTZzUCpEvU5l1teeUr7LXrRkkvhEseWM7g2WasmkuJ5FOAbcAKFoLOt+Z JObDSIG7kPleapndZBKwPcaXuFWHcuVUtKTMw+M5hFzf8nwr+bXZRLVa2egw5x76aJjkCOMskqpx+ hPPqWqubsqZiug1ko1+urQt4/zlBZiPHW9p/naAwvxGSqnJ9BCKdk8iSR0XO/wfCgt6ryA+vO7pjX j2soFyT7M/N6AIynTWXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhS-00Ef4N-1U; Wed, 13 Dec 2023 12:50:54 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOh9-00Eelo-0m; Wed, 13 Dec 2023 12:50:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=toielIZHns+JJqGdwW2Er+9+wyZ/FNy7YC4xlMkof/0=; b=FuF1YeT++Jin3KgRrWcSzJupOG 0HOKnlnAn4rO5PAD2r+eXKtzTLzlJ4inML+s5IXIlItQJWuhjlEz05y1hwOH9KgLBRkHUkaSj+FPh bBjtvh7/mb6icsbs5fcCAwZPVFhBfOKX1oN4jYsTJAAcVzS721QIS3SUDhrfMX9yqKiuEbC/rRB0Y 0tlbZv7aWhdUhiUOXkTBZ9zLDIg527ZWtteePC0ko4AohNoQgmh+g84wwZZcuLSgTicKULYz14oBA C6zvXCmsCE/RFcNtXx9yCnXqfBYeKzKOWLRiQHcmU9zMy1efW24j7stwbuDgpj0vlSho/wQekkF8C mw/KxqHQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:50064 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOh0-0008GU-1Q; Wed, 13 Dec 2023 12:50:26 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOh2-00Dvl1-H6; Wed, 13 Dec 2023 12:50:28 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 15/21] irqchip/gic-v3: Add support for ACPI's disabled but 'online capable' CPUs MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:50:28 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_045035_300336_51444F38 X-CRM114-Status: GOOD ( 18.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) ---- 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 Changes since RFC v2: * use gicc->flags & (ACPI_MADT_ENABLED | ACPI_MADT_GICC_CPU_CAPABLE) Reviewed-by: Jonathan Cameron --- drivers/irqchip/irq-gic-v3.c | 14 ++++++++++++++ include/linux/acpi.h | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index ebecd4546830..6d0f98d3540e 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -2370,11 +2370,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 19d009ca9e7a..00be66683505 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -238,7 +238,7 @@ 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 | ACPI_MADT_GICC_CPU_CAPABLE); } /* the following numa functions are architecture-dependent */ From patchwork Wed Dec 13 12:50:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490920 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 32855C4167D for ; Wed, 13 Dec 2023 12:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LbuhzRE1XK8P+LKr30a/gbPJbdTKkCSf2cc9yOn/euM=; b=fxvlS6Z5rtnQEu zbIXLNWlv2wnX3C3e3WS1eX1LHvzmj1/ZNGoVGEj4bXZyqAhEd0J604euniMAqBsM6dN3rz++bB1v 7PCBYnjElVWymSbH9LXlLdHE84gUEIzus42f5OHa0XDCO7eRHYxj7q9T/9TF125+2wj4R+JxMtYDX aTBptr6nTq48iuEOXbXzaEWjjOqCxdUZgx2bxNa9kCHrlN1vLYI+wOQFA1YDYyAlgYvT49SoXzfck LvntCwKT+YZDh3qOHSkjAQeupBTLrDJBIoyf+0/YIUVRAK+0J0qupPQibfH2HLxnlaGbKtgbFVh19 ZgH7Kh2IjtzqFNz2tmVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhU-00Ef75-2F; Wed, 13 Dec 2023 12:50:56 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhH-00EetU-2w; Wed, 13 Dec 2023 12:50:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description; bh=CzUDlXDbVRENX5I3t4jDtWhqIqX9ckshZ8M9DQwNtkI=; b=pHtbl7iOqeqwD2XFf/yKviGOKH 9+7d8rF0+El1Ez9w2bGm4bnOP6+lkE/ijmC6UQfypuCbmPGFJkc17Ne9QJqsJ811oOEYdwLUbRq+s jMO8AoqXBK/0UsGwTdXcnuceXNDFBC90POSsUL7jJ5V6yWqpbP0AcV4w+OdN8OMBTBS4ibqVqKjOu yEXuVsVHNy81/HfwuOo/25mQ2vpz8elNOcQN4gSxLZ0tAmxwhDajTy4kbQ8wDz76nAuW2jfHTgQO0 i8eTy8a4uu3g7WgAMoB4eYbmtNFEl/8ChTL59Bq1cNNhsc8c639nqpIEYFSUwJOtGmwTMc6jrTWBz 8DLX5NIA==; Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhD-009663-2Y; Wed, 13 Dec 2023 12:50:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CzUDlXDbVRENX5I3t4jDtWhqIqX9ckshZ8M9DQwNtkI=; b=ryyhQHuRHb7agprV7SzAPCOWs7 +KSXGolWfQxBz68idh9LhxWZ4JzZ71clasxJMQDmclWim/lWLX+Gb1xqGHQ9n3UU4aTI4I9d13qgo hj4BIus5sr1uZgPAKqSg5BR+qboNz0g2L0iDXYBeGJ7lvBRoed+H+5R2YFjK8ueU93g8YItCdFaeb fxbImF1Xl0TwiBldiAdAMRv9Tgek/TNe6QoJrV9pJFFkVccAuQ3oipJY0EaPDNElQ4hd2UdXqoxdp PQJmrKVqAhtuUZLhBMQbgjSydQTFhRQyXfg22Jx79LASfFaMpnGo14mdNGw9zQWMI8ZnrjSj92Dyh 1BXBKHfg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:50070 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOh5-0008Gu-1L; Wed, 13 Dec 2023 12:50:31 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOh7-00Dvl7-LR; Wed, 13 Dec 2023 12:50:33 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 16/21] arm64: psci: Ignore DENIED CPUs MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:50:33 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_125040_109194_74C3D8A7 X-CRM114-Status: GOOD ( 12.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. See https://developer.arm.com/documentation/den0022/f/?lang=en page 58. Signed-off-by: Jean-Philippe Brucker [ morse: Rewrote commit message ] Signed-off-by: James Morse Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) Reviewed-by: Jonathan Cameron --- Changes since RFC v2 * Add specification reference * Use EPERM rather than EPROBE_DEFER Changes since RFC v3: * Use EPERM everywhere * Drop unnecessary changes to drivers/firmware/psci/psci.c --- arch/arm64/kernel/psci.c | 2 +- arch/arm64/kernel/smp.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c index 29a8e444db83..fabd732d0a2d 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 != -EPERM) 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 defbab84e9e5..6bc9094feb19 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -132,7 +132,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 != -EPERM) + pr_err("CPU%u: failed to boot: %d\n", cpu, ret); return ret; } From patchwork Wed Dec 13 12:50:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490922 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1ACDAC4332F for ; Wed, 13 Dec 2023 12:51:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c1mFfOFfwyeGmtf9Khkq5BLPYCSjpFvjUUENvzKUwxg=; b=xm055hDqNU+oFV uMsmA6Ku6QN2BVVUXmzMPoBFpBk8PVqCXo5fEomBOqe2pU81AZjWK11rAZmtXNuaTvSu0AHXa/KGY NTSBClVGPxHb26U+z+joXpacgkQVaQyeEQ/bEvt6wphQu9PhCwyA7AdyOr8tNrDyFVxgOt6eVPAE4 t2h3bw/KumQKCxe5GoybgA1xsJWxQ0DqIAI4/cYz6XRuIN7oIW0qHDrwV4+i7d79br2L1L0i7/s86 RHrlmDlun7gh8/vtBNI/f/FD5WtRFJQObiWG+4C1TOw20PnwmGYai5xRbTBK/RgkeFWBITMe8A2LL huDULg+d/xTGVi6+BIFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhd-00EfGI-2z; Wed, 13 Dec 2023 12:51:05 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhL-00EewP-0e; Wed, 13 Dec 2023 12:50:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description; bh=zH347rXIT/Wy1fT2AxJrWucdhRljJuHMrMKFDlPOdGs=; b=EvuCRupmOoivEDiPJ/uQJlnIQP ZofMLgLv92oIdye76uE+fo/DClHgnxgnuv0qM4jBAMXa67qjine0ILYg7LwPaVONRlh6SIfZ+ov5A QAfwbQAWGuxpauTSKzuZlpw2pbghhXwYaPBU7KB/UFe+LKhAcNyp7IcNQptTdxulUQ5UlQNd/2Jly W5J24rn4NDf3z+F/Kk8vLu4fGG6yyK2xYEbJAd1hFE0lvpCr76ZmKRwExvkB2p9cYZ12B/DayqlVT wOuzW/MiRD6y1z5ozDn7iQdOc7VhGbKgtJGf/HYr/pNm6N8byG7ZHjXySiuo3pvipEEHTpqXZIZMG WYzypjIQ==; Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhH-00967F-2x; Wed, 13 Dec 2023 12:50:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=zH347rXIT/Wy1fT2AxJrWucdhRljJuHMrMKFDlPOdGs=; b=C8V6ZPDmidjU0rPM3MNO+Oz7/r 9Q4u3gedUI33lJ3NyGNwKUy257pNGfSyYof4TiYnY84kRmEo7Mjfg8LvEbcLtLDFgYbhhYPYk2DM6 qL91mkIsdsCL8QpgAEvD98lEcW9ZWUCCtXbaZRScR4ytVUzn0OSU3bWGhXZ0f+Zow2X/C+jtBjBCJ 8k7jFCMRILZ83BDKElnsNyxKh8EE1JHqMJBWe4q2OZIRUlrlhx2Gv/XPkllFPQS3+FndJm9Ov670Y khCRzwlW2Se1hrI6UNoeQT7K33f2KTHrEpmLBpfwq30WM335VyRik2rw9Vls1PanX7hwhyv2vD+Cu BIEJ2DIw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:51442 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOhA-0008HE-1e; Wed, 13 Dec 2023 12:50:36 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOhC-00DvlI-Pp; Wed, 13 Dec 2023 12:50:38 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 17/21] ACPI: add support to register CPUs based on the _STA enabled bit MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:50:38 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_125044_188200_5C06C5E9 X-CRM114-Status: GOOD ( 13.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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: Gavin Shan Reviewed-by: Jonathan Cameron Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) --- 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 b7a94c1348b0..5dabb426481f 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -228,6 +228,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 Dec 13 12:50:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0D39AC4332F for ; Wed, 13 Dec 2023 12:51:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=REHBy9mG+GEuiVm390YQYAaK8LiHleCzprlOesyHADw=; b=MDkSZeUSROimnx zhIQPDhEQ4pt4Hnnx0ogWCGy63m6MY/PVWA7kaWHJ4IpJBbLyFI5qL97qYgYwXFm9ykFjZ+4LN1Cw K7IU1AKMV0WktPBRCp0QZf+jKiewu1IZBv4jWyUjVjlLkqElGBn+m8cXJQSJCJ15M27Z0F5yaLmT/ 1uUhShIYhLr/KWX++naYv6lQFS/BB4cvpC9PDkPq0SFJfqQW4URLPJH+iHH/45znoeYSZaQqzYpmG LF6XSTIFjVOST+O3l3wttXFbkehbCH3/EXhXv0PciV1VU40Hg1V17Mlj5DI9il1n7TOcc5ImFFUdb rx0U+kOdXM5Oabu5UZxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhl-00EfOv-2N; Wed, 13 Dec 2023 12:51:13 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhQ-00Ef2Q-2k; Wed, 13 Dec 2023 12:50:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description; bh=lmtH59uo0RH6OWln4SWiUMu9ATT5+EWsaWDCzIDILMw=; b=pMqckjb85eBCivxGbpsNv/CRjq ZRf05ySMnGbEeYhiKV96yYztuA19cyJ8fSCnGriut//JqO3b1zbkfmEIVsfTc+3tu2JzxDkppIiTJ 9QbtlkCk5EXlZ9cc63sPA/xSUgkvdY1tZWi0wgXt0+Gto1CuF2b2dff6cfz35fCz1EcG/RoiEQbo6 Gwp1xktk+IsxFHk/9uDQh6bwqheFg4E5njwOOafv9UpO6o5d52606kQsfqwVF+nXB6AHzzAZiPQEi mM/LQmSYyGQZUDKo5UNR6oI0UaCc47J5Odnt7zodK9u1kziwDzW7wstW5H9VklA3eXRyGTdMBW0Vi q0FqH4kg==; Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhN-00967w-1F; Wed, 13 Dec 2023 12:50:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=lmtH59uo0RH6OWln4SWiUMu9ATT5+EWsaWDCzIDILMw=; b=vjgZ5o4FgP2eXJBezIZp2zJ0xr t6xOqiS/tNc9Agtr4/gEtULHWFMdo+cMAqDbsj713CNHaHJh2E0IqnABMfHkAOf9zrsn8DfVcJDcA WkPWWZdNLaXZYBdXwmXvxAT4XOzI7++DthIonECZ/hHPO8CCBoK7myVrtmg7BcHy9HoM5Z1D8HRRy EeIGP/Kl3ObL1mjz6SIe0wNRspxRzY3s7YWxE88eF3Uk+9CSW1a2I7yhLMFjyPBF6Unn/nd9LnM7z EhdbIpoz0zO5WdAFp06vz+2/m5mcxpTMeF2HPrsXAVjTO1hJ+KQySmSlpsrEjacXbVpeeo8+7e5uu ck4N+yzw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:51452 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOhF-0008HS-2A; Wed, 13 Dec 2023 12:50:41 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOhH-00DvlO-UP; Wed, 13 Dec 2023 12:50:43 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 18/21] ACPI: processor: Only call arch_unregister_cpu() if HOTPLUG_CPU is selected MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:50:43 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_125049_628264_549EAB23 X-CRM114-Status: GOOD ( 10.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse The kbuild robot points out that configurations without HOTPLUG_CPU selected can try to build acpi_processor_post_eject() without success as arch_unregister_cpu() is not defined. Check this explicitly. This will be merged into: | ACPI: Add post_eject to struct acpi_scan_handler for cpu hotplug for any subsequent posting. Reported-by: kbuild test robot Signed-off-by: James Morse Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Reviewed-by: Jonathan Cameron --- This should probably be squashed into an earlier patch. --- drivers/acpi/acpi_processor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 5dabb426481f..ea12e70dfd39 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -537,7 +537,7 @@ static void acpi_processor_post_eject(struct acpi_device *device) unsigned long long sta; acpi_status status; - if (!device) + if (!IS_ENABLED(CONFIG_HOTPLUG_CPU) || !device) return; pr = acpi_driver_data(device); From patchwork Wed Dec 13 12:50:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490924 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6818AC4332F for ; Wed, 13 Dec 2023 12:51:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8YfnybclqFE/vATucoz5OB9Elf+gWSPuCwXWRE6CNCs=; b=2j2hm1xy7WKgVs mcphBnZ8aR5D7bZoYv3xIhiNf5+sdrU6LxQWiKN9tpo+sYa/9CAcpbbkrPWp9QTfmYIu/cPn/3fJa b6Ze75ZIKCOA88y5hmjxFt6GrnoY9QwANFmZCMubKyl8GT6WkaUDjyGvTsC9ci0I1qEZzCfeLY0GF wOtmoo81MRpArV3ouHghjtgXvEkK8LZUBDpXrGjweqUE9oF20kwEkqoYTfQUHttsWs/rpDsMc1/k2 lL1W0gugeRb7r//Mwu/62o9Yo65fUV3MDDvuoDWvX0FL4MAhQh2wnIIl1ZM/sG9cH9KOEobrQnK4N ZfHnJElOHffg0gP54eqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhr-00EfVc-2E; Wed, 13 Dec 2023 12:51:19 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhW-00Ef8m-2p; Wed, 13 Dec 2023 12:50:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description; bh=dR7JNhitZsYYNsJnRBxnMA0zB4zlIQmz4Z+T0N0ONL4=; b=IY22zMrh166wpMxmiaeV5yLvIe x7xDiCBRQDjo5/KrdFnM4Eg3N+I8xCYqj3mqlGbqjxcPJgHsS7jz5Ga3KxeCjapMhzK/mURctQqQb 28XPzOPdgA1BiEG4DdI2Ax6Oje3CJCOSihUoOhghW3jh7CXCPKDT9g+np09wr50R6DU0rJTMTiYKt STYRbZYq6xq2sDYpVG84wdrIQpQWAWTeZdfHdUPr6AdmAckjkdSVcVkcR+pHPLtD797X0kcoUAU0E GzLsWRqlS4jyPCMJ+Jiph/p0LJNTxWOjMaWbW1bCws6KRrHKQOfBu+dbjnaK668C1zHPB9/OI23/Z IsAcTYZw==; Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhT-00968G-03; Wed, 13 Dec 2023 12:50:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dR7JNhitZsYYNsJnRBxnMA0zB4zlIQmz4Z+T0N0ONL4=; b=edybxLfqLwDaq9HY6CNb9zw0Jr pjBeF6oG5grGntw4FYgF5CREBzDB5dQDEtjzB3UZQUl+wbostnK/9T02VUHkT0JYG2jBM6RVHOMn5 Bh94I73D++Zeo6Jc7kZ6c5ETvudIKqevgd2Dr0/kJFbjoLlCoJOiHdKcsVEyct0DmxDTuXgThoZZg tuxfi6iWKWjuyyE+YZJK1d1Z/ENuelO5+CZXSCAcjSafhCSRkN24DfSaHCW2DWepIU5IMPK55DT/D n9+M/ibWloQmZI3ayPPRY1E2fF1rT7rEb9ehWZaOsxryJVKcLNEMSRRHtSceBX8paS8oD2O3twZkH QYyyICPQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:44930 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOhK-0008Hg-2l; Wed, 13 Dec 2023 12:50:46 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOhN-00DvlU-2e; Wed, 13 Dec 2023 12:50:49 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 19/21] arm64: document virtual CPU hotplug's expectations MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:50:49 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_125055_345376_14921167 X-CRM114-Status: GOOD ( 23.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Reviewed-by: Jonathan Cameron --- Outstanding comment: https://lore.kernel.org/r/20230914174137.00000a62@Huawei.com --- 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 Dec 13 12:50:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490926 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB9BDC4167D for ; Wed, 13 Dec 2023 12:52:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pQ9Br9wiFQRq/dEhhgVKB3Dk7kvZdxptdzDmdkeGzy4=; b=CR+MejOXheE7zH fCoZ0YUJER6JfJtvNJtts6JDQPOoNO9CrRpi50Vb8Ew2MMhJYgPcbjGx8WqNTK6bOPDtgkvCD7ukL wDTNpai9kmpwmfwgXHXXWSmYdq/32TsigIV2uEOw/SUdCz/lICDbH4TaYPO0GvlY3Jqy9uk2GnDPK 18tlTHu9ODcTgXBtxpWHgfjDNBINV3E5BpxdXsK9QlxPBLZwuSc1ZabRYZUgLvNdIsN4ldTRTHIRz k6ZYpcFsrl63H1a94ofXcKoztgxVkbayVjyQHmEhWxPmV3nUmkbatJZGwaxXsrFM6IsYNrEadD1pk PQE9QNcPMIATwFC7H2kA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhx-00EfcD-0F; Wed, 13 Dec 2023 12:51:25 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhb-00EfE5-2T; Wed, 13 Dec 2023 12:51:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description; bh=GjL2kXTMd2i2PnTpLka9uYvIe3wh2ToEdTiKO8t/ZLs=; b=lz3etuZwplEtsavbkGepf9o3d/ fxqUdKSUMTqbsaqtLZIRbExQziCSQgLLHehDA2Yyq7pGfPiUrzIqStwkLKKdRGBYS/4M0djb8mLm+ t+FzdJGlmfwS5eW970d6D6PWGt3zslf6ePL+fK1MeV0fFJGyPFke2iNckBkrJ+FZhLREc64dcxe8Z 9q5+SQXv2/vfDUtp6QpRFSaNbAsf+M4PiGdNwJctT/kPUofS3d3e2ZXxp4c3Ek64rRigdtsoZZ5wd Iaajher0O+26DmT5jl6a40RZVuDjkbjhXEskKyFfVyJlMIDJ5pEzb++L6/TO0P/I1Wb1O1qduKgr2 l6bUEOTw==; Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhY-00968c-0S; Wed, 13 Dec 2023 12:51:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GjL2kXTMd2i2PnTpLka9uYvIe3wh2ToEdTiKO8t/ZLs=; b=GBHhS3atcKbvYSZE+G7lr2xVSQ J8Xru9Y54/v9+enWJoWXlcLkIb+UuCAY3g8d/K+IbsmOVNvLtIrmEMFHDoDdsXzBv06qv1y61z79P BMxJ8FdjAQm2gM7JfKDvbfwGy4QHuIhxTSAaf0NOkDOS6ChYkW8Uf9bYIDcEVnVr1+Na7zNCxYm8L YUxzIokMmeol0Thdj+nFdSCNSPrZTCTyqkGyqhPGFF06oijt4zU/TSoCSo2c0ysNpBZN3e00i+wJn vFW+8Z6fY10dFz+JNi6Kg+JJM7xwb/1usJghBrUNHGADIPkPNmb9Nq50ZUdGkY2mjVKU8Os5ZpGni bXfksiIw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:44942 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOhP-0008Ht-3D; Wed, 13 Dec 2023 12:50:52 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOhS-00Dvla-7i; Wed, 13 Dec 2023 12:50:54 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 20/21] ACPI: Add _OSC bits to advertise OS support for toggling CPU present/enabled MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:50:54 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_125100_379235_6739E2BF X-CRM114-Status: GOOD ( 17.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu --- I'm assuming Loongarch machines do not support physical CPU hotplug. Changes since RFC v3: * Drop ia64 changes * Update James' comment below "---" to remove reference to ia64 Outstanding comment: https://lore.kernel.org/r/20230914175021.000018fd@Huawei.com --- arch/x86/Kconfig | 1 + drivers/acpi/Kconfig | 9 +++++++++ drivers/acpi/acpi_processor.c | 14 +++++++++++++- drivers/acpi/bus.c | 16 ++++++++++++++++ include/linux/acpi.h | 4 ++++ 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 64fc7c475ab0..33fc4dcd950c 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_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 9c5a43d0aff4..020e7c0ab985 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -311,6 +311,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 ea12e70dfd39..5bb207a7a1dd 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -182,6 +182,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) { @@ -189,7 +201,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 72e64c0718c9..7122450739d6 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 00be66683505..c572abac803c 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -559,12 +559,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 Dec 13 12:50:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13490925 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19A80C4332F for ; Wed, 13 Dec 2023 12:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Date:Message-Id:MIME-Version:Subject:Cc :To:From:References:In-Reply-To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LyVMQObCstqu/JDez0nYlflwOhK02S7th5IzO7sa4Pw=; b=jUqGOodFccpms7 1erAMMsVRzmlxnt9bohSFrz7y9u3N16Cj1rJD5YEDe6yWg0Vb0sVBMWLzzP4YBofu1+m+aBj1M0yF Qq0RkKPnp6xhTQYJ//D0zCwbXRJd/pSNjNohG+mu/OLN81hj4P1kjL0feeRminFwjJdqsDlGbtvli 3KH8I7brUqIvLqlhVEi8Zl9kts91qd7WZZYYLNNgfhMziK/5NTQB1ZSOIJeE+Ph1WM0Nw4tIdjNT/ CKo0MsDbamWqMlxbuWeP/a3lWUNfFIB8frYgPxkY2XUwlEGNnQbpEPDGdFtg/UGd9IXjViZG1ZcWe o+PSKkfuVICLcwKMst1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDOi1-00EfgJ-08; Wed, 13 Dec 2023 12:51:29 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhg-00EfIm-2k; Wed, 13 Dec 2023 12:51:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description; bh=4ff4rMpb4e8+j2FVzHVtwCCPXNpYraqqrJVEXYQ7zus=; b=YwGt7GLrCt9VrplkntH378wAUB tedtCrkrjR1MuUxD8jUjseuxNHaRPL5I5+AYuL9bZR/zus4IwXYOersdMQElw49OI71tB0Kg/7Kwr XdVIkYciLKQtkgFath6/9+tgvvsz5YQ4aU5DROrmdaoKHZoDFTiW9NXHMGnnp91JbTyiVl85UlPea ukWxI6rdkR07Yus4teNTDqgE5ZOBqezoMFg77eBM3UNVq8899ibyoSAIkeU1KGLLDo/oISXliMq6Z QTbMq53kml+qDsCYB6yo4r4Eis9+BR6NFEExpsB32sjc5G9qWKrRT3Q6MUwXbMSFGDK56hvb17wtt sn6ieRNg==; Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDOhc-00968u-33; Wed, 13 Dec 2023 12:51:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4ff4rMpb4e8+j2FVzHVtwCCPXNpYraqqrJVEXYQ7zus=; b=FTxlsm7nMbZ2auwIoWztzjGrLr eJ/+UAL4mRlb+xzpeos7afUrQbA793swTrEBkQs15e6/U2pZQzuZK+w+1AHJpkI3HfUJGZEjFm/Kp W9jVCjZgcW9jZXNT7d7yYBD6uXj3FP+JGLZOMl2DiqfJobHMrn+f2Rn1YL+OviAx4TvVtCo8v3NhG ha0rLs1UNyB4oOrGfMvPk8nj7AxLUehHcXG4csWrXQ+KZWl07iCkmqKO7r4ZhGqDaej9rOshtXdE9 mIEiNCaE7QZ92nAimpN8JuMZiod0x/DZEKdfe4Kl4qSvzrc78tI8xR7PubiPehT6ssECE39vdnOjp zzmnovvQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:33330 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rDOhV-0008IF-1A; Wed, 13 Dec 2023 12:50:57 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rDOhX-00Dvlg-Ci; Wed, 13 Dec 2023 12:50:59 +0000 In-Reply-To: References: From: Russell King (Oracle) 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, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse Subject: [PATCH RFC v3 21/21] cpumask: Add enabled cpumask for present CPUs that can be brought online MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 13 Dec 2023 12:50:59 +0000 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_125105_264323_FB4FA6EB X-CRM114-Status: GOOD ( 12.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: James Morse 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 Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Acked-by: Thomas Gleixner --- Outstanding comment: https://lore.kernel.org/r/20230914175443.000038f6@Huawei.com --- 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 13d052bf13f4..a6e96a0a92b7 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 cfb545841a2c..cc72a0887f04 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) @@ -993,6 +996,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 @@ -1015,6 +1019,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) { @@ -1096,6 +1109,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) @@ -1104,6 +1118,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); @@ -1128,6 +1147,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 @@ -1141,6 +1161,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 a86972a91991..fe0a5189f8ae 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -3122,6 +3122,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);