smp.h 4.3 KB

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