Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.19-rc4 160 lines 3.9 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright (C) 2012 ARM Ltd. 4 */ 5#ifndef __ASM_SMP_H 6#define __ASM_SMP_H 7 8#include <linux/const.h> 9 10/* Values for secondary_data.status */ 11#define CPU_STUCK_REASON_SHIFT (8) 12#define CPU_BOOT_STATUS_MASK ((UL(1) << CPU_STUCK_REASON_SHIFT) - 1) 13 14#define CPU_MMU_OFF (-1) 15#define CPU_BOOT_SUCCESS (0) 16/* The cpu invoked ops->cpu_die, synchronise it with cpu_kill */ 17#define CPU_KILL_ME (1) 18/* The cpu couldn't die gracefully and is looping in the kernel */ 19#define CPU_STUCK_IN_KERNEL (2) 20/* Fatal system error detected by secondary CPU, crash the system */ 21#define CPU_PANIC_KERNEL (3) 22 23#define CPU_STUCK_REASON_52_BIT_VA (UL(1) << CPU_STUCK_REASON_SHIFT) 24#define CPU_STUCK_REASON_NO_GRAN (UL(2) << CPU_STUCK_REASON_SHIFT) 25 26#ifndef __ASSEMBLER__ 27 28#include <linux/threads.h> 29#include <linux/cpumask.h> 30#include <linux/thread_info.h> 31 32#define raw_smp_processor_id() (current_thread_info()->cpu) 33 34/* 35 * Logical CPU mapping. 36 */ 37extern u64 __cpu_logical_map[NR_CPUS]; 38extern u64 cpu_logical_map(unsigned int cpu); 39 40static inline void set_cpu_logical_map(unsigned int cpu, u64 hwid) 41{ 42 __cpu_logical_map[cpu] = hwid; 43} 44 45struct seq_file; 46 47/* 48 * Discover the set of possible CPUs and determine their 49 * SMP operations. 50 */ 51extern void smp_init_cpus(void); 52 53enum ipi_msg_type { 54 IPI_RESCHEDULE, 55 IPI_CALL_FUNC, 56 IPI_CPU_STOP, 57 IPI_CPU_STOP_NMI, 58 IPI_TIMER, 59 IPI_IRQ_WORK, 60 NR_IPI, 61 /* 62 * Any enum >= NR_IPI and < MAX_IPI is special and not tracable 63 * with trace_ipi_* 64 */ 65 IPI_CPU_BACKTRACE = NR_IPI, 66 IPI_KGDB_ROUNDUP, 67 MAX_IPI 68}; 69 70/* 71 * Register IPI interrupts with the arch SMP code 72 */ 73extern void set_smp_ipi_range_percpu(int ipi_base, int nr_ipi, int ncpus); 74 75static inline void set_smp_ipi_range(int ipi_base, int n) 76{ 77 set_smp_ipi_range_percpu(ipi_base, n, 0); 78} 79 80/* 81 * Called from the secondary holding pen, this is the secondary CPU entry point. 82 */ 83asmlinkage void secondary_start_kernel(void); 84 85/* 86 * Initial data for bringing up a secondary CPU. 87 * @status - Result passed back from the secondary CPU to 88 * indicate failure. 89 */ 90struct secondary_data { 91 struct task_struct *task; 92 long status; 93}; 94 95extern struct secondary_data secondary_data; 96extern long __early_cpu_boot_status; 97extern void secondary_entry(void); 98 99extern void arch_send_call_function_single_ipi(int cpu); 100extern void arch_send_call_function_ipi_mask(const struct cpumask *mask); 101 102#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL 103extern void arch_send_wakeup_ipi(unsigned int cpu); 104#else 105static inline void arch_send_wakeup_ipi(unsigned int cpu) 106{ 107 BUILD_BUG(); 108} 109#endif 110 111extern int __cpu_disable(void); 112 113static inline void __cpu_die(unsigned int cpu) { } 114extern void __noreturn cpu_die(void); 115extern void __noreturn cpu_die_early(void); 116 117static inline void __noreturn cpu_park_loop(void) 118{ 119 for (;;) { 120 wfe(); 121 wfi(); 122 } 123} 124 125static inline void update_cpu_boot_status(int val) 126{ 127 WRITE_ONCE(secondary_data.status, val); 128 /* Ensure the visibility of the status update */ 129 dsb(ishst); 130} 131 132/* 133 * The calling secondary CPU has detected serious configuration mismatch, 134 * which calls for a kernel panic. Update the boot status and park the calling 135 * CPU. 136 */ 137static inline void __noreturn cpu_panic_kernel(void) 138{ 139 update_cpu_boot_status(CPU_PANIC_KERNEL); 140 cpu_park_loop(); 141} 142 143/* 144 * If a secondary CPU enters the kernel but fails to come online, 145 * (e.g. due to mismatched features), and cannot exit the kernel, 146 * we increment cpus_stuck_in_kernel and leave the CPU in a 147 * quiesecent loop within the kernel text. The memory containing 148 * this loop must not be re-used for anything else as the 'stuck' 149 * core is executing it. 150 * 151 * This function is used to inhibit features like kexec and hibernate. 152 */ 153bool cpus_are_stuck_in_kernel(void); 154 155extern void crash_smp_send_stop(void); 156extern bool smp_crash_stop_failed(void); 157 158#endif /* ifndef __ASSEMBLER__ */ 159 160#endif /* ifndef __ASM_SMP_H */