From 3dd9cfbdf57e8a2cdd48d51b81bf77662de25154 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Wed, 20 Oct 2021 18:39:00 +0200 Subject: cpu/x86/mp_init: use cb_err as wait_for_aps return type Using cb_err as return type clarifies the meaning of the different return values. Also restructure the implementation of wait_for_aps to not need a local timeout variable. Signed-off-by: Felix Held Change-Id: I86b8c8b0849ae130c78125b83d159147ce11914c Reviewed-on: https://review.coreboot.org/c/coreboot/+/58488 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans --- src/cpu/x86/mp_init.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/cpu/x86') diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c index 4b173a4888..2af5b1f9f0 100644 --- a/src/cpu/x86/mp_init.c +++ b/src/cpu/x86/mp_init.c @@ -140,22 +140,21 @@ static inline void release_barrier(atomic_t *b) atomic_set(b, 1); } -/* Returns 1 if timeout waiting for APs. 0 if target aps found. */ -static int wait_for_aps(atomic_t *val, int target, int total_delay, +static enum cb_err wait_for_aps(atomic_t *val, int target, int total_delay, int delay_step) { - int timeout = 0; int delayed = 0; while (atomic_read(val) != target) { udelay(delay_step); delayed += delay_step; if (delayed >= total_delay) { - timeout = 1; - break; + /* Not all APs ready before timeout */ + return CB_ERR; } } - return timeout; + /* APs ready before timeout */ + return CB_SUCCESS; } static void ap_do_flight_plan(void) @@ -487,7 +486,7 @@ static enum cb_err start_aps(struct bus *cpu_bus, int ap_count, atomic_t *num_ap return CB_ERR; /* Wait for CPUs to check in. */ - if (wait_for_aps(num_aps, ap_count, 100000 /* 100 ms */, 50 /* us */)) { + if (wait_for_aps(num_aps, ap_count, 100000 /* 100 ms */, 50 /* us */) != CB_SUCCESS) { printk(BIOS_ERR, "Not all APs checked in: %d/%d.\n", atomic_read(num_aps), ap_count); return CB_ERR; @@ -520,7 +519,7 @@ static int bsp_do_flight_plan(struct mp_params *mp_params) if (atomic_read(&rec->barrier) == 0) { /* Wait for the APs to check in. */ if (wait_for_aps(&rec->cpus_entered, num_aps, - timeout_us, step_us)) { + timeout_us, step_us) != CB_SUCCESS) { printk(BIOS_ERR, "MP record %d timeout.\n", i); ret = -1; } -- cgit v1.2.3