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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDC3DCD3439 for ; Tue, 19 Sep 2023 04:47:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231437AbjISEr0 (ORCPT ); Tue, 19 Sep 2023 00:47:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231423AbjISErY (ORCPT ); Tue, 19 Sep 2023 00:47:24 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34CCE102 for ; Mon, 18 Sep 2023 21:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695098794; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0md79eddiFVt37093ccE7iiQ7K8nZkLOgQESfCPy8Vw=; b=ABBcJbCglt1qxSif2IH5J3qgXYyXsxJaWfF3gBRp1dPh6ss73WMMOWAbl+ey1zKq2ZQVUs uLFgztIA8qetI/t/H6tYs1zxuUXVPiCDw6S12ftz0f8EI3VpWgl1tYFVayboLVpoORjp2E I3Ro9znR8eHFbfC3m2M6w7pXHJHP1EY= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-643-cfWSVcc3NhCs9BwUQ0GadQ-1; Tue, 19 Sep 2023 00:46:32 -0400 X-MC-Unique: cfWSVcc3NhCs9BwUQ0GadQ-1 Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-6bf001e729bso7391756a34.0 for ; Mon, 18 Sep 2023 21:46:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695098791; x=1695703591; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=0md79eddiFVt37093ccE7iiQ7K8nZkLOgQESfCPy8Vw=; b=aHm/8zPoaHoAVkLUDaYYriDB2ohCUfZIXekfr4Qo/cgs24I/ApbALsuzxslzoVz10E V3wv4jCW5flfXnx4RDWOVTe4p3q6Sm1hIfeCY5t4FZiQPQ3wwKENjecbJARCq8cps4jQ +x85DK9Efy3VPlcOhYT1nvaXpy6yoMtql0uaUyVPklJbH7MRrmL1Vtp0D5HqZu8GxPmw QZA9uFeTncXBxHj4pp+790aGpmqi6gxheCcReSeLPvFFVsIkbDnrO2MUqjdr4ekd7bo3 uaXdUCf/O1YX94Z0740OjSOcN5mO4r4+yP7z+vp2rCU4g9eDoHYLJQUwPKC+bl9+Wk6m 3Tpg== X-Gm-Message-State: AOJu0Yz/l+46gfEag9TQrUTiJUg+tS08Lqf6nnWpwfguACbOZrQhnHjz dwbuUoFr4ikTsyWodS0BvmhddOxhrFUBedXaGUfCU0WoKp0mleeBAqaDcr/JkqvfuZMqpXiBEHi 9f1kLEOSrCRK3sHKwogs= X-Received: by 2002:a05:6358:249d:b0:134:e603:116e with SMTP id m29-20020a056358249d00b00134e603116emr9678039rwc.6.1695098791617; Mon, 18 Sep 2023 21:46:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKkoLP87+mw9T8TQ8bjb6RIWKH/vCCTjI0tHPFOvwV8K6Ynikd7+Ff2EaTqVQJl8SE4ves7A== X-Received: by 2002:a05:6358:249d:b0:134:e603:116e with SMTP id m29-20020a056358249d00b00134e603116emr9678018rwc.6.1695098791296; Mon, 18 Sep 2023 21:46:31 -0700 (PDT) Received: from ?IPV6:2001:8003:e5b0:9f00:dbbc:1945:6e65:ec5? ([2001:8003:e5b0:9f00:dbbc:1945:6e65:ec5]) by smtp.gmail.com with ESMTPSA id d3-20020a633603000000b0057749dc8d3asm196597pga.47.2023.09.18.21.46.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Sep 2023 21:46:30 -0700 (PDT) Message-ID: Date: Tue, 19 Sep 2023 14:46:22 +1000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [RFC PATCH v2 32/35] ACPI: add support to register CPUs based on the _STA enabled bit Content-Language: en-US To: James Morse , linux-pm@vger.kernel.org, loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, kvmarm@lists.linux.dev Cc: x86@kernel.org, Salil Mehta , Russell King , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com References: <20230913163823.7880-1-james.morse@arm.com> <20230913163823.7880-33-james.morse@arm.com> From: Gavin Shan In-Reply-To: <20230913163823.7880-33-james.morse@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On 9/14/23 02:38, 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 > --- > drivers/acpi/acpi_processor.c | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) > With below nits addressed: Reviewed-by: Gavin Shan > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c > index b67616079751..b49859eab01a 100644 > --- a/drivers/acpi/acpi_processor.c > +++ b/drivers/acpi/acpi_processor.c > @@ -227,6 +227,32 @@ static int acpi_processor_make_present(struct acpi_processor *pr) > return ret; > } > > +static int acpi_processor_make_enabled(struct acpi_processor *pr) > +{ > + unsigned long long sta; > + acpi_status status; > + bool present, enabled; > + > + if (!acpi_has_method(pr->handle, "_STA")) > + return arch_register_cpu(pr->id); > + > + status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); > + if (ACPI_FAILURE(status)) > + return -ENODEV; > + > + present = sta & ACPI_STA_DEVICE_PRESENT; > + enabled = sta & ACPI_STA_DEVICE_ENABLED; > + > + if (cpu_online(pr->id) && (!present || !enabled)) { > + pr_err_once(FW_BUG "CPU %u is online, but described as not present or disabled!\n", pr->id); > + add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK); > + } else if (!present || !enabled) { > + return -ENODEV; > + } > + > + return arch_register_cpu(pr->id); > +} > + The message needs to be split up into multiple lines to make ./scripts/checkpatch.pl happy: pr_err_once(FW_BUG "CPU %u is online, but described " "as not present or disabled!\n", 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 Thanks, Gavin