Aamir Bohra has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/51271 )
Change subject: src/cpu/x86: Add helper mp_run_on_all_aps ......................................................................
src/cpu/x86: Add helper mp_run_on_all_aps
Add a helper function mp_run_on_all_aps, it allows running a given func on all APs excluding the BSP, with an added provison to run func in serial manner per AP.
BUG=b:169114674
Signed-off-by: Aamir Bohra aamir.bohra@intel.com Change-Id: I74ee8168eb6380e346590f2575350e0a6b73856e --- M src/cpu/x86/mp_init.c M src/include/cpu/x86/mp.h 2 files changed, 20 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/71/51271/1
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c index cca6093..1960d93 100644 --- a/src/cpu/x86/mp_init.c +++ b/src/cpu/x86/mp_init.c @@ -992,6 +992,23 @@ return run_ap_work(&lcb, expire_us); }
+int mp_run_on_all_aps(void (*func)(void *), void *arg, long expire_us, bool run_serial) +{ + const int bsp_index = cpu_index(); + if (run_serial) { + for (int ap_index = 0; ap_index <= global_num_aps; ap_index++) { + /* skip if BSP */ + if (ap_index == bsp_index) + continue; + if (mp_run_on_aps(func, arg, ap_index, expire_us)) + return -1; + } + } else { /* Run parallel on all APs */ + return mp_run_on_aps(func, arg, 0, expire_us); + } + return 0; +} + 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 b2704eb..d97958d 100644 --- a/src/include/cpu/x86/mp.h +++ b/src/include/cpu/x86/mp.h @@ -125,6 +125,9 @@ 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 serially per AP */ +int mp_run_on_all_aps(void (*func)(void *), void *arg, long expire_us, bool run_serial); + /* Like mp_run_on_aps() but also runs func on BSP. */ int mp_run_on_all_cpus(void (*func)(void *), void *arg);