smp.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * include/asm-s390/smp.h
  3. *
  4. * S390 version
  5. * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
  6. * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com),
  7. * Martin Schwidefsky (schwidefsky@de.ibm.com)
  8. * Heiko Carstens (heiko.carstens@de.ibm.com)
  9. */
  10. #ifndef __ASM_SMP_H
  11. #define __ASM_SMP_H
  12. #include <linux/threads.h>
  13. #include <linux/cpumask.h>
  14. #include <linux/bitops.h>
  15. #if defined(__KERNEL__) && defined(CONFIG_SMP) && !defined(__ASSEMBLY__)
  16. #include <asm/lowcore.h>
  17. #include <asm/sigp.h>
  18. #include <asm/ptrace.h>
  19. /*
  20. s390 specific smp.c headers
  21. */
  22. typedef struct
  23. {
  24. int intresting;
  25. sigp_ccode ccode;
  26. __u32 status;
  27. __u16 cpu;
  28. } sigp_info;
  29. extern void machine_restart_smp(char *);
  30. extern void machine_halt_smp(void);
  31. extern void machine_power_off_smp(void);
  32. extern void smp_setup_cpu_possible_map(void);
  33. extern int smp_call_function_on(void (*func) (void *info), void *info,
  34. int nonatomic, int wait, int cpu);
  35. #define NO_PROC_ID 0xFF /* No processor magic marker */
  36. /*
  37. * This magic constant controls our willingness to transfer
  38. * a process across CPUs. Such a transfer incurs misses on the L1
  39. * cache, and on a P6 or P5 with multiple L2 caches L2 hits. My
  40. * gut feeling is this will vary by board in value. For a board
  41. * with separate L2 cache it probably depends also on the RSS, and
  42. * for a board with shared L2 cache it ought to decay fast as other
  43. * processes are run.
  44. */
  45. #define PROC_CHANGE_PENALTY 20 /* Schedule penalty */
  46. #define raw_smp_processor_id() (S390_lowcore.cpu_data.cpu_nr)
  47. extern int smp_get_cpu(cpumask_t cpu_map);
  48. extern void smp_put_cpu(int cpu);
  49. static inline __u16 hard_smp_processor_id(void)
  50. {
  51. __u16 cpu_address;
  52. asm volatile("stap %0" : "=m" (cpu_address));
  53. return cpu_address;
  54. }
  55. /*
  56. * returns 1 if cpu is in stopped/check stopped state or not operational
  57. * returns 0 otherwise
  58. */
  59. static inline int
  60. smp_cpu_not_running(int cpu)
  61. {
  62. __u32 status;
  63. switch (signal_processor_ps(&status, 0, cpu, sigp_sense)) {
  64. case sigp_order_code_accepted:
  65. case sigp_status_stored:
  66. /* Check for stopped and check stop state */
  67. if (status & 0x50)
  68. return 1;
  69. break;
  70. case sigp_not_operational:
  71. return 1;
  72. default:
  73. break;
  74. }
  75. return 0;
  76. }
  77. #define cpu_logical_map(cpu) (cpu)
  78. extern int __cpu_disable (void);
  79. extern void __cpu_die (unsigned int cpu);
  80. extern void cpu_die (void) __attribute__ ((noreturn));
  81. extern int __cpu_up (unsigned int cpu);
  82. #endif
  83. #ifndef CONFIG_SMP
  84. static inline int
  85. smp_call_function_on(void (*func) (void *info), void *info,
  86. int nonatomic, int wait, int cpu)
  87. {
  88. func(info);
  89. return 0;
  90. }
  91. static inline void smp_send_stop(void)
  92. {
  93. /* Disable all interrupts/machine checks */
  94. __load_psw_mask(psw_kernel_bits & ~PSW_MASK_MCHECK);
  95. }
  96. #define smp_cpu_not_running(cpu) 1
  97. #define smp_get_cpu(cpu) ({ 0; })
  98. #define smp_put_cpu(cpu) ({ 0; })
  99. #define smp_setup_cpu_possible_map() do { } while (0)
  100. #endif
  101. #endif