]> Pileus Git - ~andy/linux/commitdiff
apic: add apic_set_eoi_write for PV use
authorMichael S. Tsirkin <mst@redhat.com>
Sun, 15 Jul 2012 12:56:46 +0000 (15:56 +0300)
committerAvi Kivity <avi@redhat.com>
Mon, 16 Jul 2012 09:51:23 +0000 (12:51 +0300)
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>
arch/x86/include/asm/apic.h
arch/x86/kernel/apic/apic.c

index aa5b2eec3602f70ff8e8410840dafaf339fa0a0c..ff8dff645e80b2fa40b81696520c8d1293449d5d 100644 (file)
@@ -469,6 +469,8 @@ static inline u32 safe_apic_wait_icr_idle(void)
        return apic->safe_wait_icr_idle();
 }
 
+extern void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v));
+
 #else /* CONFIG_X86_LOCAL_APIC */
 
 static inline u32 apic_read(u32 reg) { return 0; }
@@ -478,6 +480,7 @@ static inline u64 apic_icr_read(void) { return 0; }
 static inline void apic_icr_write(u32 low, u32 high) { }
 static inline void apic_wait_icr_idle(void) { }
 static inline u32 safe_apic_wait_icr_idle(void) { return 0; }
+static inline void apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v)) {}
 
 #endif /* CONFIG_X86_LOCAL_APIC */
 
index 39a222e094af0b1ac3c0904a9c977be9b2a95795..c7520b6184efbbe3f09d60cfa95e552d1969da43 100644 (file)
@@ -2123,6 +2123,23 @@ void default_init_apic_ldr(void)
        apic_write(APIC_LDR, val);
 }
 
+/*
+ * Override the generic EOI implementation with an optimized version.
+ * Only called during early boot when only one CPU is active and with
+ * interrupts disabled, so we know this does not race with actual APIC driver
+ * use.
+ */
+void __init apic_set_eoi_write(void (*eoi_write)(u32 reg, u32 v))
+{
+       struct apic **drv;
+
+       for (drv = __apicdrivers; drv < __apicdrivers_end; drv++) {
+               /* Should happen once for each apic */
+               WARN_ON((*drv)->eoi_write == eoi_write);
+               (*drv)->eoi_write = eoi_write;
+       }
+}
+
 /*
  * Power management
  */