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 processor container

The ACPI MPAM table uses the UID of a processor container specified in
the PPTT to indicate the subset of CPUs and cache topology that can
access each MPAM System Component (MSC).

This information is not directly useful to the kernel. The equivalent
cpumask is needed instead.

Add a helper to find the processor container by its id, then walk
the possible CPUs to fill a cpumask with the CPUs that have this
processor container as a parent.

CC: Dave Martin <dave.martin@arm.com>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
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: 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
796e29b8 3a866087

+87
+84
drivers/acpi/pptt.c
··· 817 817 return find_acpi_cpu_topology_tag(cpu, PPTT_ABORT_PACKAGE, 818 818 ACPI_PPTT_ACPI_IDENTICAL); 819 819 } 820 + 821 + /** 822 + * acpi_pptt_get_child_cpus() - Find all the CPUs below a PPTT 823 + * processor hierarchy node 824 + * 825 + * @table_hdr: A reference to the PPTT table 826 + * @parent_node: A pointer to the processor hierarchy node in the 827 + * table_hdr 828 + * @cpus: A cpumask to fill with the CPUs below @parent_node 829 + * 830 + * Walks up the PPTT from every possible CPU to find if the provided 831 + * @parent_node is a parent of this CPU. 832 + */ 833 + static void acpi_pptt_get_child_cpus(struct acpi_table_header *table_hdr, 834 + struct acpi_pptt_processor *parent_node, 835 + cpumask_t *cpus) 836 + { 837 + struct acpi_pptt_processor *cpu_node; 838 + u32 acpi_id; 839 + int cpu; 840 + 841 + cpumask_clear(cpus); 842 + 843 + for_each_possible_cpu(cpu) { 844 + acpi_id = get_acpi_id_for_cpu(cpu); 845 + cpu_node = acpi_find_processor_node(table_hdr, acpi_id); 846 + 847 + while (cpu_node) { 848 + if (cpu_node == parent_node) { 849 + cpumask_set_cpu(cpu, cpus); 850 + break; 851 + } 852 + cpu_node = fetch_pptt_node(table_hdr, cpu_node->parent); 853 + } 854 + } 855 + } 856 + 857 + /** 858 + * acpi_pptt_get_cpus_from_container() - Populate a cpumask with all CPUs in a 859 + * processor container 860 + * @acpi_cpu_id: The UID of the processor container 861 + * @cpus: The resulting CPU mask 862 + * 863 + * Find the specified Processor Container, and fill @cpus with all the cpus 864 + * below it. 865 + * 866 + * Not all 'Processor Hierarchy' entries in the PPTT are either a CPU 867 + * or a Processor Container, they may exist purely to describe a 868 + * Private resource. CPUs have to be leaves, so a Processor Container 869 + * is a non-leaf that has the 'ACPI Processor ID valid' flag set. 870 + */ 871 + void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, cpumask_t *cpus) 872 + { 873 + struct acpi_table_header *table_hdr; 874 + struct acpi_subtable_header *entry; 875 + unsigned long table_end; 876 + u32 proc_sz; 877 + 878 + cpumask_clear(cpus); 879 + 880 + table_hdr = acpi_get_pptt(); 881 + if (!table_hdr) 882 + return; 883 + 884 + table_end = (unsigned long)table_hdr + table_hdr->length; 885 + entry = ACPI_ADD_PTR(struct acpi_subtable_header, table_hdr, 886 + sizeof(struct acpi_table_pptt)); 887 + proc_sz = sizeof(struct acpi_pptt_processor); 888 + while ((unsigned long)entry + proc_sz <= table_end) { 889 + if (entry->type == ACPI_PPTT_TYPE_PROCESSOR) { 890 + struct acpi_pptt_processor *cpu_node; 891 + 892 + cpu_node = (struct acpi_pptt_processor *)entry; 893 + if (cpu_node->flags & ACPI_PPTT_ACPI_PROCESSOR_ID_VALID && 894 + !acpi_pptt_leaf_node(table_hdr, cpu_node) && 895 + cpu_node->acpi_processor_id == acpi_cpu_id) { 896 + acpi_pptt_get_child_cpus(table_hdr, cpu_node, cpus); 897 + break; 898 + } 899 + } 900 + entry = ACPI_ADD_PTR(struct acpi_subtable_header, entry, 901 + entry->length); 902 + } 903 + }
+3
include/linux/acpi.h
··· 1541 1541 int find_acpi_cpu_topology_cluster(unsigned int cpu); 1542 1542 int find_acpi_cpu_topology_package(unsigned int cpu); 1543 1543 int find_acpi_cpu_topology_hetero_id(unsigned int cpu); 1544 + void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, cpumask_t *cpus); 1544 1545 #else 1545 1546 static inline int acpi_pptt_cpu_is_thread(unsigned int cpu) 1546 1547 { ··· 1563 1562 { 1564 1563 return -EINVAL; 1565 1564 } 1565 + static inline void acpi_pptt_get_cpus_from_container(u32 acpi_cpu_id, 1566 + cpumask_t *cpus) { } 1566 1567 #endif 1567 1568 1568 1569 void acpi_arch_init(void);