summaryrefslogtreecommitdiff
path: root/src/cpu/x86
diff options
context:
space:
mode:
authorSubrata Banik <subrata.banik@intel.com>2018-05-03 18:48:41 +0530
committerSubrata Banik <subrata.banik@intel.com>2018-05-19 01:16:06 +0000
commit8a25caee0507655d775e3dcc21b36b01ca517113 (patch)
tree7cde904b2a0c3a3296a1008a3167a0f1f43e61de /src/cpu/x86
parente66600ee4f33291ef620133c7f2df54f449d9470 (diff)
downloadcoreboot-8a25caee0507655d775e3dcc21b36b01ca517113.tar.xz
cpu/x86: Add support to run function on single AP
This patch ensures that user can select a specific AP to run a function. BUG=b:74436746 BRANCH=none TEST=Able to run functions over APs with argument. Change-Id: Iff2f34900ce2a96ef6ff0779b651f25ebfc739ad Signed-off-by: Subrata Banik <subrata.banik@intel.com> Reviewed-on: https://review.coreboot.org/26034 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/cpu/x86')
-rw-r--r--src/cpu/x86/mp_init.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c
index ef576ec26d..a696cd0a5c 100644
--- a/src/cpu/x86/mp_init.c
+++ b/src/cpu/x86/mp_init.c
@@ -43,6 +43,7 @@
struct mp_callback {
void (*func)(void *);
void *arg;
+ int logical_cpu_number;
};
/*
@@ -924,11 +925,13 @@ static void ap_wait_for_instruction(void)
{
struct mp_callback lcb;
struct mp_callback **per_cpu_slot;
+ int cur_cpu;
if (!IS_ENABLED(CONFIG_PARALLEL_MP_AP_WORK))
return;
- per_cpu_slot = &ap_callbacks[cpu_index()];
+ cur_cpu = cpu_index();
+ per_cpu_slot = &ap_callbacks[cur_cpu];
while (1) {
struct mp_callback *cb = read_callback(per_cpu_slot);
@@ -942,13 +945,19 @@ static void ap_wait_for_instruction(void)
memcpy(&lcb, cb, sizeof(lcb));
mfence();
store_callback(per_cpu_slot, NULL);
- lcb.func(lcb.arg);
+ if (lcb.logical_cpu_number && (cur_cpu !=
+ lcb.logical_cpu_number))
+ continue;
+ else
+ lcb.func(lcb.arg);
}
}
-int mp_run_on_aps(void (*func)(void *), void *arg, long expire_us)
+int mp_run_on_aps(void (*func)(void *), void *arg, int logical_cpu_num,
+ long expire_us)
{
- struct mp_callback lcb = { .func = func, .arg = arg };
+ struct mp_callback lcb = { .func = func, .arg = arg,
+ .logical_cpu_number = logical_cpu_num};
return run_ap_work(&lcb, expire_us);
}
@@ -957,7 +966,7 @@ int mp_run_on_all_cpus(void (*func)(void *), void *arg, long expire_us)
/* Run on BSP first. */
func(arg);
- return mp_run_on_aps(func, arg, expire_us);
+ return mp_run_on_aps(func, arg, MP_RUN_ON_ALL_CPUS, expire_us);
}
int mp_park_aps(void)
@@ -968,7 +977,8 @@ int mp_park_aps(void)
stopwatch_init(&sw);
- ret = mp_run_on_aps(park_this_cpu, NULL, 250 * USECS_PER_MSEC);
+ ret = mp_run_on_aps(park_this_cpu, NULL, MP_RUN_ON_ALL_CPUS,
+ 250 * USECS_PER_MSEC);
duration_msecs = stopwatch_duration_msecs(&sw);