2 * Copyright (C) 2012 Regents of the University of California
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef _ASM_RISCV_SMP_H
15 #define _ASM_RISCV_SMP_H
17 #include <linux/cpumask.h>
18 #include <linux/irqreturn.h>
19 #include <linux/thread_info.h>
21 #define INVALID_HARTID ULONG_MAX
24 extern unsigned long boot_cpu_hartid
;
28 * Mapping between linux logical cpu index and hartid.
30 extern unsigned long __cpuid_to_hartid_map
[NR_CPUS
];
31 #define cpuid_to_hartid_map(cpu) __cpuid_to_hartid_map[cpu]
34 void show_ipi_stats(struct seq_file
*p
, int prec
);
36 /* SMP initialization hook for setup_arch */
37 void __init
setup_smp(void);
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
);
49 * Obtains the hart ID of the currently executing task. This relies on
50 * THREAD_INFO_IN_TASK, but we define that unconditionally.
52 #define raw_smp_processor_id() (current_thread_info()->cpu)
56 static inline void show_ipi_stats(struct seq_file
*p
, int prec
)
60 static inline int riscv_hartid_to_cpuid(int hartid
)
62 if (hartid
== boot_cpu_hartid
)
67 static inline unsigned long cpuid_to_hartid_map(int cpu
)
69 return boot_cpu_hartid
;
72 static inline void riscv_cpuid_to_hartid_mask(const struct cpumask
*in
,
75 cpumask_set_cpu(cpuid_to_hartid_map(0), out
);
78 #endif /* CONFIG_SMP */
79 #endif /* _ASM_RISCV_SMP_H */