smp.h 2.3 KB

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