Commit | Line | Data |
---|---|---|
08e875c1 CM |
1 | /* |
2 | * Copyright (C) 2012 ARM Ltd. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License version 2 as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | */ | |
16 | #ifndef __ASM_SMP_H | |
17 | #define __ASM_SMP_H | |
18 | ||
1236cd2b SZ |
19 | #include <linux/const.h> |
20 | ||
bb905274 | 21 | /* Values for secondary_data.status */ |
66f16a24 | 22 | #define CPU_STUCK_REASON_SHIFT (8) |
1236cd2b | 23 | #define CPU_BOOT_STATUS_MASK ((UL(1) << CPU_STUCK_REASON_SHIFT) - 1) |
bb905274 | 24 | |
66f16a24 WD |
25 | #define CPU_MMU_OFF (-1) |
26 | #define CPU_BOOT_SUCCESS (0) | |
bb905274 | 27 | /* The cpu invoked ops->cpu_die, synchronise it with cpu_kill */ |
66f16a24 | 28 | #define CPU_KILL_ME (1) |
bb905274 | 29 | /* The cpu couldn't die gracefully and is looping in the kernel */ |
66f16a24 | 30 | #define CPU_STUCK_IN_KERNEL (2) |
bb905274 | 31 | /* Fatal system error detected by secondary CPU, crash the system */ |
66f16a24 WD |
32 | #define CPU_PANIC_KERNEL (3) |
33 | ||
1236cd2b SZ |
34 | #define CPU_STUCK_REASON_52_BIT_VA (UL(1) << CPU_STUCK_REASON_SHIFT) |
35 | #define CPU_STUCK_REASON_NO_GRAN (UL(2) << CPU_STUCK_REASON_SHIFT) | |
bb905274 SP |
36 | |
37 | #ifndef __ASSEMBLY__ | |
38 | ||
57c82954 MR |
39 | #include <asm/percpu.h> |
40 | ||
08e875c1 CM |
41 | #include <linux/threads.h> |
42 | #include <linux/cpumask.h> | |
43 | #include <linux/thread_info.h> | |
44 | ||
57c82954 MR |
45 | DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number); |
46 | ||
47 | /* | |
48 | * We don't use this_cpu_read(cpu_number) as that has implicit writes to | |
49 | * preempt_count, and associated (compiler) barriers, that we'd like to avoid | |
50 | * the expense of. If we're preemptible, the value can be stale at use anyway. | |
34a6980c RM |
51 | * And we can't use this_cpu_ptr() either, as that winds up recursing back |
52 | * here under CONFIG_DEBUG_PREEMPT=y. | |
57c82954 | 53 | */ |
34a6980c | 54 | #define raw_smp_processor_id() (*raw_cpu_ptr(&cpu_number)) |
08e875c1 | 55 | |
262afe92 FF |
56 | /* |
57 | * Logical CPU mapping. | |
58 | */ | |
59 | extern u64 __cpu_logical_map[NR_CPUS]; | |
60 | #define cpu_logical_map(cpu) __cpu_logical_map[cpu] | |
61 | ||
08e875c1 CM |
62 | struct seq_file; |
63 | ||
64 | /* | |
65 | * generate IPI list text | |
66 | */ | |
67 | extern void show_ipi_list(struct seq_file *p, int prec); | |
68 | ||
69 | /* | |
70 | * Called from C code, this handles an IPI. | |
71 | */ | |
72 | extern void handle_IPI(int ipinr, struct pt_regs *regs); | |
73 | ||
74 | /* | |
fccb9a81 HG |
75 | * Discover the set of possible CPUs and determine their |
76 | * SMP operations. | |
08e875c1 | 77 | */ |
0f078336 | 78 | extern void smp_init_cpus(void); |
08e875c1 CM |
79 | |
80 | /* | |
81 | * Provide a function to raise an IPI cross call on CPUs in callmap. | |
82 | */ | |
83 | extern void set_smp_cross_call(void (*)(const struct cpumask *, unsigned int)); | |
84 | ||
36310736 FW |
85 | extern void (*__smp_cross_call)(const struct cpumask *, unsigned int); |
86 | ||
08e875c1 CM |
87 | /* |
88 | * Called from the secondary holding pen, this is the secondary CPU entry point. | |
89 | */ | |
90 | asmlinkage void secondary_start_kernel(void); | |
91 | ||
92 | /* | |
93 | * Initial data for bringing up a secondary CPU. | |
bb905274 SP |
94 | * @stack - sp for the secondary CPU |
95 | * @status - Result passed back from the secondary CPU to | |
96 | * indicate failure. | |
08e875c1 CM |
97 | */ |
98 | struct secondary_data { | |
99 | void *stack; | |
c02433dd | 100 | struct task_struct *task; |
bb905274 | 101 | long status; |
08e875c1 | 102 | }; |
bb905274 | 103 | |
08e875c1 | 104 | extern struct secondary_data secondary_data; |
bb905274 | 105 | extern long __early_cpu_boot_status; |
652af899 | 106 | extern void secondary_entry(void); |
08e875c1 CM |
107 | |
108 | extern void arch_send_call_function_single_ipi(int cpu); | |
109 | extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); | |
110 | ||
5e89c55e LP |
111 | #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL |
112 | extern void arch_send_wakeup_ipi_mask(const struct cpumask *mask); | |
113 | #else | |
114 | static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask) | |
115 | { | |
116 | BUILD_BUG(); | |
117 | } | |
118 | #endif | |
119 | ||
9327e2c6 MR |
120 | extern int __cpu_disable(void); |
121 | ||
122 | extern void __cpu_die(unsigned int cpu); | |
123 | extern void cpu_die(void); | |
fce6361f | 124 | extern void cpu_die_early(void); |
9327e2c6 | 125 | |
c4bc34d2 SP |
126 | static inline void cpu_park_loop(void) |
127 | { | |
128 | for (;;) { | |
129 | wfe(); | |
130 | wfi(); | |
131 | } | |
132 | } | |
133 | ||
bb905274 SP |
134 | static inline void update_cpu_boot_status(int val) |
135 | { | |
136 | WRITE_ONCE(secondary_data.status, val); | |
137 | /* Ensure the visibility of the status update */ | |
138 | dsb(ishst); | |
139 | } | |
140 | ||
17eebd1a SP |
141 | /* |
142 | * The calling secondary CPU has detected serious configuration mismatch, | |
143 | * which calls for a kernel panic. Update the boot status and park the calling | |
144 | * CPU. | |
145 | */ | |
146 | static inline void cpu_panic_kernel(void) | |
147 | { | |
148 | update_cpu_boot_status(CPU_PANIC_KERNEL); | |
149 | cpu_park_loop(); | |
150 | } | |
151 | ||
5c492c3f JM |
152 | /* |
153 | * If a secondary CPU enters the kernel but fails to come online, | |
154 | * (e.g. due to mismatched features), and cannot exit the kernel, | |
155 | * we increment cpus_stuck_in_kernel and leave the CPU in a | |
156 | * quiesecent loop within the kernel text. The memory containing | |
157 | * this loop must not be re-used for anything else as the 'stuck' | |
158 | * core is executing it. | |
159 | * | |
160 | * This function is used to inhibit features like kexec and hibernate. | |
161 | */ | |
162 | bool cpus_are_stuck_in_kernel(void); | |
163 | ||
a88ce63b | 164 | extern void crash_smp_send_stop(void); |
78fd584c AT |
165 | extern bool smp_crash_stop_failed(void); |
166 | ||
bb905274 SP |
167 | #endif /* ifndef __ASSEMBLY__ */ |
168 | ||
08e875c1 | 169 | #endif /* ifndef __ASM_SMP_H */ |