xref: /openbmc/linux/arch/s390/include/asm/topology.h (revision 4b4193256c8d3bc3a5397b5cd9494c2ad386317d)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2c6557e7fSMartin Schwidefsky #ifndef _ASM_S390_TOPOLOGY_H
3c6557e7fSMartin Schwidefsky #define _ASM_S390_TOPOLOGY_H
4c6557e7fSMartin Schwidefsky 
5c6557e7fSMartin Schwidefsky #include <linux/cpumask.h>
63a368f74SPhilipp Hachtmann #include <asm/numa.h>
7c6557e7fSMartin Schwidefsky 
878609132SHeiko Carstens struct sysinfo_15_1_x;
983a24e32SHeiko Carstens struct cpu;
1083a24e32SHeiko Carstens 
119236b4ddSHeiko Carstens #ifdef CONFIG_SCHED_TOPOLOGY
1283a24e32SHeiko Carstens 
13d1e57508SHeiko Carstens struct cpu_topology_s390 {
1410ad34bcSMartin Schwidefsky 	unsigned short thread_id;
15d1e57508SHeiko Carstens 	unsigned short core_id;
16d1e57508SHeiko Carstens 	unsigned short socket_id;
17d1e57508SHeiko Carstens 	unsigned short book_id;
18adac0f1eSHeiko Carstens 	unsigned short drawer_id;
191887aa07SMartin Schwidefsky 	unsigned short dedicated : 1;
20*95968497SAlexander Gordeev 	int booted_cores;
2110ad34bcSMartin Schwidefsky 	cpumask_t thread_mask;
22d1e57508SHeiko Carstens 	cpumask_t core_mask;
23d1e57508SHeiko Carstens 	cpumask_t book_mask;
24adac0f1eSHeiko Carstens 	cpumask_t drawer_mask;
25d1e57508SHeiko Carstens };
26658e5ce7SHeiko Carstens 
2730fc4ca2SHeiko Carstens extern struct cpu_topology_s390 cpu_topology[NR_CPUS];
28d1e57508SHeiko Carstens 
2930fc4ca2SHeiko Carstens #define topology_physical_package_id(cpu) (cpu_topology[cpu].socket_id)
3030fc4ca2SHeiko Carstens #define topology_thread_id(cpu)		  (cpu_topology[cpu].thread_id)
3130fc4ca2SHeiko Carstens #define topology_sibling_cpumask(cpu)	  (&cpu_topology[cpu].thread_mask)
3230fc4ca2SHeiko Carstens #define topology_core_id(cpu)		  (cpu_topology[cpu].core_id)
3330fc4ca2SHeiko Carstens #define topology_core_cpumask(cpu)	  (&cpu_topology[cpu].core_mask)
3430fc4ca2SHeiko Carstens #define topology_book_id(cpu)		  (cpu_topology[cpu].book_id)
3530fc4ca2SHeiko Carstens #define topology_book_cpumask(cpu)	  (&cpu_topology[cpu].book_mask)
3630fc4ca2SHeiko Carstens #define topology_drawer_id(cpu)		  (cpu_topology[cpu].drawer_id)
3730fc4ca2SHeiko Carstens #define topology_drawer_cpumask(cpu)	  (&cpu_topology[cpu].drawer_mask)
381887aa07SMartin Schwidefsky #define topology_cpu_dedicated(cpu)	  (cpu_topology[cpu].dedicated)
39*95968497SAlexander Gordeev #define topology_booted_cores(cpu)	  (cpu_topology[cpu].booted_cores)
40d1e57508SHeiko Carstens 
41d1e57508SHeiko Carstens #define mc_capable() 1
42c6557e7fSMartin Schwidefsky 
438c910580SHeiko Carstens void topology_init_early(void);
4483a24e32SHeiko Carstens int topology_cpu_init(struct cpu *);
45c6557e7fSMartin Schwidefsky int topology_set_cpu_management(int fc);
46c6557e7fSMartin Schwidefsky void topology_schedule_update(void);
4796f4a70dSHeiko Carstens void store_topology(struct sysinfo_15_1_x *info);
4852aeda7aSAlexander Gordeev void update_cpu_masks(void);
49d68bddb7SHeiko Carstens void topology_expect_change(void);
502dfd7476SVincent Guittot const struct cpumask *cpu_coregroup_mask(int cpu);
51c6557e7fSMartin Schwidefsky 
529236b4ddSHeiko Carstens #else /* CONFIG_SCHED_TOPOLOGY */
5383a24e32SHeiko Carstens 
topology_init_early(void)548c910580SHeiko Carstens static inline void topology_init_early(void) { }
topology_schedule_update(void)5583a24e32SHeiko Carstens static inline void topology_schedule_update(void) { }
topology_cpu_init(struct cpu * cpu)5683a24e32SHeiko Carstens static inline int topology_cpu_init(struct cpu *cpu) { return 0; }
topology_cpu_dedicated(int cpu_nr)5738389ec8SThomas Richter static inline int topology_cpu_dedicated(int cpu_nr) { return 0; }
topology_booted_cores(int cpu_nr)58*95968497SAlexander Gordeev static inline int topology_booted_cores(int cpu_nr) { return 1; }
update_cpu_masks(void)5952aeda7aSAlexander Gordeev static inline void update_cpu_masks(void) { }
topology_expect_change(void)60d68bddb7SHeiko Carstens static inline void topology_expect_change(void) { }
6183a24e32SHeiko Carstens 
629236b4ddSHeiko Carstens #endif /* CONFIG_SCHED_TOPOLOGY */
6383a24e32SHeiko Carstens 
6483a24e32SHeiko Carstens #define POLARIZATION_UNKNOWN	(-1)
65c6557e7fSMartin Schwidefsky #define POLARIZATION_HRZ	(0)
66c6557e7fSMartin Schwidefsky #define POLARIZATION_VL		(1)
67c6557e7fSMartin Schwidefsky #define POLARIZATION_VM		(2)
68c6557e7fSMartin Schwidefsky #define POLARIZATION_VH		(3)
69c6557e7fSMartin Schwidefsky 
703a368f74SPhilipp Hachtmann #define SD_BOOK_INIT	SD_CPU_INIT
713a368f74SPhilipp Hachtmann 
723a368f74SPhilipp Hachtmann #ifdef CONFIG_NUMA
733a368f74SPhilipp Hachtmann 
743a368f74SPhilipp Hachtmann #define cpu_to_node cpu_to_node
cpu_to_node(int cpu)753a368f74SPhilipp Hachtmann static inline int cpu_to_node(int cpu)
763a368f74SPhilipp Hachtmann {
77701dc81eSHeiko Carstens 	return 0;
783a368f74SPhilipp Hachtmann }
793a368f74SPhilipp Hachtmann 
803a368f74SPhilipp Hachtmann /* Returns a pointer to the cpumask of CPUs on node 'node'. */
813a368f74SPhilipp Hachtmann #define cpumask_of_node cpumask_of_node
cpumask_of_node(int node)823a368f74SPhilipp Hachtmann static inline const struct cpumask *cpumask_of_node(int node)
833a368f74SPhilipp Hachtmann {
84701dc81eSHeiko Carstens 	return cpu_possible_mask;
853a368f74SPhilipp Hachtmann }
863a368f74SPhilipp Hachtmann 
873a368f74SPhilipp Hachtmann #define pcibus_to_node(bus) __pcibus_to_node(bus)
883a368f74SPhilipp Hachtmann 
893a368f74SPhilipp Hachtmann #else /* !CONFIG_NUMA */
903a368f74SPhilipp Hachtmann 
913a368f74SPhilipp Hachtmann #define numa_node_id numa_node_id
numa_node_id(void)923a368f74SPhilipp Hachtmann static inline int numa_node_id(void)
933a368f74SPhilipp Hachtmann {
943a368f74SPhilipp Hachtmann 	return 0;
953a368f74SPhilipp Hachtmann }
963a368f74SPhilipp Hachtmann 
973a368f74SPhilipp Hachtmann #endif /* CONFIG_NUMA */
983a368f74SPhilipp Hachtmann 
99c6557e7fSMartin Schwidefsky #include <asm-generic/topology.h>
100c6557e7fSMartin Schwidefsky 
101c6557e7fSMartin Schwidefsky #endif /* _ASM_S390_TOPOLOGY_H */
102