Linux 5.6.13
[linux/fpc-iii.git] / arch / riscv / include / asm / smp.h
bloba83451d73a4e2e88e6c64fde600511a48d1b78c5
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2012 Regents of the University of California
4 */
6 #ifndef _ASM_RISCV_SMP_H
7 #define _ASM_RISCV_SMP_H
9 #include <linux/cpumask.h>
10 #include <linux/irqreturn.h>
11 #include <linux/thread_info.h>
13 #define INVALID_HARTID ULONG_MAX
15 struct seq_file;
16 extern unsigned long boot_cpu_hartid;
18 #ifdef CONFIG_SMP
20 * Mapping between linux logical cpu index and hartid.
22 extern unsigned long __cpuid_to_hartid_map[NR_CPUS];
23 #define cpuid_to_hartid_map(cpu) __cpuid_to_hartid_map[cpu]
25 /* print IPI stats */
26 void show_ipi_stats(struct seq_file *p, int prec);
28 /* SMP initialization hook for setup_arch */
29 void __init setup_smp(void);
31 /* Hook for the generic smp_call_function_many() routine. */
32 void arch_send_call_function_ipi_mask(struct cpumask *mask);
34 /* Hook for the generic smp_call_function_single() routine. */
35 void arch_send_call_function_single_ipi(int cpu);
37 int riscv_hartid_to_cpuid(int hartid);
38 void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out);
41 * Obtains the hart ID of the currently executing task. This relies on
42 * THREAD_INFO_IN_TASK, but we define that unconditionally.
44 #define raw_smp_processor_id() (current_thread_info()->cpu)
46 #else
48 static inline void show_ipi_stats(struct seq_file *p, int prec)
52 static inline int riscv_hartid_to_cpuid(int hartid)
54 if (hartid == boot_cpu_hartid)
55 return 0;
57 return -1;
59 static inline unsigned long cpuid_to_hartid_map(int cpu)
61 return boot_cpu_hartid;
64 #endif /* CONFIG_SMP */
65 #endif /* _ASM_RISCV_SMP_H */