1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Author: Huacai Chen <chenhuacai@loongson.cn>
4 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
9 #include <linux/atomic.h>
10 #include <linux/bitops.h>
11 #include <linux/linkage.h>
12 #include <linux/threads.h>
13 #include <linux/cpumask.h>
15 extern int smp_num_siblings;
16 extern int num_processors;
17 extern int disabled_cpus;
18 extern cpumask_t cpu_sibling_map[];
19 extern cpumask_t cpu_core_map[];
20 extern cpumask_t cpu_foreign_map[];
22 void loongson_smp_setup(void);
23 void loongson_prepare_cpus(unsigned int max_cpus);
24 void loongson_boot_secondary(int cpu, struct task_struct *idle);
25 void loongson_init_secondary(void);
26 void loongson_smp_finish(void);
27 void loongson_send_ipi_single(int cpu, unsigned int action);
28 void loongson_send_ipi_mask(const struct cpumask *mask, unsigned int action);
29 #ifdef CONFIG_HOTPLUG_CPU
30 int loongson_cpu_disable(void);
31 void loongson_cpu_die(unsigned int cpu);
34 static inline void plat_smp_setup(void)
39 static inline int raw_smp_processor_id(void)
42 extern int vdso_smp_processor_id(void)
43 __compiletime_error("VDSO should not call smp_processor_id()");
44 return vdso_smp_processor_id();
46 return current_thread_info()->cpu;
49 #define raw_smp_processor_id raw_smp_processor_id
51 /* Map from cpu id to sequential logical cpu number. This will only
52 * not be idempotent when cpus failed to come on-line. */
53 extern int __cpu_number_map[NR_CPUS];
54 #define cpu_number_map(cpu) __cpu_number_map[cpu]
56 /* The reverse map from sequential logical cpu number to cpu id. */
57 extern int __cpu_logical_map[NR_CPUS];
58 #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
60 #define cpu_physical_id(cpu) cpu_logical_map(cpu)
62 #define SMP_BOOT_CPU 0x1
63 #define SMP_RESCHEDULE 0x2
64 #define SMP_CALL_FUNCTION 0x4
66 struct secondary_data {
68 unsigned long thread_info;
70 extern struct secondary_data cpuboot_data;
72 extern asmlinkage void smpboot_entry(void);
73 extern asmlinkage void start_secondary(void);
75 extern void calculate_cpu_foreign_map(void);
78 * Generate IPI list text
80 extern void show_ipi_list(struct seq_file *p, int prec);
82 static inline void arch_send_call_function_single_ipi(int cpu)
84 loongson_send_ipi_single(cpu, SMP_CALL_FUNCTION);
87 static inline void arch_send_call_function_ipi_mask(const struct cpumask *mask)
89 loongson_send_ipi_mask(mask, SMP_CALL_FUNCTION);
92 #ifdef CONFIG_HOTPLUG_CPU
93 static inline int __cpu_disable(void)
95 return loongson_cpu_disable();
98 static inline void __cpu_die(unsigned int cpu)
100 loongson_cpu_die(cpu);
104 #endif /* __ASM_SMP_H */