mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 05:11:48 +00:00
bb9052744f
A secondary CPU could fail to come online due to insufficient capabilities and could simply die or loop in the kernel. e.g, a CPU with no support for the selected kernel PAGE_SIZE loops in kernel with MMU turned off. or a hotplugged CPU which doesn't have one of the advertised system capability will die during the activation. There is no way to synchronise the status of the failing CPU back to the master. This patch solves the issue by adding a field to the secondary_data which can be updated by the failing CPU. If the secondary CPU fails even before turning the MMU on, it updates the status in a special variable reserved in the head.txt section to make sure that the update can be cache invalidated safely without possible sharing of cache write back granule. Here are the possible states : -1. CPU_MMU_OFF - Initial value set by the master CPU, this value indicates that the CPU could not turn the MMU on, hence the status could not be reliably updated in the secondary_data. Instead, the CPU has updated the status @ __early_cpu_boot_status. 0. CPU_BOOT_SUCCESS - CPU has booted successfully. 1. CPU_KILL_ME - CPU has invoked cpu_ops->die, indicating the master CPU to synchronise by issuing a cpu_ops->cpu_kill. 2. CPU_STUCK_IN_KERNEL - CPU couldn't invoke die(), instead is looping in the kernel. This information could be used by say, kexec to check if it is really safe to do a kexec reboot. 3. CPU_PANIC_KERNEL - CPU detected some serious issues which requires kernel to crash immediately. The secondary CPU cannot call panic() until it has initialised the GIC. This flag can be used to instruct the master to do so. Cc: Mark Rutland <mark.rutland@arm.com> Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> [catalin.marinas@arm.com: conflict resolution] [catalin.marinas@arm.com: converted "status" from int to long] [catalin.marinas@arm.com: updated update_early_cpu_boot_status to use str_l] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
119 lines
3.0 KiB
C
119 lines
3.0 KiB
C
/*
|
|
* Copyright (C) 2012 ARM Ltd.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef __ASM_SMP_H
|
|
#define __ASM_SMP_H
|
|
|
|
/* Values for secondary_data.status */
|
|
|
|
#define CPU_MMU_OFF (-1)
|
|
#define CPU_BOOT_SUCCESS (0)
|
|
/* The cpu invoked ops->cpu_die, synchronise it with cpu_kill */
|
|
#define CPU_KILL_ME (1)
|
|
/* The cpu couldn't die gracefully and is looping in the kernel */
|
|
#define CPU_STUCK_IN_KERNEL (2)
|
|
/* Fatal system error detected by secondary CPU, crash the system */
|
|
#define CPU_PANIC_KERNEL (3)
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#include <linux/threads.h>
|
|
#include <linux/cpumask.h>
|
|
#include <linux/thread_info.h>
|
|
|
|
#define raw_smp_processor_id() (current_thread_info()->cpu)
|
|
|
|
struct seq_file;
|
|
|
|
/*
|
|
* generate IPI list text
|
|
*/
|
|
extern void show_ipi_list(struct seq_file *p, int prec);
|
|
|
|
/*
|
|
* Called from C code, this handles an IPI.
|
|
*/
|
|
extern void handle_IPI(int ipinr, struct pt_regs *regs);
|
|
|
|
/*
|
|
* Discover the set of possible CPUs and determine their
|
|
* SMP operations.
|
|
*/
|
|
extern void smp_init_cpus(void);
|
|
|
|
/*
|
|
* Provide a function to raise an IPI cross call on CPUs in callmap.
|
|
*/
|
|
extern void set_smp_cross_call(void (*)(const struct cpumask *, unsigned int));
|
|
|
|
extern void (*__smp_cross_call)(const struct cpumask *, unsigned int);
|
|
|
|
/*
|
|
* Called from the secondary holding pen, this is the secondary CPU entry point.
|
|
*/
|
|
asmlinkage void secondary_start_kernel(void);
|
|
|
|
/*
|
|
* Initial data for bringing up a secondary CPU.
|
|
* @stack - sp for the secondary CPU
|
|
* @status - Result passed back from the secondary CPU to
|
|
* indicate failure.
|
|
*/
|
|
struct secondary_data {
|
|
void *stack;
|
|
long status;
|
|
};
|
|
|
|
extern struct secondary_data secondary_data;
|
|
extern long __early_cpu_boot_status;
|
|
extern void secondary_entry(void);
|
|
|
|
extern void arch_send_call_function_single_ipi(int cpu);
|
|
extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
|
|
|
|
#ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
|
|
extern void arch_send_wakeup_ipi_mask(const struct cpumask *mask);
|
|
#else
|
|
static inline void arch_send_wakeup_ipi_mask(const struct cpumask *mask)
|
|
{
|
|
BUILD_BUG();
|
|
}
|
|
#endif
|
|
|
|
extern int __cpu_disable(void);
|
|
|
|
extern void __cpu_die(unsigned int cpu);
|
|
extern void cpu_die(void);
|
|
extern void cpu_die_early(void);
|
|
|
|
static inline void cpu_park_loop(void)
|
|
{
|
|
for (;;) {
|
|
wfe();
|
|
wfi();
|
|
}
|
|
}
|
|
|
|
static inline void update_cpu_boot_status(int val)
|
|
{
|
|
WRITE_ONCE(secondary_data.status, val);
|
|
/* Ensure the visibility of the status update */
|
|
dsb(ishst);
|
|
}
|
|
|
|
#endif /* ifndef __ASSEMBLY__ */
|
|
|
|
#endif /* ifndef __ASM_SMP_H */
|