smp.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2012 Regents of the University of California
  3. *
  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.
  7. *
  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.
  12. */
  13. #ifndef _ASM_RISCV_SMP_H
  14. #define _ASM_RISCV_SMP_H
  15. #include <linux/cpumask.h>
  16. #include <linux/irqreturn.h>
  17. #include <linux/thread_info.h>
  18. #define INVALID_HARTID ULONG_MAX
  19. /*
  20. * Mapping between linux logical cpu index and hartid.
  21. */
  22. extern unsigned long __cpuid_to_hartid_map[NR_CPUS];
  23. #define cpuid_to_hartid_map(cpu) __cpuid_to_hartid_map[cpu]
  24. struct seq_file;
  25. #ifdef CONFIG_SMP
  26. /* print IPI stats */
  27. void show_ipi_stats(struct seq_file *p, int prec);
  28. /* SMP initialization hook for setup_arch */
  29. void __init setup_smp(void);
  30. /* Hook for the generic smp_call_function_many() routine. */
  31. void arch_send_call_function_ipi_mask(struct cpumask *mask);
  32. /* Hook for the generic smp_call_function_single() routine. */
  33. void arch_send_call_function_single_ipi(int cpu);
  34. int riscv_hartid_to_cpuid(int hartid);
  35. void riscv_cpuid_to_hartid_mask(const struct cpumask *in, struct cpumask *out);
  36. /*
  37. * Obtains the hart ID of the currently executing task. This relies on
  38. * THREAD_INFO_IN_TASK, but we define that unconditionally.
  39. */
  40. #define raw_smp_processor_id() (current_thread_info()->cpu)
  41. #else
  42. static inline void show_ipi_stats(struct seq_file *p, int prec)
  43. {
  44. }
  45. static inline int riscv_hartid_to_cpuid(int hartid)
  46. {
  47. return 0;
  48. }
  49. static inline void riscv_cpuid_to_hartid_mask(const struct cpumask *in,
  50. struct cpumask *out)
  51. {
  52. cpumask_set_cpu(cpuid_to_hartid_map(0), out);
  53. }
  54. #endif /* CONFIG_SMP */
  55. #endif /* _ASM_RISCV_SMP_H */