]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/PiSmmCpuDxeSmm: Combine INIT-SIPI-SIPI.
authorEric Dong <eric.dong@intel.com>
Thu, 28 Sep 2017 08:57:35 +0000 (16:57 +0800)
committerEric Dong <eric.dong@intel.com>
Fri, 29 Sep 2017 01:54:09 +0000 (09:54 +0800)
In S3 resume path, current implementation do 2 separate INIT-SIPI-SIPI,
this is not necessary. This change combine these 2 INIT-SIPI-SIPI to 1
and add CpuPause between them.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c

index 940450149810d3dbebea356f8eab31d5ceb8422e..ae4b5162eb2f69778a64139760d20843f7b891da 100644 (file)
@@ -39,6 +39,11 @@ typedef struct {
 //\r
 SPIN_LOCK                *mMemoryMappedLock = NULL;\r
 \r
+//\r
+// Signal that SMM BASE relocation is complete.\r
+//\r
+volatile BOOLEAN         mInitApsAfterSmmBaseReloc;\r
+\r
 /**\r
   Get starting address and size of the rendezvous entry for APs.\r
   Information for fixing a jump instruction in the code is also returned.\r
@@ -342,17 +347,21 @@ SetProcessorRegister (
   }\r
 }\r
 \r
+\r
+\r
 /**\r
-  AP initialization before SMBASE relocation in the S3 boot path.\r
+  AP initialization before then after SMBASE relocation in the S3 boot path.\r
 **/\r
 VOID\r
-EarlyMPRendezvousProcedure (\r
+MPRendezvousProcedure (\r
   VOID\r
   )\r
 {\r
   CPU_REGISTER_TABLE         *RegisterTableList;\r
   UINT32                     InitApicId;\r
   UINTN                      Index;\r
+  UINTN                      TopOfStack;\r
+  UINT8                      Stack[128];\r
 \r
   LoadMtrrData (mAcpiCpuData.MtrrTable);\r
 \r
@@ -368,25 +377,18 @@ EarlyMPRendezvousProcedure (
     }\r
   }\r
 \r
+\r
   //\r
   // Count down the number with lock mechanism.\r
   //\r
   InterlockedDecrement (&mNumberToFinish);\r
-}\r
 \r
-/**\r
-  AP initialization after SMBASE relocation in the S3 boot path.\r
-**/\r
-VOID\r
-MPRendezvousProcedure (\r
-  VOID\r
-  )\r
-{\r
-  CPU_REGISTER_TABLE         *RegisterTableList;\r
-  UINT32                     InitApicId;\r
-  UINTN                      Index;\r
-  UINTN                      TopOfStack;\r
-  UINT8                      Stack[128];\r
+  //\r
+  // Wait for BSP to signal SMM Base relocation done.\r
+  //\r
+  while (!mInitApsAfterSmmBaseReloc) {\r
+    CpuPause ();\r
+  }\r
 \r
   ProgramVirtualWireMode ();\r
   DisableLvtInterrupts ();\r
@@ -500,7 +502,12 @@ EarlyInitializeCpu (
   PrepareApStartupVector (mAcpiCpuData.StartupVector);\r
 \r
   mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1;\r
-  mExchangeInfo->ApFunction  = (VOID *) (UINTN) EarlyMPRendezvousProcedure;\r
+  mExchangeInfo->ApFunction  = (VOID *) (UINTN) MPRendezvousProcedure;\r
+\r
+  //\r
+  // Execute code for before SmmBaseReloc. Note: This flag is maintained across S3 boots.\r
+  //\r
+  mInitApsAfterSmmBaseReloc = FALSE;\r
 \r
   //\r
   // Send INIT IPI - SIPI to all APs\r
@@ -538,17 +545,11 @@ InitializeCpu (
   }\r
 \r
   mNumberToFinish = mAcpiCpuData.NumberOfCpus - 1;\r
-  //\r
-  // StackStart was updated when APs were waken up in EarlyInitializeCpu.\r
-  // Re-initialize StackAddress to original beginning address.\r
-  //\r
-  mExchangeInfo->StackStart  = (VOID *) (UINTN) mAcpiCpuData.StackAddress;\r
-  mExchangeInfo->ApFunction  = (VOID *) (UINTN) MPRendezvousProcedure;\r
 \r
   //\r
-  // Send INIT IPI - SIPI to all APs\r
+  // Signal that SMM base relocation is complete and to continue initialization.\r
   //\r
-  SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);\r
+  mInitApsAfterSmmBaseReloc = TRUE;\r
 \r
   while (mNumberToFinish > 0) {\r
     CpuPause ();\r