1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_S390_TOPOLOGY_H
3 #define _ASM_S390_TOPOLOGY_H
4 
5 #include <linux/cpumask.h>
6 #include <asm/numa.h>
7 
8 struct sysinfo_15_1_x;
9 struct cpu;
10 
11 #ifdef CONFIG_SCHED_TOPOLOGY
12 
13 struct cpu_topology_s390 {
14 	unsigned short thread_id;
15 	unsigned short core_id;
16 	unsigned short socket_id;
17 	unsigned short book_id;
18 	unsigned short drawer_id;
19 	unsigned short dedicated : 1;
20 	int booted_cores;
21 	cpumask_t thread_mask;
22 	cpumask_t core_mask;
23 	cpumask_t book_mask;
24 	cpumask_t drawer_mask;
25 };
26 
27 extern struct cpu_topology_s390 cpu_topology[NR_CPUS];
28 
29 #define topology_physical_package_id(cpu) (cpu_topology[cpu].socket_id)
30 #define topology_thread_id(cpu)		  (cpu_topology[cpu].thread_id)
31 #define topology_sibling_cpumask(cpu)	  (&cpu_topology[cpu].thread_mask)
32 #define topology_core_id(cpu)		  (cpu_topology[cpu].core_id)
33 #define topology_core_cpumask(cpu)	  (&cpu_topology[cpu].core_mask)
34 #define topology_book_id(cpu)		  (cpu_topology[cpu].book_id)
35 #define topology_book_cpumask(cpu)	  (&cpu_topology[cpu].book_mask)
36 #define topology_drawer_id(cpu)		  (cpu_topology[cpu].drawer_id)
37 #define topology_drawer_cpumask(cpu)	  (&cpu_topology[cpu].drawer_mask)
38 #define topology_cpu_dedicated(cpu)	  (cpu_topology[cpu].dedicated)
39 #define topology_booted_cores(cpu)	  (cpu_topology[cpu].booted_cores)
40 
41 #define mc_capable() 1
42 
43 void topology_init_early(void);
44 int topology_cpu_init(struct cpu *);
45 int topology_set_cpu_management(int fc);
46 void topology_schedule_update(void);
47 void store_topology(struct sysinfo_15_1_x *info);
48 void update_cpu_masks(void);
49 void topology_expect_change(void);
50 const struct cpumask *cpu_coregroup_mask(int cpu);
51 
52 #else /* CONFIG_SCHED_TOPOLOGY */
53 
topology_init_early(void)54 static inline void topology_init_early(void) { }
topology_schedule_update(void)55 static inline void topology_schedule_update(void) { }
topology_cpu_init(struct cpu * cpu)56 static inline int topology_cpu_init(struct cpu *cpu) { return 0; }
topology_cpu_dedicated(int cpu_nr)57 static inline int topology_cpu_dedicated(int cpu_nr) { return 0; }
topology_booted_cores(int cpu_nr)58 static inline int topology_booted_cores(int cpu_nr) { return 1; }
update_cpu_masks(void)59 static inline void update_cpu_masks(void) { }
topology_expect_change(void)60 static inline void topology_expect_change(void) { }
61 
62 #endif /* CONFIG_SCHED_TOPOLOGY */
63 
topology_is_primary_thread(unsigned int cpu)64 static inline bool topology_is_primary_thread(unsigned int cpu)
65 {
66 	return smp_get_base_cpu(cpu) == cpu;
67 }
68 #define topology_is_primary_thread topology_is_primary_thread
69 
70 #define POLARIZATION_UNKNOWN	(-1)
71 #define POLARIZATION_HRZ	(0)
72 #define POLARIZATION_VL		(1)
73 #define POLARIZATION_VM		(2)
74 #define POLARIZATION_VH		(3)
75 
76 #define CPU_CAPACITY_HIGH	SCHED_CAPACITY_SCALE
77 #define CPU_CAPACITY_LOW	(SCHED_CAPACITY_SCALE >> 3)
78 
79 #define SD_BOOK_INIT	SD_CPU_INIT
80 
81 #ifdef CONFIG_NUMA
82 
83 #define cpu_to_node cpu_to_node
cpu_to_node(int cpu)84 static inline int cpu_to_node(int cpu)
85 {
86 	return 0;
87 }
88 
89 /* Returns a pointer to the cpumask of CPUs on node 'node'. */
90 #define cpumask_of_node cpumask_of_node
cpumask_of_node(int node)91 static inline const struct cpumask *cpumask_of_node(int node)
92 {
93 	return cpu_possible_mask;
94 }
95 
96 #define pcibus_to_node(bus) __pcibus_to_node(bus)
97 
98 #else /* !CONFIG_NUMA */
99 
100 #define numa_node_id numa_node_id
numa_node_id(void)101 static inline int numa_node_id(void)
102 {
103 	return 0;
104 }
105 
106 #endif /* CONFIG_NUMA */
107 
108 #include <asm-generic/topology.h>
109 
110 #endif /* _ASM_S390_TOPOLOGY_H */
111