probe_32.c 6.5 KB

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