cpu/x86/lapic: Add lapic_send_ipi_self,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>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/60713
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
This commit is contained in:
Kyösti Mälkki
2021-10-15 17:14:20 +03:00
parent 0c1158b15d
commit 710bdc42a5
3 changed files with 16 additions and 6 deletions

View File

@@ -55,7 +55,7 @@ void stop_this_cpu(void)
printk(BIOS_DEBUG, "CPU %ld going down...\n", id); printk(BIOS_DEBUG, "CPU %ld going down...\n", id);
/* send an LAPIC INIT to myself */ /* 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); wait_for_ipi_completion_without_printk(timeout_100ms);
mdelay(10); mdelay(10);
@@ -63,7 +63,7 @@ void stop_this_cpu(void)
dprintk(BIOS_SPEW, "Deasserting INIT.\n"); dprintk(BIOS_SPEW, "Deasserting INIT.\n");
/* Deassert the LAPIC INIT */ /* 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); wait_for_ipi_completion_without_printk(timeout_100ms);
halt(); halt();

View File

@@ -423,8 +423,7 @@ static enum cb_err send_sipi_to_aps(int ap_count, atomic_t *num_aps, int sipi_ve
printk(BIOS_DEBUG, "done.\n"); printk(BIOS_DEBUG, "done.\n");
} }
lapic_send_ipi(LAPIC_DEST_ALLBUT | LAPIC_INT_ASSERT | LAPIC_DM_STARTUP | sipi_vector, lapic_send_ipi_others(LAPIC_INT_ASSERT | LAPIC_DM_STARTUP | sipi_vector);
0);
printk(BIOS_DEBUG, "Waiting for SIPI to complete...\n"); printk(BIOS_DEBUG, "Waiting for SIPI to complete...\n");
if (apic_wait_timeout(10000 /* 10 ms */, 50 /* us */) != CB_SUCCESS) { if (apic_wait_timeout(10000 /* 10 ms */, 50 /* us */) != CB_SUCCESS) {
printk(BIOS_ERR, "timed out.\n"); printk(BIOS_ERR, "timed out.\n");
@@ -464,7 +463,7 @@ static enum cb_err start_aps(struct bus *cpu_bus, int ap_count, atomic_t *num_ap
} }
/* Send INIT IPI to all but self. */ /* 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)) { if (!CONFIG(X86_INIT_NEED_1_SIPI)) {
printk(BIOS_DEBUG, "Waiting for 10ms after sending INIT.\n"); printk(BIOS_DEBUG, "Waiting for 10ms after sending INIT.\n");
@@ -649,7 +648,7 @@ void smm_initiate_relocation_parallel(void)
printk(BIOS_DEBUG, "done.\n"); 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 (lapic_busy()) {
if (apic_wait_timeout(1000 /* 1 ms */, 100 /* us */) != CB_SUCCESS) { if (apic_wait_timeout(1000 /* 1 ms */, 100 /* us */) != CB_SUCCESS) {

View File

@@ -143,6 +143,17 @@ static __always_inline unsigned int lapicid(void)
return lapicid; return lapicid;
} }
static __always_inline void lapic_send_ipi_self(uint32_t icrlow)
{
/* LAPIC_DEST_SELF does not support all delivery mode -fields. */
lapic_send_ipi(icrlow, lapicid());
}
static __always_inline void lapic_send_ipi_others(uint32_t icrlow)
{
lapic_send_ipi(LAPIC_DEST_ALLBUT | icrlow, 0);
}
#if !CONFIG(AP_IN_SIPI_WAIT) #if !CONFIG(AP_IN_SIPI_WAIT)
/* If we need to go back to sipi wait, we use the long non-inlined version of /* If we need to go back to sipi wait, we use the long non-inlined version of
* this function in lapic_cpu_stop.c * this function in lapic_cpu_stop.c