]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: Remove redundant CpuStateFinished State.
authorEric Dong <eric.dong@intel.com>
Tue, 24 Jul 2018 14:25:41 +0000 (22:25 +0800)
committerEric Dong <eric.dong@intel.com>
Thu, 26 Jul 2018 08:54:09 +0000 (16:54 +0800)
Current CPU state definition include CpuStateIdle and CpuStateFinished.
After investigation, current code can use CpuStateIdle to replace the
CpuStateFinished. It will reduce the state number and easy for maintenance.

> Before this patch, the state transitions for an AP are:
>
>   Idle ----> Ready ----> Busy ----> Finished ----> Idle
>        [BSP]       [AP]       [AP]           [BSP]
>
> After the patch, the state transitions for an AP are:
>
>   Idle ----> Ready ----> Busy ----> Idle
>        [BSP]       [AP]       [AP]

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
UefiCpuPkg/Library/MpInitLib/MpLib.c
UefiCpuPkg/Library/MpInitLib/MpLib.h

index c82b9859439c6481f39702e910b5699aaacb9a70..ff09a0e9e7e843f2332a0d78fb7b24a138414ee5 100644 (file)
@@ -696,7 +696,7 @@ ApWakeupFunction (
             }\r
           }\r
         }\r
             }\r
           }\r
         }\r
-        SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateFinished);\r
+        SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateIdle);\r
       }\r
     }\r
 \r
       }\r
     }\r
 \r
@@ -1352,18 +1352,17 @@ CheckThisAP (
   CpuData   = &CpuMpData->CpuData[ProcessorNumber];\r
 \r
   //\r
   CpuData   = &CpuMpData->CpuData[ProcessorNumber];\r
 \r
   //\r
-  //  Check the CPU state of AP. If it is CpuStateFinished, then the AP has finished its task.\r
+  //  Check the CPU state of AP. If it is CpuStateIdle, then the AP has finished its task.\r
   //  Only BSP and corresponding AP access this unit of CPU Data. This means the AP will not modify the\r
   //  Only BSP and corresponding AP access this unit of CPU Data. This means the AP will not modify the\r
-  //  value of state after setting the it to CpuStateFinished, so BSP can safely make use of its value.\r
+  //  value of state after setting the it to CpuStateIdle, so BSP can safely make use of its value.\r
   //\r
   //\r
   // If the AP finishes for StartupThisAP(), return EFI_SUCCESS.\r
   //\r
   //\r
   //\r
   // If the AP finishes for StartupThisAP(), return EFI_SUCCESS.\r
   //\r
-  if (GetApState(CpuData) == CpuStateFinished) {\r
+  if (GetApState(CpuData) == CpuStateIdle) {\r
     if (CpuData->Finished != NULL) {\r
       *(CpuData->Finished) = TRUE;\r
     }\r
     if (CpuData->Finished != NULL) {\r
       *(CpuData->Finished) = TRUE;\r
     }\r
-    SetApState (CpuData, CpuStateIdle);\r
     return EFI_SUCCESS;\r
   } else {\r
     //\r
     return EFI_SUCCESS;\r
   } else {\r
     //\r
@@ -1420,14 +1419,13 @@ CheckAllAPs (
 \r
     CpuData = &CpuMpData->CpuData[ProcessorNumber];\r
     //\r
 \r
     CpuData = &CpuMpData->CpuData[ProcessorNumber];\r
     //\r
-    // Check the CPU state of AP. If it is CpuStateFinished, then the AP has finished its task.\r
+    // Check the CPU state of AP. If it is CpuStateIdle, then the AP has finished its task.\r
     // Only BSP and corresponding AP access this unit of CPU Data. This means the AP will not modify the\r
     // Only BSP and corresponding AP access this unit of CPU Data. This means the AP will not modify the\r
-    // value of state after setting the it to CpuStateFinished, so BSP can safely make use of its value.\r
+    // value of state after setting the it to CpuStateIdle, so BSP can safely make use of its value.\r
     //\r
     //\r
-    if (GetApState(CpuData) == CpuStateFinished) {\r
+    if (GetApState(CpuData) == CpuStateIdle) {\r
       CpuMpData->RunningCount ++;\r
       CpuMpData->CpuData[ProcessorNumber].Waiting = FALSE;\r
       CpuMpData->RunningCount ++;\r
       CpuMpData->CpuData[ProcessorNumber].Waiting = FALSE;\r
-      SetApState(CpuData, CpuStateIdle);\r
 \r
       //\r
       // If in Single Thread mode, then search for the next waiting AP for execution.\r
 \r
       //\r
       // If in Single Thread mode, then search for the next waiting AP for execution.\r
@@ -1923,7 +1921,7 @@ SwitchBSPWorker (
   //\r
   // Wait for old BSP finished AP task\r
   //\r
   //\r
   // Wait for old BSP finished AP task\r
   //\r
-  while (GetApState (&CpuMpData->CpuData[CallerNumber]) != CpuStateFinished) {\r
+  while (GetApState (&CpuMpData->CpuData[CallerNumber]) != CpuStateIdle) {\r
     CpuPause ();\r
   }\r
 \r
     CpuPause ();\r
   }\r
 \r
index 9d0b866d097962208437352f208eb1f80ff4d9b7..b3a38b4ce7eca35022db87bac15cc26e5cf03bea 100644 (file)
@@ -81,11 +81,14 @@ typedef enum {
 //\r
 // AP state\r
 //\r
 //\r
 // AP state\r
 //\r
+// The state transitions for an AP when it process a procedure are:\r
+//  Idle ----> Ready ----> Busy ----> Idle\r
+//       [BSP]       [AP]       [AP]\r
+//\r
 typedef enum {\r
   CpuStateIdle,\r
   CpuStateReady,\r
   CpuStateBusy,\r
 typedef enum {\r
   CpuStateIdle,\r
   CpuStateReady,\r
   CpuStateBusy,\r
-  CpuStateFinished,\r
   CpuStateDisabled\r
 } CPU_STATE;\r
 \r
   CpuStateDisabled\r
 } CPU_STATE;\r
 \r