From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93FF82BE632; Wed, 19 Nov 2025 16:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569544; cv=none; b=Dip7cMEosGqmS6RmFqhiRIqOGGFG5FyssmcyCSiU2QhgjrFMgrX+V2tIBuxssjbAchyMvrY2Z+PSbi8XRpp4I4W+O7OyTzQlSD4YlVyIBjRqAPzWB6u8zAdpLuOMZihw6aKGq799Ie8qJ9zPpyJS+sx0mGihpyAKpauG/mqrZkU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763569544; c=relaxed/simple; bh=Ga0lixxhrYPZE4SSZzD+XzBKaMqZs4tC/kSZx/TQHXM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=LTGYVwdDVjeb95vC096vvF/HnHrlMEqCbuN4SLdpMUItJRDzMXDSvYYuLOjZ+52WLKm4vqT1em7LivC9ZvJ92A9GyqjBIcjC8mUmIP0DXte1ddKUyuzT5EaPbfXrFNpgSHWh9ki9UCTtXICEhGcRJb8gRJsIXrMPJTuaRB88j8w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 58B4BFEC; Wed, 19 Nov 2025 08:25:34 -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 3BFC43F740; Wed, 19 Nov 2025 08:25:38 -0800 (PST) Message-ID: Date: Wed, 19 Nov 2025 10:25:37 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 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, Shaopeng Tan , Zeng Heng References: <20251117170014.4113754-1-ben.horgan@arm.com> <20251117170014.4113754-3-ben.horgan@arm.com> Content-Language: en-US From: Jeremy Linton In-Reply-To: <20251117170014.4113754-3-ben.horgan@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/17/25 10:59 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. Sure, 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 > Tested-by: Fenghua Yu > Tested-by: Shaopeng Tan > Tested-by: Peter Newman > Tested-by: Carl Worth > Tested-by: Gavin Shan > Tested-by: Zeng Heng > 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);