summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
authorFelix Held <felix.held@amd.corp-partner.google.com>2021-10-20 18:33:06 +0200
committerFelix Held <felix-coreboot@felixheld.de>2021-10-21 18:23:44 +0000
commit2939ebd05167d8681f973910b3bbcd68b3b2d1e6 (patch)
tree1e3998079e4f8e17e6df9901b872dc1d261b0050 /src/cpu
parent2461a09b4478d734cc749d059011c429515d59c7 (diff)
cpu/x86/mp_init: use cb_err as apic_wait_timeout return type
Using cb_err as return type clarifies the meaning of the different return values. Also restructure the implementation of apic_wait_timeout to not need a local timeout variable. Signed-off-by: Felix Held <felix-coreboot@felixheld.de> Change-Id: I2fe32c761492d252b154d2f50f2a330cf4f412d5 Reviewed-on: https://review.coreboot.org/c/coreboot/+/58487 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/x86/mp_init.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c
index eb6f1a27d1..4b173a4888 100644
--- a/src/cpu/x86/mp_init.c
+++ b/src/cpu/x86/mp_init.c
@@ -395,22 +395,21 @@ static int allocate_cpu_devices(struct bus *cpu_bus, struct mp_params *p)
return max_cpus;
}
-/* Returns 1 for timeout. 0 on success. */
-static int apic_wait_timeout(int total_delay, int delay_step)
+static enum cb_err apic_wait_timeout(int total_delay, int delay_step)
{
int total = 0;
- int timeout = 0;
while (lapic_busy()) {
udelay(delay_step);
total += delay_step;
if (total >= total_delay) {
- timeout = 1;
- break;
+ /* LAPIC not ready before the timeout */
+ return CB_ERR;
}
}
- return timeout;
+ /* LAPIC ready before the timeout */
+ return CB_SUCCESS;
}
/* Send Startup IPI to APs */
@@ -418,7 +417,7 @@ static enum cb_err send_sipi_to_aps(int ap_count, atomic_t *num_aps, int sipi_ve
{
if (lapic_busy()) {
printk(BIOS_DEBUG, "Waiting for ICR not to be busy...\n");
- if (apic_wait_timeout(1000 /* 1 ms */, 50)) {
+ if (apic_wait_timeout(1000 /* 1 ms */, 50) != CB_SUCCESS) {
printk(BIOS_ERR, "timed out. Aborting.\n");
return CB_ERR;
}
@@ -428,7 +427,7 @@ static enum cb_err send_sipi_to_aps(int ap_count, atomic_t *num_aps, int sipi_ve
lapic_send_ipi(LAPIC_DEST_ALLBUT | LAPIC_INT_ASSERT | LAPIC_DM_STARTUP | sipi_vector,
0);
printk(BIOS_DEBUG, "Waiting for SIPI to complete...\n");
- if (apic_wait_timeout(10000 /* 10 ms */, 50 /* us */)) {
+ if (apic_wait_timeout(10000 /* 10 ms */, 50 /* us */) != CB_SUCCESS) {
printk(BIOS_ERR, "timed out.\n");
return CB_ERR;
}
@@ -461,7 +460,7 @@ static enum cb_err start_aps(struct bus *cpu_bus, int ap_count, atomic_t *num_ap
if (lapic_busy()) {
printk(BIOS_DEBUG, "Waiting for ICR not to be busy...\n");
- if (apic_wait_timeout(1000 /* 1 ms */, 50)) {
+ if (apic_wait_timeout(1000 /* 1 ms */, 50) != CB_SUCCESS) {
printk(BIOS_ERR, "timed out. Aborting.\n");
return CB_ERR;
}
@@ -645,7 +644,7 @@ void smm_initiate_relocation_parallel(void)
{
if (lapic_busy()) {
printk(BIOS_DEBUG, "Waiting for ICR not to be busy...");
- if (apic_wait_timeout(1000 /* 1 ms */, 50)) {
+ if (apic_wait_timeout(1000 /* 1 ms */, 50) != CB_SUCCESS) {
printk(BIOS_DEBUG, "timed out. Aborting.\n");
return;
}
@@ -655,7 +654,7 @@ void smm_initiate_relocation_parallel(void)
lapic_send_ipi(LAPIC_INT_ASSERT | LAPIC_DM_SMI, lapicid());
if (lapic_busy()) {
- if (apic_wait_timeout(1000 /* 1 ms */, 100 /* us */)) {
+ if (apic_wait_timeout(1000 /* 1 ms */, 100 /* us */) != CB_SUCCESS) {
printk(BIOS_DEBUG, "SMI Relocation timed out.\n");
return;
}