Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * include/linux/arch_topology.h - arch specific cpu topology information
0004  */
0005 #ifndef _LINUX_ARCH_TOPOLOGY_H_
0006 #define _LINUX_ARCH_TOPOLOGY_H_
0007 
0008 #include <linux/types.h>
0009 #include <linux/percpu.h>
0010 
0011 void topology_normalize_cpu_scale(void);
0012 int topology_update_cpu_topology(void);
0013 
0014 #ifdef CONFIG_ACPI_CPPC_LIB
0015 void topology_init_cpu_capacity_cppc(void);
0016 #endif
0017 
0018 struct device_node;
0019 bool topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu);
0020 
0021 DECLARE_PER_CPU(unsigned long, cpu_scale);
0022 
0023 static inline unsigned long topology_get_cpu_scale(int cpu)
0024 {
0025     return per_cpu(cpu_scale, cpu);
0026 }
0027 
0028 void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity);
0029 
0030 DECLARE_PER_CPU(unsigned long, arch_freq_scale);
0031 
0032 static inline unsigned long topology_get_freq_scale(int cpu)
0033 {
0034     return per_cpu(arch_freq_scale, cpu);
0035 }
0036 
0037 void topology_set_freq_scale(const struct cpumask *cpus, unsigned long cur_freq,
0038                  unsigned long max_freq);
0039 bool topology_scale_freq_invariant(void);
0040 
0041 enum scale_freq_source {
0042     SCALE_FREQ_SOURCE_CPUFREQ = 0,
0043     SCALE_FREQ_SOURCE_ARCH,
0044     SCALE_FREQ_SOURCE_CPPC,
0045 };
0046 
0047 struct scale_freq_data {
0048     enum scale_freq_source source;
0049     void (*set_freq_scale)(void);
0050 };
0051 
0052 void topology_scale_freq_tick(void);
0053 void topology_set_scale_freq_source(struct scale_freq_data *data, const struct cpumask *cpus);
0054 void topology_clear_scale_freq_source(enum scale_freq_source source, const struct cpumask *cpus);
0055 
0056 DECLARE_PER_CPU(unsigned long, thermal_pressure);
0057 
0058 static inline unsigned long topology_get_thermal_pressure(int cpu)
0059 {
0060     return per_cpu(thermal_pressure, cpu);
0061 }
0062 
0063 void topology_update_thermal_pressure(const struct cpumask *cpus,
0064                       unsigned long capped_freq);
0065 
0066 struct cpu_topology {
0067     int thread_id;
0068     int core_id;
0069     int cluster_id;
0070     int package_id;
0071     cpumask_t thread_sibling;
0072     cpumask_t core_sibling;
0073     cpumask_t cluster_sibling;
0074     cpumask_t llc_sibling;
0075 };
0076 
0077 #ifdef CONFIG_GENERIC_ARCH_TOPOLOGY
0078 extern struct cpu_topology cpu_topology[NR_CPUS];
0079 
0080 #define topology_physical_package_id(cpu)   (cpu_topology[cpu].package_id)
0081 #define topology_cluster_id(cpu)    (cpu_topology[cpu].cluster_id)
0082 #define topology_core_id(cpu)       (cpu_topology[cpu].core_id)
0083 #define topology_core_cpumask(cpu)  (&cpu_topology[cpu].core_sibling)
0084 #define topology_sibling_cpumask(cpu)   (&cpu_topology[cpu].thread_sibling)
0085 #define topology_cluster_cpumask(cpu)   (&cpu_topology[cpu].cluster_sibling)
0086 #define topology_llc_cpumask(cpu)   (&cpu_topology[cpu].llc_sibling)
0087 void init_cpu_topology(void);
0088 void store_cpu_topology(unsigned int cpuid);
0089 const struct cpumask *cpu_coregroup_mask(int cpu);
0090 const struct cpumask *cpu_clustergroup_mask(int cpu);
0091 void update_siblings_masks(unsigned int cpu);
0092 void remove_cpu_topology(unsigned int cpuid);
0093 void reset_cpu_topology(void);
0094 int parse_acpi_topology(void);
0095 #endif
0096 
0097 #endif /* _LINUX_ARCH_TOPOLOGY_H_ */