From 0e724fc1981b3c47bb16432c4c414a50c9e3a519 Mon Sep 17 00:00:00 2001 From: Chen Fan Date: Thu, 13 Nov 2014 18:29:40 +0000 Subject: [PATCH] UefiCpuPkg/MpService: avoid reset AP still hold a lock Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen Fan Reviewed-by: Jeff Fan git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16368 6f19259b-4bc3-4df7-8a09-765794883524 --- 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 10065762a2..e03c7f1e49 100644 --- a/UefiCpuPkg/CpuDxe/CpuMp.c +++ b/UefiCpuPkg/CpuDxe/CpuMp.c @@ -52,6 +52,7 @@ GetMpSpinLock ( while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) { CpuPause (); } + CpuData->LockSelf = GetApicId (); } /** @@ -1144,6 +1145,13 @@ ProcessorToIdleState ( WhoAmI (&mMpServicesTemplate, &ProcessorNumber); CpuData = &mMpSystemData.CpuDatas[ProcessorNumber]; + // + // Avoid forcibly reset AP caused the AP got lock not release. + // + if (CpuData->LockSelf == (INTN) GetApicId ()) { + ReleaseSpinLock (&CpuData->CpuDataLock); + } + // // Avoid forcibly reset AP caused the AP State is not updated. // @@ -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 4254419a93..5c892381ef 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; -- 2.39.2