bigsmp_32.c 5.1 KB

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