smp.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_SH_SMP_H
  3. #define __ASM_SH_SMP_H
  4. #include <linux/bitops.h>
  5. #include <linux/cpumask.h>
  6. #include <asm/smp-ops.h>
  7. #ifdef CONFIG_SMP
  8. #include <linux/spinlock.h>
  9. #include <linux/atomic.h>
  10. #include <asm/current.h>
  11. #include <asm/percpu.h>
  12. #define raw_smp_processor_id() (current_thread_info()->cpu)
  13. /* Map from cpu id to sequential logical cpu number. */
  14. extern int __cpu_number_map[NR_CPUS];
  15. #define cpu_number_map(cpu) __cpu_number_map[cpu]
  16. /* The reverse map from sequential logical cpu number to cpu id. */
  17. extern int __cpu_logical_map[NR_CPUS];
  18. #define cpu_logical_map(cpu) __cpu_logical_map[cpu]
  19. enum {
  20. SMP_MSG_FUNCTION,
  21. SMP_MSG_RESCHEDULE,
  22. SMP_MSG_FUNCTION_SINGLE,
  23. SMP_MSG_TIMER,
  24. SMP_MSG_NR, /* must be last */
  25. };
  26. DECLARE_PER_CPU(int, cpu_state);
  27. void smp_message_recv(unsigned int msg);
  28. void arch_send_call_function_single_ipi(int cpu);
  29. void arch_send_call_function_ipi_mask(const struct cpumask *mask);
  30. void native_play_dead(void);
  31. void native_cpu_die(unsigned int cpu);
  32. int native_cpu_disable(unsigned int cpu);
  33. #ifdef CONFIG_HOTPLUG_CPU
  34. void play_dead_common(void);
  35. extern int __cpu_disable(void);
  36. static inline void __cpu_die(unsigned int cpu)
  37. {
  38. extern struct plat_smp_ops *mp_ops; /* private */
  39. mp_ops->cpu_die(cpu);
  40. }
  41. #endif
  42. static inline int hard_smp_processor_id(void)
  43. {
  44. extern struct plat_smp_ops *mp_ops; /* private */
  45. if (!mp_ops)
  46. return 0; /* boot CPU */
  47. return mp_ops->smp_processor_id();
  48. }
  49. struct of_cpu_method {
  50. const char *method;
  51. struct plat_smp_ops *ops;
  52. };
  53. #define CPU_METHOD_OF_DECLARE(name, _method, _ops) \
  54. static const struct of_cpu_method __cpu_method_of_table_##name \
  55. __used __section(__cpu_method_of_table) \
  56. = { .method = _method, .ops = _ops }
  57. #else
  58. #define hard_smp_processor_id() (0)
  59. #endif /* CONFIG_SMP */
  60. #endif /* __ASM_SH_SMP_H */