[PATCH v3 02/29] ACPI / PPTT: Stop acpi_count_levels() expecting callers to clear levels
Ben Horgan
ben.horgan at arm.com
Thu Nov 6 08:10:33 PST 2025
Hi Jonathan,
On 10/24/25 12:29, Jonathan Cameron wrote:
> On Fri, 17 Oct 2025 18:56:18 +0000
> James Morse <james.morse at arm.com> wrote:
>
>> 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.
>>
>> Suggested-by: Jonathan Cameron <jonathan.cameron at huawei.com>
>> Signed-off-by: James Morse <james.morse at arm.com>
>> Reviewed-by: Lorenzo Pieralisi <lpieralisi at kernel.org>
>> Reviewed-by: Jonathan Cameron <jonathan.cameron at huawei.com>
>> Reviewed-by: Fenghua Yu <fenghuay at nvidia.com>
>> Tested-by: Fenghua Yu <fenghuay at nvidia.com>
>
> Another meh, the name is confusing type comment.
>
>> -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 starting_level = 0;
>> +
>> do {
>> - acpi_find_cache_level(table_hdr, cpu_node, levels, split_levels, 0, 0);
>> + acpi_find_cache_level(table_hdr, cpu_node, &starting_level, split_levels, 0, 0);
>> cpu_node = fetch_pptt_node(table_hdr, cpu_node->parent);
>> } while (cpu_node);
>> +
>> + return starting_level;
> Given it's not the starting level at this point... Maybe just call it level or current_level.
Makes sense. I've made this update.
>> }
>>
>> /**
>> @@ -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);
>
>
Thanks,
Ben
More information about the linux-arm-kernel
mailing list