From: Eric Dong <eric.dong@intel.com>
To: edk2-devel@lists.01.org
Cc: Ruiyu Ni <ruiyu.ni@intel.com>, Laszlo Ersek <lersek@redhat.com>
Subject: [Patch 2/3] UefiCpuPkg/RegisterCpuFeaturesLib: Avoid AP calls PeiService.
Date: Thu, 20 Dec 2018 09:15:52 +0800 [thread overview]
Message-ID: <20181220011553.14900-3-eric.dong@intel.com> (raw)
In-Reply-To: <20181220011553.14900-1-eric.dong@intel.com>
GetProcessorIndex function calls GetMpPpi to get the MP Ppi.
Ap will calls GetProcessorIndex function which final let AP
calls PeiService.
This patch avoid GetProcessorIndex call PeiService.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1411
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
.../RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 2 +-
.../DxeRegisterCpuFeaturesLib.c | 6 ++++--
.../PeiRegisterCpuFeaturesLib.c | 21 ++++++++++++++++-----
.../RegisterCpuFeaturesLib/RegisterCpuFeatures.h | 6 +++++-
4 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
index a64326239f..81f4652a03 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
@@ -409,7 +409,7 @@ CollectProcessorData (
CPU_FEATURES_DATA *CpuFeaturesData;
CpuFeaturesData = (CPU_FEATURES_DATA *)Buffer;
- ProcessorNumber = GetProcessorIndex ();
+ ProcessorNumber = GetProcessorIndex (CpuFeaturesData);
CpuInfo = &CpuFeaturesData->InitOrder[ProcessorNumber].CpuInfo;
//
// collect processor information
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
index 926698dc95..6f3e5bd2a8 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
@@ -66,11 +66,13 @@ GetMpProtocol (
/**
Worker function to return processor index.
+ @param CpuFeaturesData Cpu Feature Data structure.
+
@return The processor index.
**/
UINTN
GetProcessorIndex (
- VOID
+ IN CPU_FEATURES_DATA *CpuFeaturesData
)
{
EFI_STATUS Status;
@@ -225,7 +227,7 @@ CpuFeaturesInitialize (
CpuFeaturesData = GetCpuFeaturesData ();
- OldBspNumber = GetProcessorIndex();
+ OldBspNumber = GetProcessorIndex(CpuFeaturesData);
CpuFeaturesData->BspNumber = OldBspNumber;
Status = gBS->CreateEvent (
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
index 0bb3dee8b6..0bbcb50181 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
@@ -96,20 +96,26 @@ GetMpPpi (
/**
Worker function to return processor index.
+ @param CpuFeaturesData Cpu Feature Data structure.
+
@return The processor index.
**/
UINTN
GetProcessorIndex (
- VOID
+ IN CPU_FEATURES_DATA *CpuFeaturesData
)
{
EFI_STATUS Status;
- EFI_PEI_MP_SERVICES_PPI *CpuMpPpi;
UINTN ProcessorIndex;
+ EFI_PEI_MP_SERVICES_PPI *CpuMpPpi;
- CpuMpPpi = GetMpPpi ();
+ ASSERT (CpuFeaturesData->CpuMpPpi != NULL);
+ if (CpuFeaturesData->CpuMpPpi == NULL) {
+ return (UINTN) (-1);
+ }
+ CpuMpPpi = (EFI_PEI_MP_SERVICES_PPI *)CpuFeaturesData->CpuMpPpi;
- Status = CpuMpPpi->WhoAmI(GetPeiServicesTablePointer (), CpuMpPpi, &ProcessorIndex);
+ Status = CpuMpPpi->WhoAmI(NULL, CpuMpPpi, &ProcessorIndex);
ASSERT_EFI_ERROR (Status);
return ProcessorIndex;
}
@@ -286,6 +292,9 @@ GetNumberOfProcessor (
{
EFI_STATUS Status;
EFI_PEI_MP_SERVICES_PPI *CpuMpPpi;
+ CPU_FEATURES_DATA *CpuFeaturesData;
+
+ CpuFeaturesData = GetCpuFeaturesData();
//
// Get MP Services Protocol
@@ -298,6 +307,8 @@ GetNumberOfProcessor (
);
ASSERT_EFI_ERROR (Status);
+ CpuFeaturesData->CpuMpPpi = CpuMpPpi;
+
//
// Get the number of CPUs
//
@@ -329,7 +340,7 @@ CpuFeaturesInitialize (
CpuFeaturesData = GetCpuFeaturesData ();
- OldBspNumber = GetProcessorIndex();
+ OldBspNumber = GetProcessorIndex (CpuFeaturesData);
CpuFeaturesData->BspNumber = OldBspNumber;
//
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
index cf3da84837..19c3420511 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
@@ -85,6 +85,8 @@ typedef struct {
UINTN BspNumber;
PROGRAM_CPU_REGISTER_FLAGS CpuFlags;
+
+ VOID *CpuMpPpi;
} CPU_FEATURES_DATA;
#define CPU_FEATURE_ENTRY_FROM_LINK(a) \
@@ -108,11 +110,13 @@ GetCpuFeaturesData (
/**
Worker function to return processor index.
+ @param CpuFeaturesData Cpu Feature Data structure.
+
@return The processor index.
**/
UINTN
GetProcessorIndex (
- VOID
+ IN CPU_FEATURES_DATA *CpuFeaturesData
);
/**
--
2.15.0.windows.1
next prev parent reply other threads:[~2018-12-20 1:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-20 1:15 [Patch 0/3] Avoid AP calls PeiService Eric Dong
2018-12-20 1:15 ` [Patch 1/3] UefiCpuPkg/RegisterCpuFeaturesLib: " Eric Dong
2018-12-20 1:19 ` Yao, Jiewen
2018-12-20 1:22 ` Dong, Eric
2018-12-20 2:06 ` Ni, Ruiyu
2018-12-20 2:08 ` Yao, Jiewen
2018-12-20 16:36 ` Brian J. Johnson
2018-12-21 2:06 ` Dong, Eric
2019-01-09 5:26 ` Dong, Eric
2019-01-09 10:35 ` Laszlo Ersek
2019-01-10 5:53 ` Dong, Eric
[not found] ` <734D49CCEBEEF84792F5B80ED585239D5BFAE3BF@SHSMSX103.ccr.corp.intel.com>
2019-01-10 12:51 ` Laszlo Ersek
2018-12-20 1:15 ` Eric Dong [this message]
2018-12-20 1:15 ` [Patch 3/3] UefiCpuPkg/RegisterCpuFeaturesLib: Remove useless function Eric Dong
2018-12-20 2:03 ` Ni, Ruiyu
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=20181220011553.14900-3-eric.dong@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