summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
37676b9)
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>
Cr3Location equ LockLocation + 34h\r
InitFlagLocation equ LockLocation + 38h\r
CpuInfoLocation equ LockLocation + 3Ch\r
Cr3Location equ LockLocation + 34h\r
InitFlagLocation equ LockLocation + 38h\r
CpuInfoLocation equ LockLocation + 3Ch\r
+NumApsExecutingLocation equ LockLocation + 40h\r
+ ; Increment the number of APs executing here as early as possible\r
+ ; This is decremented in C code when AP is finished executing\r
+ mov edi, esi\r
+ add edi, NumApsExecutingLocation\r
+ lock inc dword [edi]\r
+\r
mov edi, esi\r
add edi, EnableExecuteDisableLocation\r
cmp byte [edi], 0\r
mov edi, esi\r
add edi, EnableExecuteDisableLocation\r
cmp byte [edi], 0\r
// AP finished executing C code\r
//\r
InterlockedIncrement ((UINT32 *) &CpuMpData->FinishedCount);\r
// AP finished executing C code\r
//\r
InterlockedIncrement ((UINT32 *) &CpuMpData->FinishedCount);\r
+ InterlockedDecrement ((UINT32 *) &CpuMpData->MpCpuExchangeInfo->NumApsExecuting);\r
\r
//\r
// Place AP is specified loop mode\r
\r
//\r
// Place AP is specified loop mode\r
\r
ExchangeInfo->CFunction = (UINTN) ApWakeupFunction;\r
ExchangeInfo->ApIndex = 0;\r
\r
ExchangeInfo->CFunction = (UINTN) ApWakeupFunction;\r
ExchangeInfo->ApIndex = 0;\r
+ ExchangeInfo->NumApsExecuting = 0;\r
ExchangeInfo->InitFlag = (UINTN) CpuMpData->InitFlag;\r
ExchangeInfo->CpuInfo = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob;\r
ExchangeInfo->CpuMpData = CpuMpData;\r
ExchangeInfo->InitFlag = (UINTN) CpuMpData->InitFlag;\r
ExchangeInfo->CpuInfo = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob;\r
ExchangeInfo->CpuMpData = CpuMpData;\r
}\r
if (CpuMpData->InitFlag == ApInitConfig) {\r
//\r
}\r
if (CpuMpData->InitFlag == ApInitConfig) {\r
//\r
- // Wait for all potential APs waken up in one specified period\r
+ // Wait for one potential AP waken up in one specified period\r
- TimedWaitForApFinish (\r
- CpuMpData,\r
- PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1,\r
- PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds)\r
- );\r
+ if (CpuMpData->CpuCount == 0) {\r
+ TimedWaitForApFinish (\r
+ CpuMpData,\r
+ PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1,\r
+ PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds)\r
+ );\r
+ }\r
+\r
+ while (CpuMpData->MpCpuExchangeInfo->NumApsExecuting != 0) {\r
+ CpuPause();\r
+ }\r
} else {\r
//\r
// Wait all APs waken up if this is not the 1st broadcast of SIPI\r
} else {\r
//\r
// Wait all APs waken up if this is not the 1st broadcast of SIPI\r
UINTN Cr3;\r
UINTN InitFlag;\r
CPU_INFO_IN_HOB *CpuInfo;\r
UINTN Cr3;\r
UINTN InitFlag;\r
CPU_INFO_IN_HOB *CpuInfo;\r
+ UINTN NumApsExecuting;\r
CPU_MP_DATA *CpuMpData;\r
UINTN InitializeFloatingPointUnitsAddress;\r
} MP_CPU_EXCHANGE_INFO;\r
CPU_MP_DATA *CpuMpData;\r
UINTN InitializeFloatingPointUnitsAddress;\r
} MP_CPU_EXCHANGE_INFO;\r
Cr3Location equ LockLocation + 64h\r
InitFlagLocation equ LockLocation + 6Ch\r
CpuInfoLocation equ LockLocation + 74h\r
Cr3Location equ LockLocation + 64h\r
InitFlagLocation equ LockLocation + 6Ch\r
CpuInfoLocation equ LockLocation + 74h\r
-InitializeFloatingPointUnitsAddress equ LockLocation + 84h\r
+NumApsExecutingLocation equ LockLocation + 7Ch\r
+InitializeFloatingPointUnitsAddress equ LockLocation + 8Ch\r
cmp qword [edi], 1 ; ApInitConfig\r
jnz GetApicId\r
\r
cmp qword [edi], 1 ; ApInitConfig\r
jnz GetApicId\r
\r
+ ; Increment the number of APs executing here as early as possible\r
+ ; This is decremented in C code when AP is finished executing\r
+ mov edi, esi\r
+ add edi, NumApsExecutingLocation\r
+ lock inc dword [edi]\r
+\r
; AP init\r
mov edi, esi\r
add edi, LockLocation\r
; AP init\r
mov edi, esi\r
add edi, LockLocation\r