Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/60713 )
Change subject: cpu/x86/lapic: Add lapic_send_self_ipi,others() ......................................................................
cpu/x86/lapic: Add lapic_send_self_ipi,others()
This avoids unnecessary passing of APIC ID parameter and allows some minor optimisation for X2APIC mode.
Change-Id: I0b0c8c39ecd13858cffc91cc781bea52decf67c5 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/cpu/x86/lapic/lapic_cpu_stop.c M src/cpu/x86/mp_init.c M src/include/cpu/x86/lapic.h 3 files changed, 15 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/13/60713/1
diff --git a/src/cpu/x86/lapic/lapic_cpu_stop.c b/src/cpu/x86/lapic/lapic_cpu_stop.c index e933ce4..1affe15 100644 --- a/src/cpu/x86/lapic/lapic_cpu_stop.c +++ b/src/cpu/x86/lapic/lapic_cpu_stop.c @@ -55,7 +55,7 @@ printk(BIOS_DEBUG, "CPU %ld going down...\n", id);
/* send an LAPIC INIT to myself */ - lapic_send_ipi(LAPIC_INT_LEVELTRIG | LAPIC_INT_ASSERT | LAPIC_DM_INIT, id); + lapic_send_ipi_self(LAPIC_INT_LEVELTRIG | LAPIC_INT_ASSERT | LAPIC_DM_INIT); wait_for_ipi_completion_without_printk(timeout_100ms);
mdelay(10); @@ -63,7 +63,7 @@ dprintk(BIOS_SPEW, "Deasserting INIT.\n");
/* Deassert the LAPIC INIT */ - lapic_send_ipi(LAPIC_INT_LEVELTRIG | LAPIC_DM_INIT, id); + lapic_send_ipi_self(LAPIC_INT_LEVELTRIG | LAPIC_DM_INIT); wait_for_ipi_completion_without_printk(timeout_100ms);
halt(); diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c index c589747..4f8131c 100644 --- a/src/cpu/x86/mp_init.c +++ b/src/cpu/x86/mp_init.c @@ -423,8 +423,7 @@ printk(BIOS_DEBUG, "done.\n"); }
- lapic_send_ipi(LAPIC_DEST_ALLBUT | LAPIC_INT_ASSERT | LAPIC_DM_STARTUP | sipi_vector, - 0); + lapic_send_ipi_others(LAPIC_INT_ASSERT | LAPIC_DM_STARTUP | sipi_vector); printk(BIOS_DEBUG, "Waiting for SIPI to complete...\n"); if (apic_wait_timeout(10000 /* 10 ms */, 50 /* us */) != CB_SUCCESS) { printk(BIOS_ERR, "timed out.\n"); @@ -464,7 +463,7 @@ }
/* Send INIT IPI to all but self. */ - lapic_send_ipi(LAPIC_DEST_ALLBUT | LAPIC_INT_ASSERT | LAPIC_DM_INIT, 0); + lapic_send_ipi_others(LAPIC_INT_ASSERT | LAPIC_DM_INIT);
if (!CONFIG(X86_INIT_NEED_1_SIPI)) { printk(BIOS_DEBUG, "Waiting for 10ms after sending INIT.\n"); @@ -649,7 +648,7 @@ printk(BIOS_DEBUG, "done.\n"); }
- lapic_send_ipi(LAPIC_INT_ASSERT | LAPIC_DM_SMI, lapicid()); + lapic_send_ipi_self(LAPIC_INT_ASSERT | LAPIC_DM_SMI);
if (lapic_busy()) { if (apic_wait_timeout(1000 /* 1 ms */, 100 /* us */) != CB_SUCCESS) { diff --git a/src/include/cpu/x86/lapic.h b/src/include/cpu/x86/lapic.h index 779799e..c1601d2 100644 --- a/src/include/cpu/x86/lapic.h +++ b/src/include/cpu/x86/lapic.h @@ -115,6 +115,16 @@ xapic_send_ipi(icrlow, SET_LAPIC_DEST_FIELD(apicid)); }
+static __always_inline void lapic_send_ipi_self(uint32_t icrlow) +{ + lapic_send_ipi(LAPIC_DEST_SELF | icrlow, 0); +} + +static __always_inline void lapic_send_ipi_others(uint32_t icrlow) +{ + lapic_send_ipi(LAPIC_DEST_ALLBUT | icrlow, 0); +} + static __always_inline int lapic_busy(void) { if (is_x2apic_mode())