diff options
author | Michael Kinney <michael.d.kinney@intel.com> | 2015-10-19 19:07:52 +0000 |
---|---|---|
committer | mdkinney <mdkinney@Edk2> | 2015-10-19 19:07:52 +0000 |
commit | 944f45ae2f7ecbff2c66622d15d52ffbc3455bfb (patch) | |
tree | 267d6c89d5d23e402df70f6c9b9522e9a2ba43e5 /UefiCpuPkg | |
parent | 368002a31c7998d8f00f5e77acee14d49afc2b2d (diff) | |
download | edk2-944f45ae2f7ecbff2c66622d15d52ffbc3455bfb.zip edk2-944f45ae2f7ecbff2c66622d15d52ffbc3455bfb.tar.gz edk2-944f45ae2f7ecbff2c66622d15d52ffbc3455bfb.tar.bz2 |
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
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r-- | UefiCpuPkg/CpuDxe/CpuMp.c | 49 | ||||
-rw-r--r-- | UefiCpuPkg/CpuMpPei/CpuMpPei.c | 34 |
2 files changed, 48 insertions, 35 deletions
diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c index 4ddcca2..da3686e 100644 --- a/UefiCpuPkg/CpuDxe/CpuMp.c +++ b/UefiCpuPkg/CpuDxe/CpuMp.c @@ -1642,35 +1642,40 @@ InitializeMpSupport ( 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);
+ InitMpSystemData ();
//
- // 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.
+ // Only perform AP detection if PcdCpuMaxLogicalProcessorNumber is greater than 1
//
- mCommonStack = mApStackStart;
- mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize;
- mApStackStart = mTopOfApCommonStack;
+ if (gMaxLogicalProcessorNumber > 1) {
- InitMpSystemData ();
+ 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 ();
+ PrepareAPStartupCode ();
- StartApsStackless ();
+ StartApsStackless ();
+ }
DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mMpSystemData.NumberOfProcessors));
if (mMpSystemData.NumberOfProcessors == 1) {
FreeApStartupCode ();
- FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));
- return;
+ if (mCommonStack != NULL) {
+ FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));
+ }
}
mMpSystemData.CpuDatas = ReallocatePool (
@@ -1692,10 +1697,12 @@ InitializeMpSupport ( );
ASSERT_EFI_ERROR (Status);
- if (mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {
- FreePages (mApStackStart, EFI_SIZE_TO_PAGES (
- (gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) *
- gApStackSize));
+ if (mMpSystemData.NumberOfProcessors > 1 && mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {
+ if (mApStackStart != NULL) {
+ FreePages (mApStackStart, EFI_SIZE_TO_PAGES (
+ (gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) *
+ gApStackSize));
+ }
}
Status = gBS->CreateEvent (
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c index d5bc0c9..8e35f28 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -357,22 +357,28 @@ CountProcessorNumber ( // Store BSP's MTRR setting
//
MtrrGetAllMtrrs (&PeiCpuMpData->MtrrTable);
+
//
- // Send broadcast IPI to APs to wakeup APs
- //
- PeiCpuMpData->InitFlag = 1;
- WakeUpAP (PeiCpuMpData, TRUE, 0, NULL, NULL);
- //
- // Wait for AP task to complete and then exit.
- //
- MicroSecondDelay (PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds));
- PeiCpuMpData->InitFlag = 0;
- PeiCpuMpData->CpuCount += (UINT32) PeiCpuMpData->MpCpuExchangeInfo->NumApsExecuting;
- ASSERT (PeiCpuMpData->CpuCount <= PcdGet32(PcdCpuMaxLogicalProcessorNumber));
- //
- // Sort BSP/Aps by CPU APIC ID in ascending order
+ // Only perform AP detection if PcdCpuMaxLogicalProcessorNumber is greater than 1
//
- SortApicId (PeiCpuMpData);
+ if (PcdGet32 (PcdCpuMaxLogicalProcessorNumber) > 1) {
+ //
+ // Send broadcast IPI to APs to wakeup APs
+ //
+ PeiCpuMpData->InitFlag = 1;
+ WakeUpAP (PeiCpuMpData, TRUE, 0, NULL, NULL);
+ //
+ // Wait for AP task to complete and then exit.
+ //
+ MicroSecondDelay (PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds));
+ PeiCpuMpData->InitFlag = 0;
+ PeiCpuMpData->CpuCount += (UINT32)PeiCpuMpData->MpCpuExchangeInfo->NumApsExecuting;
+ 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));
return PeiCpuMpData->CpuCount;
|