smp.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. #ifdef CONFIG_SMP
  31. struct smp_ops_t {
  32. void (*message_pass)(int cpu, int msg);
  33. #ifdef CONFIG_PPC_SMP_MUXED_IPI
  34. void (*cause_ipi)(int cpu, unsigned long data);
  35. #endif
  36. int (*probe)(void);
  37. int (*kick_cpu)(int nr);
  38. void (*setup_cpu)(int nr);
  39. void (*bringup_done)(void);
  40. void (*take_timebase)(void);
  41. void (*give_timebase)(void);
  42. int (*cpu_disable)(void);
  43. void (*cpu_die)(unsigned int nr);
  44. int (*cpu_bootable)(unsigned int nr);
  45. };
  46. extern void smp_send_debugger_break(void);
  47. extern void start_secondary_resume(void);
  48. extern void __devinit smp_generic_give_timebase(void);
  49. extern void __devinit smp_generic_take_timebase(void);
  50. DECLARE_PER_CPU(unsigned int, cpu_pvr);
  51. #ifdef CONFIG_HOTPLUG_CPU
  52. extern void migrate_irqs(void);
  53. int generic_cpu_disable(void);
  54. void generic_cpu_die(unsigned int cpu);
  55. void generic_mach_cpu_die(void);
  56. void generic_set_cpu_dead(unsigned int cpu);
  57. int generic_check_cpu_restart(unsigned int cpu);
  58. extern void inhibit_secondary_onlining(void);
  59. extern void uninhibit_secondary_onlining(void);
  60. #else /* HOTPLUG_CPU */
  61. static inline void inhibit_secondary_onlining(void) {}
  62. static inline void uninhibit_secondary_onlining(void) {}
  63. #endif
  64. #ifdef CONFIG_PPC64
  65. #define raw_smp_processor_id() (local_paca->paca_index)
  66. #define hard_smp_processor_id() (get_paca()->hw_cpu_id)
  67. #else
  68. /* 32-bit */
  69. extern int smp_hw_index[];
  70. #define raw_smp_processor_id() (current_thread_info()->cpu)
  71. #define hard_smp_processor_id() (smp_hw_index[smp_processor_id()])
  72. static inline int get_hard_smp_processor_id(int cpu)
  73. {
  74. return smp_hw_index[cpu];
  75. }
  76. static inline void set_hard_smp_processor_id(int cpu, int phys)
  77. {
  78. smp_hw_index[cpu] = phys;
  79. }
  80. #endif
  81. DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map);
  82. DECLARE_PER_CPU(cpumask_var_t, cpu_core_map);
  83. static inline struct cpumask *cpu_sibling_mask(int cpu)
  84. {
  85. return per_cpu(cpu_sibling_map, cpu);
  86. }
  87. static inline struct cpumask *cpu_core_mask(int cpu)
  88. {
  89. return per_cpu(cpu_core_map, cpu);
  90. }
  91. extern int cpu_to_core_id(int cpu);
  92. /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
  93. *
  94. * Make sure this matches openpic_request_IPIs in open_pic.c, or what shows up
  95. * in /proc/interrupts will be wrong!!! --Troy */
  96. #define PPC_MSG_CALL_FUNCTION 0
  97. #define PPC_MSG_RESCHEDULE 1
  98. #define PPC_MSG_CALL_FUNC_SINGLE 2
  99. #define PPC_MSG_DEBUGGER_BREAK 3
  100. /* for irq controllers that have dedicated ipis per message (4) */
  101. extern int smp_request_message_ipi(int virq, int message);
  102. extern const char *smp_ipi_name[];
  103. /* for irq controllers with only a single ipi */
  104. extern void smp_muxed_ipi_set_data(int cpu, unsigned long data);
  105. extern void smp_muxed_ipi_message_pass(int cpu, int msg);
  106. extern irqreturn_t smp_ipi_demux(void);
  107. void smp_init_pSeries(void);
  108. void smp_init_cell(void);
  109. void smp_init_celleb(void);
  110. void smp_setup_cpu_maps(void);
  111. extern int __cpu_disable(void);
  112. extern void __cpu_die(unsigned int cpu);
  113. #else
  114. /* for UP */
  115. #define hard_smp_processor_id() get_hard_smp_processor_id(0)
  116. #define smp_setup_cpu_maps()
  117. #endif /* CONFIG_SMP */
  118. #ifdef CONFIG_PPC64
  119. static inline int get_hard_smp_processor_id(int cpu)
  120. {
  121. return paca[cpu].hw_cpu_id;
  122. }
  123. static inline void set_hard_smp_processor_id(int cpu, int phys)
  124. {
  125. paca[cpu].hw_cpu_id = phys;
  126. }
  127. extern void smp_release_cpus(void);
  128. #else
  129. /* 32-bit */
  130. #ifndef CONFIG_SMP
  131. extern int boot_cpuid_phys;
  132. static inline int get_hard_smp_processor_id(int cpu)
  133. {
  134. return boot_cpuid_phys;
  135. }
  136. static inline void set_hard_smp_processor_id(int cpu, int phys)
  137. {
  138. boot_cpuid_phys = phys;
  139. }
  140. #endif /* !CONFIG_SMP */
  141. #endif /* !CONFIG_PPC64 */
  142. extern int smt_enabled_at_boot;
  143. extern int smp_mpic_probe(void);
  144. extern void smp_mpic_setup_cpu(int cpu);
  145. extern int smp_generic_kick_cpu(int nr);
  146. extern void smp_generic_give_timebase(void);
  147. extern void smp_generic_take_timebase(void);
  148. extern struct smp_ops_t *smp_ops;
  149. extern void arch_send_call_function_single_ipi(int cpu);
  150. extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);
  151. /* Definitions relative to the secondary CPU spin loop
  152. * and entry point. Not all of them exist on both 32 and
  153. * 64-bit but defining them all here doesn't harm
  154. */
  155. extern void generic_secondary_smp_init(void);
  156. extern void generic_secondary_thread_init(void);
  157. extern unsigned long __secondary_hold_spinloop;
  158. extern unsigned long __secondary_hold_acknowledge;
  159. extern char __secondary_hold;
  160. #endif /* __ASSEMBLY__ */
  161. #endif /* __KERNEL__ */
  162. #endif /* _ASM_POWERPC_SMP_H) */