From nobody Thu Dec 18 12:59:21 2025 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 49A98C32792 for ; Tue, 23 Aug 2022 09:22:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349429AbiHWJWq (ORCPT ); Tue, 23 Aug 2022 05:22:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350011AbiHWJVY (ORCPT ); Tue, 23 Aug 2022 05:21:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11F5F8B99B; Tue, 23 Aug 2022 01:34:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 53C5DB81C29; Tue, 23 Aug 2022 08:33:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD894C433B5; Tue, 23 Aug 2022 08:33:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243611; bh=lFI0+KLWRHDwjEi/LS3WyQnU8XrSg5yvyMJoMLq3Zbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0YghMQJSLr2xWSDFThmXLMYHzs0GJ2cvN3/BijrmLstPkyKnT6SnhldoaNoLQ0wPc tNnEwk+/SD/+Q3ZkkFr1S6fE5Ne1ExEt+stzHdPpUXUp5QtamzMSP8wYjkTSeokL0I g2f2om4XSnEGUvP9T1aNwmgVj2NTetnJ3rF7mOhY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck , "Rafael J. Wysocki" , Sudeep Holla , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.19 302/365] ACPI: PPTT: Leave the table mapped for the runtime usage Date: Tue, 23 Aug 2022 10:03:23 +0200 Message-Id: <20220823080130.818824528@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sudeep Holla [ Upstream commit 0c80f9e165f8f9cca743d7b6cbdb54362da297e0 ] Currently, everytime an information needs to be fetched from the PPTT, the table is mapped via acpi_get_table() and unmapped after the use via acpi_put_table() which is fine. However we do this at runtime especially when the CPU is hotplugged out and plugged in back since we re-populate the cache topology and other information. However, with the support to fetch LLC information from the PPTT in the cpuhotplug path which is executed in the atomic context, it is preferred to avoid mapping and unmapping of the PPTT for every single use as the acpi_get_table() might sleep waiting for a mutex. In order to avoid the same, the table is needs to just mapped once on the boot CPU and is never unmapped allowing it to be used at runtime with out the hassle of mapping and unmapping the table. Reported-by: Guenter Roeck Cc: Rafael J. Wysocki Signed-off-by: Sudeep Holla -- Hi Rafael, Sorry to bother you again on this PPTT changes. Guenter reported an issue with lockdep enabled in -next that include my cacheinfo/arch_topology chang= es to utilise LLC from PPTT in the CPU hotplug path. Please ack the change once you are happy so that I can get it merged with other fixes via Greg's tree. Regards, Sudeep Acked-by: Rafael J. Wysocki Link: https://lore.kernel.org/r/20220720-arch_topo_fixes-v3-2-43d696288e84@= arm.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/acpi/pptt.c | 102 ++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 55 deletions(-) diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index 701f61c01359..3ad2823eb6f8 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -532,21 +532,37 @@ static int topology_get_acpi_cpu_tag(struct acpi_tabl= e_header *table, return -ENOENT; } =20 + +static struct acpi_table_header *acpi_get_pptt(void) +{ + static struct acpi_table_header *pptt; + acpi_status status; + + /* + * PPTT will be used at runtime on every CPU hotplug in path, so we + * don't need to call acpi_put_table() to release the table mapping. + */ + if (!pptt) { + status =3D acpi_get_table(ACPI_SIG_PPTT, 0, &pptt); + if (ACPI_FAILURE(status)) + acpi_pptt_warn_missing(); + } + + return pptt; +} + static int find_acpi_cpu_topology_tag(unsigned int cpu, int level, int fla= g) { struct acpi_table_header *table; - acpi_status status; int retval; =20 - status =3D acpi_get_table(ACPI_SIG_PPTT, 0, &table); - if (ACPI_FAILURE(status)) { - acpi_pptt_warn_missing(); + table =3D acpi_get_pptt(); + if (!table) return -ENOENT; - } + retval =3D topology_get_acpi_cpu_tag(table, cpu, level, flag); pr_debug("Topology Setup ACPI CPU %d, level %d ret =3D %d\n", cpu, level, retval); - acpi_put_table(table); =20 return retval; } @@ -567,16 +583,13 @@ static int find_acpi_cpu_topology_tag(unsigned int cp= u, int level, int flag) static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag) { struct acpi_table_header *table; - acpi_status status; u32 acpi_cpu_id =3D get_acpi_id_for_cpu(cpu); struct acpi_pptt_processor *cpu_node =3D NULL; int ret =3D -ENOENT; =20 - status =3D acpi_get_table(ACPI_SIG_PPTT, 0, &table); - if (ACPI_FAILURE(status)) { - acpi_pptt_warn_missing(); - return ret; - } + table =3D acpi_get_pptt(); + if (!table) + return -ENOENT; =20 if (table->revision >=3D rev) cpu_node =3D acpi_find_processor_node(table, acpi_cpu_id); @@ -584,8 +597,6 @@ static int check_acpi_cpu_flag(unsigned int cpu, int re= v, u32 flag) if (cpu_node) ret =3D (cpu_node->flags & flag) !=3D 0; =20 - acpi_put_table(table); - return ret; } =20 @@ -604,18 +615,15 @@ int acpi_find_last_cache_level(unsigned int cpu) u32 acpi_cpu_id; struct acpi_table_header *table; int number_of_levels =3D 0; - acpi_status status; + + table =3D acpi_get_pptt(); + if (!table) + return -ENOENT; =20 pr_debug("Cache Setup find last level CPU=3D%d\n", cpu); =20 acpi_cpu_id =3D get_acpi_id_for_cpu(cpu); - status =3D acpi_get_table(ACPI_SIG_PPTT, 0, &table); - if (ACPI_FAILURE(status)) { - acpi_pptt_warn_missing(); - } else { - number_of_levels =3D acpi_find_cache_levels(table, acpi_cpu_id); - acpi_put_table(table); - } + number_of_levels =3D acpi_find_cache_levels(table, acpi_cpu_id); pr_debug("Cache Setup find last level level=3D%d\n", number_of_levels); =20 return number_of_levels; @@ -637,20 +645,16 @@ int acpi_find_last_cache_level(unsigned int cpu) int cache_setup_acpi(unsigned int cpu) { struct acpi_table_header *table; - acpi_status status; =20 - pr_debug("Cache Setup ACPI CPU %d\n", cpu); - - status =3D acpi_get_table(ACPI_SIG_PPTT, 0, &table); - if (ACPI_FAILURE(status)) { - acpi_pptt_warn_missing(); + table =3D acpi_get_pptt(); + if (!table) return -ENOENT; - } + + pr_debug("Cache Setup ACPI CPU %d\n", cpu); =20 cache_setup_acpi_cpu(table, cpu); - acpi_put_table(table); =20 - return status; + return 0; } =20 /** @@ -766,50 +770,38 @@ int find_acpi_cpu_topology_package(unsigned int cpu) int find_acpi_cpu_topology_cluster(unsigned int cpu) { struct acpi_table_header *table; - acpi_status status; struct acpi_pptt_processor *cpu_node, *cluster_node; u32 acpi_cpu_id; int retval; int is_thread; =20 - status =3D acpi_get_table(ACPI_SIG_PPTT, 0, &table); - if (ACPI_FAILURE(status)) { - acpi_pptt_warn_missing(); + table =3D acpi_get_pptt(); + if (!table) return -ENOENT; - } =20 acpi_cpu_id =3D get_acpi_id_for_cpu(cpu); cpu_node =3D acpi_find_processor_node(table, acpi_cpu_id); - if (cpu_node =3D=3D NULL || !cpu_node->parent) { - retval =3D -ENOENT; - goto put_table; - } + if (!cpu_node || !cpu_node->parent) + return -ENOENT; =20 is_thread =3D cpu_node->flags & ACPI_PPTT_ACPI_PROCESSOR_IS_THREAD; cluster_node =3D fetch_pptt_node(table, cpu_node->parent); - if (cluster_node =3D=3D NULL) { - retval =3D -ENOENT; - goto put_table; - } + if (!cluster_node) + return -ENOENT; + if (is_thread) { - if (!cluster_node->parent) { - retval =3D -ENOENT; - goto put_table; - } + if (!cluster_node->parent) + return -ENOENT; + cluster_node =3D fetch_pptt_node(table, cluster_node->parent); - if (cluster_node =3D=3D NULL) { - retval =3D -ENOENT; - goto put_table; - } + if (!cluster_node) + return -ENOENT; } if (cluster_node->flags & ACPI_PPTT_ACPI_PROCESSOR_ID_VALID) retval =3D cluster_node->acpi_processor_id; else retval =3D ACPI_PTR_DIFF(cluster_node, table); =20 -put_table: - acpi_put_table(table); - return retval; } =20 --=20 2.35.1