]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmulatorPkg/Mpservice: Add StateLock where missing
authorChen Fan <chen.fan.fnst@cn.fujitsu.com>
Thu, 31 Jul 2014 15:45:27 +0000 (15:45 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 31 Jul 2014 15:45:27 +0000 (15:45 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15730 6f19259b-4bc3-4df7-8a09-765794883524

EmulatorPkg/CpuRuntimeDxe/MpService.c

index d79abd2989626546b2e0f6896b4ed238115e8ad4..536a47f7ec02d192eebbf02fc77e0dce013cfdce 100644 (file)
@@ -437,17 +437,17 @@ CpuMpServicesStartupAllAps (
     // state 1 by 1, until the previous 1 finished its task\r
     // if not "SingleThread", all APs are put to ready state from the beginning\r
     //\r
+    gThread->MutexLock(ProcessorData->StateLock);\r
     if (ProcessorData->State == CPU_STATE_IDLE) {\r
-      gMPSystem.StartCount++;\r
-\r
-      gThread->MutexLock (ProcessorData->StateLock);\r
       ProcessorData->State = APInitialState;\r
       gThread->MutexUnlock (ProcessorData->StateLock);\r
 \r
+      gMPSystem.StartCount++;\r
       if (SingleThread) {\r
         APInitialState = CPU_STATE_BLOCKED;\r
       }\r
     } else {\r
+      gThread->MutexUnlock (ProcessorData->StateLock);\r
       return EFI_NOT_READY;\r
     }\r
   }\r
@@ -671,9 +671,12 @@ CpuMpServicesStartupThisAP (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  gThread->MutexLock(gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
   if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) {\r
+    gThread->MutexUnlock(gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
     return EFI_NOT_READY;\r
   }\r
+  gThread->MutexUnlock(gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
 \r
   if ((WaitEvent != NULL)  && gReadToBoot) {\r
     return EFI_UNSUPPORTED;\r
@@ -789,9 +792,12 @@ CpuMpServicesSwitchBSP (
   }\r
   ASSERT (Index != gMPSystem.NumberOfProcessors);\r
 \r
+  gThread->MutexLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
   if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) {\r
+    gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
     return EFI_NOT_READY;\r
   }\r
+  gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
 \r
   // Skip for now as we need switch a bunch of stack stuff around and it's complex\r
   // May not be worth it?\r
@@ -861,9 +867,12 @@ CpuMpServicesEnableDisableAP (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  gThread->MutexLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
   if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) {\r
+    gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
     return EFI_UNSUPPORTED;\r
   }\r
+  gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
 \r
   if (EnableAP) {\r
     if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0 ) {\r
@@ -1019,7 +1028,9 @@ CpuCheckAllAPsStatus (
         }\r
       }\r
 \r
+      gThread->MutexLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
       gMPSystem.ProcessorData[ProcessorNumber].State = CPU_STATE_IDLE;\r
+      gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);\r
       gMPSystem.FinishCount++;\r
       break;\r
 \r