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

diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index d657152..183a27d 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -52,6 +52,7 @@ GetMpSpinLock (
   while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
     CpuPause ();
   }
+  CpuData->LockSelf = GetApicId ();
 }
 
 /**
@@ -1145,6 +1146,13 @@ ProcessorToIdleState (
   CpuData = &mMpSystemData.CpuDatas[ProcessorNumber];
 
   //
+  // Avoid forcibly reset AP caused the AP got lock not release.
+  //
+  if (CpuData->LockSelf == GetApicId ()) {
+    ReleaseSpinLock (&CpuData->CpuDataLock);
+  }
+
+  //
   // Avoid forcibly reset AP caused the AP State is not updated.
   //
   GetMpSpinLock (CpuData);
@@ -1395,6 +1403,7 @@ FillInProcessorInformation (
   CpuData->Procedure        = NULL;
   CpuData->Parameter        = NULL;
   InitializeSpinLock (&CpuData->CpuDataLock);
+  CpuData->LockSelf         = -1;
 
   return EFI_SUCCESS;
 }
diff --git a/UefiCpuPkg/CpuDxe/CpuMp.h b/UefiCpuPkg/CpuDxe/CpuMp.h
index 2533f4e..4820d4d 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.h
+++ b/UefiCpuPkg/CpuDxe/CpuMp.h
@@ -90,6 +90,7 @@ typedef enum {
 typedef struct {
   EFI_PROCESSOR_INFORMATION      Info;
   SPIN_LOCK                      CpuDataLock;
+  INTN                           LockSelf;
   volatile CPU_STATE             State;
 
   EFI_AP_PROCEDURE               Procedure;
-- 
1.9.3


------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to