]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: Do not wakeup AP if only one processor supported
authorJeff Fan <jeff.fan@intel.com>
Fri, 4 Nov 2016 07:45:13 +0000 (15:45 +0800)
committerJeff Fan <jeff.fan@intel.com>
Wed, 9 Nov 2016 08:01:13 +0000 (16:01 +0800)
If MaxLogicalProcessorNumber is only 1, we needn't to wake up APs at all
and needn't to register callback functions.

It could improve boot performance on single supported system.

https://bugzilla.tianocore.org/show_bug.cgi?id=204

Cc: Feng Tian <feng.tian@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
UefiCpuPkg/Library/MpInitLib/MpLib.c
UefiCpuPkg/Library/MpInitLib/PeiMpLib.c

index b399f1c24d301158ee79c8245a38ba818c1b6b05..eb36d6f78d972716408378517cc9b8c35e4b089c 100644 (file)
@@ -290,6 +290,13 @@ InitMpGlobalData (
 \r
   SaveCpuMpData (CpuMpData);\r
 \r
+  if (CpuMpData->CpuCount == 1) {\r
+    //\r
+    // If only BSP exists, return\r
+    //\r
+    return;\r
+  }\r
+\r
   //\r
   // Avoid APs access invalid buff data which allocated by BootServices,\r
   // so we will allocate reserved data for AP loop code.\r
index 56b870e52748b42672b086666f73880df7f8af2d..a0edc55f5254b0031cc6ecf97a8bbd4414f66128 100644 (file)
@@ -1143,6 +1143,7 @@ MpInitLibInitialize (
   } else {\r
     MaxLogicalProcessorNumber = OldCpuMpData->CpuCount;\r
   }\r
+  ASSERT (MaxLogicalProcessorNumber != 0);\r
 \r
   AsmGetAddressMap (&AddressMap);\r
   ApResetVectorSize = AddressMap.RendezvousFunnelSize + sizeof (MP_CPU_EXCHANGE_INFO);\r
@@ -1209,10 +1210,12 @@ MpInitLibInitialize (
   MtrrGetAllMtrrs (&CpuMpData->MtrrTable);\r
 \r
   if (OldCpuMpData == NULL) {\r
-    //\r
-    // Wakeup all APs and calculate the processor count in system\r
-    //\r
-    CollectProcessorCount (CpuMpData);\r
+    if (MaxLogicalProcessorNumber > 1) {\r
+      //\r
+      // Wakeup all APs and calculate the processor count in system\r
+      //\r
+      CollectProcessorCount (CpuMpData);\r
+    }\r
   } else {\r
     //\r
     // APs have been wakeup before, just get the CPU Information\r
@@ -1238,19 +1241,21 @@ MpInitLibInitialize (
         sizeof (CPU_VOLATILE_REGISTERS)\r
         );\r
     }\r
-    //\r
-    // Wakeup APs to do some AP initialize sync\r
-    //\r
-    WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData);\r
-    //\r
-    // Wait for all APs finished initialization\r
-    //\r
-    while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) {\r
-      CpuPause ();\r
-    }\r
-    CpuMpData->InitFlag = ApInitDone;\r
-    for (Index = 0; Index < CpuMpData->CpuCount; Index++) {\r
-      SetApState (&CpuMpData->CpuData[Index], CpuStateIdle);\r
+    if (MaxLogicalProcessorNumber > 1) {\r
+      //\r
+      // Wakeup APs to do some AP initialize sync\r
+      //\r
+      WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData);\r
+      //\r
+      // Wait for all APs finished initialization\r
+      //\r
+      while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) {\r
+        CpuPause ();\r
+      }\r
+      CpuMpData->InitFlag = ApInitDone;\r
+      for (Index = 0; Index < CpuMpData->CpuCount; Index++) {\r
+        SetApState (&CpuMpData->CpuData[Index], CpuStateIdle);\r
+      }\r
     }\r
   }\r
 \r
index e242d37b3b3973ca78724c5d2c485191d74b8350..1f2fcb8b1ceaa0ed1ac2c15b75fe85636a042c29 100644 (file)
@@ -321,6 +321,14 @@ InitMpGlobalData (
   EFI_STATUS      Status;\r
 \r
   SaveCpuMpData (CpuMpData);\r
+\r
+  if (CpuMpData->CpuCount == 1) {\r
+    //\r
+    // If only BSP exists, return\r
+    //\r
+    return;\r
+  }\r
+\r
   //\r
   // Register an event for EndOfPei\r
   //\r