mirror of https://github.com/torvalds/linux.git
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>
This commit is contained in:
parent
796e29b857
commit
eeec7845e9
|
|
@ -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
|
* acpi_count_levels() - Given a PPTT table, and a CPU node, count the
|
||||||
* levels and split cache levels (data/instruction).
|
* total number of levels and split cache levels (data/instruction).
|
||||||
* @table_hdr: Pointer to the head of the PPTT table
|
* @table_hdr: Pointer to the head of the PPTT table
|
||||||
* @cpu_node: processor node we wish to count caches for
|
* @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
|
* @split_levels: Number of split cache levels (data/instruction) if
|
||||||
* success. Can by NULL.
|
* success. Can by NULL.
|
||||||
*
|
*
|
||||||
|
* Return: number of levels.
|
||||||
* Given a processor node containing a processing unit, walk into it and count
|
* 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
|
* 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
|
* 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
|
* split cache levels (data/instruction) that exist at each level on the way
|
||||||
* up.
|
* up.
|
||||||
*/
|
*/
|
||||||
static void acpi_count_levels(struct acpi_table_header *table_hdr,
|
static int acpi_count_levels(struct acpi_table_header *table_hdr,
|
||||||
struct acpi_pptt_processor *cpu_node,
|
struct acpi_pptt_processor *cpu_node,
|
||||||
unsigned int *levels, unsigned int *split_levels)
|
unsigned int *split_levels)
|
||||||
{
|
{
|
||||||
|
int current_level = 0;
|
||||||
|
|
||||||
do {
|
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);
|
cpu_node = fetch_pptt_node(table_hdr, cpu_node->parent);
|
||||||
} while (cpu_node);
|
} while (cpu_node);
|
||||||
|
|
||||||
|
return current_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -645,7 +649,7 @@ int acpi_get_cache_info(unsigned int cpu, unsigned int *levels,
|
||||||
if (!cpu_node)
|
if (!cpu_node)
|
||||||
return -ENOENT;
|
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",
|
pr_debug("Cache Setup: last_level=%d split_levels=%d\n",
|
||||||
*levels, split_levels ? *split_levels : -1);
|
*levels, split_levels ? *split_levels : -1);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue