<p>Subrata Banik has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/25622">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cpu/x86: Refactor run_ap_work() function to support no timeout<br><br>There might be certain requirement in user function where user<br>might not want to pass any timeout value, in those cases run_ap_work() should<br>consider infinity as timeout and perform all APs initialization as per specification.<br><br>BRANCH=none<br>BUG=b:74436746<br>TEST=run_ap_work() is running successfully with 0 expire_us.<br><br>Change-Id: Iacd67768c8a120f6a01baaa6817468f6b9a3b764<br>Signed-off-by: Subrata Banik <subrata.banik@intel.com><br>---<br>M src/cpu/x86/mp_init.c<br>1 file changed, 37 insertions(+), 16 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/22/25622/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c</span><br><span>index 52feca9..f1600fd 100644</span><br><span>--- a/src/cpu/x86/mp_init.c</span><br><span>+++ b/src/cpu/x86/mp_init.c</span><br><span>@@ -946,6 +946,24 @@</span><br><span>     *(volatile mp_callback_t *)slot = value;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static int execute_callback_on_ap(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ int cpus_accepted;</span><br><span style="color: hsl(120, 100%, 40%);">+    int i;</span><br><span style="color: hsl(120, 100%, 40%);">+        int cur_cpu = cpu_index();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  cpus_accepted = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+  for (i = 0; i < ARRAY_SIZE(ap_callbacks); i++) {</span><br><span style="color: hsl(120, 100%, 40%);">+           if (cur_cpu == i)</span><br><span style="color: hsl(120, 100%, 40%);">+                     continue;</span><br><span style="color: hsl(120, 100%, 40%);">+             if (read_callback(&ap_callbacks[i]) == NULL)</span><br><span style="color: hsl(120, 100%, 40%);">+                      cpus_accepted++;</span><br><span style="color: hsl(120, 100%, 40%);">+      }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+   return cpus_accepted;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static int run_ap_work(mp_callback_t func, long expire_us)</span><br><span> {</span><br><span>        int i;</span><br><span>@@ -966,22 +984,25 @@</span><br><span>       }</span><br><span>    mfence();</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-   /* Wait for all the APs to signal back that call has been accepted. */</span><br><span style="color: hsl(0, 100%, 40%);">-  stopwatch_init_usecs_expire(&sw, expire_us);</span><br><span style="color: hsl(0, 100%, 40%);">-        do {</span><br><span style="color: hsl(0, 100%, 40%);">-            cpus_accepted = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-              for (i = 0; i < ARRAY_SIZE(ap_callbacks); i++) {</span><br><span style="color: hsl(0, 100%, 40%);">-                     if (cur_cpu == i)</span><br><span style="color: hsl(0, 100%, 40%);">-                               continue;</span><br><span style="color: hsl(0, 100%, 40%);">-                       if (read_callback(&ap_callbacks[i]) == NULL)</span><br><span style="color: hsl(0, 100%, 40%);">-                                cpus_accepted++;</span><br><span style="color: hsl(0, 100%, 40%);">-                }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-               if (cpus_accepted == global_num_aps)</span><br><span style="color: hsl(0, 100%, 40%);">-                    return 0;</span><br><span style="color: hsl(0, 100%, 40%);">-       } while (!stopwatch_expired(&sw));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+        if (expire_us) {</span><br><span style="color: hsl(120, 100%, 40%);">+              /*</span><br><span style="color: hsl(120, 100%, 40%);">+             * Wait for all the APs to signal back that call has been</span><br><span style="color: hsl(120, 100%, 40%);">+              * accepted.</span><br><span style="color: hsl(120, 100%, 40%);">+           */</span><br><span style="color: hsl(120, 100%, 40%);">+           stopwatch_init_usecs_expire(&sw, expire_us);</span><br><span style="color: hsl(120, 100%, 40%);">+              do {</span><br><span style="color: hsl(120, 100%, 40%);">+                  cpus_accepted = execute_callback_on_ap();</span><br><span style="color: hsl(120, 100%, 40%);">+                     if (cpus_accepted == global_num_aps)</span><br><span style="color: hsl(120, 100%, 40%);">+                          return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+             } while (!stopwatch_expired(&sw));</span><br><span style="color: hsl(120, 100%, 40%);">+        } else {</span><br><span style="color: hsl(120, 100%, 40%);">+              /* Wait for all the APs to signal back with no timeout */</span><br><span style="color: hsl(120, 100%, 40%);">+             do {</span><br><span style="color: hsl(120, 100%, 40%);">+                  cpus_accepted = execute_callback_on_ap();</span><br><span style="color: hsl(120, 100%, 40%);">+                     if (cpus_accepted == global_num_aps)</span><br><span style="color: hsl(120, 100%, 40%);">+                          return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+             } while (1);</span><br><span style="color: hsl(120, 100%, 40%);">+  }</span><br><span>    printk(BIOS_ERR, "AP call expired. %d/%d CPUs accepted.\n",</span><br><span>                cpus_accepted, global_num_aps);</span><br><span>      return -1;</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/25622">change 25622</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/25622"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Iacd67768c8a120f6a01baaa6817468f6b9a3b764 </div>
<div style="display:none"> Gerrit-Change-Number: 25622 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Subrata Banik <subrata.banik@intel.com> </div>