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