aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2012-07-15 08:56:46 -0400
committerAvi Kivity <avi@redhat.com>2012-07-16 05:51:23 -0400
commit1551df646dd42122e17401013dba7a509d0f1b0d (patch)
treeb8c10e19edbee20c4c2f1eb99010a58f34e56bd7 /arch
parent64604e09ec3389cfc9668136a9302a3832cf0095 (diff)
apic: add apic_set_eoi_write for PV use
KVM PV EOI optimization overrides eoi_write apic op with its own version. Add an API for this to avoid meddling with core x86 apic driver data structures directly. For KVM use, we don't need any guarantees about when the switch to the new op will take place, so it could in theory use this API after SMP init, but it currently doesn't, and restricting callers to early init makes it clear that it's safe as it won't race with actual APIC driver use. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/apic.h3
-rw-r--r--arch/x86/kernel/apic/apic.c17
2 files changed, 20 insertions, 0 deletions
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index aa5b2eec3602..ff8dff645e80 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -469,6 +469,8 @@ static inline u32 safe_apic_wait_icr_idle(void)
469 return apic->safe_wait_icr_idle(); 469 return apic->safe_wait_icr_idle();
470} 470}
471 471
472extern void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v));
473
472#else /* CONFIG_X86_LOCAL_APIC */ 474#else /* CONFIG_X86_LOCAL_APIC */
473 475
474static inline u32 apic_read(u32 reg) { return 0; } 476static inline u32 apic_read(u32 reg) { return 0; }
@@ -478,6 +480,7 @@ static inline u64 apic_icr_read(void) { return 0; }
478static inline void apic_icr_write(u32 low, u32 high) { } 480static inline void apic_icr_write(u32 low, u32 high) { }
479static inline void apic_wait_icr_idle(void) { } 481static inline void apic_wait_icr_idle(void) { }
480static inline u32 safe_apic_wait_icr_idle(void) { return 0; } 482static inline u32 safe_apic_wait_icr_idle(void) { return 0; }
483static inline void apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v)) {}
481 484
482#endif /* CONFIG_X86_LOCAL_APIC */ 485#endif /* CONFIG_X86_LOCAL_APIC */
483 486
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 39a222e094af..c7520b6184ef 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -2124,6 +2124,23 @@ void default_init_apic_ldr(void)
2124} 2124}
2125 2125
2126/* 2126/*
2127 * Override the generic EOI implementation with an optimized version.
2128 * Only called during early boot when only one CPU is active and with
2129 * interrupts disabled, so we know this does not race with actual APIC driver
2130 * use.
2131 */
2132void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v))
2133{
2134 struct apic **drv;
2135
2136 for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
2137 /* Should happen once for each apic */
2138 WARN_ON((*drv)->eoi_write == eoi_write);
2139 (*drv)->eoi_write = eoi_write;
2140 }
2141}
2142
2143/*
2127 * Power management 2144 * Power management
2128 */ 2145 */
2129#ifdef CONFIG_PM 2146#ifdef CONFIG_PM