UefiCpuPkg/MpInitLib: Enhance waiting for AP initialization logic.

Current logic always waiting for a specific value to collect all APs
count. This logic may caused some platforms cost too much time to
wait for time out.
This patch add new logic to collect APs count. It adds new variable
NumApsExecuting to detect whether all APs have finished initialization.
Each AP let NumApsExecuting++ when begin to initialize itself and let
NumApsExecuting-- when it finish the initialization. BSP base on whether
NumApsExecuting == 0  to finished the collect AP process.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jeff Fan <vanjeff_919@hotmail.com>
This commit is contained in:
Eric Dong
2017-10-23 15:02:36 +08:00
parent 37676b9f82
commit 0594ec417c
6 changed files with 30 additions and 7 deletions

View File

@@ -662,6 +662,7 @@ ApWakeupFunction (
// AP finished executing C code
//
InterlockedIncrement ((UINT32 *) &CpuMpData->FinishedCount);
InterlockedDecrement ((UINT32 *) &CpuMpData->MpCpuExchangeInfo->NumApsExecuting);
//
// Place AP is specified loop mode
@@ -765,6 +766,7 @@ FillExchangeInfoData (
ExchangeInfo->CFunction = (UINTN) ApWakeupFunction;
ExchangeInfo->ApIndex = 0;
ExchangeInfo->NumApsExecuting = 0;
ExchangeInfo->InitFlag = (UINTN) CpuMpData->InitFlag;
ExchangeInfo->CpuInfo = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob;
ExchangeInfo->CpuMpData = CpuMpData;
@@ -934,13 +936,19 @@ WakeUpAP (
}
if (CpuMpData->InitFlag == ApInitConfig) {
//
// Wait for all potential APs waken up in one specified period
// Wait for one potential AP waken up in one specified period
//
TimedWaitForApFinish (
CpuMpData,
PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1,
PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds)
);
if (CpuMpData->CpuCount == 0) {
TimedWaitForApFinish (
CpuMpData,
PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1,
PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds)
);
}
while (CpuMpData->MpCpuExchangeInfo->NumApsExecuting != 0) {
CpuPause();
}
} else {
//
// Wait all APs waken up if this is not the 1st broadcast of SIPI