probe_32.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. /*
  2. * Default generic APIC driver. This handles up to 8 CPUs.
  3. *
  4. * Copyright 2003 Andi Kleen, SuSE Labs.
  5. * Subject to the GNU Public License, v.2
  6. *
  7. * Generic x86 APIC driver probe layer.
  8. */
  9. #include <linux/threads.h>
  10. #include <linux/cpumask.h>
  11. #include <linux/module.h>
  12. #include <linux/string.h>
  13. #include <linux/kernel.h>
  14. #include <linux/ctype.h>
  15. #include <linux/init.h>
  16. #include <linux/errno.h>
  17. #include <asm/fixmap.h>
  18. #include <asm/mpspec.h>
  19. #include <asm/apicdef.h>
  20. #include <asm/apic.h>
  21. #include <asm/setup.h>
  22. #include <linux/threads.h>
  23. #include <linux/cpumask.h>
  24. #include <asm/mpspec.h>
  25. #include <asm/fixmap.h>
  26. #include <asm/apicdef.h>
  27. #include <linux/kernel.h>
  28. #include <linux/string.h>
  29. #include <linux/smp.h>
  30. #include <linux/init.h>
  31. #include <asm/ipi.h>
  32. #include <linux/smp.h>
  33. #include <linux/init.h>
  34. #include <linux/interrupt.h>
  35. #include <asm/acpi.h>
  36. #include <asm/arch_hooks.h>
  37. #include <asm/e820.h>
  38. #include <asm/setup.h>
  39. #ifdef CONFIG_HOTPLUG_CPU
  40. #define DEFAULT_SEND_IPI (1)
  41. #else
  42. #define DEFAULT_SEND_IPI (0)
  43. #endif
  44. int no_broadcast = DEFAULT_SEND_IPI;
  45. static __init int no_ipi_broadcast(char *str)
  46. {
  47. get_option(&str, &no_broadcast);
  48. pr_info("Using %s mode\n",
  49. no_broadcast ? "No IPI Broadcast" : "IPI Broadcast");
  50. return 1;
  51. }
  52. __setup("no_ipi_broadcast=", no_ipi_broadcast);
  53. static int __init print_ipi_mode(void)
  54. {
  55. pr_info("Using IPI %s mode\n",
  56. no_broadcast ? "No-Shortcut" : "Shortcut");
  57. return 0;
  58. }
  59. late_initcall(print_ipi_mode);
  60. void default_setup_apic_routing(void)
  61. {
  62. #ifdef CONFIG_X86_IO_APIC
  63. printk(KERN_INFO
  64. "Enabling APIC mode: Flat. Using %d I/O APICs\n",
  65. nr_ioapics);
  66. #endif
  67. }
  68. static void default_vector_allocation_domain(int cpu, struct cpumask *retmask)
  69. {
  70. /*
  71. * Careful. Some cpus do not strictly honor the set of cpus
  72. * specified in the interrupt destination when using lowest
  73. * priority interrupt delivery mode.
  74. *
  75. * In particular there was a hyperthreading cpu observed to
  76. * deliver interrupts to the wrong hyperthread when only one
  77. * hyperthread was specified in the interrupt desitination.
  78. */
  79. *retmask = (cpumask_t) { { [0] = APIC_ALL_CPUS } };
  80. }
  81. /* should be called last. */
  82. static int probe_default(void)
  83. {
  84. return 1;
  85. }
  86. struct apic apic_default = {
  87. .name = "default",
  88. .probe = probe_default,
  89. .acpi_madt_oem_check = NULL,
  90. .apic_id_registered = default_apic_id_registered,
  91. .irq_delivery_mode = dest_LowestPrio,
  92. /* logical delivery broadcast to all CPUs: */
  93. .irq_dest_mode = 1,
  94. .target_cpus = default_target_cpus,
  95. .disable_esr = 0,
  96. .dest_logical = APIC_DEST_LOGICAL,
  97. .check_apicid_used = default_check_apicid_used,
  98. .check_apicid_present = default_check_apicid_present,
  99. .vector_allocation_domain = default_vector_allocation_domain,
  100. .init_apic_ldr = default_init_apic_ldr,
  101. .ioapic_phys_id_map = default_ioapic_phys_id_map,
  102. .setup_apic_routing = default_setup_apic_routing,
  103. .multi_timer_check = NULL,
  104. .apicid_to_node = default_apicid_to_node,
  105. .cpu_to_logical_apicid = default_cpu_to_logical_apicid,
  106. .cpu_present_to_apicid = default_cpu_present_to_apicid,
  107. .apicid_to_cpu_present = default_apicid_to_cpu_present,
  108. .setup_portio_remap = NULL,
  109. .check_phys_apicid_present = default_check_phys_apicid_present,
  110. .enable_apic_mode = NULL,
  111. .phys_pkg_id = default_phys_pkg_id,
  112. .mps_oem_check = NULL,
  113. .get_apic_id = default_get_apic_id,
  114. .set_apic_id = NULL,
  115. .apic_id_mask = 0x0F << 24,
  116. .cpu_mask_to_apicid = default_cpu_mask_to_apicid,
  117. .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
  118. .send_IPI_mask = default_send_IPI_mask_logical,
  119. .send_IPI_mask_allbutself = default_send_IPI_mask_allbutself_logical,
  120. .send_IPI_allbutself = default_send_IPI_allbutself,
  121. .send_IPI_all = default_send_IPI_all,
  122. .send_IPI_self = default_send_IPI_self,
  123. .wakeup_cpu = NULL,
  124. .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
  125. .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
  126. .wait_for_init_deassert = default_wait_for_init_deassert,
  127. .smp_callin_clear_local_apic = NULL,
  128. .inquire_remote_apic = default_inquire_remote_apic,
  129. .read = native_apic_mem_read,
  130. .write = native_apic_mem_write,
  131. .icr_read = native_apic_icr_read,
  132. .icr_write = native_apic_icr_write,
  133. .wait_icr_idle = native_apic_wait_icr_idle,
  134. .safe_wait_icr_idle = native_safe_apic_wait_icr_idle,
  135. };
  136. extern struct apic apic_numaq;
  137. extern struct apic apic_summit;
  138. extern struct apic apic_bigsmp;
  139. extern struct apic apic_es7000;
  140. extern struct apic apic_default;
  141. struct apic *apic = &apic_default;
  142. EXPORT_SYMBOL_GPL(apic);
  143. static struct apic *apic_probe[] __initdata = {
  144. #ifdef CONFIG_X86_NUMAQ
  145. &apic_numaq,
  146. #endif
  147. #ifdef CONFIG_X86_SUMMIT
  148. &apic_summit,
  149. #endif
  150. #ifdef CONFIG_X86_BIGSMP
  151. &apic_bigsmp,
  152. #endif
  153. #ifdef CONFIG_X86_ES7000
  154. &apic_es7000,
  155. #endif
  156. &apic_default, /* must be last */
  157. NULL,
  158. };
  159. static int cmdline_apic __initdata;
  160. static int __init parse_apic(char *arg)
  161. {
  162. int i;
  163. if (!arg)
  164. return -EINVAL;
  165. for (i = 0; apic_probe[i]; i++) {
  166. if (!strcmp(apic_probe[i]->name, arg)) {
  167. apic = apic_probe[i];
  168. cmdline_apic = 1;
  169. return 0;
  170. }
  171. }
  172. if (x86_quirks->update_apic)
  173. x86_quirks->update_apic();
  174. /* Parsed again by __setup for debug/verbose */
  175. return 0;
  176. }
  177. early_param("apic", parse_apic);
  178. void __init generic_bigsmp_probe(void)
  179. {
  180. #ifdef CONFIG_X86_BIGSMP
  181. /*
  182. * This routine is used to switch to bigsmp mode when
  183. * - There is no apic= option specified by the user
  184. * - generic_apic_probe() has chosen apic_default as the sub_arch
  185. * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
  186. */
  187. if (!cmdline_apic && apic == &apic_default) {
  188. if (apic_bigsmp.probe()) {
  189. apic = &apic_bigsmp;
  190. if (x86_quirks->update_apic)
  191. x86_quirks->update_apic();
  192. printk(KERN_INFO "Overriding APIC driver with %s\n",
  193. apic->name);
  194. }
  195. }
  196. #endif
  197. }
  198. void __init generic_apic_probe(void)
  199. {
  200. if (!cmdline_apic) {
  201. int i;
  202. for (i = 0; apic_probe[i]; i++) {
  203. if (apic_probe[i]->probe()) {
  204. apic = apic_probe[i];
  205. break;
  206. }
  207. }
  208. /* Not visible without early console */
  209. if (!apic_probe[i])
  210. panic("Didn't find an APIC driver");
  211. if (x86_quirks->update_apic)
  212. x86_quirks->update_apic();
  213. }
  214. printk(KERN_INFO "Using APIC driver %s\n", apic->name);
  215. }
  216. /* These functions can switch the APIC even after the initial ->probe() */
  217. int __init
  218. generic_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
  219. {
  220. int i;
  221. for (i = 0; apic_probe[i]; ++i) {
  222. if (!apic_probe[i]->mps_oem_check)
  223. continue;
  224. if (!apic_probe[i]->mps_oem_check(mpc, oem, productid))
  225. continue;
  226. if (!cmdline_apic) {
  227. apic = apic_probe[i];
  228. if (x86_quirks->update_apic)
  229. x86_quirks->update_apic();
  230. printk(KERN_INFO "Switched to APIC driver `%s'.\n",
  231. apic->name);
  232. }
  233. return 1;
  234. }
  235. return 0;
  236. }
  237. int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
  238. {
  239. int i;
  240. for (i = 0; apic_probe[i]; ++i) {
  241. if (!apic_probe[i]->acpi_madt_oem_check)
  242. continue;
  243. if (!apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id))
  244. continue;
  245. if (!cmdline_apic) {
  246. apic = apic_probe[i];
  247. if (x86_quirks->update_apic)
  248. x86_quirks->update_apic();
  249. printk(KERN_INFO "Switched to APIC driver `%s'.\n",
  250. apic->name);
  251. }
  252. return 1;
  253. }
  254. return 0;
  255. }