0001
0002
0003
0004
0005 #ifndef __ASM_SMP_H
0006 #define __ASM_SMP_H
0007
0008 #include <linux/const.h>
0009
0010
0011 #define CPU_STUCK_REASON_SHIFT (8)
0012 #define CPU_BOOT_STATUS_MASK ((UL(1) << CPU_STUCK_REASON_SHIFT) - 1)
0013
0014 #define CPU_MMU_OFF (-1)
0015 #define CPU_BOOT_SUCCESS (0)
0016
0017 #define CPU_KILL_ME (1)
0018
0019 #define CPU_STUCK_IN_KERNEL (2)
0020
0021 #define CPU_PANIC_KERNEL (3)
0022
0023 #define CPU_STUCK_REASON_52_BIT_VA (UL(1) << CPU_STUCK_REASON_SHIFT)
0024 #define CPU_STUCK_REASON_NO_GRAN (UL(2) << CPU_STUCK_REASON_SHIFT)
0025
0026 #ifndef __ASSEMBLY__
0027
0028 #include <asm/percpu.h>
0029
0030 #include <linux/threads.h>
0031 #include <linux/cpumask.h>
0032 #include <linux/thread_info.h>
0033
0034 DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
0035
0036
0037
0038
0039
0040
0041
0042
0043 #define raw_smp_processor_id() (*raw_cpu_ptr(&cpu_number))
0044
0045
0046
0047
0048 extern u64 __cpu_logical_map[NR_CPUS];
0049 extern u64 cpu_logical_map(unsigned int cpu);
0050
0051 static inline void set_cpu_logical_map(unsigned int cpu, u64 hwid)
0052 {
0053 __cpu_logical_map[cpu] = hwid;
0054 }
0055
0056 struct seq_file;
0057
0058
0059
0060
0061
0062 extern void smp_init_cpus(void);
0063
0064
0065
0066
0067 extern void set_smp_ipi_range(int ipi_base, int nr_ipi);
0068
0069
0070
0071
0072 asmlinkage void secondary_start_kernel(void);
0073
0074
0075
0076
0077
0078
0079 struct secondary_data {
0080 struct task_struct *task;
0081 long status;
0082 };
0083
0084 extern struct secondary_data secondary_data;
0085 extern long __early_cpu_boot_status;
0086 extern void secondary_entry(void);
0087
0088 extern void arch_send_call_function_single_ipi(int cpu);
0089 extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
0090
0091 #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
0092 extern void arch_send_wakeup_ipi_mask(const struct cpumask *mask);
0093 #else
0094 static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask)
0095 {
0096 BUILD_BUG();
0097 }
0098 #endif
0099
0100 extern int __cpu_disable(void);
0101
0102 extern void __cpu_die(unsigned int cpu);
0103 extern void cpu_die(void);
0104 extern void cpu_die_early(void);
0105
0106 static inline void cpu_park_loop(void)
0107 {
0108 for (;;) {
0109 wfe();
0110 wfi();
0111 }
0112 }
0113
0114 static inline void update_cpu_boot_status(int val)
0115 {
0116 WRITE_ONCE(secondary_data.status, val);
0117
0118 dsb(ishst);
0119 }
0120
0121
0122
0123
0124
0125
0126 static inline void cpu_panic_kernel(void)
0127 {
0128 update_cpu_boot_status(CPU_PANIC_KERNEL);
0129 cpu_park_loop();
0130 }
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 bool cpus_are_stuck_in_kernel(void);
0143
0144 extern void crash_smp_send_stop(void);
0145 extern bool smp_crash_stop_failed(void);
0146 extern void panic_smp_self_stop(void);
0147
0148 #endif
0149
0150 #endif