x86: waits after sending IPIs
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 19 Mar 2010 00:07:00 +0000 (17:07 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 00:35:40 +0000 (17:35 -0700)
Instead of checking before, wait afterwards.  It should provide the same
protection from losing IPIs (since all IPI-making functions adhere to
this), but now the send functions return once the IPI should have made
it to the distant end.  This way, we don't need to wait twice or have a
separate call for an IPI-barrier (like the wmb()s).

kern/arch/i686/apic.h

index aa5d7b2..3752952 100644 (file)
@@ -202,39 +202,39 @@ static inline void lapic_enable(void)
 
 static inline void send_init_ipi(void)
 {
-       lapic_wait_to_send();
        write_mmreg32(LAPIC_IPI_ICR_LOWER, 0x000c4500);
+       lapic_wait_to_send();
 }
 
 static inline void send_startup_ipi(uint8_t vector)
 {
-       lapic_wait_to_send();
        write_mmreg32(LAPIC_IPI_ICR_LOWER, 0x000c4600 | vector);
+       lapic_wait_to_send();
 }
 
 static inline void send_self_ipi(uint8_t vector)
 {
-       lapic_wait_to_send();
        write_mmreg32(LAPIC_IPI_ICR_LOWER, 0x00044000 | vector);
+       lapic_wait_to_send();
 }
 
 static inline void send_broadcast_ipi(uint8_t vector)
 {
-       lapic_wait_to_send();
        write_mmreg32(LAPIC_IPI_ICR_LOWER, 0x00084000 | vector);
+       lapic_wait_to_send();
 }
 
 static inline void send_all_others_ipi(uint8_t vector)
 {
-       lapic_wait_to_send();
        write_mmreg32(LAPIC_IPI_ICR_LOWER, 0x000c4000 | vector);
+       lapic_wait_to_send();
 }
 
 static inline void __send_ipi(uint8_t hw_coreid, uint8_t vector)
 {
-       lapic_wait_to_send();
        write_mmreg32(LAPIC_IPI_ICR_UPPER, hw_coreid << 24);
        write_mmreg32(LAPIC_IPI_ICR_LOWER, 0x00004000 | vector);
+       lapic_wait_to_send();
 }
 
 static inline void send_ipi(uint8_t hw_coreid, uint8_t vector)
@@ -249,9 +249,9 @@ static inline void send_ipi(uint8_t hw_coreid, uint8_t vector)
 
 static inline void send_group_ipi(uint8_t hw_groupid, uint8_t vector)
 {
-       lapic_wait_to_send();
        write_mmreg32(LAPIC_IPI_ICR_UPPER, hw_groupid << 24);
        write_mmreg32(LAPIC_IPI_ICR_LOWER, 0x00004800 | vector);
+       lapic_wait_to_send();
 }
 
 /* To change the LAPIC Base (not recommended):