smp.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright IBM Corp. 1999, 2012
  4. * Author(s): Denis Joseph Barrow,
  5. * Martin Schwidefsky <schwidefsky@de.ibm.com>,
  6. * Heiko Carstens <heiko.carstens@de.ibm.com>,
  7. */
  8. #ifndef __ASM_SMP_H
  9. #define __ASM_SMP_H
  10. #include <asm/sigp.h>
  11. #ifdef CONFIG_SMP
  12. #include <asm/lowcore.h>
  13. #define raw_smp_processor_id() (S390_lowcore.cpu_nr)
  14. extern struct mutex smp_cpu_state_mutex;
  15. extern unsigned int smp_cpu_mt_shift;
  16. extern unsigned int smp_cpu_mtid;
  17. extern __vector128 __initdata boot_cpu_vector_save_area[__NUM_VXRS];
  18. extern int __cpu_up(unsigned int cpu, struct task_struct *tidle);
  19. extern void arch_send_call_function_single_ipi(int cpu);
  20. extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
  21. extern void smp_call_online_cpu(void (*func)(void *), void *);
  22. extern void smp_call_ipl_cpu(void (*func)(void *), void *);
  23. extern void smp_emergency_stop(void);
  24. extern int smp_find_processor_id(u16 address);
  25. extern int smp_store_status(int cpu);
  26. extern void smp_save_dump_cpus(void);
  27. extern int smp_vcpu_scheduled(int cpu);
  28. extern void smp_yield_cpu(int cpu);
  29. extern void smp_cpu_set_polarization(int cpu, int val);
  30. extern int smp_cpu_get_polarization(int cpu);
  31. extern void smp_fill_possible_mask(void);
  32. extern void smp_detect_cpus(void);
  33. #else /* CONFIG_SMP */
  34. #define smp_cpu_mtid 0
  35. static inline void smp_call_ipl_cpu(void (*func)(void *), void *data)
  36. {
  37. func(data);
  38. }
  39. static inline void smp_call_online_cpu(void (*func)(void *), void *data)
  40. {
  41. func(data);
  42. }
  43. static inline void smp_emergency_stop(void)
  44. {
  45. }
  46. static inline int smp_find_processor_id(u16 address) { return 0; }
  47. static inline int smp_store_status(int cpu) { return 0; }
  48. static inline int smp_vcpu_scheduled(int cpu) { return 1; }
  49. static inline void smp_yield_cpu(int cpu) { }
  50. static inline void smp_fill_possible_mask(void) { }
  51. static inline void smp_detect_cpus(void) { }
  52. #endif /* CONFIG_SMP */
  53. static inline void smp_stop_cpu(void)
  54. {
  55. u16 pcpu = stap();
  56. for (;;) {
  57. __pcpu_sigp(pcpu, SIGP_STOP, 0, NULL);
  58. cpu_relax();
  59. }
  60. }
  61. /* Return thread 0 CPU number as base CPU */
  62. static inline int smp_get_base_cpu(int cpu)
  63. {
  64. return cpu - (cpu % (smp_cpu_mtid + 1));
  65. }
  66. #ifdef CONFIG_HOTPLUG_CPU
  67. extern int smp_rescan_cpus(void);
  68. extern void __noreturn cpu_die(void);
  69. extern void __cpu_die(unsigned int cpu);
  70. extern int __cpu_disable(void);
  71. #else
  72. static inline int smp_rescan_cpus(void) { return 0; }
  73. static inline void cpu_die(void) { }
  74. #endif
  75. #endif /* __ASM_SMP_H */