smp.h 4.2 KB

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