diff options
author | Felix Held <felix.held@amd.corp-partner.google.com> | 2021-10-20 18:39:00 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2021-10-21 18:23:55 +0000 |
commit | 3dd9cfbdf57e8a2cdd48d51b81bf77662de25154 (patch) | |
tree | a7917853bd8b8c45e8aaa2f11ee2533ad4c14543 /src/cpu | |
parent | 2939ebd05167d8681f973910b3bbcd68b3b2d1e6 (diff) |
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 <felix-coreboot@felixheld.de>
Change-Id: I86b8c8b0849ae130c78125b83d159147ce11914c
Reviewed-on: https://review.coreboot.org/c/coreboot/+/58488
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.c | 15 |
1 files changed, 7 insertions, 8 deletions
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; } |