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 #include <linux/jump_label.h>
23 * Mapping between linux logical cpu index and hartid.
25 extern unsigned long __cpuid_to_hartid_map
[NR_CPUS
];
26 #define cpuid_to_hartid_map(cpu) __cpuid_to_hartid_map[cpu]
29 void show_ipi_stats(struct seq_file
*p
, int prec
);
31 /* SMP initialization hook for setup_arch */
32 void __init
setup_smp(void);
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(unsigned long hartid
);
42 /* Enable IPI for CPU hotplug */
43 void riscv_ipi_enable(void);
45 /* Disable IPI for CPU hotplug */
46 void riscv_ipi_disable(void);
48 /* Check if IPI interrupt numbers are available */
49 bool riscv_ipi_have_virq_range(void);
51 /* Set the IPI interrupt numbers for arch (called by irqchip drivers) */
52 void riscv_ipi_set_virq_range(int virq
, int nr
);
54 /* Check other CPUs stop or not */
55 bool smp_crash_stop_failed(void);
57 /* Secondary hart entry */
58 asmlinkage
void smp_callin(void);
61 * Obtains the hart ID of the currently executing task. This relies on
62 * THREAD_INFO_IN_TASK, but we define that unconditionally.
64 #define raw_smp_processor_id() (current_thread_info()->cpu)
66 #if defined CONFIG_HOTPLUG_CPU
67 int __cpu_disable(void);
68 static inline void __cpu_die(unsigned int cpu
) { }
69 #endif /* CONFIG_HOTPLUG_CPU */
73 static inline void show_ipi_stats(struct seq_file
*p
, int prec
)
77 static inline int riscv_hartid_to_cpuid(unsigned long hartid
)
79 if (hartid
== boot_cpu_hartid
)
84 static inline unsigned long cpuid_to_hartid_map(int cpu
)
86 return boot_cpu_hartid
;
89 static inline void riscv_ipi_enable(void)
93 static inline void riscv_ipi_disable(void)
97 static inline bool riscv_ipi_have_virq_range(void)
102 static inline void riscv_ipi_set_virq_range(int virq
, int nr
)
106 #endif /* CONFIG_SMP */
108 #if defined(CONFIG_HOTPLUG_CPU) && (CONFIG_SMP)
109 bool cpu_has_hotplug(unsigned int cpu
);
111 static inline bool cpu_has_hotplug(unsigned int cpu
)
117 #endif /* _ASM_RISCV_SMP_H */