public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: "Tan, Dun" <dun.tan@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Dong, Eric" <eric.dong@intel.com>,
	"Kumar, Rahul R" <rahul.r.kumar@intel.com>
Subject: Re: [edk2-devel] [Patch V3 5/5] UefiCpuPkg/PiSmmCpuDxe: use MpService2Ppi to wakeup AP in s3
Date: Wed, 6 Sep 2023 05:19:12 +0000	[thread overview]
Message-ID: <MN6PR11MB824447ED71D5C398398B18278CEFA@MN6PR11MB8244.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20230830073418.586-3-dun.tan@intel.com>

[-- Attachment #1: Type: text/plain, Size: 4615 bytes --]

Reviewed-by: Ray Ni <ray.ni@intel.com>



Thanks,
Ray
________________________________
From: Tan, Dun <dun.tan@intel.com>
Sent: Wednesday, August 30, 2023 3:34 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Kumar, Rahul R <rahul.r.kumar@intel.com>
Subject: [Patch V3 5/5] UefiCpuPkg/PiSmmCpuDxe: use MpService2Ppi to wakeup AP in s3

Use MpService2Ppi to wakeup AP in s3 boot flow during initializing
CPU. If mSmmS3ResumeState->MpService2Ppi is not 0, then BSP will
use MpService2Ppi->StartupAllCPUs to do CPU initialization for both
BSP and AP instead of only sending InitSipiSipi for AP.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 58 +++++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 35 insertions(+), 23 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
index b9dbeaef87..0bae0e33f1 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c
@@ -7,6 +7,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 **/

 #include "PiSmmCpuDxeSmm.h"
+#include <PiPei.h>
+#include <Ppi/MpServices2.h>

 #pragma pack(1)
 typedef struct {
@@ -594,18 +596,21 @@ InitializeCpuAfterRebase (
   UINT8  Stack[128];

   SetRegister (FALSE);
-  if (IsBsp) {
-    while (mNumberToFinish > 0) {
-      CpuPause ();
+
+  if (mSmmS3ResumeState->MpService2Ppi == 0) {
+    if (IsBsp) {
+      while (mNumberToFinish > 0) {
+        CpuPause ();
+      }
+    } else {
+      //
+      // Place AP into the safe code, count down the number with lock mechanism in the safe code.
+      //
+      TopOfStack  = (UINTN)Stack + sizeof (Stack);
+      TopOfStack &= ~(UINTN)(CPU_STACK_ALIGNMENT - 1);
+      CopyMem ((VOID *)(UINTN)mApHltLoopCode, mApHltLoopCodeTemplate, sizeof (mApHltLoopCodeTemplate));
+      TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)&mNumberToFinish);
     }
-  } else {
-    //
-    // Place AP into the safe code, count down the number with lock mechanism in the safe code.
-    //
-    TopOfStack  = (UINTN)Stack + sizeof (Stack);
-    TopOfStack &= ~(UINTN)(CPU_STACK_ALIGNMENT - 1);
-    CopyMem ((VOID *)(UINTN)mApHltLoopCode, mApHltLoopCodeTemplate, sizeof (mApHltLoopCodeTemplate));
-    TransferApToSafeState ((UINTN)mApHltLoopCode, TopOfStack, (UINTN)&mNumberToFinish);
   }
 }

@@ -783,11 +788,12 @@ SmmRestoreCpu (
   VOID
   )
 {
-  SMM_S3_RESUME_STATE       *SmmS3ResumeState;
-  IA32_DESCRIPTOR           Ia32Idtr;
-  IA32_DESCRIPTOR           X64Idtr;
-  IA32_IDT_GATE_DESCRIPTOR  IdtEntryTable[EXCEPTION_VECTOR_NUMBER];
-  EFI_STATUS                Status;
+  SMM_S3_RESUME_STATE         *SmmS3ResumeState;
+  IA32_DESCRIPTOR             Ia32Idtr;
+  IA32_DESCRIPTOR             X64Idtr;
+  IA32_IDT_GATE_DESCRIPTOR    IdtEntryTable[EXCEPTION_VECTOR_NUMBER];
+  EFI_STATUS                  Status;
+  EDKII_PEI_MP_SERVICES2_PPI  *Mp2ServicePpi;

   DEBUG ((DEBUG_INFO, "SmmRestoreCpu()\n"));

@@ -852,15 +858,21 @@ SmmRestoreCpu (
     //
     mInitApsAfterSmmBaseReloc = FALSE;

-    PrepareApStartupVector (mAcpiCpuData.StartupVector);
-    //
-    // Send INIT IPI - SIPI to all APs
-    //
-    SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
+    if (mSmmS3ResumeState->MpService2Ppi != 0) {
+      Mp2ServicePpi = (EDKII_PEI_MP_SERVICES2_PPI *)(UINTN)mSmmS3ResumeState->MpService2Ppi;
+      Mp2ServicePpi->StartupAllCPUs (Mp2ServicePpi, InitializeCpuProcedure, 0, NULL);
+    } else {
+      PrepareApStartupVector (mAcpiCpuData.StartupVector);
+      //
+      // Send INIT IPI - SIPI to all APs
+      //
+      SendInitSipiSipiAllExcludingSelf ((UINT32)mAcpiCpuData.StartupVector);
+      InitializeCpuProcedure (NULL);
+    }
+  } else {
+    InitializeCpuProcedure (NULL);
   }

-  InitializeCpuProcedure (NULL);
-
   //
   // Set a flag to restore SMM configuration in S3 path.
   //
--
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108304): https://edk2.groups.io/g/devel/message/108304
Mute This Topic: https://groups.io/mt/101047983/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



[-- Attachment #2: Type: text/html, Size: 8680 bytes --]

      reply	other threads:[~2023-09-06  5:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30  7:34 [edk2-devel] [Patch V3 0/5] Use MpService2Ppi to wakeup CPU in Smm CpuS3 duntan
2023-08-30  7:34 ` [edk2-devel] [Patch V3 4/5] UefiCpuPkg/PiSmmCpuDxe: code refinement for CpuS3.c duntan
2023-09-06  5:19   ` Ni, Ray
2023-08-30  7:34 ` [edk2-devel] [Patch V3 5/5] UefiCpuPkg/PiSmmCpuDxe: use MpService2Ppi to wakeup AP in s3 duntan
2023-09-06  5:19   ` Ni, Ray [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MN6PR11MB824447ED71D5C398398B18278CEFA@MN6PR11MB8244.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox