diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cpu/x86/mp_init.c | 22 | ||||
-rw-r--r-- | src/include/cpu/x86/mp.h | 6 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c index cca6093458..3edb5e7693 100644 --- a/src/cpu/x86/mp_init.c +++ b/src/cpu/x86/mp_init.c @@ -992,6 +992,28 @@ int mp_run_on_aps(void (*func)(void *), void *arg, int logical_cpu_num, return run_ap_work(&lcb, expire_us); } +int mp_run_on_all_aps(void (*func)(void *), void *arg, long expire_us, bool run_parallel) +{ + int ap_index, bsp_index; + + if (run_parallel) + return mp_run_on_aps(func, arg, 0, expire_us); + + bsp_index = cpu_index(); + + const int total_threads = global_num_aps + 1; /* +1 for BSP */ + + for (ap_index = 0; ap_index < total_threads; ap_index++) { + /* skip if BSP */ + if (ap_index == bsp_index) + continue; + if (mp_run_on_aps(func, arg, ap_index, expire_us)) + return CB_ERR; + } + + return CB_SUCCESS; +} + int mp_run_on_all_cpus(void (*func)(void *), void *arg) { /* Run on BSP first. */ diff --git a/src/include/cpu/x86/mp.h b/src/include/cpu/x86/mp.h index b2704eb5b0..bc44415fdb 100644 --- a/src/include/cpu/x86/mp.h +++ b/src/include/cpu/x86/mp.h @@ -125,6 +125,12 @@ enum { int mp_run_on_aps(void (*func)(void *), void *arg, int logical_cpu_num, long expire_us); +/* + * Runs func on all APs excluding BSP, with a provision to run calls in parallel + * or serially per AP. + */ +int mp_run_on_all_aps(void (*func)(void *), void *arg, long expire_us, bool run_parallel); + /* Like mp_run_on_aps() but also runs func on BSP. */ int mp_run_on_all_cpus(void (*func)(void *), void *arg); |