diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c index e03c7f1e49..5d5c7db765 100644 --- a/UefiCpuPkg/CpuDxe/CpuMp.c +++ b/UefiCpuPkg/CpuDxe/CpuMp.c @@ -632,6 +632,11 @@ StartupAllAPs ( return EFI_INVALID_PARAMETER; } + // + // temporarily stop checkAllAPsStatus for avoid resource dead-lock. + // + mStopCheckAllAPsStatus = TRUE; + for (Number = 0; Number < mMpSystemData.NumberOfProcessors; Number++) { CpuData = &mMpSystemData.CpuDatas[Number]; if (TestCpuStatusFlag (CpuData, PROCESSOR_AS_BSP_BIT)) { @@ -653,11 +658,6 @@ StartupAllAPs ( } } - // - // temporarily stop checkAllAPsStatus for initialize parameters. - // - mStopCheckAllAPsStatus = TRUE; - mMpSystemData.Procedure = Procedure; mMpSystemData.ProcedureArgument = ProcedureArgument; mMpSystemData.WaitEvent = WaitEvent; @@ -716,6 +716,11 @@ StartupAllAPs ( return EFI_SUCCESS; } + // + // Blocking temporarily stop CheckAllAPsStatus() + // + mStopCheckAllAPsStatus = TRUE; + while (TRUE) { CheckAndUpdateAllAPsToIdleState (); if (mMpSystemData.FinishCount == mMpSystemData.StartCount) { @@ -859,6 +864,11 @@ StartupThisAP ( return EFI_NOT_FOUND; } + // + // temporarily stop checkAllAPsStatus for avoid resource dead-lock. + // + mStopCheckAllAPsStatus = TRUE; + CpuData = &mMpSystemData.CpuDatas[ProcessorNumber]; if (TestCpuStatusFlag (CpuData, PROCESSOR_AS_BSP_BIT) || !TestCpuStatusFlag (CpuData, PROCESSOR_ENABLED_BIT)) { @@ -869,11 +879,6 @@ StartupThisAP ( return EFI_NOT_READY; } - // - // temporarily stop checkAllAPsStatus for initialize parameters. - // - mStopCheckAllAPsStatus = TRUE; - SetApState (CpuData, CpuStateReady); SetApProcedure (CpuData, Procedure, ProcedureArgument); @@ -1013,6 +1018,10 @@ EnableDisableAP ( ) { CPU_DATA_BLOCK *CpuData; + BOOLEAN TempStopCheckState; + + CpuData = NULL; + TempStopCheckState = FALSE; if (!IsBSP ()) { return EFI_DEVICE_ERROR; @@ -1022,6 +1031,14 @@ EnableDisableAP ( return EFI_NOT_FOUND; } + // + // temporarily stop checkAllAPsStatus for initialize parameters. + // + if (!mStopCheckAllAPsStatus) { + mStopCheckAllAPsStatus = TRUE; + TempStopCheckState = TRUE; + } + CpuData = &mMpSystemData.CpuDatas[ProcessorNumber]; if (TestCpuStatusFlag (CpuData, PROCESSOR_AS_BSP_BIT)) { return EFI_INVALID_PARAMETER; @@ -1048,6 +1065,10 @@ EnableDisableAP ( CpuStatusFlagOr (CpuData, (*HealthFlag & PROCESSOR_HEALTH_STATUS_BIT)); } + if (TempStopCheckState) { + mStopCheckAllAPsStatus = FALSE; + } + return EFI_SUCCESS; } @@ -1303,20 +1324,6 @@ CheckAllAPsStatus ( // for (Number = 0; Number < mMpSystemData.NumberOfProcessors; Number++) { CpuData = &mMpSystemData.CpuDatas[Number]; - if (TestCpuStatusFlag (CpuData, PROCESSOR_AS_BSP_BIT)) { - // - // Skip BSP - // - continue; - } - - if (!TestCpuStatusFlag (CpuData, PROCESSOR_ENABLED_BIT)) { - // - // Skip Disabled processors - // - continue; - } - if (CpuData->WaitEvent) { CheckThisAPStatus (NULL, (VOID *)CpuData); }