mirror of https://github.com/acidanthera/audk.git
UefiCpuPkg: Update CPU MP drivers to support single CPU configuration
Only perform AP detection if PcdCpuMaxLogicalProcessorNumber > 1 Only free AP related structures of they were allocated Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael Kinney <michael.d.kinney@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18629 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
368002a31c
commit
944f45ae2f
|
@ -1642,35 +1642,40 @@ InitializeMpSupport (
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gMaxLogicalProcessorNumber == 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);
|
|
||||||
ASSERT ((gApStackSize & (SIZE_4KB - 1)) == 0);
|
|
||||||
|
|
||||||
mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));
|
|
||||||
ASSERT (mApStackStart != NULL);
|
|
||||||
|
|
||||||
//
|
|
||||||
// the first buffer of stack size used for common stack, when the amount of AP
|
|
||||||
// more than 1, we should never free the common stack which maybe used for AP reset.
|
|
||||||
//
|
|
||||||
mCommonStack = mApStackStart;
|
|
||||||
mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize;
|
|
||||||
mApStackStart = mTopOfApCommonStack;
|
|
||||||
|
|
||||||
InitMpSystemData ();
|
InitMpSystemData ();
|
||||||
|
|
||||||
PrepareAPStartupCode ();
|
//
|
||||||
|
// Only perform AP detection if PcdCpuMaxLogicalProcessorNumber is greater than 1
|
||||||
|
//
|
||||||
|
if (gMaxLogicalProcessorNumber > 1) {
|
||||||
|
|
||||||
StartApsStackless ();
|
gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);
|
||||||
|
ASSERT ((gApStackSize & (SIZE_4KB - 1)) == 0);
|
||||||
|
|
||||||
|
mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));
|
||||||
|
ASSERT (mApStackStart != NULL);
|
||||||
|
|
||||||
|
//
|
||||||
|
// the first buffer of stack size used for common stack, when the amount of AP
|
||||||
|
// more than 1, we should never free the common stack which maybe used for AP reset.
|
||||||
|
//
|
||||||
|
mCommonStack = mApStackStart;
|
||||||
|
mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize;
|
||||||
|
mApStackStart = mTopOfApCommonStack;
|
||||||
|
|
||||||
|
PrepareAPStartupCode ();
|
||||||
|
|
||||||
|
StartApsStackless ();
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mMpSystemData.NumberOfProcessors));
|
DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mMpSystemData.NumberOfProcessors));
|
||||||
if (mMpSystemData.NumberOfProcessors == 1) {
|
if (mMpSystemData.NumberOfProcessors == 1) {
|
||||||
FreeApStartupCode ();
|
FreeApStartupCode ();
|
||||||
FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));
|
if (mCommonStack != NULL) {
|
||||||
return;
|
FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mMpSystemData.CpuDatas = ReallocatePool (
|
mMpSystemData.CpuDatas = ReallocatePool (
|
||||||
|
@ -1692,10 +1697,12 @@ InitializeMpSupport (
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
if (mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {
|
if (mMpSystemData.NumberOfProcessors > 1 && mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {
|
||||||
FreePages (mApStackStart, EFI_SIZE_TO_PAGES (
|
if (mApStackStart != NULL) {
|
||||||
(gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) *
|
FreePages (mApStackStart, EFI_SIZE_TO_PAGES (
|
||||||
gApStackSize));
|
(gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) *
|
||||||
|
gApStackSize));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = gBS->CreateEvent (
|
Status = gBS->CreateEvent (
|
||||||
|
|
|
@ -357,22 +357,28 @@ CountProcessorNumber (
|
||||||
// Store BSP's MTRR setting
|
// Store BSP's MTRR setting
|
||||||
//
|
//
|
||||||
MtrrGetAllMtrrs (&PeiCpuMpData->MtrrTable);
|
MtrrGetAllMtrrs (&PeiCpuMpData->MtrrTable);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Send broadcast IPI to APs to wakeup APs
|
// Only perform AP detection if PcdCpuMaxLogicalProcessorNumber is greater than 1
|
||||||
//
|
//
|
||||||
PeiCpuMpData->InitFlag = 1;
|
if (PcdGet32 (PcdCpuMaxLogicalProcessorNumber) > 1) {
|
||||||
WakeUpAP (PeiCpuMpData, TRUE, 0, NULL, NULL);
|
//
|
||||||
//
|
// Send broadcast IPI to APs to wakeup APs
|
||||||
// Wait for AP task to complete and then exit.
|
//
|
||||||
//
|
PeiCpuMpData->InitFlag = 1;
|
||||||
MicroSecondDelay (PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds));
|
WakeUpAP (PeiCpuMpData, TRUE, 0, NULL, NULL);
|
||||||
PeiCpuMpData->InitFlag = 0;
|
//
|
||||||
PeiCpuMpData->CpuCount += (UINT32) PeiCpuMpData->MpCpuExchangeInfo->NumApsExecuting;
|
// Wait for AP task to complete and then exit.
|
||||||
ASSERT (PeiCpuMpData->CpuCount <= PcdGet32(PcdCpuMaxLogicalProcessorNumber));
|
//
|
||||||
//
|
MicroSecondDelay (PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds));
|
||||||
// Sort BSP/Aps by CPU APIC ID in ascending order
|
PeiCpuMpData->InitFlag = 0;
|
||||||
//
|
PeiCpuMpData->CpuCount += (UINT32)PeiCpuMpData->MpCpuExchangeInfo->NumApsExecuting;
|
||||||
SortApicId (PeiCpuMpData);
|
ASSERT (PeiCpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
|
||||||
|
//
|
||||||
|
// Sort BSP/Aps by CPU APIC ID in ascending order
|
||||||
|
//
|
||||||
|
SortApicId (PeiCpuMpData);
|
||||||
|
}
|
||||||
|
|
||||||
DEBUG ((EFI_D_INFO, "CpuMpPei: Find %d processors in system.\n", PeiCpuMpData->CpuCount));
|
DEBUG ((EFI_D_INFO, "CpuMpPei: Find %d processors in system.\n", PeiCpuMpData->CpuCount));
|
||||||
return PeiCpuMpData->CpuCount;
|
return PeiCpuMpData->CpuCount;
|
||||||
|
|
Loading…
Reference in New Issue