2 * Copyright (C) 2012 ARM Ltd.
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.
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.
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/>.
19 /* Values for secondary_data.status */
21 #define CPU_MMU_OFF (-1)
22 #define CPU_BOOT_SUCCESS (0)
23 /* The cpu invoked ops->cpu_die, synchronise it with cpu_kill */
24 #define CPU_KILL_ME (1)
25 /* The cpu couldn't die gracefully and is looping in the kernel */
26 #define CPU_STUCK_IN_KERNEL (2)
27 /* Fatal system error detected by secondary CPU, crash the system */
28 #define CPU_PANIC_KERNEL (3)
32 #include <asm/percpu.h>
34 #include <linux/threads.h>
35 #include <linux/cpumask.h>
36 #include <linux/thread_info.h>
38 DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number
);
41 * We don't use this_cpu_read(cpu_number) as that has implicit writes to
42 * preempt_count, and associated (compiler) barriers, that we'd like to avoid
43 * the expense of. If we're preemptible, the value can be stale at use anyway.
44 * And we can't use this_cpu_ptr() either, as that winds up recursing back
45 * here under CONFIG_DEBUG_PREEMPT=y.
47 #define raw_smp_processor_id() (*raw_cpu_ptr(&cpu_number))
52 * generate IPI list text
54 extern void show_ipi_list(struct seq_file
*p
, int prec
);
57 * Called from C code, this handles an IPI.
59 extern void handle_IPI(int ipinr
, struct pt_regs
*regs
);
62 * Discover the set of possible CPUs and determine their
65 extern void smp_init_cpus(void);
68 * Provide a function to raise an IPI cross call on CPUs in callmap.
70 extern void set_smp_cross_call(void (*)(const struct cpumask
*, unsigned int));
72 extern void (*__smp_cross_call
)(const struct cpumask
*, unsigned int);
75 * Called from the secondary holding pen, this is the secondary CPU entry point.
77 asmlinkage
void secondary_start_kernel(void);
80 * Initial data for bringing up a secondary CPU.
81 * @stack - sp for the secondary CPU
82 * @status - Result passed back from the secondary CPU to
85 struct secondary_data
{
87 struct task_struct
*task
;
91 extern struct secondary_data secondary_data
;
92 extern long __early_cpu_boot_status
;
93 extern void secondary_entry(void);
95 extern void arch_send_call_function_single_ipi(int cpu
);
96 extern void arch_send_call_function_ipi_mask(const struct cpumask
*mask
);
98 #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
99 extern void arch_send_wakeup_ipi_mask(const struct cpumask
*mask
);
101 static inline void arch_send_wakeup_ipi_mask(const struct cpumask
*mask
)
107 extern int __cpu_disable(void);
109 extern void __cpu_die(unsigned int cpu
);
110 extern void cpu_die(void);
111 extern void cpu_die_early(void);
113 static inline void cpu_park_loop(void)
121 static inline void update_cpu_boot_status(int val
)
123 WRITE_ONCE(secondary_data
.status
, val
);
124 /* Ensure the visibility of the status update */
129 * The calling secondary CPU has detected serious configuration mismatch,
130 * which calls for a kernel panic. Update the boot status and park the calling
133 static inline void cpu_panic_kernel(void)
135 update_cpu_boot_status(CPU_PANIC_KERNEL
);
140 * If a secondary CPU enters the kernel but fails to come online,
141 * (e.g. due to mismatched features), and cannot exit the kernel,
142 * we increment cpus_stuck_in_kernel and leave the CPU in a
143 * quiesecent loop within the kernel text. The memory containing
144 * this loop must not be re-used for anything else as the 'stuck'
145 * core is executing it.
147 * This function is used to inhibit features like kexec and hibernate.
149 bool cpus_are_stuck_in_kernel(void);
151 extern void crash_smp_send_stop(void);
152 extern bool smp_crash_stop_failed(void);
154 #endif /* ifndef __ASSEMBLY__ */
156 #endif /* ifndef __ASM_SMP_H */