xref: /openbmc/linux/arch/x86/kernel/apic/apic_noop.c (revision a946d8f1)
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_cpu_to_logical_apicid(int cpu)
58f88f2b4fSCyrill Gorcunov {
59f88f2b4fSCyrill Gorcunov 	return 0;
60f88f2b4fSCyrill Gorcunov }
61f88f2b4fSCyrill Gorcunov 
62f88f2b4fSCyrill Gorcunov static int noop_phys_pkg_id(int cpuid_apic, int index_msb)
63f88f2b4fSCyrill Gorcunov {
64f88f2b4fSCyrill Gorcunov 	return 0;
65f88f2b4fSCyrill Gorcunov }
66f88f2b4fSCyrill Gorcunov 
67f88f2b4fSCyrill Gorcunov static unsigned int noop_get_apic_id(unsigned long x)
68f88f2b4fSCyrill Gorcunov {
69f88f2b4fSCyrill Gorcunov 	return 0;
70f88f2b4fSCyrill Gorcunov }
719844ab11SCyrill Gorcunov 
729844ab11SCyrill Gorcunov static int noop_probe(void)
739844ab11SCyrill Gorcunov {
74f88f2b4fSCyrill Gorcunov 	/*
75f88f2b4fSCyrill Gorcunov 	 * NOOP apic should not ever be
76f88f2b4fSCyrill Gorcunov 	 * enabled via probe routine
77f88f2b4fSCyrill Gorcunov 	 */
789844ab11SCyrill Gorcunov 	return 0;
799844ab11SCyrill Gorcunov }
809844ab11SCyrill Gorcunov 
819844ab11SCyrill Gorcunov static int noop_apic_id_registered(void)
829844ab11SCyrill Gorcunov {
83f88f2b4fSCyrill Gorcunov 	/*
84f88f2b4fSCyrill Gorcunov 	 * if we would be really "pedantic"
85f88f2b4fSCyrill Gorcunov 	 * we should pass read_apic_id() here
86f88f2b4fSCyrill Gorcunov 	 * but since NOOP suppose APIC ID = 0
87f88f2b4fSCyrill Gorcunov 	 * lets save a few cycles
88f88f2b4fSCyrill Gorcunov 	 */
89f88f2b4fSCyrill Gorcunov 	return physid_isset(0, phys_cpu_present_map);
909844ab11SCyrill Gorcunov }
919844ab11SCyrill Gorcunov 
929844ab11SCyrill Gorcunov static const struct cpumask *noop_target_cpus(void)
939844ab11SCyrill Gorcunov {
949844ab11SCyrill Gorcunov 	/* only BSP here */
959844ab11SCyrill Gorcunov 	return cpumask_of(0);
969844ab11SCyrill Gorcunov }
979844ab11SCyrill Gorcunov 
987abc0753SCyrill Gorcunov static unsigned long noop_check_apicid_used(physid_mask_t *map, int apicid)
999844ab11SCyrill Gorcunov {
1007abc0753SCyrill Gorcunov 	return physid_isset(apicid, *map);
1019844ab11SCyrill Gorcunov }
1029844ab11SCyrill Gorcunov 
1039844ab11SCyrill Gorcunov static unsigned long noop_check_apicid_present(int bit)
1049844ab11SCyrill Gorcunov {
1059844ab11SCyrill Gorcunov 	return physid_isset(bit, phys_cpu_present_map);
1069844ab11SCyrill Gorcunov }
1079844ab11SCyrill Gorcunov 
1089844ab11SCyrill Gorcunov static void noop_vector_allocation_domain(int cpu, struct cpumask *retmask)
1099844ab11SCyrill Gorcunov {
1109844ab11SCyrill Gorcunov 	if (cpu != 0)
1119844ab11SCyrill Gorcunov 		pr_warning("APIC: Vector allocated for non-BSP cpu\n");
1129844ab11SCyrill Gorcunov 	cpumask_clear(retmask);
1139844ab11SCyrill Gorcunov 	cpumask_set_cpu(cpu, retmask);
1149844ab11SCyrill Gorcunov }
1159844ab11SCyrill Gorcunov 
1169844ab11SCyrill Gorcunov int noop_apicid_to_node(int logical_apicid)
1179844ab11SCyrill Gorcunov {
1189844ab11SCyrill Gorcunov 	/* we're always on node 0 */
1199844ab11SCyrill Gorcunov 	return 0;
1209844ab11SCyrill Gorcunov }
1219844ab11SCyrill Gorcunov 
1229844ab11SCyrill Gorcunov static u32 noop_apic_read(u32 reg)
1239844ab11SCyrill Gorcunov {
1249844ab11SCyrill Gorcunov 	WARN_ON_ONCE((cpu_has_apic && !disable_apic));
1259844ab11SCyrill Gorcunov 	return 0;
1269844ab11SCyrill Gorcunov }
1279844ab11SCyrill Gorcunov 
128f88f2b4fSCyrill Gorcunov static void noop_apic_write(u32 reg, u32 v)
129f88f2b4fSCyrill Gorcunov {
130a946d8f1SThomas Gleixner 	WARN_ON_ONCE(cpu_has_apic && !disable_apic);
131f88f2b4fSCyrill Gorcunov }
132f88f2b4fSCyrill Gorcunov 
1339844ab11SCyrill Gorcunov struct apic apic_noop = {
1349844ab11SCyrill Gorcunov 	.name				= "noop",
1359844ab11SCyrill Gorcunov 	.probe				= noop_probe,
1369844ab11SCyrill Gorcunov 	.acpi_madt_oem_check		= NULL,
1379844ab11SCyrill Gorcunov 
1389844ab11SCyrill Gorcunov 	.apic_id_registered		= noop_apic_id_registered,
1399844ab11SCyrill Gorcunov 
1409844ab11SCyrill Gorcunov 	.irq_delivery_mode		= dest_LowestPrio,
1419844ab11SCyrill Gorcunov 	/* logical delivery broadcast to all CPUs: */
1429844ab11SCyrill Gorcunov 	.irq_dest_mode			= 1,
1439844ab11SCyrill Gorcunov 
1449844ab11SCyrill Gorcunov 	.target_cpus			= noop_target_cpus,
1459844ab11SCyrill Gorcunov 	.disable_esr			= 0,
1469844ab11SCyrill Gorcunov 	.dest_logical			= APIC_DEST_LOGICAL,
1479844ab11SCyrill Gorcunov 	.check_apicid_used		= noop_check_apicid_used,
1489844ab11SCyrill Gorcunov 	.check_apicid_present		= noop_check_apicid_present,
1499844ab11SCyrill Gorcunov 
1509844ab11SCyrill Gorcunov 	.vector_allocation_domain	= noop_vector_allocation_domain,
1519844ab11SCyrill Gorcunov 	.init_apic_ldr			= noop_init_apic_ldr,
1529844ab11SCyrill Gorcunov 
1537abc0753SCyrill Gorcunov 	.ioapic_phys_id_map		= default_ioapic_phys_id_map,
1549844ab11SCyrill Gorcunov 	.setup_apic_routing		= NULL,
1559844ab11SCyrill Gorcunov 	.multi_timer_check		= NULL,
1569844ab11SCyrill Gorcunov 	.apicid_to_node			= noop_apicid_to_node,
1579844ab11SCyrill Gorcunov 
1589844ab11SCyrill Gorcunov 	.cpu_to_logical_apicid		= noop_cpu_to_logical_apicid,
1599844ab11SCyrill Gorcunov 	.cpu_present_to_apicid		= default_cpu_present_to_apicid,
1607abc0753SCyrill Gorcunov 	.apicid_to_cpu_present		= physid_set_mask_of_physid,
1619844ab11SCyrill Gorcunov 
1629844ab11SCyrill Gorcunov 	.setup_portio_remap		= NULL,
1639844ab11SCyrill Gorcunov 	.check_phys_apicid_present	= default_check_phys_apicid_present,
1649844ab11SCyrill Gorcunov 	.enable_apic_mode		= NULL,
1659844ab11SCyrill Gorcunov 
166f88f2b4fSCyrill Gorcunov 	.phys_pkg_id			= noop_phys_pkg_id,
1679844ab11SCyrill Gorcunov 
1689844ab11SCyrill Gorcunov 	.mps_oem_check			= NULL,
1699844ab11SCyrill Gorcunov 
1709844ab11SCyrill Gorcunov 	.get_apic_id			= noop_get_apic_id,
1719844ab11SCyrill Gorcunov 	.set_apic_id			= NULL,
1729844ab11SCyrill Gorcunov 	.apic_id_mask			= 0x0F << 24,
1739844ab11SCyrill Gorcunov 
1749844ab11SCyrill Gorcunov 	.cpu_mask_to_apicid		= default_cpu_mask_to_apicid,
1759844ab11SCyrill Gorcunov 	.cpu_mask_to_apicid_and		= default_cpu_mask_to_apicid_and,
1769844ab11SCyrill Gorcunov 
1779844ab11SCyrill Gorcunov 	.send_IPI_mask			= noop_send_IPI_mask,
1789844ab11SCyrill Gorcunov 	.send_IPI_mask_allbutself	= noop_send_IPI_mask_allbutself,
1799844ab11SCyrill Gorcunov 	.send_IPI_allbutself		= noop_send_IPI_allbutself,
1809844ab11SCyrill Gorcunov 	.send_IPI_all			= noop_send_IPI_all,
1819844ab11SCyrill Gorcunov 	.send_IPI_self			= noop_send_IPI_self,
1829844ab11SCyrill Gorcunov 
1839844ab11SCyrill Gorcunov 	.wakeup_secondary_cpu		= noop_wakeup_secondary_cpu,
1849844ab11SCyrill Gorcunov 
1859844ab11SCyrill Gorcunov 	/* should be safe */
1869844ab11SCyrill Gorcunov 	.trampoline_phys_low		= DEFAULT_TRAMPOLINE_PHYS_LOW,
1879844ab11SCyrill Gorcunov 	.trampoline_phys_high		= DEFAULT_TRAMPOLINE_PHYS_HIGH,
1889844ab11SCyrill Gorcunov 
1899844ab11SCyrill Gorcunov 	.wait_for_init_deassert		= NULL,
1909844ab11SCyrill Gorcunov 
1919844ab11SCyrill Gorcunov 	.smp_callin_clear_local_apic	= NULL,
1929844ab11SCyrill Gorcunov 	.inquire_remote_apic		= NULL,
1939844ab11SCyrill Gorcunov 
1949844ab11SCyrill Gorcunov 	.read				= noop_apic_read,
1959844ab11SCyrill Gorcunov 	.write				= noop_apic_write,
1969844ab11SCyrill Gorcunov 	.icr_read			= noop_apic_icr_read,
1979844ab11SCyrill Gorcunov 	.icr_write			= noop_apic_icr_write,
1989844ab11SCyrill Gorcunov 	.wait_icr_idle			= noop_apic_wait_icr_idle,
1999844ab11SCyrill Gorcunov 	.safe_wait_icr_idle		= noop_safe_apic_wait_icr_idle,
2009844ab11SCyrill Gorcunov };
201