summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/CpuDxe/CpuMp.c
diff options
context:
space:
mode:
authorChen Fan <chen.fan.fnst@cn.fujitsu.com>2014-11-13 18:29:13 +0000
committerjljusten <jljusten@Edk2>2014-11-13 18:29:13 +0000
commitac9dbb3b03313c7426c5bb15663b20b57ca771ce (patch)
treeb0508860d80959af572753abd09e7a86802b51a5 /UefiCpuPkg/CpuDxe/CpuMp.c
parentfe078dd57f5e935c28eac7348b758ca6fb5e696f (diff)
downloadedk2-ac9dbb3b03313c7426c5bb15663b20b57ca771ce.tar.gz
edk2-ac9dbb3b03313c7426c5bb15663b20b57ca771ce.tar.bz2
edk2-ac9dbb3b03313c7426c5bb15663b20b57ca771ce.zip
UefiCpuPkg/CpuDxe: introduce ResetApStackless()
If timeout expires before AP returns from Procedure, the AP should be terminated, we introduce ResetApStackLess() to send init IPI to let AP exit Procedurce and re-available. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16366 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'UefiCpuPkg/CpuDxe/CpuMp.c')
-rw-r--r--UefiCpuPkg/CpuDxe/CpuMp.c36
1 files changed, 31 insertions, 5 deletions
diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c
index 029e8d4331..13fcda5859 100644
--- a/UefiCpuPkg/CpuDxe/CpuMp.c
+++ b/UefiCpuPkg/CpuDxe/CpuMp.c
@@ -25,6 +25,7 @@ VOID *mCommonStack = 0;
VOID *mTopOfApCommonStack = 0;
VOID *mApStackStart = 0;
+BOOLEAN mAPsAlreadyInitFinished = FALSE;
volatile BOOLEAN mStopCheckAllAPsStatus = TRUE;
EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {
@@ -1112,6 +1113,7 @@ ResetProcessorToIdleState (
IN CPU_DATA_BLOCK *CpuData
)
{
+ ResetApStackless ((UINT32)CpuData->Info.ProcessorId);
}
/**
@@ -1138,6 +1140,14 @@ ProcessorToIdleState (
AsmApDoneWithCommonStack ();
+ //
+ // Avoid forcibly reset AP caused the AP State is not updated.
+ //
+ GetMpSpinLock (CpuData);
+ CpuData->State = CpuStateIdle;
+ CpuData->Procedure = NULL;
+ ReleaseMpSpinLock (CpuData);
+
while (TRUE) {
GetMpSpinLock (CpuData);
ProcedureArgument = CpuData->Parameter;
@@ -1319,13 +1329,27 @@ ApEntryPointInC (
VOID
)
{
- VOID* TopOfApStack;
+ VOID* TopOfApStack;
+ UINTN ProcessorNumber;
- FillInProcessorInformation (FALSE, mMpSystemData.NumberOfProcessors);
- TopOfApStack = (UINT8*)mApStackStart + gApStackSize;
- mApStackStart = TopOfApStack;
+ if (!mAPsAlreadyInitFinished) {
+ FillInProcessorInformation (FALSE, mMpSystemData.NumberOfProcessors);
+ TopOfApStack = (UINT8*)mApStackStart + gApStackSize;
+ mApStackStart = TopOfApStack;
- mMpSystemData.NumberOfProcessors++;
+ //
+ // Store the Stack address, when reset the AP, We can found the original address.
+ //
+ mMpSystemData.CpuDatas[mMpSystemData.NumberOfProcessors].TopOfStack = TopOfApStack;
+ mMpSystemData.NumberOfProcessors++;
+ mMpSystemData.NumberOfEnabledProcessors++;
+ } else {
+ WhoAmI (&mMpServicesTemplate, &ProcessorNumber);
+ //
+ // Get the original stack address.
+ //
+ TopOfApStack = mMpSystemData.CpuDatas[ProcessorNumber].TopOfStack;
+ }
SwitchStack (
(SWITCH_STACK_ENTRY_POINT)(UINTN)ProcessorToIdleState,
@@ -1462,6 +1486,8 @@ InitializeMpSupport (
return;
}
+ mAPsAlreadyInitFinished = TRUE;
+
if (mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {
FreePages (mApStackStart, EFI_SIZE_TO_PAGES (
(gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) *