cpu/x86/mp_init: use cb_err as mp_init & bsp_do_flight_plan return type

Using cb_err as return type clarifies the meaning of the different
return values. To not change the return types of mp_init_with_smm which
is exposed outside of this compilation unit to keep the scope of this
patch limited, the return value of mp_init gets translated to the int
values in mp_init_with_smm. This could also be done by a cast of the
mp_init return value to int, but an explicit translation of the return
values should be clearer about what it does there.

Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: I4129c1db06a877c47cca87782af965b62dcbbdc2
Reviewed-on: https://review.coreboot.org/c/coreboot/+/58489
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 19:27:14 +02:00 committed by Felix Held
parent 3dd9cfbdf5
commit c6f0ed789b
1 changed files with 11 additions and 11 deletions

View File

@ -495,10 +495,10 @@ static enum cb_err start_aps(struct bus *cpu_bus, int ap_count, atomic_t *num_ap
return CB_SUCCESS; return CB_SUCCESS;
} }
static int bsp_do_flight_plan(struct mp_params *mp_params) static enum cb_err bsp_do_flight_plan(struct mp_params *mp_params)
{ {
int i; int i;
int ret = 0; enum cb_err ret = CB_SUCCESS;
/* /*
* Set time out for flight plan to a huge minimum value (>=1 second). * Set time out for flight plan to a huge minimum value (>=1 second).
* CPUs with many APs may take longer if there is contention for * CPUs with many APs may take longer if there is contention for
@ -521,7 +521,7 @@ static int bsp_do_flight_plan(struct mp_params *mp_params)
if (wait_for_aps(&rec->cpus_entered, num_aps, if (wait_for_aps(&rec->cpus_entered, num_aps,
timeout_us, step_us) != CB_SUCCESS) { 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 = CB_ERR;
} }
} }
@ -580,10 +580,8 @@ static void init_bsp(struct bus *cpu_bus)
* Therefore, one cannot rely on this property or the order of devices in * Therefore, one cannot rely on this property or the order of devices in
* the device tree unless the chipset or mainboard know the APIC ids * the device tree unless the chipset or mainboard know the APIC ids
* a priori. * a priori.
*
* mp_init() returns < 0 on error, 0 on success.
*/ */
static int mp_init(struct bus *cpu_bus, struct mp_params *p) static enum cb_err mp_init(struct bus *cpu_bus, struct mp_params *p)
{ {
int num_cpus; int num_cpus;
atomic_t *ap_count; atomic_t *ap_count;
@ -592,7 +590,7 @@ static int mp_init(struct bus *cpu_bus, struct mp_params *p)
if (p == NULL || p->flight_plan == NULL || p->num_records < 1) { if (p == NULL || p->flight_plan == NULL || p->num_records < 1) {
printk(BIOS_CRIT, "Invalid MP parameters\n"); printk(BIOS_CRIT, "Invalid MP parameters\n");
return -1; return CB_ERR;
} }
/* Default to currently running CPU. */ /* Default to currently running CPU. */
@ -602,7 +600,7 @@ static int mp_init(struct bus *cpu_bus, struct mp_params *p)
printk(BIOS_CRIT, printk(BIOS_CRIT,
"ERROR: More cpus requested (%d) than supported (%d).\n", "ERROR: More cpus requested (%d) than supported (%d).\n",
p->num_cpus, num_cpus); p->num_cpus, num_cpus);
return -1; return CB_ERR;
} }
/* Copy needed parameters so that APs have a reference to the plan. */ /* Copy needed parameters so that APs have a reference to the plan. */
@ -612,7 +610,7 @@ static int mp_init(struct bus *cpu_bus, struct mp_params *p)
/* Load the SIPI vector. */ /* Load the SIPI vector. */
ap_count = load_sipi_vector(p); ap_count = load_sipi_vector(p);
if (ap_count == NULL) if (ap_count == NULL)
return -1; return CB_ERR;
/* Make sure SIPI data hits RAM so the APs that come up will see /* Make sure SIPI data hits RAM so the APs that come up will see
* the startup code even if the caches are disabled. */ * the startup code even if the caches are disabled. */
@ -624,7 +622,7 @@ static int mp_init(struct bus *cpu_bus, struct mp_params *p)
mdelay(1000); mdelay(1000);
printk(BIOS_DEBUG, "%d/%d eventually checked in?\n", printk(BIOS_DEBUG, "%d/%d eventually checked in?\n",
atomic_read(ap_count), global_num_aps); atomic_read(ap_count), global_num_aps);
return -1; return CB_ERR;
} }
/* Walk the flight plan for the BSP. */ /* Walk the flight plan for the BSP. */
@ -1133,7 +1131,9 @@ int mp_init_with_smm(struct bus *cpu_bus, const struct mp_ops *mp_ops)
/* Perform backup of default SMM area. */ /* Perform backup of default SMM area. */
default_smm_area = backup_default_smm_area(); default_smm_area = backup_default_smm_area();
ret = mp_init(cpu_bus, &mp_params); /* TODO: Remove this return value translation after changing the return type of
mp_init_with_smm to enum cb_err */
ret = mp_init(cpu_bus, &mp_params) == CB_SUCCESS ? 0 : -1;
restore_default_smm_area(default_smm_area); restore_default_smm_area(default_smm_area);