smp.h 5.0 KB

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