smp.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * smp.h: PowerPC-specific SMP code.
  3. *
  4. * Original was a copy of sparc smp.h. Now heavily modified
  5. * for PPC.
  6. *
  7. * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  8. * Copyright (C) 1996-2001 Cort Dougan <cort@fsmlabs.com>
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version
  13. * 2 of the License, or (at your option) any later version.
  14. */
  15. #ifndef _ASM_POWERPC_SMP_H
  16. #define _ASM_POWERPC_SMP_H
  17. #ifdef __KERNEL__
  18. #include <linux/threads.h>
  19. #include <linux/cpumask.h>
  20. #include <linux/kernel.h>
  21. #include <linux/irqreturn.h>
  22. #ifndef __ASSEMBLY__
  23. #ifdef CONFIG_PPC64
  24. #include <asm/paca.h>
  25. #endif
  26. #include <asm/percpu.h>
  27. extern int boot_cpuid;
  28. extern int spinning_secondaries;
  29. extern void cpu_die(void);
  30. extern int cpu_to_chip_id(int cpu);
  31. #ifdef CONFIG_SMP
  32. struct smp_ops_t {
  33. void (*message_pass)(int cpu, int msg);
  34. #ifdef CONFIG_PPC_SMP_MUXED_IPI
  35. void (*cause_ipi)(int cpu, unsigned long data);
  36. #endif
  37. void (*probe)(void);
  38. int (*kick_cpu)(int nr);
  39. void (*setup_cpu)(int nr);
  40. void (*bringup_done)(void);
  41. void (*take_timebase)(void);
  42. void (*give_timebase)(void);
  43. int (*cpu_disable)(void);
  44. void (*cpu_die)(unsigned int nr);
  45. int (*cpu_bootable)(unsigned int nr);
  46. };
  47. extern void smp_send_debugger_break(void);
  48. extern void start_secondary_resume(void);
  49. extern void smp_generic_give_timebase(void);
  50. extern void smp_generic_take_timebase(void);
  51. DECLARE_PER_CPU(unsigned int, cpu_pvr);
  52. #ifdef CONFIG_HOTPLUG_CPU
  53. extern void migrate_irqs(void);
  54. int generic_cpu_disable(void);
  55. void generic_cpu_die(unsigned int cpu);
  56. void generic_set_cpu_dead(unsigned int cpu);
  57. void generic_set_cpu_up(unsigned int cpu);
  58. int generic_check_cpu_restart(unsigned int cpu);
  59. #endif
  60. #ifdef CONFIG_PPC64
  61. #define raw_smp_processor_id() (local_paca->paca_index)
  62. #define hard_smp_processor_id() (get_paca()->hw_cpu_id)
  63. #else
  64. /* 32-bit */
  65. extern int smp_hw_index[];
  66. #define raw_smp_processor_id() (current_thread_info()->cpu)
  67. #define hard_smp_processor_id() (smp_hw_index[smp_processor_id()])
  68. static inline int get_hard_smp_processor_id(int cpu)
  69. {
  70. return smp_hw_index[cpu];
  71. }
  72. static inline void set_hard_smp_processor_id(int cpu, int phys)
  73. {
  74. smp_hw_index[cpu] = phys;
  75. }
  76. #endif
  77. DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map);
  78. DECLARE_PER_CPU(cpumask_var_t, cpu_core_map);
  79. static inline struct cpumask *cpu_sibling_mask(int cpu)
  80. {
  81. return per_cpu(cpu_sibling_map, cpu);
  82. }
  83. static inline struct cpumask *cpu_core_mask(int cpu)
  84. {
  85. return per_cpu(cpu_core_map, cpu);
  86. }
  87. extern int cpu_to_core_id(int cpu);
  88. /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
  89. *
  90. * Make sure this matches openpic_request_IPIs in open_pic.c, or what shows up
  91. * in /proc/interrupts will be wrong!!! --Troy */
  92. #define PPC_MSG_CALL_FUNCTION 0
  93. #define PPC_MSG_RESCHEDULE 1
  94. #define PPC_MSG_TICK_BROADCAST 2
  95. #define PPC_MSG_DEBUGGER_BREAK 3
  96. /* for irq controllers that have dedicated ipis per message (4) */
  97. extern int smp_request_message_ipi(int virq, int message);
  98. extern const char *smp_ipi_name[];
  99. /* for irq controllers with only a single ipi */
  100. extern void smp_muxed_ipi_set_data(int cpu, unsigned long data);
  101. extern void smp_muxed_ipi_message_pass(int cpu, int msg);
  102. extern irqreturn_t smp_ipi_demux(void);
  103. void smp_init_pSeries(void);
  104. void smp_init_cell(void);
  105. void smp_setup_cpu_maps(void);
  106. extern int __cpu_disable(void);
  107. extern void __cpu_die(unsigned int cpu);
  108. #else
  109. /* for UP */
  110. #define hard_smp_processor_id() get_hard_smp_processor_id(0)
  111. #define smp_setup_cpu_maps()
  112. static inline void inhibit_secondary_onlining(void) {}
  113. static inline void uninhibit_secondary_onlining(void) {}
  114. static inline const struct cpumask *cpu_sibling_mask(int cpu)
  115. {
  116. return cpumask_of(cpu);
  117. }
  118. #endif /* CONFIG_SMP */
  119. #ifdef CONFIG_PPC64
  120. static inline int get_hard_smp_processor_id(int cpu)
  121. {
  122. return paca[cpu].hw_cpu_id;
  123. }
  124. static inline void set_hard_smp_processor_id(int cpu, int phys)
  125. {
  126. paca[cpu].hw_cpu_id = phys;
  127. }
  128. extern void smp_release_cpus(void);
  129. #else
  130. /* 32-bit */
  131. #ifndef CONFIG_SMP
  132. extern int boot_cpuid_phys;
  133. static inline int get_hard_smp_processor_id(int cpu)
  134. {
  135. return boot_cpuid_phys;
  136. }
  137. static inline void set_hard_smp_processor_id(int cpu, int phys)
  138. {
  139. boot_cpuid_phys = phys;
  140. }
  141. #endif /* !CONFIG_SMP */
  142. #endif /* !CONFIG_PPC64 */
  143. extern int smt_enabled_at_boot;
  144. extern void smp_mpic_probe(void);
  145. extern void smp_mpic_setup_cpu(int cpu);
  146. extern int smp_generic_kick_cpu(int nr);
  147. extern int smp_generic_cpu_bootable(unsigned int nr);
  148. extern void smp_generic_give_timebase(void);
  149. extern void smp_generic_take_timebase(void);
  150. extern struct smp_ops_t *smp_ops;
  151. extern void arch_send_call_function_single_ipi(int cpu);
  152. extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
  153. /* Definitions relative to the secondary CPU spin loop
  154. * and entry point. Not all of them exist on both 32 and
  155. * 64-bit but defining them all here doesn't harm
  156. */
  157. extern void generic_secondary_smp_init(void);
  158. extern void generic_secondary_thread_init(void);
  159. extern unsigned long __secondary_hold_spinloop;
  160. extern unsigned long __secondary_hold_acknowledge;
  161. extern char __secondary_hold;
  162. extern void __early_start(void);
  163. #endif /* __ASSEMBLY__ */
  164. #endif /* __KERNEL__ */
  165. #endif /* _ASM_POWERPC_SMP_H) */