From c1192210604f51c8397864293b1bdc00c5242c58 Mon Sep 17 00:00:00 2001 From: Jeff Fan Date: Wed, 24 Aug 2016 21:37:14 +0800 Subject: [PATCH] UefiCpuPkg/MpInitLib: Move timeout delay to WakupAp() After sending the 1st broadcast INIT-SIPI-SIPI, BSP will collect APs count after one specified timeout delay. However, WakupAp() will restore reset vector immediately after sending 1st broadcast INIT-SIPI-SIPI. Some processors may not complete executing reset vector code. This fix is to move MicroSecondDelay() from CollectProcessorCount() to the place that is after sending 1st broadcast INIT-SIPI-SIPI and before FreeResetVector() in WakupAp(). Cc: Michael Kinney Cc: Feng Tian Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan Reviewed-by: Feng Tian --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index fbe2e8b8c4..47a971bf97 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -513,10 +513,6 @@ CollectProcessorCount ( CpuMpData->InitFlag = ApInitConfig; CpuMpData->X2ApicEnable = FALSE; WakeUpAP (CpuMpData, TRUE, 0, NULL, NULL); - // - // Wait for AP task to complete and then exit. - // - MicroSecondDelay (PcdGet32(PcdCpuApInitTimeOutInMicroSeconds)); CpuMpData->InitFlag = ApInitDone; ASSERT (CpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); // @@ -863,7 +859,12 @@ WakeUpAP ( // SendInitSipiSipiAllExcludingSelf ((UINT32) ExchangeInfo->BufferStart); } - if (CpuMpData->InitFlag != ApInitConfig) { + if (CpuMpData->InitFlag == ApInitConfig) { + // + // Wait for all potential APs waken up in one specified period + // + MicroSecondDelay (PcdGet32(PcdCpuApInitTimeOutInMicroSeconds)); + } else { // // Wait all APs waken up if this is not the 1st broadcast of SIPI // -- 2.39.2