xref: /openbmc/linux/arch/x86/kernel/apic/apic_noop.c (revision d92e5e7c)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
29844ab11SCyrill Gorcunov /*
39844ab11SCyrill Gorcunov  * NOOP APIC driver.
49844ab11SCyrill Gorcunov  *
59844ab11SCyrill Gorcunov  * Does almost nothing and should be substituted by a real apic driver via
69844ab11SCyrill Gorcunov  * probe routine.
79844ab11SCyrill Gorcunov  *
89844ab11SCyrill Gorcunov  * Though in case if apic is disabled (for some reason) we try
99844ab11SCyrill Gorcunov  * to not uglify the caller's code and allow to call (some) apic routines
10f88f2b4fSCyrill Gorcunov  * like self-ipi, etc...
119844ab11SCyrill Gorcunov  */
129844ab11SCyrill Gorcunov #include <linux/cpumask.h>
130cd39f46SPeter Zijlstra #include <linux/thread_info.h>
14521b82feSThomas Gleixner 
159844ab11SCyrill Gorcunov #include <asm/apic.h>
169844ab11SCyrill Gorcunov 
174727da2eSThomas Gleixner static void noop_send_IPI(int cpu, int vector) { }
18f88f2b4fSCyrill Gorcunov static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector) { }
19f88f2b4fSCyrill Gorcunov static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) { }
20f88f2b4fSCyrill Gorcunov static void noop_send_IPI_allbutself(int vector) { }
21f88f2b4fSCyrill Gorcunov static void noop_send_IPI_all(int vector) { }
22f88f2b4fSCyrill Gorcunov static void noop_send_IPI_self(int vector) { }
23f88f2b4fSCyrill Gorcunov static void noop_apic_icr_write(u32 low, u32 id) { }
24f88f2b4fSCyrill Gorcunov 
25f88f2b4fSCyrill Gorcunov static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip)
269844ab11SCyrill Gorcunov {
27f88f2b4fSCyrill Gorcunov 	return -1;
289844ab11SCyrill Gorcunov }
299844ab11SCyrill Gorcunov 
30f88f2b4fSCyrill Gorcunov static u64 noop_apic_icr_read(void)
31f88f2b4fSCyrill Gorcunov {
32f88f2b4fSCyrill Gorcunov 	return 0;
33f88f2b4fSCyrill Gorcunov }
34f88f2b4fSCyrill Gorcunov 
35f88f2b4fSCyrill Gorcunov static int noop_phys_pkg_id(int cpuid_apic, int index_msb)
36f88f2b4fSCyrill Gorcunov {
37f88f2b4fSCyrill Gorcunov 	return 0;
38f88f2b4fSCyrill Gorcunov }
39f88f2b4fSCyrill Gorcunov 
40f88f2b4fSCyrill Gorcunov static unsigned int noop_get_apic_id(unsigned long x)
41f88f2b4fSCyrill Gorcunov {
42f88f2b4fSCyrill Gorcunov 	return 0;
43f88f2b4fSCyrill Gorcunov }
449844ab11SCyrill Gorcunov 
459844ab11SCyrill Gorcunov static int noop_probe(void)
469844ab11SCyrill Gorcunov {
47f88f2b4fSCyrill Gorcunov 	/*
48f88f2b4fSCyrill Gorcunov 	 * NOOP apic should not ever be
49f88f2b4fSCyrill Gorcunov 	 * enabled via probe routine
50f88f2b4fSCyrill Gorcunov 	 */
519844ab11SCyrill Gorcunov 	return 0;
529844ab11SCyrill Gorcunov }
539844ab11SCyrill Gorcunov 
549844ab11SCyrill Gorcunov static u32 noop_apic_read(u32 reg)
559844ab11SCyrill Gorcunov {
5649062454SThomas Gleixner 	WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !apic_is_disabled);
579844ab11SCyrill Gorcunov 	return 0;
589844ab11SCyrill Gorcunov }
599844ab11SCyrill Gorcunov 
6049062454SThomas Gleixner static void noop_apic_write(u32 reg, u32 val)
61f88f2b4fSCyrill Gorcunov {
6249062454SThomas Gleixner 	WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !apic_is_disabled);
63f88f2b4fSCyrill Gorcunov }
64f88f2b4fSCyrill Gorcunov 
65404f6aacSKees Cook struct apic apic_noop __ro_after_init = {
669844ab11SCyrill Gorcunov 	.name				= "noop",
679844ab11SCyrill Gorcunov 	.probe				= noop_probe,
689844ab11SCyrill Gorcunov 	.acpi_madt_oem_check		= NULL,
699844ab11SCyrill Gorcunov 
70fa63030eSDaniel J Blueman 	.apic_id_valid			= default_apic_id_valid,
719844ab11SCyrill Gorcunov 
7272161299SThomas Gleixner 	.delivery_mode			= APIC_DELIVERY_MODE_FIXED,
738c44963bSThomas Gleixner 	.dest_mode_logical		= true,
749844ab11SCyrill Gorcunov 
759844ab11SCyrill Gorcunov 	.disable_esr			= 0,
76e57d04e5SThomas Gleixner 
774c59f3e6SDavid Rientjes 	.check_apicid_used		= default_check_apicid_used,
787abc0753SCyrill Gorcunov 	.ioapic_phys_id_map		= default_ioapic_phys_id_map,
799844ab11SCyrill Gorcunov 	.cpu_present_to_apicid		= default_cpu_present_to_apicid,
809844ab11SCyrill Gorcunov 
81f88f2b4fSCyrill Gorcunov 	.phys_pkg_id			= noop_phys_pkg_id,
829844ab11SCyrill Gorcunov 
83*d92e5e7cSThomas Gleixner 	.max_apic_id			= 0xFE,
849844ab11SCyrill Gorcunov 	.get_apic_id			= noop_get_apic_id,
859844ab11SCyrill Gorcunov 	.set_apic_id			= NULL,
869844ab11SCyrill Gorcunov 
879f9e3bb1SThomas Gleixner 	.calc_dest_apicid		= apic_flat_calc_apicid,
889844ab11SCyrill Gorcunov 
894727da2eSThomas Gleixner 	.send_IPI			= noop_send_IPI,
909844ab11SCyrill Gorcunov 	.send_IPI_mask			= noop_send_IPI_mask,
919844ab11SCyrill Gorcunov 	.send_IPI_mask_allbutself	= noop_send_IPI_mask_allbutself,
929844ab11SCyrill Gorcunov 	.send_IPI_allbutself		= noop_send_IPI_allbutself,
939844ab11SCyrill Gorcunov 	.send_IPI_all			= noop_send_IPI_all,
949844ab11SCyrill Gorcunov 	.send_IPI_self			= noop_send_IPI_self,
959844ab11SCyrill Gorcunov 
969844ab11SCyrill Gorcunov 	.wakeup_secondary_cpu		= noop_wakeup_secondary_cpu,
979844ab11SCyrill Gorcunov 
989844ab11SCyrill Gorcunov 	.read				= noop_apic_read,
999844ab11SCyrill Gorcunov 	.write				= noop_apic_write,
1002a43195dSMichael S. Tsirkin 	.eoi_write			= noop_apic_write,
1019844ab11SCyrill Gorcunov 	.icr_read			= noop_apic_icr_read,
1029844ab11SCyrill Gorcunov 	.icr_write			= noop_apic_icr_write,
1039844ab11SCyrill Gorcunov };
104