blob: 88a115e81f2769b5e9f411bbcaf646799eaa5f08 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Juri Lelli615ffd62017-05-31 17:59:30 +01002/*
3 * include/linux/arch_topology.h - arch specific cpu topology information
4 */
5#ifndef _LINUX_ARCH_TOPOLOGY_H_
6#define _LINUX_ARCH_TOPOLOGY_H_
7
Viresh Kumar805df292017-06-23 14:55:32 +05308#include <linux/types.h>
Dietmar Eggemann0e27c562017-09-26 17:41:10 +01009#include <linux/percpu.h>
Viresh Kumar805df292017-06-23 14:55:32 +053010
Juri Lelli4ca4f262017-05-31 17:59:31 +010011void topology_normalize_cpu_scale(void);
Morten Rasmussenbb1fbdd2018-07-20 14:32:32 +010012int topology_update_cpu_topology(void);
Juri Lelli615ffd62017-05-31 17:59:30 +010013
14struct device_node;
Viresh Kumar805df292017-06-23 14:55:32 +053015bool topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu);
Juri Lelli615ffd62017-05-31 17:59:30 +010016
Dietmar Eggemann8216f582017-09-26 17:41:11 +010017DECLARE_PER_CPU(unsigned long, cpu_scale);
18
Juri Lelli615ffd62017-05-31 17:59:30 +010019struct sched_domain;
Dietmar Eggemann8216f582017-09-26 17:41:11 +010020static inline
Vincent Guittot8ec59c02019-06-17 17:00:17 +020021unsigned long topology_get_cpu_scale(int cpu)
Dietmar Eggemann8216f582017-09-26 17:41:11 +010022{
23 return per_cpu(cpu_scale, cpu);
24}
Juri Lelli615ffd62017-05-31 17:59:30 +010025
Juri Lelli4ca4f262017-05-31 17:59:31 +010026void topology_set_cpu_scale(unsigned int cpu, unsigned long capacity);
Juri Lelli615ffd62017-05-31 17:59:30 +010027
Dietmar Eggemann0e27c562017-09-26 17:41:10 +010028DECLARE_PER_CPU(unsigned long, freq_scale);
29
30static inline
Juri Lelli7673c8a2017-12-04 11:23:23 +010031unsigned long topology_get_freq_scale(int cpu)
Dietmar Eggemann0e27c562017-09-26 17:41:10 +010032{
33 return per_cpu(freq_scale, cpu);
34}
35
Thara Gopinathad58cc52020-02-21 19:52:07 -050036DECLARE_PER_CPU(unsigned long, thermal_pressure);
37
38static inline unsigned long topology_get_thermal_pressure(int cpu)
39{
40 return per_cpu(thermal_pressure, cpu);
41}
42
43void arch_set_thermal_pressure(struct cpumask *cpus,
44 unsigned long th_pressure);
45
Atish Patra60c1b222019-06-27 12:52:58 -070046struct cpu_topology {
47 int thread_id;
48 int core_id;
49 int package_id;
50 int llc_id;
51 cpumask_t thread_sibling;
52 cpumask_t core_sibling;
53 cpumask_t llc_sibling;
54};
55
56#ifdef CONFIG_GENERIC_ARCH_TOPOLOGY
57extern struct cpu_topology cpu_topology[NR_CPUS];
58
59#define topology_physical_package_id(cpu) (cpu_topology[cpu].package_id)
60#define topology_core_id(cpu) (cpu_topology[cpu].core_id)
61#define topology_core_cpumask(cpu) (&cpu_topology[cpu].core_sibling)
62#define topology_sibling_cpumask(cpu) (&cpu_topology[cpu].thread_sibling)
63#define topology_llc_cpumask(cpu) (&cpu_topology[cpu].llc_sibling)
64void init_cpu_topology(void);
65void store_cpu_topology(unsigned int cpuid);
66const struct cpumask *cpu_coregroup_mask(int cpu);
Atish Patra60c1b222019-06-27 12:52:58 -070067void update_siblings_masks(unsigned int cpu);
Atish Patra60c1b222019-06-27 12:52:58 -070068void remove_cpu_topology(unsigned int cpuid);
Atish Patraca74b312019-06-27 12:52:59 -070069void reset_cpu_topology(void);
Ben Dooks (Codethink)edb44e842019-10-22 09:43:23 +010070int parse_acpi_topology(void);
Atish Patraca74b312019-06-27 12:52:59 -070071#endif
Atish Patra60c1b222019-06-27 12:52:58 -070072
Juri Lelli615ffd62017-05-31 17:59:30 +010073#endif /* _LINUX_ARCH_TOPOLOGY_H_ */