Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ACPI / PPTT: Stop acpi_count_levels() expecting callers to clear levels

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@huawei.com>
Signed-off-by: James Morse <james.morse@arm.com>
Reviewed-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
Reviewed-by: Jeremy Linton <jeremy.linton@arm.com>
Tested-by: Fenghua Yu <fenghuay@nvidia.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Peter Newman <peternewman@google.com>
Tested-by: Carl Worth <carl@os.amperecomputing.com>
Tested-by: Gavin Shan <gshan@redhat.com>
Tested-by: Zeng Heng <zengheng4@huawei.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

James Morse and committed by
Catalin Marinas
eeec7845 796e29b8

+12 -8
+12 -8
drivers/acpi/pptt.c
··· 177 177 } 178 178 179 179 /** 180 - * acpi_count_levels() - Given a PPTT table, and a CPU node, count the cache 181 - * levels and split cache levels (data/instruction). 180 + * acpi_count_levels() - Given a PPTT table, and a CPU node, count the 181 + * total number of levels and split cache levels (data/instruction). 182 182 * @table_hdr: Pointer to the head of the PPTT table 183 183 * @cpu_node: processor node we wish to count caches for 184 - * @levels: Number of levels if success. 185 184 * @split_levels: Number of split cache levels (data/instruction) if 186 185 * success. Can by NULL. 187 186 * 187 + * Return: number of levels. 188 188 * Given a processor node containing a processing unit, walk into it and count 189 189 * how many levels exist solely for it, and then walk up each level until we hit 190 190 * the root node (ignore the package level because it may be possible to have ··· 192 192 * split cache levels (data/instruction) that exist at each level on the way 193 193 * up. 194 194 */ 195 - static void acpi_count_levels(struct acpi_table_header *table_hdr, 196 - struct acpi_pptt_processor *cpu_node, 197 - unsigned int *levels, unsigned int *split_levels) 195 + static int acpi_count_levels(struct acpi_table_header *table_hdr, 196 + struct acpi_pptt_processor *cpu_node, 197 + unsigned int *split_levels) 198 198 { 199 + int current_level = 0; 200 + 199 201 do { 200 - acpi_find_cache_level(table_hdr, cpu_node, levels, split_levels, 0, 0); 202 + acpi_find_cache_level(table_hdr, cpu_node, &current_level, split_levels, 0, 0); 201 203 cpu_node = fetch_pptt_node(table_hdr, cpu_node->parent); 202 204 } while (cpu_node); 205 + 206 + return current_level; 203 207 } 204 208 205 209 /** ··· 649 645 if (!cpu_node) 650 646 return -ENOENT; 651 647 652 - acpi_count_levels(table, cpu_node, levels, split_levels); 648 + *levels = acpi_count_levels(table, cpu_node, split_levels); 653 649 654 650 pr_debug("Cache Setup: last_level=%d split_levels=%d\n", 655 651 *levels, split_levels ? *split_levels : -1);