Attention is currently required from: Arthur Heymans. Hello Arthur Heymans,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/55191
to review the following change.
Change subject: cpu/x86/lapic: Add lapic_busy() helper ......................................................................
cpu/x86/lapic: Add lapic_busy() helper
Change-Id: Ife127d6dc8241cccb9d52236a9152da707f0e261 Signed-off-by: Arthur Heymans arthur@aheymans.xyz Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/cpu/x86/lapic/lapic_cpu_init.c M src/cpu/x86/mp_init.c M src/include/cpu/x86/lapic.h 3 files changed, 20 insertions(+), 12 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/91/55191/1
diff --git a/src/cpu/x86/lapic/lapic_cpu_init.c b/src/cpu/x86/lapic/lapic_cpu_init.c index 5988919..132cb5a 100644 --- a/src/cpu/x86/lapic/lapic_cpu_init.c +++ b/src/cpu/x86/lapic/lapic_cpu_init.c @@ -110,7 +110,7 @@ do { printk(BIOS_SPEW, "+"); udelay(100); - send_status = lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY; + send_status = lapic_busy(); } while (send_status && (timeout++ < 1000)); if (timeout >= 1000) { printk(BIOS_ERR, "CPU %ld: First APIC write timed out. " @@ -136,7 +136,7 @@ do { printk(BIOS_SPEW, "+"); udelay(100); - send_status = lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY; + send_status = lapic_busy(); } while (send_status && (timeout++ < 1000)); if (timeout >= 1000) { printk(BIOS_ERR, "CPU %ld: Second APIC write timed out. " @@ -177,7 +177,7 @@ do { printk(BIOS_SPEW, "+"); udelay(100); - send_status = lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY; + send_status = lapic_busy(); } while (send_status && (timeout++ < 1000));
/* @@ -330,7 +330,7 @@ do { dprintk(BIOS_SPEW, "+"); udelay(100); - send_status = lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY; + send_status = lapic_busy(); } while (send_status && (timeout++ < 1000));
if (timeout >= 1000) @@ -349,7 +349,7 @@ do { dprintk(BIOS_SPEW, "+"); udelay(100); - send_status = lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY; + send_status = lapic_busy(); } while (send_status && (timeout++ < 1000));
if (timeout >= 1000) diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c index 87ddb0d..ad45ee9 100644 --- a/src/cpu/x86/mp_init.c +++ b/src/cpu/x86/mp_init.c @@ -403,7 +403,7 @@ int total = 0; int timeout = 0;
- while (lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY) { + while (lapic_busy()) { udelay(delay_step); total += delay_step; if (total >= total_delay) { @@ -457,7 +457,7 @@ return 0; }
- if ((lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY)) { + if (lapic_busy()) { printk(BIOS_DEBUG, "Waiting for ICR not to be busy..."); if (apic_wait_timeout(1000 /* 1 ms */, 50)) { printk(BIOS_ERR, "timed out. Aborting.\n"); @@ -472,7 +472,7 @@ mdelay(10);
/* Send 1st SIPI */ - if ((lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY)) { + if (lapic_busy()) { printk(BIOS_DEBUG, "Waiting for ICR not to be busy..."); if (apic_wait_timeout(1000 /* 1 ms */, 50)) { printk(BIOS_ERR, "timed out. Aborting.\n"); @@ -497,7 +497,7 @@ return 0;
/* Send 2nd SIPI */ - if ((lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY)) { + if (lapic_busy()) { printk(BIOS_DEBUG, "Waiting for ICR not to be busy..."); if (apic_wait_timeout(1000 /* 1 ms */, 50)) { printk(BIOS_ERR, "timed out. Aborting.\n"); @@ -676,7 +676,7 @@ return; }
- if ((lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY)) { + if (lapic_busy()) { printk(BIOS_DEBUG, "Waiting for ICR not to be busy..."); if (apic_wait_timeout(1000 /* 1 ms */, 50)) { printk(BIOS_DEBUG, "timed out. Aborting.\n"); diff --git a/src/include/cpu/x86/lapic.h b/src/include/cpu/x86/lapic.h index e297e3b7..13510ea 100644 --- a/src/include/cpu/x86/lapic.h +++ b/src/include/cpu/x86/lapic.h @@ -35,6 +35,11 @@ xapic_write_atomic(LAPIC_ICR, icrlow); }
+static __always_inline int xapic_busy(void) +{ + return xapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY; +} + #define lapic_read_around(x) lapic_read(x) #define lapic_write_around(x, y) xapic_write_atomic((x), (y))
@@ -124,9 +129,12 @@ xapic_send_ipi(icrlow, apicid); }
-static __always_inline void lapic_wait_icr_idle(void) +static __always_inline int lapic_busy(void) { - do { } while (lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY); + if (is_x2apic_mode()) + return 0; + else + return xapic_busy(); }
static inline void enable_lapic(void)