]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg: Update CPU MP drivers to support single CPU configuration
authorMichael Kinney <michael.d.kinney@intel.com>
Mon, 19 Oct 2015 19:07:52 +0000 (19:07 +0000)
committermdkinney <mdkinney@Edk2>
Mon, 19 Oct 2015 19:07:52 +0000 (19:07 +0000)
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

UefiCpuPkg/CpuDxe/CpuMp.c
UefiCpuPkg/CpuMpPei/CpuMpPei.c

index 4ddcca208a36cf7f82ff89764f8f4b22fe034228..da3686e2788e8c50f0652bd743a3a010c42e5a2e 100644 (file)
@@ -1642,35 +1642,40 @@ InitializeMpSupport (
     return;\r
   }\r
 \r
-  if (gMaxLogicalProcessorNumber == 1) {\r
-    return;\r
-  }\r
 \r
-  gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);\r
-  ASSERT ((gApStackSize & (SIZE_4KB - 1)) == 0);\r
 \r
-  mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r
-  ASSERT (mApStackStart != NULL);\r
+  InitMpSystemData ();\r
 \r
   //\r
-  // the first buffer of stack size used for common stack, when the amount of AP\r
-  // more than 1, we should never free the common stack which maybe used for AP reset.\r
+  // Only perform AP detection if PcdCpuMaxLogicalProcessorNumber is greater than 1\r
   //\r
-  mCommonStack = mApStackStart;\r
-  mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize;\r
-  mApStackStart = mTopOfApCommonStack;\r
+  if (gMaxLogicalProcessorNumber > 1) {\r
 \r
-  InitMpSystemData ();\r
+    gApStackSize = (UINTN) PcdGet32 (PcdCpuApStackSize);\r
+    ASSERT ((gApStackSize & (SIZE_4KB - 1)) == 0);\r
+\r
+    mApStackStart = AllocatePages (EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r
+    ASSERT (mApStackStart != NULL);\r
+\r
+    //\r
+    // the first buffer of stack size used for common stack, when the amount of AP\r
+    // more than 1, we should never free the common stack which maybe used for AP reset.\r
+    //\r
+    mCommonStack = mApStackStart;\r
+    mTopOfApCommonStack = (UINT8*) mApStackStart + gApStackSize;\r
+    mApStackStart = mTopOfApCommonStack;\r
 \r
-  PrepareAPStartupCode ();\r
+    PrepareAPStartupCode ();\r
 \r
-  StartApsStackless ();\r
+    StartApsStackless ();\r
+  }\r
 \r
   DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mMpSystemData.NumberOfProcessors));\r
   if (mMpSystemData.NumberOfProcessors == 1) {\r
     FreeApStartupCode ();\r
-    FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r
-    return;\r
+    if (mCommonStack != NULL) {\r
+      FreePages (mCommonStack, EFI_SIZE_TO_PAGES (gMaxLogicalProcessorNumber * gApStackSize));\r
+    }\r
   }\r
 \r
   mMpSystemData.CpuDatas = ReallocatePool (\r
@@ -1692,10 +1697,12 @@ InitializeMpSupport (
                   );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  if (mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {\r
-    FreePages (mApStackStart, EFI_SIZE_TO_PAGES (\r
-                                (gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) *\r
-                                gApStackSize));\r
+  if (mMpSystemData.NumberOfProcessors > 1 && mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) {\r
+    if (mApStackStart != NULL) {\r
+      FreePages (mApStackStart, EFI_SIZE_TO_PAGES (\r
+                                  (gMaxLogicalProcessorNumber - mMpSystemData.NumberOfProcessors) *\r
+                                  gApStackSize));\r
+    }\r
   }\r
 \r
   Status = gBS->CreateEvent (\r
index d5bc0c9b806af5672826c648c34dc580887081b1..8e35f288fe3c64fd235a84658a851671f6317029 100644 (file)
@@ -357,22 +357,28 @@ CountProcessorNumber (
   // Store BSP's MTRR setting\r
   //\r
   MtrrGetAllMtrrs (&PeiCpuMpData->MtrrTable);\r
+\r
   //\r
-  // Send broadcast IPI to APs to wakeup APs\r
-  //\r
-  PeiCpuMpData->InitFlag = 1;\r
-  WakeUpAP (PeiCpuMpData, TRUE, 0, NULL, NULL);\r
-  //\r
-  // Wait for AP task to complete and then exit.\r
-  //\r
-  MicroSecondDelay (PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds));\r
-  PeiCpuMpData->InitFlag  = 0;\r
-  PeiCpuMpData->CpuCount += (UINT32) PeiCpuMpData->MpCpuExchangeInfo->NumApsExecuting;\r
-  ASSERT (PeiCpuMpData->CpuCount <= PcdGet32(PcdCpuMaxLogicalProcessorNumber));\r
-  //\r
-  // Sort BSP/Aps by CPU APIC ID in ascending order\r
+  // Only perform AP detection if PcdCpuMaxLogicalProcessorNumber is greater than 1\r
   //\r
-  SortApicId (PeiCpuMpData);\r
+  if (PcdGet32 (PcdCpuMaxLogicalProcessorNumber) > 1) {\r
+    //\r
+    // Send broadcast IPI to APs to wakeup APs\r
+    //\r
+    PeiCpuMpData->InitFlag = 1;\r
+    WakeUpAP (PeiCpuMpData, TRUE, 0, NULL, NULL);\r
+    //\r
+    // Wait for AP task to complete and then exit.\r
+    //\r
+    MicroSecondDelay (PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds));\r
+    PeiCpuMpData->InitFlag = 0;\r
+    PeiCpuMpData->CpuCount += (UINT32)PeiCpuMpData->MpCpuExchangeInfo->NumApsExecuting;\r
+    ASSERT (PeiCpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));\r
+    //\r
+    // Sort BSP/Aps by CPU APIC ID in ascending order\r
+    //\r
+    SortApicId (PeiCpuMpData);\r
+  }\r
 \r
   DEBUG ((EFI_D_INFO, "CpuMpPei: Find %d processors in system.\n", PeiCpuMpData->CpuCount));\r
   return PeiCpuMpData->CpuCount;\r