xref: /openbmc/linux/arch/x86/kernel/apic/apic_noop.c (revision 66441bd3)
19844ab11SCyrill Gorcunov /*
29844ab11SCyrill Gorcunov  * NOOP APIC driver.
39844ab11SCyrill Gorcunov  *
49844ab11SCyrill Gorcunov  * Does almost nothing and should be substituted by a real apic driver via
59844ab11SCyrill Gorcunov  * probe routine.
69844ab11SCyrill Gorcunov  *
79844ab11SCyrill Gorcunov  * Though in case if apic is disabled (for some reason) we try
89844ab11SCyrill Gorcunov  * to not uglify the caller's code and allow to call (some) apic routines
9f88f2b4fSCyrill Gorcunov  * like self-ipi, etc...
109844ab11SCyrill Gorcunov  */
119844ab11SCyrill Gorcunov 
129844ab11SCyrill Gorcunov #include <linux/threads.h>
139844ab11SCyrill Gorcunov #include <linux/cpumask.h>
149844ab11SCyrill Gorcunov #include <linux/string.h>
159844ab11SCyrill Gorcunov #include <linux/kernel.h>
169844ab11SCyrill Gorcunov #include <linux/ctype.h>
179844ab11SCyrill Gorcunov #include <linux/errno.h>
189844ab11SCyrill Gorcunov #include <asm/fixmap.h>
199844ab11SCyrill Gorcunov #include <asm/mpspec.h>
209844ab11SCyrill Gorcunov #include <asm/apicdef.h>
219844ab11SCyrill Gorcunov #include <asm/apic.h>
229844ab11SCyrill Gorcunov #include <asm/setup.h>
239844ab11SCyrill Gorcunov 
249844ab11SCyrill Gorcunov #include <linux/smp.h>
259844ab11SCyrill Gorcunov #include <asm/ipi.h>
269844ab11SCyrill Gorcunov 
279844ab11SCyrill Gorcunov #include <linux/interrupt.h>
289844ab11SCyrill Gorcunov #include <asm/acpi.h>
2966441bd3SIngo Molnar #include <asm/e820/api.h>
309844ab11SCyrill Gorcunov 
31f88f2b4fSCyrill Gorcunov static void noop_init_apic_ldr(void) { }
324727da2eSThomas Gleixner static void noop_send_IPI(int cpu, int vector) { }
33f88f2b4fSCyrill Gorcunov static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector) { }
34f88f2b4fSCyrill Gorcunov static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) { }
35f88f2b4fSCyrill Gorcunov static void noop_send_IPI_allbutself(int vector) { }
36f88f2b4fSCyrill Gorcunov static void noop_send_IPI_all(int vector) { }
37f88f2b4fSCyrill Gorcunov static void noop_send_IPI_self(int vector) { }
38f88f2b4fSCyrill Gorcunov static void noop_apic_wait_icr_idle(void) { }
39f88f2b4fSCyrill Gorcunov static void noop_apic_icr_write(u32 low, u32 id) { }
40f88f2b4fSCyrill Gorcunov 
41f88f2b4fSCyrill Gorcunov static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip)
429844ab11SCyrill Gorcunov {
43f88f2b4fSCyrill Gorcunov 	return -1;
449844ab11SCyrill Gorcunov }
459844ab11SCyrill Gorcunov 
46f88f2b4fSCyrill Gorcunov static u32 noop_safe_apic_wait_icr_idle(void)
47f88f2b4fSCyrill Gorcunov {
48f88f2b4fSCyrill Gorcunov 	return 0;
49f88f2b4fSCyrill Gorcunov }
509844ab11SCyrill Gorcunov 
51f88f2b4fSCyrill Gorcunov static u64 noop_apic_icr_read(void)
52f88f2b4fSCyrill Gorcunov {
53f88f2b4fSCyrill Gorcunov 	return 0;
54f88f2b4fSCyrill Gorcunov }
55f88f2b4fSCyrill Gorcunov 
56f88f2b4fSCyrill Gorcunov static int noop_phys_pkg_id(int cpuid_apic, int index_msb)
57f88f2b4fSCyrill Gorcunov {
58f88f2b4fSCyrill Gorcunov 	return 0;
59f88f2b4fSCyrill Gorcunov }
60f88f2b4fSCyrill Gorcunov 
61f88f2b4fSCyrill Gorcunov static unsigned int noop_get_apic_id(unsigned long x)
62f88f2b4fSCyrill Gorcunov {
63f88f2b4fSCyrill Gorcunov 	return 0;
64f88f2b4fSCyrill Gorcunov }
659844ab11SCyrill Gorcunov 
669844ab11SCyrill Gorcunov static int noop_probe(void)
679844ab11SCyrill Gorcunov {
68f88f2b4fSCyrill Gorcunov 	/*
69f88f2b4fSCyrill Gorcunov 	 * NOOP apic should not ever be
70f88f2b4fSCyrill Gorcunov 	 * enabled via probe routine
71f88f2b4fSCyrill Gorcunov 	 */
729844ab11SCyrill Gorcunov 	return 0;
739844ab11SCyrill Gorcunov }
749844ab11SCyrill Gorcunov 
759844ab11SCyrill Gorcunov static int noop_apic_id_registered(void)
769844ab11SCyrill Gorcunov {
77f88f2b4fSCyrill Gorcunov 	/*
78f88f2b4fSCyrill Gorcunov 	 * if we would be really "pedantic"
79f88f2b4fSCyrill Gorcunov 	 * we should pass read_apic_id() here
80f88f2b4fSCyrill Gorcunov 	 * but since NOOP suppose APIC ID = 0
81f88f2b4fSCyrill Gorcunov 	 * lets save a few cycles
82f88f2b4fSCyrill Gorcunov 	 */
83f88f2b4fSCyrill Gorcunov 	return physid_isset(0, phys_cpu_present_map);
849844ab11SCyrill Gorcunov }
859844ab11SCyrill Gorcunov 
869844ab11SCyrill Gorcunov static const struct cpumask *noop_target_cpus(void)
879844ab11SCyrill Gorcunov {
889844ab11SCyrill Gorcunov 	/* only BSP here */
899844ab11SCyrill Gorcunov 	return cpumask_of(0);
909844ab11SCyrill Gorcunov }
919844ab11SCyrill Gorcunov 
921ac322d0SSuresh Siddha static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask,
931ac322d0SSuresh Siddha 					  const struct cpumask *mask)
949844ab11SCyrill Gorcunov {
959844ab11SCyrill Gorcunov 	if (cpu != 0)
969844ab11SCyrill Gorcunov 		pr_warning("APIC: Vector allocated for non-BSP cpu\n");
979d8e1066SAlexander Gordeev 	cpumask_copy(retmask, cpumask_of(cpu));
989844ab11SCyrill Gorcunov }
999844ab11SCyrill Gorcunov 
1009844ab11SCyrill Gorcunov static u32 noop_apic_read(u32 reg)
1019844ab11SCyrill Gorcunov {
10293984fbdSBorislav Petkov 	WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic);
1039844ab11SCyrill Gorcunov 	return 0;
1049844ab11SCyrill Gorcunov }
1059844ab11SCyrill Gorcunov 
106f88f2b4fSCyrill Gorcunov static void noop_apic_write(u32 reg, u32 v)
107f88f2b4fSCyrill Gorcunov {
10893984fbdSBorislav Petkov 	WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic);
109f88f2b4fSCyrill Gorcunov }
110f88f2b4fSCyrill Gorcunov 
111404f6aacSKees Cook struct apic apic_noop __ro_after_init = {
1129844ab11SCyrill Gorcunov 	.name				= "noop",
1139844ab11SCyrill Gorcunov 	.probe				= noop_probe,
1149844ab11SCyrill Gorcunov 	.acpi_madt_oem_check		= NULL,
1159844ab11SCyrill Gorcunov 
116fa63030eSDaniel J Blueman 	.apic_id_valid			= default_apic_id_valid,
1179844ab11SCyrill Gorcunov 	.apic_id_registered		= noop_apic_id_registered,
1189844ab11SCyrill Gorcunov 
1199844ab11SCyrill Gorcunov 	.irq_delivery_mode		= dest_LowestPrio,
1209844ab11SCyrill Gorcunov 	/* logical delivery broadcast to all CPUs: */
1219844ab11SCyrill Gorcunov 	.irq_dest_mode			= 1,
1229844ab11SCyrill Gorcunov 
1239844ab11SCyrill Gorcunov 	.target_cpus			= noop_target_cpus,
1249844ab11SCyrill Gorcunov 	.disable_esr			= 0,
1259844ab11SCyrill Gorcunov 	.dest_logical			= APIC_DEST_LOGICAL,
1264c59f3e6SDavid Rientjes 	.check_apicid_used		= default_check_apicid_used,
1279844ab11SCyrill Gorcunov 
1289844ab11SCyrill Gorcunov 	.vector_allocation_domain	= noop_vector_allocation_domain,
1299844ab11SCyrill Gorcunov 	.init_apic_ldr			= noop_init_apic_ldr,
1309844ab11SCyrill Gorcunov 
1317abc0753SCyrill Gorcunov 	.ioapic_phys_id_map		= default_ioapic_phys_id_map,
1329844ab11SCyrill Gorcunov 	.setup_apic_routing		= NULL,
1339844ab11SCyrill Gorcunov 
1349844ab11SCyrill Gorcunov 	.cpu_present_to_apicid		= default_cpu_present_to_apicid,
1357abc0753SCyrill Gorcunov 	.apicid_to_cpu_present		= physid_set_mask_of_physid,
1369844ab11SCyrill Gorcunov 
1379844ab11SCyrill Gorcunov 	.check_phys_apicid_present	= default_check_phys_apicid_present,
1389844ab11SCyrill Gorcunov 
139f88f2b4fSCyrill Gorcunov 	.phys_pkg_id			= noop_phys_pkg_id,
1409844ab11SCyrill Gorcunov 
1419844ab11SCyrill Gorcunov 	.get_apic_id			= noop_get_apic_id,
1429844ab11SCyrill Gorcunov 	.set_apic_id			= NULL,
1439844ab11SCyrill Gorcunov 
1446398268dSAlexander Gordeev 	.cpu_mask_to_apicid_and		= flat_cpu_mask_to_apicid_and,
1459844ab11SCyrill Gorcunov 
1464727da2eSThomas Gleixner 	.send_IPI			= noop_send_IPI,
1479844ab11SCyrill Gorcunov 	.send_IPI_mask			= noop_send_IPI_mask,
1489844ab11SCyrill Gorcunov 	.send_IPI_mask_allbutself	= noop_send_IPI_mask_allbutself,
1499844ab11SCyrill Gorcunov 	.send_IPI_allbutself		= noop_send_IPI_allbutself,
1509844ab11SCyrill Gorcunov 	.send_IPI_all			= noop_send_IPI_all,
1519844ab11SCyrill Gorcunov 	.send_IPI_self			= noop_send_IPI_self,
1529844ab11SCyrill Gorcunov 
1539844ab11SCyrill Gorcunov 	.wakeup_secondary_cpu		= noop_wakeup_secondary_cpu,
1549844ab11SCyrill Gorcunov 
1559844ab11SCyrill Gorcunov 	.inquire_remote_apic		= NULL,
1569844ab11SCyrill Gorcunov 
1579844ab11SCyrill Gorcunov 	.read				= noop_apic_read,
1589844ab11SCyrill Gorcunov 	.write				= noop_apic_write,
1592a43195dSMichael S. Tsirkin 	.eoi_write			= noop_apic_write,
1609844ab11SCyrill Gorcunov 	.icr_read			= noop_apic_icr_read,
1619844ab11SCyrill Gorcunov 	.icr_write			= noop_apic_icr_write,
1629844ab11SCyrill Gorcunov 	.wait_icr_idle			= noop_apic_wait_icr_idle,
1639844ab11SCyrill Gorcunov 	.safe_wait_icr_idle		= noop_safe_apic_wait_icr_idle,
164acb8bc09STejun Heo 
165acb8bc09STejun Heo #ifdef CONFIG_X86_32
166acb8bc09STejun Heo 	.x86_32_early_logical_apicid	= noop_x86_32_early_logical_apicid,
167acb8bc09STejun Heo #endif
1689844ab11SCyrill Gorcunov };
169