From: "Yuanhao Xie" <yuanhao.xie@intel.com>
To: devel@edk2.groups.io
Cc: Gerd Hoffmann <kraxel@redhat.com>,
Eric Dong <eric.dong@intel.com>, Ray Ni <ray.ni@intel.com>,
Rahul Kumar <rahul1.kumar@intel.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Yuanhao Xie <yuanhao.xie@intel.com>
Subject: [Patch V3 2/5] UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop.
Date: Mon, 26 Jun 2023 13:57:02 +0800 [thread overview]
Message-ID: <20230626055705.57145-3-yuanhao.xie@intel.com> (raw)
In-Reply-To: <20230626055705.57145-1-yuanhao.xie@intel.com>
Refactor the logic for placing APs in
Mwait/Runloop into a separate function.
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
---
UefiCpuPkg/Library/MpInitLib/MpLib.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 50 insertions(+), 33 deletions(-)
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 9560b39220..e8dd640f9b 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -658,6 +658,54 @@ PlaceAPInHltLoop (
}
}
+/**
+ This function place APs in Mwait or Run loop.
+
+ @param[in] ApLoopMode Ap Loop Mode
+ @param[in] ApStartupSignalBuffer Pointer to Ap Startup Signal Buffer
+ @param[in] ApTargetCState Ap Target CState
+**/
+VOID
+PlaceAPInMwaitLoopOrRunLoop (
+ IN UINT8 ApLoopMode,
+ IN volatile UINT32 *ApStartupSignalBuffer,
+ IN UINT8 ApTargetCState
+ )
+{
+ while (TRUE) {
+ DisableInterrupts ();
+ if (ApLoopMode == ApInMwaitLoop) {
+ //
+ // Place AP in MWAIT-loop
+ //
+ AsmMonitor ((UINTN)ApStartupSignalBuffer, 0, 0);
+ if (*ApStartupSignalBuffer != WAKEUP_AP_SIGNAL) {
+ //
+ // Check AP start-up signal again.
+ // If AP start-up signal is not set, place AP into
+ // the specified C-state
+ //
+ AsmMwait (ApTargetCState << 4, 0);
+ }
+ } else if (ApLoopMode == ApInRunLoop) {
+ //
+ // Place AP in Run-loop
+ //
+ CpuPause ();
+ } else {
+ ASSERT (FALSE);
+ }
+
+ //
+ // If AP start-up signal is written, AP is waken up
+ // otherwise place AP in loop again
+ //
+ if (*ApStartupSignalBuffer == WAKEUP_AP_SIGNAL) {
+ break;
+ }
+ }
+}
+
/**
This function will be called from AP reset code if BSP uses WakeUpAP.
@@ -838,39 +886,8 @@ ApWakeupFunction (
//
// Never run here
//
- }
-
- while (TRUE) {
- DisableInterrupts ();
- if (CpuMpData->ApLoopMode == ApInMwaitLoop) {
- //
- // Place AP in MWAIT-loop
- //
- AsmMonitor ((UINTN)ApStartupSignalBuffer, 0, 0);
- if (*ApStartupSignalBuffer != WAKEUP_AP_SIGNAL) {
- //
- // Check AP start-up signal again.
- // If AP start-up signal is not set, place AP into
- // the specified C-state
- //
- AsmMwait (CpuMpData->ApTargetCState << 4, 0);
- }
- } else if (CpuMpData->ApLoopMode == ApInRunLoop) {
- //
- // Place AP in Run-loop
- //
- CpuPause ();
- } else {
- ASSERT (FALSE);
- }
-
- //
- // If AP start-up signal is written, AP is waken up
- // otherwise place AP in loop again
- //
- if (*ApStartupSignalBuffer == WAKEUP_AP_SIGNAL) {
- break;
- }
+ } else {
+ PlaceAPInMwaitLoopOrRunLoop (CpuMpData->ApLoopMode, ApStartupSignalBuffer, CpuMpData->ApTargetCState);
}
}
}
--
2.36.1.windows.1
next prev parent reply other threads:[~2023-06-26 5:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-26 5:57 [Patch V3 0/5] Eliminate the second INIT-SIPI-SIPI sequence Yuanhao Xie
2023-06-26 5:57 ` [Patch V3 1/5] UefiCpuPkg: Refactor the logic for placing APs in HltLoop Yuanhao Xie
2023-06-26 9:10 ` Ni, Ray
2023-06-26 5:57 ` Yuanhao Xie [this message]
2023-06-26 9:10 ` [Patch V3 2/5] UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop Ni, Ray
2023-06-26 5:57 ` [Patch V3 3/5] UefiCpuPkg: Create MpHandOff Yuanhao Xie
2023-06-26 9:28 ` Ni, Ray
2023-06-28 8:57 ` Yuanhao Xie
2023-06-26 5:57 ` [Patch V3 4/5] UefiCpuPkg: ApWakeupFunction directly use CpuMpData Yuanhao Xie
2023-06-26 9:36 ` Ni, Ray
2023-06-26 5:57 ` [Patch V3 5/5] UefiCpuPkg: Eliminate the second INIT-SIPI-SIPI sequence Yuanhao Xie
2023-06-27 5:51 ` Ni, Ray
2023-06-28 8:52 ` Yuanhao Xie
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=20230626055705.57145-3-yuanhao.xie@intel.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