bigsmp_32.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /*
  2. * APIC driver for "bigsmp" xAPIC machines with more than 8 virtual CPUs.
  3. *
  4. * Drives the local APIC in "clustered mode".
  5. */
  6. #include <linux/threads.h>
  7. #include <linux/cpumask.h>
  8. #include <linux/kernel.h>
  9. #include <linux/init.h>
  10. #include <linux/dmi.h>
  11. #include <linux/smp.h>
  12. #include <asm/apicdef.h>
  13. #include <asm/fixmap.h>
  14. #include <asm/mpspec.h>
  15. #include <asm/apic.h>
  16. #include <asm/ipi.h>
  17. static unsigned bigsmp_get_apic_id(unsigned long x)
  18. {
  19. return (x >> 24) & 0xFF;
  20. }
  21. static int bigsmp_apic_id_registered(void)
  22. {
  23. return 1;
  24. }
  25. static unsigned long bigsmp_check_apicid_used(physid_mask_t *map, int apicid)
  26. {
  27. return 0;
  28. }
  29. static unsigned long bigsmp_check_apicid_present(int bit)
  30. {
  31. return 1;
  32. }
  33. static int bigsmp_early_logical_apicid(int cpu)
  34. {
  35. /* on bigsmp, logical apicid is the same as physical */
  36. return early_per_cpu(x86_cpu_to_apicid, cpu);
  37. }
  38. static inline unsigned long calculate_ldr(int cpu)
  39. {
  40. unsigned long val, id;
  41. val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
  42. id = per_cpu(x86_bios_cpu_apicid, cpu);
  43. val |= SET_APIC_LOGICAL_ID(id);
  44. return val;
  45. }
  46. /*
  47. * Set up the logical destination ID.
  48. *
  49. * Intel recommends to set DFR, LDR and TPR before enabling
  50. * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
  51. * document number 292116). So here it goes...
  52. */
  53. static void bigsmp_init_apic_ldr(void)
  54. {
  55. unsigned long val;
  56. int cpu = smp_processor_id();
  57. apic_write(APIC_DFR, APIC_DFR_FLAT);
  58. val = calculate_ldr(cpu);
  59. apic_write(APIC_LDR, val);
  60. }
  61. static void bigsmp_setup_apic_routing(void)
  62. {
  63. printk(KERN_INFO
  64. "Enabling APIC mode: Physflat. Using %d I/O APICs\n",
  65. nr_ioapics);
  66. }
  67. static int bigsmp_cpu_present_to_apicid(int mps_cpu)
  68. {
  69. if (mps_cpu < nr_cpu_ids)
  70. return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
  71. return BAD_APICID;
  72. }
  73. static void bigsmp_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap)
  74. {
  75. /* For clustered we don't have a good way to do this yet - hack */
  76. physids_promote(0xFFL, retmap);
  77. }
  78. static int bigsmp_check_phys_apicid_present(int phys_apicid)
  79. {
  80. return 1;
  81. }
  82. static int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb)
  83. {
  84. return cpuid_apic >> index_msb;
  85. }
  86. static inline void bigsmp_send_IPI_mask(const struct cpumask *mask, int vector)
  87. {
  88. default_send_IPI_mask_sequence_phys(mask, vector);
  89. }
  90. static void bigsmp_send_IPI_allbutself(int vector)
  91. {
  92. default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector);
  93. }
  94. static void bigsmp_send_IPI_all(int vector)
  95. {
  96. bigsmp_send_IPI_mask(cpu_online_mask, vector);
  97. }
  98. static int dmi_bigsmp; /* can be set by dmi scanners */
  99. static int hp_ht_bigsmp(const struct dmi_system_id *d)
  100. {
  101. printk(KERN_NOTICE "%s detected: force use of apic=bigsmp\n", d->ident);
  102. dmi_bigsmp = 1;
  103. return 0;
  104. }
  105. static const struct dmi_system_id bigsmp_dmi_table[] = {
  106. { hp_ht_bigsmp, "HP ProLiant DL760 G2",
  107. { DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
  108. DMI_MATCH(DMI_BIOS_VERSION, "P44-"),
  109. }
  110. },
  111. { hp_ht_bigsmp, "HP ProLiant DL740",
  112. { DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
  113. DMI_MATCH(DMI_BIOS_VERSION, "P47-"),
  114. }
  115. },
  116. { } /* NULL entry stops DMI scanning */
  117. };
  118. static int probe_bigsmp(void)
  119. {
  120. if (def_to_bigsmp)
  121. dmi_bigsmp = 1;
  122. else
  123. dmi_check_system(bigsmp_dmi_table);
  124. return dmi_bigsmp;
  125. }
  126. static struct apic apic_bigsmp = {
  127. .name = "bigsmp",
  128. .probe = probe_bigsmp,
  129. .acpi_madt_oem_check = NULL,
  130. .apic_id_valid = default_apic_id_valid,
  131. .apic_id_registered = bigsmp_apic_id_registered,
  132. .irq_delivery_mode = dest_Fixed,
  133. /* phys delivery to target CPU: */
  134. .irq_dest_mode = 0,
  135. .target_cpus = default_target_cpus,
  136. .disable_esr = 1,
  137. .dest_logical = 0,
  138. .check_apicid_used = bigsmp_check_apicid_used,
  139. .check_apicid_present = bigsmp_check_apicid_present,
  140. .vector_allocation_domain = default_vector_allocation_domain,
  141. .init_apic_ldr = bigsmp_init_apic_ldr,
  142. .ioapic_phys_id_map = bigsmp_ioapic_phys_id_map,
  143. .setup_apic_routing = bigsmp_setup_apic_routing,
  144. .multi_timer_check = NULL,
  145. .cpu_present_to_apicid = bigsmp_cpu_present_to_apicid,
  146. .apicid_to_cpu_present = physid_set_mask_of_physid,
  147. .setup_portio_remap = NULL,
  148. .check_phys_apicid_present = bigsmp_check_phys_apicid_present,
  149. .enable_apic_mode = NULL,
  150. .phys_pkg_id = bigsmp_phys_pkg_id,
  151. .mps_oem_check = NULL,
  152. .get_apic_id = bigsmp_get_apic_id,
  153. .set_apic_id = NULL,
  154. .apic_id_mask = 0xFF << 24,
  155. .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
  156. .send_IPI_mask = bigsmp_send_IPI_mask,
  157. .send_IPI_mask_allbutself = NULL,
  158. .send_IPI_allbutself = bigsmp_send_IPI_allbutself,
  159. .send_IPI_all = bigsmp_send_IPI_all,
  160. .send_IPI_self = default_send_IPI_self,
  161. .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
  162. .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
  163. .wait_for_init_deassert = default_wait_for_init_deassert,
  164. .smp_callin_clear_local_apic = NULL,
  165. .inquire_remote_apic = default_inquire_remote_apic,
  166. .read = native_apic_mem_read,
  167. .write = native_apic_mem_write,
  168. .eoi_write = native_apic_mem_write,
  169. .icr_read = native_apic_icr_read,
  170. .icr_write = native_apic_icr_write,
  171. .wait_icr_idle = native_apic_wait_icr_idle,
  172. .safe_wait_icr_idle = native_safe_apic_wait_icr_idle,
  173. .x86_32_early_logical_apicid = bigsmp_early_logical_apicid,
  174. };
  175. void __init generic_bigsmp_probe(void)
  176. {
  177. unsigned int cpu;
  178. if (!probe_bigsmp())
  179. return;
  180. apic = &apic_bigsmp;
  181. for_each_possible_cpu(cpu) {
  182. if (early_per_cpu(x86_cpu_to_logical_apicid,
  183. cpu) == BAD_APICID)
  184. continue;
  185. early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
  186. bigsmp_early_logical_apicid(cpu);
  187. }
  188. pr_info("Overriding APIC driver with %s\n", apic_bigsmp.name);
  189. }
  190. apic_driver(apic_bigsmp);