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: 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>

authored by

James Morse and committed by
Catalin Marinas
a39a723a 41a7bb39

+71
+65
drivers/acpi/pptt.c
··· 998 998 999 999 return -ENOENT; 1000 1000 } 1001 + 1002 + /** 1003 + * acpi_pptt_get_cpumask_from_cache_id() - Get the cpus associated with the 1004 + * specified cache 1005 + * @cache_id: The id field of the cache 1006 + * @cpus: Where to build the cpumask 1007 + * 1008 + * Determine which CPUs are below this cache in the PPTT. This allows the property 1009 + * to be found even if the CPUs are offline. 1010 + * 1011 + * The PPTT table must be rev 3 or later, 1012 + * 1013 + * Return: -ENOENT if the PPTT doesn't exist, or the cache cannot be found. 1014 + * Otherwise returns 0 and sets the cpus in the provided cpumask. 1015 + */ 1016 + int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id, cpumask_t *cpus) 1017 + { 1018 + int cpu; 1019 + struct acpi_table_header *table; 1020 + 1021 + cpumask_clear(cpus); 1022 + 1023 + table = acpi_get_pptt(); 1024 + if (!table) 1025 + return -ENOENT; 1026 + 1027 + if (table->revision < 3) 1028 + return -ENOENT; 1029 + 1030 + for_each_possible_cpu(cpu) { 1031 + bool empty; 1032 + int level = 1; 1033 + u32 acpi_cpu_id = get_acpi_id_for_cpu(cpu); 1034 + struct acpi_pptt_cache *cache; 1035 + struct acpi_pptt_processor *cpu_node; 1036 + 1037 + cpu_node = acpi_find_processor_node(table, acpi_cpu_id); 1038 + if (!cpu_node) 1039 + continue; 1040 + 1041 + do { 1042 + int cache_type[] = {CACHE_TYPE_INST, CACHE_TYPE_DATA, CACHE_TYPE_UNIFIED}; 1043 + 1044 + empty = true; 1045 + for (int i = 0; i < ARRAY_SIZE(cache_type); i++) { 1046 + struct acpi_pptt_cache_v1_full *cache_v1; 1047 + 1048 + cache = acpi_find_cache_node(table, acpi_cpu_id, cache_type[i], 1049 + level, &cpu_node); 1050 + 1051 + if (!cache) 1052 + continue; 1053 + 1054 + empty = false; 1055 + 1056 + cache_v1 = upgrade_pptt_cache(cache); 1057 + if (cache_v1 && cache_v1->cache_id == cache_id) 1058 + cpumask_set_cpu(cpu, cpus); 1059 + } 1060 + level++; 1061 + } while (!empty); 1062 + } 1063 + 1064 + return 0; 1065 + }
+6
include/linux/acpi.h
··· 1543 1543 int find_acpi_cpu_topology_hetero_id(unsigned int cpu); 1544 1544 void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, cpumask_t *cpus); 1545 1545 int find_acpi_cache_level_from_id(u32 cache_id); 1546 + int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id, cpumask_t *cpus); 1546 1547 #else 1547 1548 static inline int acpi_pptt_cpu_is_thread(unsigned int cpu) 1548 1549 { ··· 1568 1567 static inline void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, 1569 1568 cpumask_t *cpus) { } 1570 1569 static inline int find_acpi_cache_level_from_id(u32 cache_id) 1570 + { 1571 + return -ENOENT; 1572 + } 1573 + static inline int acpi_pptt_get_cpumask_from_cache_id(u32 cache_id, 1574 + cpumask_t *cpus) 1571 1575 { 1572 1576 return -ENOENT; 1573 1577 }