mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
fe078dd57f
commit
ac9dbb3b03
|
@ -328,3 +328,20 @@ StartApsStackless (
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets the Application Processor and directs it to jump to the
|
||||||
|
specified routine.
|
||||||
|
|
||||||
|
The processor jumps to this code in flat mode, but the processor's
|
||||||
|
stack is not initialized.
|
||||||
|
|
||||||
|
@param ProcessorId the AP of ProcessorId was reset
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
ResetApStackless (
|
||||||
|
IN UINT32 ProcessorId
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SendInitSipiSipi (ProcessorId,
|
||||||
|
(UINT32)(UINTN)(VOID*) StartupCode);
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ VOID *mCommonStack = 0;
|
||||||
VOID *mTopOfApCommonStack = 0;
|
VOID *mTopOfApCommonStack = 0;
|
||||||
VOID *mApStackStart = 0;
|
VOID *mApStackStart = 0;
|
||||||
|
|
||||||
|
BOOLEAN mAPsAlreadyInitFinished = FALSE;
|
||||||
volatile BOOLEAN mStopCheckAllAPsStatus = TRUE;
|
volatile BOOLEAN mStopCheckAllAPsStatus = TRUE;
|
||||||
|
|
||||||
EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {
|
EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {
|
||||||
|
@ -1112,6 +1113,7 @@ ResetProcessorToIdleState (
|
||||||
IN CPU_DATA_BLOCK *CpuData
|
IN CPU_DATA_BLOCK *CpuData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
ResetApStackless ((UINT32)CpuData->Info.ProcessorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1138,6 +1140,14 @@ ProcessorToIdleState (
|
||||||
|
|
||||||
AsmApDoneWithCommonStack ();
|
AsmApDoneWithCommonStack ();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Avoid forcibly reset AP caused the AP State is not updated.
|
||||||
|
//
|
||||||
|
GetMpSpinLock (CpuData);
|
||||||
|
CpuData->State = CpuStateIdle;
|
||||||
|
CpuData->Procedure = NULL;
|
||||||
|
ReleaseMpSpinLock (CpuData);
|
||||||
|
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
GetMpSpinLock (CpuData);
|
GetMpSpinLock (CpuData);
|
||||||
ProcedureArgument = CpuData->Parameter;
|
ProcedureArgument = CpuData->Parameter;
|
||||||
|
@ -1320,12 +1330,26 @@ ApEntryPointInC (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VOID* TopOfApStack;
|
VOID* TopOfApStack;
|
||||||
|
UINTN ProcessorNumber;
|
||||||
|
|
||||||
|
if (!mAPsAlreadyInitFinished) {
|
||||||
FillInProcessorInformation (FALSE, mMpSystemData.NumberOfProcessors);
|
FillInProcessorInformation (FALSE, mMpSystemData.NumberOfProcessors);
|
||||||
TopOfApStack = (UINT8*)mApStackStart + gApStackSize;
|
TopOfApStack = (UINT8*)mApStackStart + gApStackSize;
|
||||||
mApStackStart = TopOfApStack;
|
mApStackStart = TopOfApStack;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Store the Stack address, when reset the AP, We can found the original address.
|
||||||
|
//
|
||||||
|
mMpSystemData.CpuDatas[mMpSystemData.NumberOfProcessors].TopOfStack = TopOfApStack;
|
||||||
mMpSystemData.NumberOfProcessors++;
|
mMpSystemData.NumberOfProcessors++;
|
||||||
|
mMpSystemData.NumberOfEnabledProcessors++;
|
||||||
|
} else {
|
||||||
|
WhoAmI (&mMpServicesTemplate, &ProcessorNumber);
|
||||||
|
//
|
||||||
|
// Get the original stack address.
|
||||||
|
//
|
||||||
|
TopOfApStack = mMpSystemData.CpuDatas[ProcessorNumber].TopOfStack;
|
||||||
|
}
|
||||||
|
|
||||||
SwitchStack (
|
SwitchStack (
|
||||||
(SWITCH_STACK_ENTRY_POINT)(UINTN)ProcessorToIdleState,
|
(SWITCH_STACK_ENTRY_POINT)(UINTN)ProcessorToIdleState,
|
||||||
|
@ -1462,6 +1486,8 @@ InitializeMpSupport (
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mAPsAlreadyInitFinished = TRUE;
|
||||||
|
|
||||||
if (mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {
|
if (mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {
|
||||||
FreePages (mApStackStart, EFI_SIZE_TO_PAGES (
|
FreePages (mApStackStart, EFI_SIZE_TO_PAGES (
|
||||||
(gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) *
|
(gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) *
|
||||||
|
|
|
@ -99,6 +99,7 @@ typedef struct {
|
||||||
EFI_EVENT WaitEvent;
|
EFI_EVENT WaitEvent;
|
||||||
BOOLEAN TimeoutActive;
|
BOOLEAN TimeoutActive;
|
||||||
EFI_EVENT CheckThisAPEvent;
|
EFI_EVENT CheckThisAPEvent;
|
||||||
|
VOID *TopOfStack;
|
||||||
} CPU_DATA_BLOCK;
|
} CPU_DATA_BLOCK;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -622,5 +623,19 @@ FreeApStartupCode (
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets the Application Processor and directs it to jump to the
|
||||||
|
specified routine.
|
||||||
|
|
||||||
|
The processor jumps to this code in flat mode, but the processor's
|
||||||
|
stack is not initialized.
|
||||||
|
|
||||||
|
@param ProcessorId the AP of ProcessorId was reset
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
ResetApStackless (
|
||||||
|
IN UINT32 ProcessorId
|
||||||
|
);
|
||||||
|
|
||||||
#endif // _CPU_MP_H_
|
#endif // _CPU_MP_H_
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue