xref: /linux/arch/s390/include/asm/smp.h (revision 905e46acd3272d04566fec49afbd7ad9e2ed9ae3)
1 /*
2  *    Copyright IBM Corp. 1999, 2012
3  *    Author(s): Denis Joseph Barrow,
4  *		 Martin Schwidefsky <schwidefsky@de.ibm.com>,
5  *		 Heiko Carstens <heiko.carstens@de.ibm.com>,
6  */
7 #ifndef __ASM_SMP_H
8 #define __ASM_SMP_H
9 
10 #include <asm/sigp.h>
11 
12 #ifdef CONFIG_SMP
13 
14 #include <asm/lowcore.h>
15 
16 #define raw_smp_processor_id()	(S390_lowcore.cpu_nr)
17 
18 extern struct mutex smp_cpu_state_mutex;
19 extern unsigned int smp_cpu_mt_shift;
20 extern unsigned int smp_cpu_mtid;
21 extern __vector128 __initdata boot_cpu_vector_save_area[__NUM_VXRS];
22 
23 extern int __cpu_up(unsigned int cpu, struct task_struct *tidle);
24 
25 extern void arch_send_call_function_single_ipi(int cpu);
26 extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
27 
28 extern void smp_call_online_cpu(void (*func)(void *), void *);
29 extern void smp_call_ipl_cpu(void (*func)(void *), void *);
30 
31 extern int smp_find_processor_id(u16 address);
32 extern int smp_store_status(int cpu);
33 extern void smp_save_dump_cpus(void);
34 extern int smp_vcpu_scheduled(int cpu);
35 extern void smp_yield_cpu(int cpu);
36 extern void smp_cpu_set_polarization(int cpu, int val);
37 extern int smp_cpu_get_polarization(int cpu);
38 extern void smp_fill_possible_mask(void);
39 extern void smp_detect_cpus(void);
40 
41 #else /* CONFIG_SMP */
42 
43 #define smp_cpu_mtid	0
44 
45 static inline void smp_call_ipl_cpu(void (*func)(void *), void *data)
46 {
47 	func(data);
48 }
49 
50 static inline void smp_call_online_cpu(void (*func)(void *), void *data)
51 {
52 	func(data);
53 }
54 
55 static inline int smp_find_processor_id(u16 address) { return 0; }
56 static inline int smp_store_status(int cpu) { return 0; }
57 static inline int smp_vcpu_scheduled(int cpu) { return 1; }
58 static inline void smp_yield_cpu(int cpu) { }
59 static inline void smp_fill_possible_mask(void) { }
60 static inline void smp_detect_cpus(void) { }
61 
62 #endif /* CONFIG_SMP */
63 
64 static inline void smp_stop_cpu(void)
65 {
66 	u16 pcpu = stap();
67 
68 	for (;;) {
69 		__pcpu_sigp(pcpu, SIGP_STOP, 0, NULL);
70 		cpu_relax();
71 	}
72 }
73 
74 /* Return thread 0 CPU number as base CPU */
75 static inline int smp_get_base_cpu(int cpu)
76 {
77 	return cpu - (cpu % (smp_cpu_mtid + 1));
78 }
79 
80 #ifdef CONFIG_HOTPLUG_CPU
81 extern int smp_rescan_cpus(void);
82 extern void __noreturn cpu_die(void);
83 extern void __cpu_die(unsigned int cpu);
84 extern int __cpu_disable(void);
85 #else
86 static inline int smp_rescan_cpus(void) { return 0; }
87 static inline void cpu_die(void) { }
88 #endif
89 
90 #endif /* __ASM_SMP_H */
91