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>
This commit is contained in:
Felix Held
2021-10-20 18:39:00 +02:00
committed by Felix Held
parent 2939ebd051
commit 3dd9cfbdf5

View File

@@ -140,22 +140,21 @@ static inline void release_barrier(atomic_t *b)
atomic_set(b, 1); atomic_set(b, 1);
} }
/* Returns 1 if timeout waiting for APs. 0 if target aps found. */ static enum cb_err wait_for_aps(atomic_t *val, int target, int total_delay,
static int wait_for_aps(atomic_t *val, int target, int total_delay,
int delay_step) int delay_step)
{ {
int timeout = 0;
int delayed = 0; int delayed = 0;
while (atomic_read(val) != target) { while (atomic_read(val) != target) {
udelay(delay_step); udelay(delay_step);
delayed += delay_step; delayed += delay_step;
if (delayed >= total_delay) { if (delayed >= total_delay) {
timeout = 1; /* Not all APs ready before timeout */
break; return CB_ERR;
} }
} }
return timeout; /* APs ready before timeout */
return CB_SUCCESS;
} }
static void ap_do_flight_plan(void) 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; return CB_ERR;
/* Wait for CPUs to check in. */ /* 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", printk(BIOS_ERR, "Not all APs checked in: %d/%d.\n",
atomic_read(num_aps), ap_count); atomic_read(num_aps), ap_count);
return CB_ERR; return CB_ERR;
@@ -520,7 +519,7 @@ static int bsp_do_flight_plan(struct mp_params *mp_params)
if (atomic_read(&rec->barrier) == 0) { if (atomic_read(&rec->barrier) == 0) {
/* Wait for the APs to check in. */ /* Wait for the APs to check in. */
if (wait_for_aps(&rec->cpus_entered, num_aps, 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); printk(BIOS_ERR, "MP record %d timeout.\n", i);
ret = -1; ret = -1;
} }