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