mirror of https://github.com/torvalds/linux.git
ACPI / PPTT: Add a helper to fill a cpumask from a cache_id
MPAM identifies CPUs by the cache_id in the PPTT cache structure. The driver needs to know which CPUs are associated with the cache. The CPUs may not all be online, so cacheinfo does not have the information. Add a helper to pull this information out of the PPTT. CC: Rohit Mathew <Rohit.Mathew@arm.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Jeremy Linton <jeremy.linton@arm.com> Tested-by: Fenghua Yu <fenghuay@nvidia.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: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Hanjun Guo <guohanjun@huawei.com> Signed-off-by: James Morse <james.morse@arm.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
41a7bb39fe
commit
a39a723a6f
|
|
@ -998,3 +998,68 @@ int find_acpi_cache_level_from_id(u32 cache_id)
|
||||||
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* acpi_pptt_get_cpumask_from_cache_id() - Get the cpus associated with the
|
||||||
|
* specified cache
|
||||||
|
* @cache_id: The id field of the cache
|
||||||
|
* @cpus: Where to build the cpumask
|
||||||
|
*
|
||||||
|
* Determine which CPUs are below this cache in the PPTT. This allows the property
|
||||||
|
* to be found even if the CPUs are offline.
|
||||||
|
*
|
||||||
|
* The PPTT table must be rev 3 or later,
|
||||||
|
*
|
||||||
|
* Return: -ENOENT if the PPTT doesn't exist, or the cache cannot be found.
|
||||||
|
* Otherwise returns 0 and sets the cpus in the provided cpumask.
|
||||||
|
*/
|
||||||
|
int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id, cpumask_t *cpus)
|
||||||
|
{
|
||||||
|
int cpu;
|
||||||
|
struct acpi_table_header *table;
|
||||||
|
|
||||||
|
cpumask_clear(cpus);
|
||||||
|
|
||||||
|
table = acpi_get_pptt();
|
||||||
|
if (!table)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
if (table->revision < 3)
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
for_each_possible_cpu(cpu) {
|
||||||
|
bool empty;
|
||||||
|
int level = 1;
|
||||||
|
u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu);
|
||||||
|
struct acpi_pptt_cache *cache;
|
||||||
|
struct acpi_pptt_processor *cpu_node;
|
||||||
|
|
||||||
|
cpu_node = acpi_find_processor_node(table, acpi_cpu_id);
|
||||||
|
if (!cpu_node)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
do {
|
||||||
|
int cache_type[] = {CACHE_TYPE_INST, CACHE_TYPE_DATA, CACHE_TYPE_UNIFIED};
|
||||||
|
|
||||||
|
empty = true;
|
||||||
|
for (int i = 0; i < ARRAY_SIZE(cache_type); i++) {
|
||||||
|
struct acpi_pptt_cache_v1_full *cache_v1;
|
||||||
|
|
||||||
|
cache = acpi_find_cache_node(table, acpi_cpu_id, cache_type[i],
|
||||||
|
level, &cpu_node);
|
||||||
|
|
||||||
|
if (!cache)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
empty = false;
|
||||||
|
|
||||||
|
cache_v1 = upgrade_pptt_cache(cache);
|
||||||
|
if (cache_v1 && cache_v1->cache_id == cache_id)
|
||||||
|
cpumask_set_cpu(cpu, cpus);
|
||||||
|
}
|
||||||
|
level++;
|
||||||
|
} while (!empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1543,6 +1543,7 @@ int find_acpi_cpu_topology_package(unsigned int cpu);
|
||||||
int find_acpi_cpu_topology_hetero_id(unsigned int cpu);
|
int find_acpi_cpu_topology_hetero_id(unsigned int cpu);
|
||||||
void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, cpumask_t *cpus);
|
void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, cpumask_t *cpus);
|
||||||
int find_acpi_cache_level_from_id(u32 cache_id);
|
int find_acpi_cache_level_from_id(u32 cache_id);
|
||||||
|
int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id, cpumask_t *cpus);
|
||||||
#else
|
#else
|
||||||
static inline int acpi_pptt_cpu_is_thread(unsigned int cpu)
|
static inline int acpi_pptt_cpu_is_thread(unsigned int cpu)
|
||||||
{
|
{
|
||||||
|
|
@ -1570,6 +1571,11 @@ static inline int find_acpi_cache_level_from_id(u32 cache_id)
|
||||||
{
|
{
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
static inline int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id,
|
||||||
|
cpumask_t *cpus)
|
||||||
|
{
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void acpi_arch_init(void);
|
void acpi_arch_init(void);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue