1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2012 Regents of the University of California
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
16 extern unsigned long boot_cpu_hartid;
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]
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 /* Called from C code, this handles an IPI. */
32 void handle_IPI(struct pt_regs *regs);
34 /* Hook for the generic smp_call_function_many() routine. */
35 void arch_send_call_function_ipi_mask(struct cpumask *mask);
37 /* Hook for the generic smp_call_function_single() routine. */
38 void arch_send_call_function_single_ipi(int cpu);
40 int riscv_hartid_to_cpuid(int hartid);
41 void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out);
43 /* Secondary hart entry */
44 asmlinkage void smp_callin(void);
47 * Obtains the hart ID of the currently executing task. This relies on
48 * THREAD_INFO_IN_TASK, but we define that unconditionally.
50 #define raw_smp_processor_id() (current_thread_info()->cpu)
52 #if defined CONFIG_HOTPLUG_CPU
53 int __cpu_disable(void);
54 void __cpu_die(unsigned int cpu);
57 #endif /* CONFIG_HOTPLUG_CPU */
61 static inline void show_ipi_stats(struct seq_file *p, int prec)
65 static inline int riscv_hartid_to_cpuid(int hartid)
67 if (hartid == boot_cpu_hartid)
72 static inline unsigned long cpuid_to_hartid_map(int cpu)
74 return boot_cpu_hartid;
77 static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in,
81 cpumask_set_cpu(boot_cpu_hartid, out);
84 #endif /* CONFIG_SMP */
86 #if defined(CONFIG_HOTPLUG_CPU) && (CONFIG_SMP)
87 bool cpu_has_hotplug(unsigned int cpu);
89 static inline bool cpu_has_hotplug(unsigned int cpu)
95 #endif /* _ASM_RISCV_SMP_H */