xref: /openbmc/linux/arch/x86/kernel/apic/apic_noop.c (revision 2a43195d)
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/module.h>
159844ab11SCyrill Gorcunov #include <linux/string.h>
169844ab11SCyrill Gorcunov #include <linux/kernel.h>
179844ab11SCyrill Gorcunov #include <linux/ctype.h>
189844ab11SCyrill Gorcunov #include <linux/init.h>
199844ab11SCyrill Gorcunov #include <linux/errno.h>
209844ab11SCyrill Gorcunov #include <asm/fixmap.h>
219844ab11SCyrill Gorcunov #include <asm/mpspec.h>
229844ab11SCyrill Gorcunov #include <asm/apicdef.h>
239844ab11SCyrill Gorcunov #include <asm/apic.h>
249844ab11SCyrill Gorcunov #include <asm/setup.h>
259844ab11SCyrill Gorcunov 
269844ab11SCyrill Gorcunov #include <linux/smp.h>
279844ab11SCyrill Gorcunov #include <asm/ipi.h>
289844ab11SCyrill Gorcunov 
299844ab11SCyrill Gorcunov #include <linux/interrupt.h>
309844ab11SCyrill Gorcunov #include <asm/acpi.h>
319844ab11SCyrill Gorcunov #include <asm/e820.h>
329844ab11SCyrill Gorcunov 
33f88f2b4fSCyrill Gorcunov static void noop_init_apic_ldr(void) { }
34f88f2b4fSCyrill Gorcunov static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector) { }
35f88f2b4fSCyrill Gorcunov static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) { }
36f88f2b4fSCyrill Gorcunov static void noop_send_IPI_allbutself(int vector) { }
37f88f2b4fSCyrill Gorcunov static void noop_send_IPI_all(int vector) { }
38f88f2b4fSCyrill Gorcunov static void noop_send_IPI_self(int vector) { }
39f88f2b4fSCyrill Gorcunov static void noop_apic_wait_icr_idle(void) { }
40f88f2b4fSCyrill Gorcunov static void noop_apic_icr_write(u32 low, u32 id) { }
41f88f2b4fSCyrill Gorcunov 
42f88f2b4fSCyrill Gorcunov static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip)
439844ab11SCyrill Gorcunov {
44f88f2b4fSCyrill Gorcunov 	return -1;
459844ab11SCyrill Gorcunov }
469844ab11SCyrill Gorcunov 
47f88f2b4fSCyrill Gorcunov static u32 noop_safe_apic_wait_icr_idle(void)
48f88f2b4fSCyrill Gorcunov {
49f88f2b4fSCyrill Gorcunov 	return 0;
50f88f2b4fSCyrill Gorcunov }
519844ab11SCyrill Gorcunov 
52f88f2b4fSCyrill Gorcunov static u64 noop_apic_icr_read(void)
53f88f2b4fSCyrill Gorcunov {
54f88f2b4fSCyrill Gorcunov 	return 0;
55f88f2b4fSCyrill Gorcunov }
56f88f2b4fSCyrill Gorcunov 
57f88f2b4fSCyrill Gorcunov static int noop_phys_pkg_id(int cpuid_apic, int index_msb)
58f88f2b4fSCyrill Gorcunov {
59f88f2b4fSCyrill Gorcunov 	return 0;
60f88f2b4fSCyrill Gorcunov }
61f88f2b4fSCyrill Gorcunov 
62f88f2b4fSCyrill Gorcunov static unsigned int noop_get_apic_id(unsigned long x)
63f88f2b4fSCyrill Gorcunov {
64f88f2b4fSCyrill Gorcunov 	return 0;
65f88f2b4fSCyrill Gorcunov }
669844ab11SCyrill Gorcunov 
679844ab11SCyrill Gorcunov static int noop_probe(void)
689844ab11SCyrill Gorcunov {
69f88f2b4fSCyrill Gorcunov 	/*
70f88f2b4fSCyrill Gorcunov 	 * NOOP apic should not ever be
71f88f2b4fSCyrill Gorcunov 	 * enabled via probe routine
72f88f2b4fSCyrill Gorcunov 	 */
739844ab11SCyrill Gorcunov 	return 0;
749844ab11SCyrill Gorcunov }
759844ab11SCyrill Gorcunov 
769844ab11SCyrill Gorcunov static int noop_apic_id_registered(void)
779844ab11SCyrill Gorcunov {
78f88f2b4fSCyrill Gorcunov 	/*
79f88f2b4fSCyrill Gorcunov 	 * if we would be really "pedantic"
80f88f2b4fSCyrill Gorcunov 	 * we should pass read_apic_id() here
81f88f2b4fSCyrill Gorcunov 	 * but since NOOP suppose APIC ID = 0
82f88f2b4fSCyrill Gorcunov 	 * lets save a few cycles
83f88f2b4fSCyrill Gorcunov 	 */
84f88f2b4fSCyrill Gorcunov 	return physid_isset(0, phys_cpu_present_map);
859844ab11SCyrill Gorcunov }
869844ab11SCyrill Gorcunov 
879844ab11SCyrill Gorcunov static const struct cpumask *noop_target_cpus(void)
889844ab11SCyrill Gorcunov {
899844ab11SCyrill Gorcunov 	/* only BSP here */
909844ab11SCyrill Gorcunov 	return cpumask_of(0);
919844ab11SCyrill Gorcunov }
929844ab11SCyrill Gorcunov 
937abc0753SCyrill Gorcunov static unsigned long noop_check_apicid_used(physid_mask_t *map, int apicid)
949844ab11SCyrill Gorcunov {
957abc0753SCyrill Gorcunov 	return physid_isset(apicid, *map);
969844ab11SCyrill Gorcunov }
979844ab11SCyrill Gorcunov 
989844ab11SCyrill Gorcunov static unsigned long noop_check_apicid_present(int bit)
999844ab11SCyrill Gorcunov {
1009844ab11SCyrill Gorcunov 	return physid_isset(bit, phys_cpu_present_map);
1019844ab11SCyrill Gorcunov }
1029844ab11SCyrill Gorcunov 
1039844ab11SCyrill Gorcunov static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask)
1049844ab11SCyrill Gorcunov {
1059844ab11SCyrill Gorcunov 	if (cpu != 0)
1069844ab11SCyrill Gorcunov 		pr_warning("APIC: Vector allocated for non-BSP cpu\n");
1079844ab11SCyrill Gorcunov 	cpumask_clear(retmask);
1089844ab11SCyrill Gorcunov 	cpumask_set_cpu(cpu, retmask);
1099844ab11SCyrill Gorcunov }
1109844ab11SCyrill Gorcunov 
1119844ab11SCyrill Gorcunov static u32 noop_apic_read(u32 reg)
1129844ab11SCyrill Gorcunov {
1139844ab11SCyrill Gorcunov 	WARN_ON_ONCE((cpu_has_apic && !disable_apic));
1149844ab11SCyrill Gorcunov 	return 0;
1159844ab11SCyrill Gorcunov }
1169844ab11SCyrill Gorcunov 
117f88f2b4fSCyrill Gorcunov static void noop_apic_write(u32 reg, u32 v)
118f88f2b4fSCyrill Gorcunov {
119a946d8f1SThomas Gleixner 	WARN_ON_ONCE(cpu_has_apic && !disable_apic);
120f88f2b4fSCyrill Gorcunov }
121f88f2b4fSCyrill Gorcunov 
1229844ab11SCyrill Gorcunov struct apic apic_noop = {
1239844ab11SCyrill Gorcunov 	.name				= "noop",
1249844ab11SCyrill Gorcunov 	.probe				= noop_probe,
1259844ab11SCyrill Gorcunov 	.acpi_madt_oem_check		= NULL,
1269844ab11SCyrill Gorcunov 
127fa63030eSDaniel J Blueman 	.apic_id_valid			= default_apic_id_valid,
1289844ab11SCyrill Gorcunov 	.apic_id_registered		= noop_apic_id_registered,
1299844ab11SCyrill Gorcunov 
1309844ab11SCyrill Gorcunov 	.irq_delivery_mode		= dest_LowestPrio,
1319844ab11SCyrill Gorcunov 	/* logical delivery broadcast to all CPUs: */
1329844ab11SCyrill Gorcunov 	.irq_dest_mode			= 1,
1339844ab11SCyrill Gorcunov 
1349844ab11SCyrill Gorcunov 	.target_cpus			= noop_target_cpus,
1359844ab11SCyrill Gorcunov 	.disable_esr			= 0,
1369844ab11SCyrill Gorcunov 	.dest_logical			= APIC_DEST_LOGICAL,
1379844ab11SCyrill Gorcunov 	.check_apicid_used		= noop_check_apicid_used,
1389844ab11SCyrill Gorcunov 	.check_apicid_present		= noop_check_apicid_present,
1399844ab11SCyrill Gorcunov 
1409844ab11SCyrill Gorcunov 	.vector_allocation_domain	= noop_vector_allocation_domain,
1419844ab11SCyrill Gorcunov 	.init_apic_ldr			= noop_init_apic_ldr,
1429844ab11SCyrill Gorcunov 
1437abc0753SCyrill Gorcunov 	.ioapic_phys_id_map		= default_ioapic_phys_id_map,
1449844ab11SCyrill Gorcunov 	.setup_apic_routing		= NULL,
1459844ab11SCyrill Gorcunov 	.multi_timer_check		= NULL,
1469844ab11SCyrill Gorcunov 
1479844ab11SCyrill Gorcunov 	.cpu_present_to_apicid		= default_cpu_present_to_apicid,
1487abc0753SCyrill Gorcunov 	.apicid_to_cpu_present		= physid_set_mask_of_physid,
1499844ab11SCyrill Gorcunov 
1509844ab11SCyrill Gorcunov 	.setup_portio_remap		= NULL,
1519844ab11SCyrill Gorcunov 	.check_phys_apicid_present	= default_check_phys_apicid_present,
1529844ab11SCyrill Gorcunov 	.enable_apic_mode		= NULL,
1539844ab11SCyrill Gorcunov 
154f88f2b4fSCyrill Gorcunov 	.phys_pkg_id			= noop_phys_pkg_id,
1559844ab11SCyrill Gorcunov 
1569844ab11SCyrill Gorcunov 	.mps_oem_check			= NULL,
1579844ab11SCyrill Gorcunov 
1589844ab11SCyrill Gorcunov 	.get_apic_id			= noop_get_apic_id,
1599844ab11SCyrill Gorcunov 	.set_apic_id			= NULL,
1609844ab11SCyrill Gorcunov 	.apic_id_mask			= 0x0F << 24,
1619844ab11SCyrill Gorcunov 
1629844ab11SCyrill Gorcunov 	.cpu_mask_to_apicid		= default_cpu_mask_to_apicid,
1639844ab11SCyrill Gorcunov 	.cpu_mask_to_apicid_and		= default_cpu_mask_to_apicid_and,
1649844ab11SCyrill Gorcunov 
1659844ab11SCyrill Gorcunov 	.send_IPI_mask			= noop_send_IPI_mask,
1669844ab11SCyrill Gorcunov 	.send_IPI_mask_allbutself	= noop_send_IPI_mask_allbutself,
1679844ab11SCyrill Gorcunov 	.send_IPI_allbutself		= noop_send_IPI_allbutself,
1689844ab11SCyrill Gorcunov 	.send_IPI_all			= noop_send_IPI_all,
1699844ab11SCyrill Gorcunov 	.send_IPI_self			= noop_send_IPI_self,
1709844ab11SCyrill Gorcunov 
1719844ab11SCyrill Gorcunov 	.wakeup_secondary_cpu		= noop_wakeup_secondary_cpu,
1729844ab11SCyrill Gorcunov 
1739844ab11SCyrill Gorcunov 	/* should be safe */
1749844ab11SCyrill Gorcunov 	.trampoline_phys_low		= DEFAULT_TRAMPOLINE_PHYS_LOW,
1759844ab11SCyrill Gorcunov 	.trampoline_phys_high		= DEFAULT_TRAMPOLINE_PHYS_HIGH,
1769844ab11SCyrill Gorcunov 
1779844ab11SCyrill Gorcunov 	.wait_for_init_deassert		= NULL,
1789844ab11SCyrill Gorcunov 
1799844ab11SCyrill Gorcunov 	.smp_callin_clear_local_apic	= NULL,
1809844ab11SCyrill Gorcunov 	.inquire_remote_apic		= NULL,
1819844ab11SCyrill Gorcunov 
1829844ab11SCyrill Gorcunov 	.read				= noop_apic_read,
1839844ab11SCyrill Gorcunov 	.write				= noop_apic_write,
1842a43195dSMichael S. Tsirkin 	.eoi_write			= noop_apic_write,
1859844ab11SCyrill Gorcunov 	.icr_read			= noop_apic_icr_read,
1869844ab11SCyrill Gorcunov 	.icr_write			= noop_apic_icr_write,
1879844ab11SCyrill Gorcunov 	.wait_icr_idle			= noop_apic_wait_icr_idle,
1889844ab11SCyrill Gorcunov 	.safe_wait_icr_idle		= noop_safe_apic_wait_icr_idle,
189acb8bc09STejun Heo 
190acb8bc09STejun Heo #ifdef CONFIG_X86_32
191acb8bc09STejun Heo 	.x86_32_early_logical_apicid	= noop_x86_32_early_logical_apicid,
192acb8bc09STejun Heo #endif
1939844ab11SCyrill Gorcunov };
194