FILE
smp.h
File preview with syntax highlighting.
linux-6.19.14/arch/loongarch/include/asm/smp.h
1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Author: Huacai Chen <chenhuacai@loongson.cn> 4 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited 5 */ 6#ifndef __ASM_SMP_H 7#define __ASM_SMP_H 8 9#ifdef CONFIG_SMP 10 11#include <linux/atomic.h> 12#include <linux/bitops.h> 13#include <linux/linkage.h> 14#include <linux/threads.h> 15#include <linux/cpumask.h> 16 17struct smp_ops { 18 void (*init_ipi)(void); 19 void (*send_ipi_single)(int cpu, unsigned int action); 20 void (*send_ipi_mask)(const struct cpumask *mask, unsigned int action); 21}; 22extern struct smp_ops mp_ops; 23 24extern int smp_num_siblings; 25extern int num_processors; 26extern int disabled_cpus; 27extern cpumask_t cpu_sibling_map[]; 28extern cpumask_t cpu_llc_shared_map[]; 29extern cpumask_t cpu_core_map[]; 30extern cpumask_t cpu_foreign_map[]; 31 32void loongson_smp_setup(void); 33void loongson_prepare_cpus(unsigned int max_cpus); 34void loongson_boot_secondary(int cpu, struct task_struct *idle); 35void loongson_init_secondary(void); 36void loongson_smp_finish(void); 37#ifdef CONFIG_HOTPLUG_CPU 38int loongson_cpu_disable(void); 39void loongson_cpu_die(unsigned int cpu); 40#endif 41 42static inline void __init plat_smp_setup(void) 43{ 44 loongson_smp_setup(); 45} 46 47static inline int raw_smp_processor_id(void) 48{ 49#if defined(__VDSO__) 50 extern int vdso_smp_processor_id(void) 51 __compiletime_error("VDSO should not call smp_processor_id()"); 52 return vdso_smp_processor_id(); 53#else 54 return current_thread_info()->cpu; 55#endif 56} 57#define raw_smp_processor_id raw_smp_processor_id 58 59/* Map from cpu id to sequential logical cpu number. This will only 60 * not be idempotent when cpus failed to come on-line. */ 61extern int __cpu_number_map[NR_CPUS]; 62#define cpu_number_map(cpu) __cpu_number_map[cpu] 63 64/* The reverse map from sequential logical cpu number to cpu id. */ 65extern int __cpu_logical_map[NR_CPUS]; 66#define cpu_logical_map(cpu) __cpu_logical_map[cpu] 67 68#define cpu_physical_id(cpu) cpu_logical_map(cpu) 69 70#define ACTION_BOOT_CPU 0 71#define ACTION_RESCHEDULE 1 72#define ACTION_CALL_FUNCTION 2 73#define ACTION_IRQ_WORK 3 74#define ACTION_CLEAR_VECTOR 4 75#define SMP_BOOT_CPU BIT(ACTION_BOOT_CPU) 76#define SMP_RESCHEDULE BIT(ACTION_RESCHEDULE) 77#define SMP_CALL_FUNCTION BIT(ACTION_CALL_FUNCTION) 78#define SMP_IRQ_WORK BIT(ACTION_IRQ_WORK) 79#define SMP_CLEAR_VECTOR BIT(ACTION_CLEAR_VECTOR) 80 81struct seq_file; 82 83struct secondary_data { 84 unsigned long stack; 85 unsigned long thread_info; 86}; 87extern struct secondary_data cpuboot_data; 88 89extern asmlinkage void smpboot_entry(void); 90extern asmlinkage void start_secondary(void); 91 92extern void calculate_cpu_foreign_map(void); 93 94/* 95 * Generate IPI list text 96 */ 97extern void show_ipi_list(struct seq_file *p, int prec); 98 99static inline void arch_send_call_function_single_ipi(int cpu) 100{ 101 mp_ops.send_ipi_single(cpu, ACTION_CALL_FUNCTION); 102} 103 104static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask) 105{ 106 mp_ops.send_ipi_mask(mask, ACTION_CALL_FUNCTION); 107} 108 109#ifdef CONFIG_HOTPLUG_CPU 110static inline int __cpu_disable(void) 111{ 112 return loongson_cpu_disable(); 113} 114 115static inline void __cpu_die(unsigned int cpu) 116{ 117 loongson_cpu_die(cpu); 118} 119#endif 120 121#else /* !CONFIG_SMP */ 122#define cpu_logical_map(cpu) 0 123#endif /* CONFIG_SMP */ 124 125#endif /* __ASM_SMP_H */
~/
Read-only file preview.