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 84FF7CF3959 for ; Wed, 19 Nov 2025 17:08:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vLchA1ykoPbmj9AIrmBouSr4pCsQPvDvWHM4auak6/8=; b=M25XJhSOWZV/Bd/ZHpoZF8XDTV TMAudxn2xxk0zKDerP4Rsgkgg8QXrRywf1/ctqWpUQtstu+P0M0iHM0SIIQ5WqODcnezBTp5tCPnG fGyL1e1bKwK6kc6YZS7H4RYWeKNXllBDC9FqjvbWIlFbHUk58BcKrwMaxrAA5xHNd+TCiwH15SuSP vgixnCIGSfA50TzVVbSdPqt4kxnzGDTNnHXJ9Aaw/jG1uB5rLA2MNZSRY6rw2cj65zPZql5d8NlkL HrNz4AjOpJ/BYdYYUkh89M2HuJLs4/n0k3D5NO00WRreTb7oVQDmX/RqCEssnT5uonAVBrb6oaZW9 6KMoKkwA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vLlff-00000003uMI-21Lx; Wed, 19 Nov 2025 17:08:43 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vLlfd-00000003uLp-2qYm for linux-arm-kernel@lists.infradead.org; Wed, 19 Nov 2025 17:08:42 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1F27AFEC; Wed, 19 Nov 2025 09:08:33 -0800 (PST) Received: from [172.27.42.169] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA2E33F66E; Wed, 19 Nov 2025 09:08:36 -0800 (PST) Message-ID: Date: Wed, 19 Nov 2025 11:08:35 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 02/34] ACPI / PPTT: Stop acpi_count_levels() expecting callers to clear levels To: Ben Horgan , james.morse@arm.com Cc: amitsinght@marvell.com, baisheng.gao@unisoc.com, baolin.wang@linux.alibaba.com, bobo.shaobowang@huawei.com, carl@os.amperecomputing.com, catalin.marinas@arm.com, dakr@kernel.org, dave.martin@arm.com, david@redhat.com, dfustini@baylibre.com, fenghuay@nvidia.com, gregkh@linuxfoundation.org, gshan@redhat.com, guohanjun@huawei.com, jonathan.cameron@huawei.com, kobak@nvidia.com, lcherian@marvell.com, lenb@kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, lpieralisi@kernel.org, peternewman@google.com, quic_jiles@quicinc.com, rafael@kernel.org, robh@kernel.org, rohit.mathew@arm.com, scott@os.amperecomputing.com, sdonthineni@nvidia.com, sudeep.holla@arm.com, tan.shaopeng@fujitsu.com, will@kernel.org, xhao@linux.alibaba.com, reinette.chatre@intel.com, Shaopeng Tan , Zeng Heng References: <20251119122305.302149-1-ben.horgan@arm.com> <20251119122305.302149-3-ben.horgan@arm.com> Content-Language: en-US From: Jeremy Linton In-Reply-To: <20251119122305.302149-3-ben.horgan@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251119_090841_810004_43CC5C0E X-CRM114-Status: GOOD ( 24.44 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 11/19/25 6:22 AM, Ben Horgan wrote: > From: James Morse > > In acpi_count_levels(), the initial value of *levels passed by the > caller is really an implementation detail of acpi_count_levels(), so it > is unreasonable to expect the callers of this function to know what to > pass in for this parameter. The only sensible initial value is 0, > which is what the only upstream caller (acpi_get_cache_info()) passes. > > Use a local variable for the starting cache level in acpi_count_levels(), > and pass the result back to the caller via the function return value. > > Get rid of the levels parameter, which has no remaining purpose. > > Fix acpi_get_cache_info() to match. Per V5: Reviewed-by: Jeremy Linton > > Suggested-by: Jonathan Cameron > Signed-off-by: James Morse > Reviewed-by: Lorenzo Pieralisi > Reviewed-by: Jonathan Cameron > Reviewed-by: Fenghua Yu > Reviewed-by: Gavin Shan > Reviewed-by: Shaopeng Tan > Reviewed-by: Hanjun Guo > Tested-by: Fenghua Yu > Tested-by: Shaopeng Tan > Tested-by: Peter Newman > Tested-by: Carl Worth > Tested-by: Gavin Shan > Tested-by: Zeng Heng > Tested-by: Hanjun Guo > Signed-off-by: Ben Horgan > --- > Changes since v3: > s/starting_level/current_level/ (Jonathan) > --- > drivers/acpi/pptt.c | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) > > diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c > index b8248c0092fe..2856254e29d7 100644 > --- a/drivers/acpi/pptt.c > +++ b/drivers/acpi/pptt.c > @@ -177,14 +177,14 @@ acpi_find_cache_level(struct acpi_table_header *table_hdr, > } > > /** > - * acpi_count_levels() - Given a PPTT table, and a CPU node, count the cache > - * levels and split cache levels (data/instruction). > + * acpi_count_levels() - Given a PPTT table, and a CPU node, count the > + * total number of levels and split cache levels (data/instruction). > * @table_hdr: Pointer to the head of the PPTT table > * @cpu_node: processor node we wish to count caches for > - * @levels: Number of levels if success. > * @split_levels: Number of split cache levels (data/instruction) if > * success. Can by NULL. > * > + * Return: number of levels. > * Given a processor node containing a processing unit, walk into it and count > * how many levels exist solely for it, and then walk up each level until we hit > * the root node (ignore the package level because it may be possible to have > @@ -192,14 +192,18 @@ acpi_find_cache_level(struct acpi_table_header *table_hdr, > * split cache levels (data/instruction) that exist at each level on the way > * up. > */ > -static void acpi_count_levels(struct acpi_table_header *table_hdr, > - struct acpi_pptt_processor *cpu_node, > - unsigned int *levels, unsigned int *split_levels) > +static int acpi_count_levels(struct acpi_table_header *table_hdr, > + struct acpi_pptt_processor *cpu_node, > + unsigned int *split_levels) > { > + int current_level = 0; > + > do { > - acpi_find_cache_level(table_hdr, cpu_node, levels, split_levels, 0, 0); > + acpi_find_cache_level(table_hdr, cpu_node, ¤t_level, split_levels, 0, 0); > cpu_node = fetch_pptt_node(table_hdr, cpu_node->parent); > } while (cpu_node); > + > + return current_level; > } > > /** > @@ -645,7 +649,7 @@ int acpi_get_cache_info(unsigned int cpu, unsigned int *levels, > if (!cpu_node) > return -ENOENT; > > - acpi_count_levels(table, cpu_node, levels, split_levels); > + *levels = acpi_count_levels(table, cpu_node, split_levels); > > pr_debug("Cache Setup: last_level=%d split_levels=%d\n", > *levels, split_levels ? *split_levels : -1);