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 AC3D9C4345F for ; Fri, 12 Apr 2024 14:40:04 +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:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TcdJbWNZlck28k74FgMkDgQaInoMnjRexyGdVJAECas=; b=w7spt+SFC500jZ FIvUU9xHsUJi+jUTNCfy5NuCnqTfGaVK2rU2uodnHiJDjwknYNZ2F3mGwVNHRpUX62JDOXsJHatec 7If/kQHYRSC50P1OY6214FYo+UouuBYt2tiJvYdIBCLmykSSSQzoT7LF3TCNrns1QNAVjo5HuMJeG W9XCXEwnBPrsI6JubA1UShJoimGR6+ulKGj3Y2WqQyQGwYEyO1SQjRBiF0kvNUyS1HK+vfW1FEjp9 n16RtNzp1hppB5EACa6wFaw710hATvvBQO5Nq9WUEH+94w19dGm8viSNj/ZeBK5SxoOUfZvqix89N uMwTl+2qXNl3N3+yCGCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvI4J-000000001g6-2JAR; Fri, 12 Apr 2024 14:39:55 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvI4G-000000001ev-1vsL for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 14:39:53 +0000 Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4VGK185tN4z67GVD; Fri, 12 Apr 2024 22:38:04 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 9073F1408FE; Fri, 12 Apr 2024 22:39:50 +0800 (CST) Received: from SecurePC-101-06.china.huawei.com (10.122.247.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 12 Apr 2024 15:39:50 +0100 From: Jonathan Cameron To: , , , , , , , , Russell King , "Rafael J . Wysocki" , Miguel Luis , James Morse , Salil Mehta , Jean-Philippe Brucker , Catalin Marinas , Will Deacon CC: , , Subject: [PATCH v5 05/18] ACPI: utils: Add an acpi_sta_enabled() helper and use it in acpi_processor_make_present() Date: Fri, 12 Apr 2024 15:37:06 +0100 Message-ID: <20240412143719.11398-6-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240412143719.11398-1-Jonathan.Cameron@huawei.com> References: <20240412143719.11398-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml500006.china.huawei.com (7.191.161.198) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_073952_812653_410EE918 X-CRM114-Status: GOOD ( 15.93 ) 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 A device is enabled only if both the present and enabled bits are set in the result of calling the _STA method, or the _STA method is not present (in which case the device is always present and enabled). Signed-off-by: Jonathan Cameron --- v5: New patch --- drivers/acpi/acpi_processor.c | 8 +++----- drivers/acpi/utils.c | 21 +++++++++++++++++++++ include/acpi/acpi_bus.h | 1 + 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 05264722c207..3aa43dee4391 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -185,8 +185,6 @@ static void __init acpi_pcc_cpufreq_init(void) {} /* Initialization */ 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_CPU)) @@ -195,9 +193,9 @@ static int acpi_processor_make_present(struct acpi_processor *pr) if (invalid_phys_cpuid(pr->phys_id)) return -ENODEV; - status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); - if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT)) - return -ENODEV; + ret = acpi_sta_enabled(pr->handle); + if (ret) + return ret; cpu_maps_update_begin(); cpus_write_lock(); diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 202234ba54bd..3004426b218c 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -744,6 +744,27 @@ acpi_status acpi_evaluate_reg(acpi_handle handle, u8 space_id, u32 function) } EXPORT_SYMBOL(acpi_evaluate_reg); +int acpi_sta_enabled(acpi_handle handle) +{ + unsigned long long sta; + bool present, enabled; + acpi_status status; + + if (acpi_has_method(handle, "_STA")) { + status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); + if (ACPI_FAILURE(status)) + return -ENODEV; + + present = sta & ACPI_STA_DEVICE_PRESENT; + enabled = sta & ACPI_STA_DEVICE_ENABLED; + if (!present || !enabled) { + return -EPROBE_DEFER; + } + return 0; + } + return 0; /* No _STA means always on! */ +} + /** * acpi_evaluate_dsm - evaluate device's _DSM method * @handle: ACPI device handle diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 5de954e2b18a..e193507fd743 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h @@ -51,6 +51,7 @@ bool acpi_ata_match(acpi_handle handle); bool acpi_bay_match(acpi_handle handle); bool acpi_dock_match(acpi_handle handle); +int acpi_sta_enabled(acpi_handle handle); bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs); union acpi_object *acpi_evaluate_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 func, union acpi_object *argv4); -- 2.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel