Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4015829rdb; Thu, 14 Sep 2023 09:16:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHcBQUUwCrSObQF1eA/sG+h130BAxV64dM2fBA1lDL1ED8s6WrWicwWwK4pgfMOrJEy9ytU X-Received: by 2002:a92:c5a8:0:b0:345:af1c:29c4 with SMTP id r8-20020a92c5a8000000b00345af1c29c4mr5106061ilt.25.1694708161025; Thu, 14 Sep 2023 09:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694708160; cv=none; d=google.com; s=arc-20160816; b=bHf+5O4jDy1y5USKv2VcR4/SQRSo6KerywU+YKpyDO9d4hySces9KzC7/sD2XO/m7u RhwdwQG+4jOu9L7Iz2Ur54yw9rmmRzRfXTuYhqyyyULfQC6u8MJ6LIvTihT4AqSOx4fK nq+jF0XpGz7z664a37lWhZ2NYXNvsGfMf0uKr2KNp+0uLumTHAYZqQ85Ae4hkHv+gm2w EobyNCKM7H7Rl8rkZjwrlmymf2Z1FyPMkEq+ZZ9b9N6t7E8WJmGp57S2iBwyjOPYQf4l XHRgSlI8ajLxdqTxuyrjyOtSuE5BoIelEtTregHMiAwNqFKW3GEZGeKp7yX30RuBHkBm ZPQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=AlbPZ55+l301P6UrGcG5TjxiP+qwL5WwLa+RZVZb5+E=; fh=oO43h3w0Gnh1/uzgjBLTRg+oe1Gv6aFHPIod5z8aS5s=; b=IVhRgLifxLoDjygF1QaXj+xVTqPU7IxnZeTXcxTyiBsIaGJkuFZVVIq4R2nKk5pL45 hzRQ4v1O66eJPfOz6C77/J1MRv/BEuSuKFVGKEXI/+6YrduWPdr+W77btXtnznYYGptC IC8PyVTZrVtFlqz7UrLn0j5BULbiLY7iiPMWdZlIAbiMcmNXfrhGBPpuw/8y2E0ppshH mvjomuvLIyQ6GGhyG8aMUoYWjFFHFpQvJWYo15kPfGHGpSpAT2eTHeBsszVJT8S9jD+3 Mgzu+ChwAPC2CikvcSdyliiOWEEMcCbCpjwulyAPjX6s+UD4aI/iHLxj9jnU0epQxuJP twIQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id j73-20020a638b4c000000b00574057d7c19si1744654pge.220.2023.09.14.09.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 09:16:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id C6CAD83470C7; Thu, 14 Sep 2023 09:13:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238193AbjINQNv (ORCPT + 99 others); Thu, 14 Sep 2023 12:13:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232330AbjINQNt (ORCPT ); Thu, 14 Sep 2023 12:13:49 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ECC21BE1; Thu, 14 Sep 2023 09:13:45 -0700 (PDT) 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 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 14 Sep 2023 09:13:57 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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