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:
Michael Kinney 2015-10-19 19:07:52 +00:00 committed by mdkinney
parent 368002a31c
commit 944f45ae2f
2 changed files with 51 additions and 38 deletions

View File

@ -1642,9 +1642,14 @@ InitializeMpSupport (
return;
}
if (gMaxLogicalProcessorNumber == 1) {
return;
}
InitMpSystemData ();
//
// Only perform AP detection if PcdCpuMaxLogicalProcessorNumber is greater than 1
//
if (gMaxLogicalProcessorNumber > 1) {
gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);
ASSERT ((gApStackSize & (SIZE_4KB - 1)) == 0);
@ -1660,17 +1665,17 @@ InitializeMpSupport (
mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize;
mApStackStart = mTopOfApCommonStack;
InitMpSystemData ();
PrepareAPStartupCode ();
StartApsStackless ();
}
DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mMpSystemData.NumberOfProcessors));
if (mMpSystemData.NumberOfProcessors == 1) {
FreeApStartupCode ();
if (mCommonStack != NULL) {
FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));
return;
}
}
mMpSystemData.CpuDatas = ReallocatePool (
@ -1692,11 +1697,13 @@ InitializeMpSupport (
);
ASSERT_EFI_ERROR (Status);
if (mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {
if (mMpSystemData.NumberOfProcessors > 1 && mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {
if (mApStackStart != NULL) {
FreePages (mApStackStart, EFI_SIZE_TO_PAGES (
(gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) *
gApStackSize));
}
}
Status = gBS->CreateEvent (
EVT_SIGNAL_EXIT_BOOT_SERVICES,

View File

@ -357,6 +357,11 @@ CountProcessorNumber (
// Store BSP's MTRR setting
//
MtrrGetAllMtrrs (&PeiCpuMpData->MtrrTable);
//
// Only perform AP detection if PcdCpuMaxLogicalProcessorNumber is greater than 1
//
if (PcdGet32 (PcdCpuMaxLogicalProcessorNumber) > 1) {
//
// Send broadcast IPI to APs to wakeup APs
//
@ -373,6 +378,7 @@ CountProcessorNumber (
// 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));
return PeiCpuMpData->CpuCount;