Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / riscv / include / asm / smp.h
blobdf1f7c4cd4337be6fff336642d152eb0e6261f09
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 struct riscv_ipi_ops {
19 void (*ipi_inject)(const struct cpumask *target);
20 void (*ipi_clear)(void);
23 #ifdef CONFIG_SMP
25 * Mapping between linux logical cpu index and hartid.
27 extern unsigned long __cpuid_to_hartid_map[NR_CPUS];
28 #define cpuid_to_hartid_map(cpu) __cpuid_to_hartid_map[cpu]
30 /* print IPI stats */
31 void show_ipi_stats(struct seq_file *p, int prec);
33 /* SMP initialization hook for setup_arch */
34 void __init setup_smp(void);
36 /* Called from C code, this handles an IPI. */
37 void handle_IPI(struct pt_regs *regs);
39 /* Hook for the generic smp_call_function_many() routine. */
40 void arch_send_call_function_ipi_mask(struct cpumask *mask);
42 /* Hook for the generic smp_call_function_single() routine. */
43 void arch_send_call_function_single_ipi(int cpu);
45 int riscv_hartid_to_cpuid(int hartid);
46 void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out);
48 /* Set custom IPI operations */
49 void riscv_set_ipi_ops(struct riscv_ipi_ops *ops);
51 /* Clear IPI for current CPU */
52 void riscv_clear_ipi(void);
54 /* Secondary hart entry */
55 asmlinkage void smp_callin(void);
58 * Obtains the hart ID of the currently executing task. This relies on
59 * THREAD_INFO_IN_TASK, but we define that unconditionally.
61 #define raw_smp_processor_id() (current_thread_info()->cpu)
63 #if defined CONFIG_HOTPLUG_CPU
64 int __cpu_disable(void);
65 void __cpu_die(unsigned int cpu);
66 void cpu_stop(void);
67 #else
68 #endif /* CONFIG_HOTPLUG_CPU */
70 #else
72 static inline void show_ipi_stats(struct seq_file *p, int prec)
76 static inline int riscv_hartid_to_cpuid(int hartid)
78 if (hartid == boot_cpu_hartid)
79 return 0;
81 return -1;
83 static inline unsigned long cpuid_to_hartid_map(int cpu)
85 return boot_cpu_hartid;
88 static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in,
89 struct cpumask *out)
91 cpumask_clear(out);
92 cpumask_set_cpu(boot_cpu_hartid, out);
95 static inline void riscv_set_ipi_ops(struct riscv_ipi_ops *ops)
99 static inline void riscv_clear_ipi(void)
103 #endif /* CONFIG_SMP */
105 #if defined(CONFIG_HOTPLUG_CPU) && (CONFIG_SMP)
106 bool cpu_has_hotplug(unsigned int cpu);
107 #else
108 static inline bool cpu_has_hotplug(unsigned int cpu)
110 return false;
112 #endif
114 #endif /* _ASM_RISCV_SMP_H */