From mboxrd@z Thu Jan 1 00:00:00 1970 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 7F8BDEEAA53 for ; Thu, 14 Sep 2023 16:14: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:MIME-Version:References:In-Reply-To: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bXUnnCo5Iqtg+co82lBOIILn000ZNw9gdMXc5Okp7r8=; b=VQMzwtOd5QMuWh DLsvkzjR81kDpWrYIZqUMgNOI5lsVhmxFRQPKf+bzLPVk0FD5zphS27tyfjoMEetRNvriRwIAlx/J JuAqRBVMlrosYaQLSizhjgllcaCjbeLfj9ZCFHWKBWAdMitPnNHdzB3cpqlYXh3WMDtQXa7hxlyDh zCuMoRnM4xgm4iCuZIEqDb9JreoVi5jhzgsEIe5LIjfuojIzAE34NSvrWw28JVMt7F7AEZifcRaqt QZtAej5nvdIUydpoWxKxFT4Njo4U++3mZAdE9C1k7k6a3UIsgB3y7NIZTExSgmb0tB2qCHVxhwqD/ aF72mf1y44sEVG+nf+Qg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgoyX-008tBc-20; Thu, 14 Sep 2023 16:13:53 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qgoyU-008tA4-2H; Thu, 14 Sep 2023 16:13:53 +0000 Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Rmj4r2vBYz6HJcg; Fri, 15 Sep 2023 00:11:56 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 14 Sep 2023 17:13:41 +0100 Date: Thu, 14 Sep 2023 17:13:41 +0100 From: Jonathan Cameron To: James Morse CC: , , , , , , , , , Salil Mehta , Russell King , Jean-Philippe Brucker , , Subject: Re: [RFC PATCH v2 32/35] ACPI: add support to register CPUs based on the _STA enabled bit Message-ID: <20230914171341.00006e51@Huawei.com> In-Reply-To: <20230913163823.7880-33-james.morse@arm.com> References: <20230913163823.7880-1-james.morse@arm.com> <20230913163823.7880-33-james.morse@arm.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml500006.china.huawei.com (7.191.161.198) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230914_091351_027357_E15F00FC X-CRM114-Status: GOOD ( 23.34 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 13 Sep 2023 16:38:20 +0000 James Morse wrote: > 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 A small argument with myself inline. Feel free to ignore. Reviewed-by: Jonathan Cameron > --- > drivers/acpi/acpi_processor.c | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c > index b67616079751..b49859eab01a 100644 > --- a/drivers/acpi/acpi_processor.c > +++ b/drivers/acpi/acpi_processor.c > @@ -227,6 +227,32 @@ static int acpi_processor_make_present(struct acpi_processor *pr) > return ret; > } > > +static int acpi_processor_make_enabled(struct acpi_processor *pr) > +{ > + unsigned long long sta; > + acpi_status status; > + bool present, enabled; > + > + if (!acpi_has_method(pr->handle, "_STA")) > + return arch_register_cpu(pr->id); > + > + status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); > + if (ACPI_FAILURE(status)) > + return -ENODEV; > + > + present = sta & ACPI_STA_DEVICE_PRESENT; > + enabled = sta & ACPI_STA_DEVICE_ENABLED; > + > + if (cpu_online(pr->id) && (!present || !enabled)) { > + pr_err_once(FW_BUG "CPU %u is online, but described as not present or disabled!\n", pr->id); Why once? If this for some reason happened on multiple CPUs I think we'd want to know. > + add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK); > + } else if (!present || !enabled) { > + return -ENODEV; > + } I guess you didn't do a nested if here to avoid even longer lines. Could flip things around though I don't like this much either as it makes the normal good path exit mid way down. if (present && enabled) return arch_register_cpu(pr->id); if (!cpu_online(pr->id)) return -ENODEV; pr_err... add_taint(... return arch_register_cpu(pr->id); Ah well. Some code just has to be less than pretty. > + > + 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel