Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1783771rdb; Wed, 31 Jan 2024 08:58:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzPhmSXt7CVqPRzUL1jcisDwWxECDhKaZTsGwOQ5qsDdjAIvnQdF7Uz1etgVF+/+FrmO2P X-Received: by 2002:a17:906:4f0e:b0:a28:d1f9:976 with SMTP id t14-20020a1709064f0e00b00a28d1f90976mr1695012eju.65.1706720288176; Wed, 31 Jan 2024 08:58:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706720288; cv=pass; d=google.com; s=arc-20160816; b=Ln6XfHcHED/l2pwfX6wlHqeU0uxyWoGbwDKqz87UfCPj9k+3XfHhzpEJOq1MbeLeqn 9NR0ZTlhQO6fCOOvxnWOg7EjT5x7BGyCeZT5w+eY4+xlvD0D40peTAiM8LrFVc4VtLGR dfPQeuOyxGlOwjoWdj/myq89UkmGaTWxjsvcWnyIpg1QUHTFXtGQUZ7pyoQuriAShQmd yIm6QiuKBLL/xYs+yQcjdLnuJ0VWkaEoh83Eweh0js27+RZpBQZ/eV9TCJPClK3OKVJ6 u6mjysqV5/kccRFtwws2RnA+mtW4VMYvXKAEViwTDtWeUhFtA2sncYnbe2kEhCTGYHEp D8cQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:sender:message-id:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:subject:cc:to:from:references:in-reply-to :dkim-signature; bh=f5npkqxZTlvintQfJQR7JFbNovddfzG1yIBSkxo5huM=; fh=fClpqxKKtYKVCIsoOE8wqsAvQsau7mLRm+sh9pmTkLw=; b=ZTKznl+pvOG74TTCrBNArR12jFZZFwQ442OKy9fmfQN69KiZtQjuDr3XgMoR+iKvfi f0b17ewbzlkwYc53vAJISbNyhDVg4ZXtGPLtAsjtJNfFgDTXiQf6yAzKl0jUzIo18nL2 ksSeJ50v8LOyjJV8rtlsJkI9G9hF09ZmUGyIW6KP07kmAbfGXuiW4CZLb9N0sIfy6Fjn /upJpwT+xYK3QfyHwA+66GYIwJg7U4HkCy8MjkTi80IiQD0dg9T0CKYrq3KMawPAmhTw LdzC8xbVeLSXYXPydLkYfkFK8Th8MhA/z1As0P+O8eJdCCJgM3yeaNAzMDpnOr5jww29 2nbA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=rZ+y9KQN; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-46846-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46846-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk X-Forwarded-Encrypted: i=1; AJvYcCVkj7xqAm8pqZ5T6Gt26ZqBAUPZ7gQZN3wPhaVmOTxrTSTgf1e3QHGhdwdkdXsIYExgzZsP6q9tCvyIf8C1GxBi7ay4m6r+SoNkQZ3A1A== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lo14-20020a170906fa0e00b00a353bfe21f7si4634871ejb.281.2024.01.31.08.58.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 08:58:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46846-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=rZ+y9KQN; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-46846-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46846-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BE2A01F21701 for ; Wed, 31 Jan 2024 16:58:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C27F12DD81; Wed, 31 Jan 2024 16:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="rZ+y9KQN" Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4116012C522; Wed, 31 Jan 2024 16:56:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706720177; cv=none; b=cr4OwY9TWqOSoXFMFQrxpiT5QMeCfYkFkg39OoSXxqydHrsqBPj1y9ouRfqX1yHldnx+1nTGvbiumhLPPRhT1aWm11Csn3wLwdYv4o8DV9yIL5NopPaHsisqu0IqySRy1tiTTlg44TbsEkQcdHFZA+lsYMmJGP1BTB6Wz1ctDwI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706720177; c=relaxed/simple; bh=wqEyR5IykLjkRZWjBqfISdN6LAuQbshQspGGNzb4xB4=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=GnU3I8unCQwvB1RqUaDyD/mypXv+VfI4boj/l4H1TVjWMskOn42+zZQjjVePvWl1iuUCrGQ5GhesSDRYmfZb/9MO6c9Z9PKtqC4PK+f5wlrRogH7a3sjyCYJjXuCSbATPFzGuTVlnK/K+bywg/dc9FNiT49sauSxBtDki34D83Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=rZ+y9KQN; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk 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=f5npkqxZTlvintQfJQR7JFbNovddfzG1yIBSkxo5huM=; b=rZ+y9KQNys/vt6EBJk4R2yPaCi 4OKNmwHWIF+OvTh5I/L9c8gwiS0OLuRncsIm3vvJTYzYGyPl24yFVpR090gnimcgSNH4/GiyFcrOL lo7MDovAf/jMcoyctkWeHbWsOhFg1IxstP5eHZd5CdG23fpLnqXRtDHdHfWjdJ3oosl9pHh3hxHZg r2+PFBLmUHdJ4D/F3kO4APh+Oc6e2sTVlnuToDH0/pAkBPVdmJqL+SJY0KZArZMEf0BAplgmV1BIc QZwZ7uqRz3oAg8aTWw8NVtu2aty6N2PFsYTvEqAMD1hsLAhC9AMdtmWwhXCCxy7U0WDeoMRR67yJb aL9h6OEQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:33590 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 1rVDnT-0003WQ-1m; Wed, 31 Jan 2024 16:50:47 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rVDnP-0027ZZ-BN; Wed, 31 Jan 2024 16: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 , Jonathan Cameron , "Rafael J. Wysocki" Subject: [PATCH RFC v4 13/15] ACPI: add support to (un)register CPUs based on the _STA enabled bit Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Wed, 31 Jan 2024 16:50:43 +0000 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. When firmware clears the enabled bit, we need to unregister the CPU for symetry. As this is dependent on hotplug CPU being support, and arch_unregister_cpu() only exists when hotplug CPU is supported, we need to add a check for that configuration symbol. Signed-off-by: James Morse Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Signed-off-by: Russell King (Oracle) --- Changes since RFC v3 (smaller series): * Squash "ACPI: processor: Only call arch_unregister_cpu() if HOTPLUG_CPU is selected" into this patch. --- drivers/acpi/acpi_processor.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index d1d33e74216c..5e641180c45a 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; @@ -511,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); @@ -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 -- 2.30.2