[coreboot-gerrit] Change in coreboot[master]: cpu/x86: Refactor run_ap_work() function to support no timeout
Subrata Banik (Code Review)
gerrit at coreboot.org
Wed Apr 11 15:23:17 CEST 2018
Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/25622
Change subject: cpu/x86: Refactor run_ap_work() function to support no timeout
......................................................................
cpu/x86: Refactor run_ap_work() function to support no timeout
There might be certain requirement in user function where user
might not want to pass any timeout value, in those cases run_ap_work() should
consider infinity as timeout and perform all APs initialization as per specification.
BRANCH=none
BUG=b:74436746
TEST=run_ap_work() is running successfully with 0 expire_us.
Change-Id: Iacd67768c8a120f6a01baaa6817468f6b9a3b764
Signed-off-by: Subrata Banik <subrata.banik at intel.com>
---
M src/cpu/x86/mp_init.c
1 file changed, 37 insertions(+), 16 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/22/25622/1
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c
index 52feca9..f1600fd 100644
--- a/src/cpu/x86/mp_init.c
+++ b/src/cpu/x86/mp_init.c
@@ -946,6 +946,24 @@
*(volatile mp_callback_t *)slot = value;
}
+static int execute_callback_on_ap(void)
+{
+ int cpus_accepted;
+ int i;
+ int cur_cpu = cpu_index();
+
+ cpus_accepted = 0;
+
+ for (i = 0; i < ARRAY_SIZE(ap_callbacks); i++) {
+ if (cur_cpu == i)
+ continue;
+ if (read_callback(&ap_callbacks[i]) == NULL)
+ cpus_accepted++;
+ }
+
+ return cpus_accepted;
+}
+
static int run_ap_work(mp_callback_t func, long expire_us)
{
int i;
@@ -966,22 +984,25 @@
}
mfence();
- /* Wait for all the APs to signal back that call has been accepted. */
- stopwatch_init_usecs_expire(&sw, expire_us);
- do {
- cpus_accepted = 0;
-
- for (i = 0; i < ARRAY_SIZE(ap_callbacks); i++) {
- if (cur_cpu == i)
- continue;
- if (read_callback(&ap_callbacks[i]) == NULL)
- cpus_accepted++;
- }
-
- if (cpus_accepted == global_num_aps)
- return 0;
- } while (!stopwatch_expired(&sw));
-
+ if (expire_us) {
+ /*
+ * Wait for all the APs to signal back that call has been
+ * accepted.
+ */
+ stopwatch_init_usecs_expire(&sw, expire_us);
+ do {
+ cpus_accepted = execute_callback_on_ap();
+ if (cpus_accepted == global_num_aps)
+ return 0;
+ } while (!stopwatch_expired(&sw));
+ } else {
+ /* Wait for all the APs to signal back with no timeout */
+ do {
+ cpus_accepted = execute_callback_on_ap();
+ if (cpus_accepted == global_num_aps)
+ return 0;
+ } while (1);
+ }
printk(BIOS_ERR, "AP call expired. %d/%d CPUs accepted.\n",
cpus_accepted, global_num_aps);
return -1;
--
To view, visit https://review.coreboot.org/25622
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iacd67768c8a120f6a01baaa6817468f6b9a3b764
Gerrit-Change-Number: 25622
Gerrit-PatchSet: 1
Gerrit-Owner: Subrata Banik <subrata.banik at intel.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180411/b78e216c/attachment.html>
More information about the coreboot-gerrit
mailing list