summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
authorAamir Bohra <aamir.bohra@intel.com>2021-03-05 09:41:20 +0530
committerTim Wawrzynczak <twawrzynczak@chromium.org>2021-03-11 15:53:58 +0000
commit7e0019ef209b6c552f03023255b9c75418fdb88a (patch)
tree37b1096149d2cd54dff0bd455d7e0ff574800383 /src/cpu
parenta5cdf75f690c2fb48d00df6ab4e7ba2bfd8a4480 (diff)
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 provision to run func in serial manner per AP. BUG=b:169114674 Signed-off-by: Aamir Bohra <aamir.bohra@intel.com> Change-Id: I74ee8168eb6380e346590f2575350e0a6b73856e Reviewed-on: https://review.coreboot.org/c/coreboot/+/51271 Reviewed-by: Furquan Shaikh <furquan@google.com> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/x86/mp_init.c22
1 files changed, 22 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. */