CpuState should follow the process:

    Idle -> Ready -> Busy -> Finished
     ^                         |
     |                         |
     + - - - - - - - - - - - - +

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.f...@cn.fujitsu.com>
---
 UefiCpuPkg/CpuDxe/CpuMp.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index 25b6fcb..25c9091 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -1176,11 +1176,14 @@ ProcessorToIdleState (
   }
 
   //
-  // Avoid forcibly reset AP caused the AP State is not updated.
+  // Avoid forcibly reset AP caused the timeout AP State is not
+  // updated.
   //
   GetMpSpinLock (CpuData);
+  if (CpuData->State == CpuStateBusy) {
+    CpuData->Procedure = NULL;
+  }
   CpuData->State = CpuStateIdle;
-  CpuData->Procedure = NULL;
   ReleaseMpSpinLock (CpuData);
 
   while (TRUE) {
@@ -1190,6 +1193,8 @@ ProcessorToIdleState (
     ReleaseMpSpinLock (CpuData);
 
     if (Procedure != NULL) {
+      SetApState (CpuData, CpuStateBusy);
+
       Procedure (ProcedureArgument);
 
       GetMpSpinLock (CpuData);
-- 
1.9.3


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to