bigsmp_32.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * APIC driver for "bigsmp" xAPIC machines with more than 8 virtual CPUs.
  4. *
  5. * Drives the local APIC in "clustered mode".
  6. */
  7. #include <linux/threads.h>
  8. #include <linux/cpumask.h>
  9. #include <linux/kernel.h>
  10. #include <linux/init.h>
  11. #include <linux/dmi.h>
  12. #include <linux/smp.h>
  13. #include <asm/apicdef.h>
  14. #include <asm/fixmap.h>
  15. #include <asm/mpspec.h>
  16. #include <asm/apic.h>
  17. #include <asm/ipi.h>
  18. static unsigned bigsmp_get_apic_id(unsigned long x)
  19. {
  20. return (x >> 24) & 0xFF;
  21. }
  22. static int bigsmp_apic_id_registered(void)
  23. {
  24. return 1;
  25. }
  26. static bool bigsmp_check_apicid_used(physid_mask_t *map, int apicid)
  27. {
  28. return false;
  29. }
  30. static int bigsmp_early_logical_apicid(int cpu)
  31. {
  32. /* on bigsmp, logical apicid is the same as physical */
  33. return early_per_cpu(x86_cpu_to_apicid, cpu);
  34. }
  35. /*
  36. * bigsmp enables physical destination mode
  37. * and doesn't use LDR and DFR
  38. */
  39. static void bigsmp_init_apic_ldr(void)
  40. {
  41. }
  42. static void bigsmp_setup_apic_routing(void)
  43. {
  44. printk(KERN_INFO
  45. "Enabling APIC mode: Physflat. Using %d I/O APICs\n",
  46. nr_ioapics);
  47. }
  48. static int bigsmp_cpu_present_to_apicid(int mps_cpu)
  49. {
  50. if (mps_cpu < nr_cpu_ids)
  51. return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
  52. return BAD_APICID;
  53. }
  54. static void bigsmp_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap)
  55. {
  56. /* For clustered we don't have a good way to do this yet - hack */
  57. physids_promote(0xFFL, retmap);
  58. }
  59. static int bigsmp_check_phys_apicid_present(int phys_apicid)
  60. {
  61. return 1;
  62. }
  63. static int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb)
  64. {
  65. return cpuid_apic >> index_msb;
  66. }
  67. static void bigsmp_send_IPI_allbutself(int vector)
  68. {
  69. default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector);
  70. }
  71. static void bigsmp_send_IPI_all(int vector)
  72. {
  73. default_send_IPI_mask_sequence_phys(cpu_online_mask, vector);
  74. }
  75. static int dmi_bigsmp; /* can be set by dmi scanners */
  76. static int hp_ht_bigsmp(const struct dmi_system_id *d)
  77. {
  78. printk(KERN_NOTICE "%s detected: force use of apic=bigsmp\n", d->ident);
  79. dmi_bigsmp = 1;
  80. return 0;
  81. }
  82. static const struct dmi_system_id bigsmp_dmi_table[] = {
  83. { hp_ht_bigsmp, "HP ProLiant DL760 G2",
  84. { DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
  85. DMI_MATCH(DMI_BIOS_VERSION, "P44-"),
  86. }
  87. },
  88. { hp_ht_bigsmp, "HP ProLiant DL740",
  89. { DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
  90. DMI_MATCH(DMI_BIOS_VERSION, "P47-"),
  91. }
  92. },
  93. { } /* NULL entry stops DMI scanning */
  94. };
  95. static int probe_bigsmp(void)
  96. {
  97. if (def_to_bigsmp)
  98. dmi_bigsmp = 1;
  99. else
  100. dmi_check_system(bigsmp_dmi_table);
  101. return dmi_bigsmp;
  102. }
  103. static struct apic apic_bigsmp __ro_after_init = {
  104. .name = "bigsmp",
  105. .probe = probe_bigsmp,
  106. .acpi_madt_oem_check = NULL,
  107. .apic_id_valid = default_apic_id_valid,
  108. .apic_id_registered = bigsmp_apic_id_registered,
  109. .irq_delivery_mode = dest_Fixed,
  110. /* phys delivery to target CPU: */
  111. .irq_dest_mode = 0,
  112. .disable_esr = 1,
  113. .dest_logical = 0,
  114. .check_apicid_used = bigsmp_check_apicid_used,
  115. .init_apic_ldr = bigsmp_init_apic_ldr,
  116. .ioapic_phys_id_map = bigsmp_ioapic_phys_id_map,
  117. .setup_apic_routing = bigsmp_setup_apic_routing,
  118. .cpu_present_to_apicid = bigsmp_cpu_present_to_apicid,
  119. .apicid_to_cpu_present = physid_set_mask_of_physid,
  120. .check_phys_apicid_present = bigsmp_check_phys_apicid_present,
  121. .phys_pkg_id = bigsmp_phys_pkg_id,
  122. .get_apic_id = bigsmp_get_apic_id,
  123. .set_apic_id = NULL,
  124. .calc_dest_apicid = apic_default_calc_apicid,
  125. .send_IPI = default_send_IPI_single_phys,
  126. .send_IPI_mask = default_send_IPI_mask_sequence_phys,
  127. .send_IPI_mask_allbutself = NULL,
  128. .send_IPI_allbutself = bigsmp_send_IPI_allbutself,
  129. .send_IPI_all = bigsmp_send_IPI_all,
  130. .send_IPI_self = default_send_IPI_self,
  131. .inquire_remote_apic = default_inquire_remote_apic,
  132. .read = native_apic_mem_read,
  133. .write = native_apic_mem_write,
  134. .eoi_write = native_apic_mem_write,
  135. .icr_read = native_apic_icr_read,
  136. .icr_write = native_apic_icr_write,
  137. .wait_icr_idle = native_apic_wait_icr_idle,
  138. .safe_wait_icr_idle = native_safe_apic_wait_icr_idle,
  139. .x86_32_early_logical_apicid = bigsmp_early_logical_apicid,
  140. };
  141. void __init generic_bigsmp_probe(void)
  142. {
  143. unsigned int cpu;
  144. if (!probe_bigsmp())
  145. return;
  146. apic = &apic_bigsmp;
  147. for_each_possible_cpu(cpu) {
  148. if (early_per_cpu(x86_cpu_to_logical_apicid,
  149. cpu) == BAD_APICID)
  150. continue;
  151. early_per_cpu(x86_cpu_to_logical_apicid, cpu) =
  152. bigsmp_early_logical_apicid(cpu);
  153. }
  154. pr_info("Overriding APIC driver with %s\n", apic_bigsmp.name);
  155. }
  156. apic_driver(apic_bigsmp);