apic_noop.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * NOOP APIC driver.
  4. *
  5. * Does almost nothing and should be substituted by a real apic driver via
  6. * probe routine.
  7. *
  8. * Though in case if apic is disabled (for some reason) we try
  9. * to not uglify the caller's code and allow to call (some) apic routines
  10. * like self-ipi, etc...
  11. */
  12. #include <linux/threads.h>
  13. #include <linux/cpumask.h>
  14. #include <linux/string.h>
  15. #include <linux/kernel.h>
  16. #include <linux/ctype.h>
  17. #include <linux/errno.h>
  18. #include <asm/fixmap.h>
  19. #include <asm/mpspec.h>
  20. #include <asm/apicdef.h>
  21. #include <asm/apic.h>
  22. #include <asm/setup.h>
  23. #include <linux/smp.h>
  24. #include <asm/ipi.h>
  25. #include <linux/interrupt.h>
  26. #include <asm/acpi.h>
  27. #include <asm/e820/api.h>
  28. static void noop_init_apic_ldr(void) { }
  29. static void noop_send_IPI(int cpu, int vector) { }
  30. static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector) { }
  31. static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) { }
  32. static void noop_send_IPI_allbutself(int vector) { }
  33. static void noop_send_IPI_all(int vector) { }
  34. static void noop_send_IPI_self(int vector) { }
  35. static void noop_apic_wait_icr_idle(void) { }
  36. static void noop_apic_icr_write(u32 low, u32 id) { }
  37. static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip)
  38. {
  39. return -1;
  40. }
  41. static u32 noop_safe_apic_wait_icr_idle(void)
  42. {
  43. return 0;
  44. }
  45. static u64 noop_apic_icr_read(void)
  46. {
  47. return 0;
  48. }
  49. static int noop_phys_pkg_id(int cpuid_apic, int index_msb)
  50. {
  51. return 0;
  52. }
  53. static unsigned int noop_get_apic_id(unsigned long x)
  54. {
  55. return 0;
  56. }
  57. static int noop_probe(void)
  58. {
  59. /*
  60. * NOOP apic should not ever be
  61. * enabled via probe routine
  62. */
  63. return 0;
  64. }
  65. static int noop_apic_id_registered(void)
  66. {
  67. /*
  68. * if we would be really "pedantic"
  69. * we should pass read_apic_id() here
  70. * but since NOOP suppose APIC ID = 0
  71. * lets save a few cycles
  72. */
  73. return physid_isset(0, phys_cpu_present_map);
  74. }
  75. static u32 noop_apic_read(u32 reg)
  76. {
  77. WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic);
  78. return 0;
  79. }
  80. static void noop_apic_write(u32 reg, u32 v)
  81. {
  82. WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic);
  83. }
  84. #ifdef CONFIG_X86_32
  85. static int noop_x86_32_early_logical_apicid(int cpu)
  86. {
  87. return BAD_APICID;
  88. }
  89. #endif
  90. struct apic apic_noop __ro_after_init = {
  91. .name = "noop",
  92. .probe = noop_probe,
  93. .acpi_madt_oem_check = NULL,
  94. .apic_id_valid = default_apic_id_valid,
  95. .apic_id_registered = noop_apic_id_registered,
  96. .irq_delivery_mode = dest_Fixed,
  97. /* logical delivery broadcast to all CPUs: */
  98. .irq_dest_mode = 1,
  99. .disable_esr = 0,
  100. .dest_logical = APIC_DEST_LOGICAL,
  101. .check_apicid_used = default_check_apicid_used,
  102. .init_apic_ldr = noop_init_apic_ldr,
  103. .ioapic_phys_id_map = default_ioapic_phys_id_map,
  104. .setup_apic_routing = NULL,
  105. .cpu_present_to_apicid = default_cpu_present_to_apicid,
  106. .apicid_to_cpu_present = physid_set_mask_of_physid,
  107. .check_phys_apicid_present = default_check_phys_apicid_present,
  108. .phys_pkg_id = noop_phys_pkg_id,
  109. .get_apic_id = noop_get_apic_id,
  110. .set_apic_id = NULL,
  111. .calc_dest_apicid = apic_flat_calc_apicid,
  112. .send_IPI = noop_send_IPI,
  113. .send_IPI_mask = noop_send_IPI_mask,
  114. .send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself,
  115. .send_IPI_allbutself = noop_send_IPI_allbutself,
  116. .send_IPI_all = noop_send_IPI_all,
  117. .send_IPI_self = noop_send_IPI_self,
  118. .wakeup_secondary_cpu = noop_wakeup_secondary_cpu,
  119. .inquire_remote_apic = NULL,
  120. .read = noop_apic_read,
  121. .write = noop_apic_write,
  122. .eoi_write = noop_apic_write,
  123. .icr_read = noop_apic_icr_read,
  124. .icr_write = noop_apic_icr_write,
  125. .wait_icr_idle = noop_apic_wait_icr_idle,
  126. .safe_wait_icr_idle = noop_safe_apic_wait_icr_idle,
  127. #ifdef CONFIG_X86_32
  128. .x86_32_early_logical_apicid = noop_x86_32_early_logical_apicid,
  129. #endif
  130. };