* [Patch v2 1/6] UefiCpuPkg/Include/MpInitLib.h: Add MpInitLibStartupAllCPUs API.
2019-07-22 7:14 [Patch v2 0/6] UefiCpuPkg: Enable Edkii Mp Services2 Ppi Dong, Eric
@ 2019-07-22 7:14 ` Dong, Eric
2019-07-22 7:18 ` [edk2-devel] " Ni, Ray
2019-07-22 7:14 ` [Patch v2 2/6] UefiCpuPkg/MpInitLib: " Dong, Eric
` (4 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Dong, Eric @ 2019-07-22 7:14 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Laszlo Ersek, Chandana Kumar, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
Add new MpInitLibStartupAllCPUs API uses to start all processors
at the same time.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
UefiCpuPkg/Include/Library/MpInitLib.h | 33 ++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/UefiCpuPkg/Include/Library/MpInitLib.h b/UefiCpuPkg/Include/Library/MpInitLib.h
index fa82529373..a943fbd9bc 100644
--- a/UefiCpuPkg/Include/Library/MpInitLib.h
+++ b/UefiCpuPkg/Include/Library/MpInitLib.h
@@ -344,4 +344,37 @@ MpInitLibWhoAmI (
OUT UINTN *ProcessorNumber
);
+/**
+ This service executes a caller provided function on all enabled CPUs.
+
+ @param[in] Procedure A pointer to the function to be run on
+ enabled APs of the system. See type
+ EFI_AP_PROCEDURE.
+ @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
+ APs to return from Procedure, either for
+ blocking or non-blocking mode. Zero means
+ infinity.
+ @param[in] ProcedureArgument The parameter passed into Procedure for
+ all APs.
+
+ @retval EFI_SUCCESS In blocking mode, all CPUs have finished before
+ the timeout expired.
+ @retval EFI_SUCCESS In non-blocking mode, function has been dispatched
+ to all enabled CPUs.
+ @retval EFI_DEVICE_ERROR Caller processor is AP.
+ @retval EFI_NOT_READY Any enabled APs are busy.
+ @retval EFI_NOT_READY MP Initialize Library is not initialized.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before
+ all enabled APs have finished.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+MpInitLibStartupAllCPUs (
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN TimeoutInMicroseconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ );
+
#endif
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [Patch v2 1/6] UefiCpuPkg/Include/MpInitLib.h: Add MpInitLibStartupAllCPUs API.
2019-07-22 7:14 ` [Patch v2 1/6] UefiCpuPkg/Include/MpInitLib.h: Add MpInitLibStartupAllCPUs API Dong, Eric
@ 2019-07-22 7:18 ` Ni, Ray
0 siblings, 0 replies; 11+ messages in thread
From: Ni, Ray @ 2019-07-22 7:18 UTC (permalink / raw)
To: devel@edk2.groups.io, Dong, Eric
Cc: Laszlo Ersek, Kumar, Chandana C, Zeng, Star
Reviewed-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Dong,
> Eric
> Sent: Monday, July 22, 2019 3:14 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar,
> Chandana C <chandana.c.kumar@intel.com>; Zeng, Star
> <star.zeng@intel.com>
> Subject: [edk2-devel] [Patch v2 1/6] UefiCpuPkg/Include/MpInitLib.h: Add
> MpInitLibStartupAllCPUs API.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> Add new MpInitLibStartupAllCPUs API uses to start all processors at the same
> time.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/Include/Library/MpInitLib.h | 33
> ++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/UefiCpuPkg/Include/Library/MpInitLib.h
> b/UefiCpuPkg/Include/Library/MpInitLib.h
> index fa82529373..a943fbd9bc 100644
> --- a/UefiCpuPkg/Include/Library/MpInitLib.h
> +++ b/UefiCpuPkg/Include/Library/MpInitLib.h
> @@ -344,4 +344,37 @@ MpInitLibWhoAmI (
> OUT UINTN *ProcessorNumber
> );
>
> +/**
> + This service executes a caller provided function on all enabled CPUs.
> +
> + @param[in] Procedure A pointer to the function to be run on
> + enabled APs of the system. See type
> + EFI_AP_PROCEDURE.
> + @param[in] TimeoutInMicroseconds Indicates the time limit in
> microseconds for
> + APs to return from Procedure, either for
> + blocking or non-blocking mode. Zero means
> + infinity.
> + @param[in] ProcedureArgument The parameter passed into
> Procedure for
> + all APs.
> +
> + @retval EFI_SUCCESS In blocking mode, all CPUs have finished
> before
> + the timeout expired.
> + @retval EFI_SUCCESS In non-blocking mode, function has been
> dispatched
> + to all enabled CPUs.
> + @retval EFI_DEVICE_ERROR Caller processor is AP.
> + @retval EFI_NOT_READY Any enabled APs are busy.
> + @retval EFI_NOT_READY MP Initialize Library is not initialized.
> + @retval EFI_TIMEOUT In blocking mode, the timeout expired before
> + all enabled APs have finished.
> + @retval EFI_INVALID_PARAMETER Procedure is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MpInitLibStartupAllCPUs (
> + IN EFI_AP_PROCEDURE Procedure,
> + IN UINTN TimeoutInMicroseconds,
> + IN VOID *ProcedureArgument OPTIONAL
> + );
> +
> #endif
> --
> 2.21.0.windows.1
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Patch v2 2/6] UefiCpuPkg/MpInitLib: Add MpInitLibStartupAllCPUs API.
2019-07-22 7:14 [Patch v2 0/6] UefiCpuPkg: Enable Edkii Mp Services2 Ppi Dong, Eric
2019-07-22 7:14 ` [Patch v2 1/6] UefiCpuPkg/Include/MpInitLib.h: Add MpInitLibStartupAllCPUs API Dong, Eric
@ 2019-07-22 7:14 ` Dong, Eric
2019-07-23 5:46 ` [edk2-devel] " Ni, Ray
2019-07-22 7:14 ` [Patch v2 3/6] UefiCpuPkg/MpInitLibUp: " Dong, Eric
` (3 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Dong, Eric @ 2019-07-22 7:14 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Laszlo Ersek, Chandana Kumar, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
Add new MpInitLibStartupAllCPUs API uses to start all processors
at the same time.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 3 +-
UefiCpuPkg/Library/MpInitLib/MpLib.c | 60 +++++++++++++++++++++++--
UefiCpuPkg/Library/MpInitLib/MpLib.h | 4 +-
UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 3 +-
4 files changed, 63 insertions(+), 7 deletions(-)
diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index 6be1bae464..23adfd0625 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -568,9 +568,10 @@ MpInitLibStartupAllAPs (
//
mStopCheckAllApsStatus = TRUE;
- Status = StartupAllAPsWorker (
+ Status = StartupAllCpusWorker (
Procedure,
SingleThread,
+ TRUE,
WaitEvent,
TimeoutInMicroseconds,
ProcedureArgument,
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 6f51bc4ebf..51e63e14a3 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -2130,6 +2130,7 @@ MpInitLibGetNumberOfProcessors (
number. If FALSE, then all the enabled APs
execute the function specified by Procedure
simultaneously.
+ @param[in] ExcludeBsp Whether let BSP also trig this task.
@param[in] WaitEvent The event created by the caller with CreateEvent()
service.
@param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
@@ -2151,9 +2152,10 @@ MpInitLibGetNumberOfProcessors (
**/
EFI_STATUS
-StartupAllAPsWorker (
+StartupAllCpusWorker (
IN EFI_AP_PROCEDURE Procedure,
IN BOOLEAN SingleThread,
+ IN BOOLEAN ExcludeBsp,
IN EFI_EVENT WaitEvent OPTIONAL,
IN UINTN TimeoutInMicroseconds,
IN VOID *ProcedureArgument OPTIONAL,
@@ -2175,7 +2177,7 @@ StartupAllAPsWorker (
*FailedCpuList = NULL;
}
- if (CpuMpData->CpuCount == 1) {
+ if (CpuMpData->CpuCount == 1 && ExcludeBsp) {
return EFI_NOT_STARTED;
}
@@ -2218,9 +2220,9 @@ StartupAllAPsWorker (
}
}
- if (!HasEnabledAp) {
+ if (!HasEnabledAp && ExcludeBsp) {
//
- // If no enabled AP exists, return EFI_NOT_STARTED.
+ // If no enabled AP exists and not include Bsp to do the procedure, return EFI_NOT_STARTED.
//
return EFI_NOT_STARTED;
}
@@ -2266,6 +2268,13 @@ StartupAllAPsWorker (
}
}
+ if (!ExcludeBsp) {
+ //
+ // Start BSP.
+ //
+ Procedure (ProcedureArgument);
+ }
+
Status = EFI_SUCCESS;
if (WaitEvent == NULL) {
do {
@@ -2411,3 +2420,46 @@ GetCpuMpDataFromGuidedHob (
return CpuMpData;
}
+/**
+ This service executes a caller provided function on all enabled CPUs.
+
+ @param[in] Procedure A pointer to the function to be run on
+ enabled APs of the system. See type
+ EFI_AP_PROCEDURE.
+ @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
+ APs to return from Procedure, either for
+ blocking or non-blocking mode. Zero means
+ infinity.
+ @param[in] ProcedureArgument The parameter passed into Procedure for
+ all APs.
+
+ @retval EFI_SUCCESS In blocking mode, all CPUs have finished before
+ the timeout expired.
+ @retval EFI_SUCCESS In non-blocking mode, function has been dispatched
+ to all enabled CPUs.
+ @retval EFI_DEVICE_ERROR Caller processor is AP.
+ @retval EFI_NOT_READY Any enabled APs are busy.
+ @retval EFI_NOT_READY MP Initialize Library is not initialized.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before
+ all enabled APs have finished.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+MpInitLibStartupAllCPUs (
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN TimeoutInMicroseconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ )
+{
+ return StartupAllCpusWorker (
+ Procedure,
+ FALSE,
+ FALSE,
+ NULL,
+ TimeoutInMicroseconds,
+ ProcedureArgument,
+ NULL
+ );
+}
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index f89037c59e..81de45c73b 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -405,6 +405,7 @@ InitMpGlobalData (
number. If FALSE, then all the enabled APs
execute the function specified by Procedure
simultaneously.
+ @param[in] ExcludeBsp Whether let BSP also trig this task.
@param[in] WaitEvent The event created by the caller with CreateEvent()
service.
@param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
@@ -426,9 +427,10 @@ InitMpGlobalData (
**/
EFI_STATUS
-StartupAllAPsWorker (
+StartupAllCpusWorker (
IN EFI_AP_PROCEDURE Procedure,
IN BOOLEAN SingleThread,
+ IN BOOLEAN ExcludeBsp,
IN EFI_EVENT WaitEvent OPTIONAL,
IN UINTN TimeoutInMicroseconds,
IN VOID *ProcedureArgument OPTIONAL,
diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
index 35dff91fd2..5666ad0862 100644
--- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
@@ -401,9 +401,10 @@ MpInitLibStartupAllAPs (
return EFI_UNSUPPORTED;
}
- return StartupAllAPsWorker (
+ return StartupAllCpusWorker (
Procedure,
SingleThread,
+ TRUE,
NULL,
TimeoutInMicroseconds,
ProcedureArgument,
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [Patch v2 2/6] UefiCpuPkg/MpInitLib: Add MpInitLibStartupAllCPUs API.
2019-07-22 7:14 ` [Patch v2 2/6] UefiCpuPkg/MpInitLib: " Dong, Eric
@ 2019-07-23 5:46 ` Ni, Ray
0 siblings, 0 replies; 11+ messages in thread
From: Ni, Ray @ 2019-07-23 5:46 UTC (permalink / raw)
To: devel@edk2.groups.io, Dong, Eric
Cc: Laszlo Ersek, Kumar, Chandana C, Zeng, Star
"CPU" is used in MpInitLibStartupAllCPUs() and StartupAllCpusWorker().
Can you please follow today's capital rule of "AP" to update
StartupAllCpusWorker() to StartupAllCPUsWorker()?
And with the copyright year update to 2019, Reviewed-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Dong,
> Eric
> Sent: Monday, July 22, 2019 3:14 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar,
> Chandana C <chandana.c.kumar@intel.com>; Zeng, Star
> <star.zeng@intel.com>
> Subject: [edk2-devel] [Patch v2 2/6] UefiCpuPkg/MpInitLib: Add
> MpInitLibStartupAllCPUs API.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> Add new MpInitLibStartupAllCPUs API uses to start all processors at the same
> time.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 3 +-
> UefiCpuPkg/Library/MpInitLib/MpLib.c | 60 +++++++++++++++++++++++-
> -
> UefiCpuPkg/Library/MpInitLib/MpLib.h | 4 +-
> UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 3 +-
> 4 files changed, 63 insertions(+), 7 deletions(-)
>
> diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> index 6be1bae464..23adfd0625 100644
> --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
> @@ -568,9 +568,10 @@ MpInitLibStartupAllAPs (
> //
> mStopCheckAllApsStatus = TRUE;
>
> - Status = StartupAllAPsWorker (
> + Status = StartupAllCpusWorker (
> Procedure,
> SingleThread,
> + TRUE,
> WaitEvent,
> TimeoutInMicroseconds,
> ProcedureArgument,
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 6f51bc4ebf..51e63e14a3 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -2130,6 +2130,7 @@ MpInitLibGetNumberOfProcessors (
> number. If FALSE, then all the enabled APs
> execute the function specified by Procedure
> simultaneously.
> + @param[in] ExcludeBsp Whether let BSP also trig this task.
> @param[in] WaitEvent The event created by the caller with
> CreateEvent()
> service.
> @param[in] TimeoutInMicroseconds Indicates the time limit in
> microseconds for
> @@ -2151,9 +2152,10 @@ MpInitLibGetNumberOfProcessors (
>
> **/
> EFI_STATUS
> -StartupAllAPsWorker (
> +StartupAllCpusWorker (
> IN EFI_AP_PROCEDURE Procedure,
> IN BOOLEAN SingleThread,
> + IN BOOLEAN ExcludeBsp,
> IN EFI_EVENT WaitEvent OPTIONAL,
> IN UINTN TimeoutInMicroseconds,
> IN VOID *ProcedureArgument OPTIONAL,
> @@ -2175,7 +2177,7 @@ StartupAllAPsWorker (
> *FailedCpuList = NULL;
> }
>
> - if (CpuMpData->CpuCount == 1) {
> + if (CpuMpData->CpuCount == 1 && ExcludeBsp) {
> return EFI_NOT_STARTED;
> }
>
> @@ -2218,9 +2220,9 @@ StartupAllAPsWorker (
> }
> }
>
> - if (!HasEnabledAp) {
> + if (!HasEnabledAp && ExcludeBsp) {
> //
> - // If no enabled AP exists, return EFI_NOT_STARTED.
> + // If no enabled AP exists and not include Bsp to do the procedure, return
> EFI_NOT_STARTED.
> //
> return EFI_NOT_STARTED;
> }
> @@ -2266,6 +2268,13 @@ StartupAllAPsWorker (
> }
> }
>
> + if (!ExcludeBsp) {
> + //
> + // Start BSP.
> + //
> + Procedure (ProcedureArgument);
> + }
> +
> Status = EFI_SUCCESS;
> if (WaitEvent == NULL) {
> do {
> @@ -2411,3 +2420,46 @@ GetCpuMpDataFromGuidedHob (
> return CpuMpData;
> }
>
> +/**
> + This service executes a caller provided function on all enabled CPUs.
> +
> + @param[in] Procedure A pointer to the function to be run on
> + enabled APs of the system. See type
> + EFI_AP_PROCEDURE.
> + @param[in] TimeoutInMicroseconds Indicates the time limit in
> microseconds for
> + APs to return from Procedure, either for
> + blocking or non-blocking mode. Zero means
> + infinity.
> + @param[in] ProcedureArgument The parameter passed into
> Procedure for
> + all APs.
> +
> + @retval EFI_SUCCESS In blocking mode, all CPUs have finished
> before
> + the timeout expired.
> + @retval EFI_SUCCESS In non-blocking mode, function has been
> dispatched
> + to all enabled CPUs.
> + @retval EFI_DEVICE_ERROR Caller processor is AP.
> + @retval EFI_NOT_READY Any enabled APs are busy.
> + @retval EFI_NOT_READY MP Initialize Library is not initialized.
> + @retval EFI_TIMEOUT In blocking mode, the timeout expired before
> + all enabled APs have finished.
> + @retval EFI_INVALID_PARAMETER Procedure is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MpInitLibStartupAllCPUs (
> + IN EFI_AP_PROCEDURE Procedure,
> + IN UINTN TimeoutInMicroseconds,
> + IN VOID *ProcedureArgument OPTIONAL
> + )
> +{
> + return StartupAllCpusWorker (
> + Procedure,
> + FALSE,
> + FALSE,
> + NULL,
> + TimeoutInMicroseconds,
> + ProcedureArgument,
> + NULL
> + );
> +}
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h
> b/UefiCpuPkg/Library/MpInitLib/MpLib.h
> index f89037c59e..81de45c73b 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
> @@ -405,6 +405,7 @@ InitMpGlobalData (
> number. If FALSE, then all the enabled APs
> execute the function specified by Procedure
> simultaneously.
> + @param[in] ExcludeBsp Whether let BSP also trig this task.
> @param[in] WaitEvent The event created by the caller with
> CreateEvent()
> service.
> @param[in] TimeoutInMicroseconds Indicates the time limit in
> microseconds for
> @@ -426,9 +427,10 @@ InitMpGlobalData (
>
> **/
> EFI_STATUS
> -StartupAllAPsWorker (
> +StartupAllCpusWorker (
> IN EFI_AP_PROCEDURE Procedure,
> IN BOOLEAN SingleThread,
> + IN BOOLEAN ExcludeBsp,
> IN EFI_EVENT WaitEvent OPTIONAL,
> IN UINTN TimeoutInMicroseconds,
> IN VOID *ProcedureArgument OPTIONAL,
> diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
> b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
> index 35dff91fd2..5666ad0862 100644
> --- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
> @@ -401,9 +401,10 @@ MpInitLibStartupAllAPs (
> return EFI_UNSUPPORTED;
> }
>
> - return StartupAllAPsWorker (
> + return StartupAllCpusWorker (
> Procedure,
> SingleThread,
> + TRUE,
> NULL,
> TimeoutInMicroseconds,
> ProcedureArgument,
> --
> 2.21.0.windows.1
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Patch v2 3/6] UefiCpuPkg/MpInitLibUp: Add MpInitLibStartupAllCPUs API.
2019-07-22 7:14 [Patch v2 0/6] UefiCpuPkg: Enable Edkii Mp Services2 Ppi Dong, Eric
2019-07-22 7:14 ` [Patch v2 1/6] UefiCpuPkg/Include/MpInitLib.h: Add MpInitLibStartupAllCPUs API Dong, Eric
2019-07-22 7:14 ` [Patch v2 2/6] UefiCpuPkg/MpInitLib: " Dong, Eric
@ 2019-07-22 7:14 ` Dong, Eric
2019-07-23 5:49 ` [edk2-devel] " Ni, Ray
2019-07-22 7:14 ` [Patch v2 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
` (2 subsequent siblings)
5 siblings, 1 reply; 11+ messages in thread
From: Dong, Eric @ 2019-07-22 7:14 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Laszlo Ersek, Chandana Kumar, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
Add new MpInitLibStartupAllCPUs API uses to start all processors
at the same time.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c | 38 ++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
index 36c2bb5326..849600d5c2 100644
--- a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
+++ b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
@@ -405,3 +405,41 @@ MpInitLibWhoAmI (
*ProcessorNumber = 0;
return EFI_SUCCESS;
}
+
+/**
+ This service executes a caller provided function on all enabled CPUs.
+
+ @param[in] Procedure A pointer to the function to be run on
+ enabled APs of the system. See type
+ EFI_AP_PROCEDURE.
+ @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
+ APs to return from Procedure, either for
+ blocking or non-blocking mode. Zero means
+ infinity.
+ @param[in] ProcedureArgument The parameter passed into Procedure for
+ all APs.
+
+ @retval EFI_SUCCESS In blocking mode, all CPUs have finished before
+ the timeout expired.
+ @retval EFI_SUCCESS In non-blocking mode, function has been dispatched
+ to all enabled CPUs.
+ @retval EFI_DEVICE_ERROR Caller processor is AP.
+ @retval EFI_NOT_READY Any enabled APs are busy.
+ @retval EFI_NOT_READY MP Initialize Library is not initialized.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before
+ all enabled APs have finished.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+MpInitLibStartupAllCPUs (
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN TimeoutInMicroseconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ )
+{
+ Procedure (ProcedureArgument);
+
+ return EFI_SUCCESS;
+}
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [edk2-devel] [Patch v2 3/6] UefiCpuPkg/MpInitLibUp: Add MpInitLibStartupAllCPUs API.
2019-07-22 7:14 ` [Patch v2 3/6] UefiCpuPkg/MpInitLibUp: " Dong, Eric
@ 2019-07-23 5:49 ` Ni, Ray
0 siblings, 0 replies; 11+ messages in thread
From: Ni, Ray @ 2019-07-23 5:49 UTC (permalink / raw)
To: devel@edk2.groups.io, Dong, Eric
Cc: Laszlo Ersek, Kumar, Chandana C, Zeng, Star
Please add:
1. parameter check "if (Procedure == NULL) return EFI_INVALID_PARAMETER".
2. comments in function body saying TimeoutInMicroseconds is ignored for BSP.
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Dong,
> Eric
> Sent: Monday, July 22, 2019 3:14 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar,
> Chandana C <chandana.c.kumar@intel.com>; Zeng, Star
> <star.zeng@intel.com>
> Subject: [edk2-devel] [Patch v2 3/6] UefiCpuPkg/MpInitLibUp: Add
> MpInitLibStartupAllCPUs API.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> Add new MpInitLibStartupAllCPUs API uses to start all processors at the same
> time.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c | 38
> ++++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> index 36c2bb5326..849600d5c2 100644
> --- a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> +++ b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c
> @@ -405,3 +405,41 @@ MpInitLibWhoAmI (
> *ProcessorNumber = 0;
> return EFI_SUCCESS;
> }
> +
> +/**
> + This service executes a caller provided function on all enabled CPUs.
> +
> + @param[in] Procedure A pointer to the function to be run on
> + enabled APs of the system. See type
> + EFI_AP_PROCEDURE.
> + @param[in] TimeoutInMicroseconds Indicates the time limit in
> microseconds for
> + APs to return from Procedure, either for
> + blocking or non-blocking mode. Zero means
> + infinity.
> + @param[in] ProcedureArgument The parameter passed into
> Procedure for
> + all APs.
> +
> + @retval EFI_SUCCESS In blocking mode, all CPUs have finished
> before
> + the timeout expired.
> + @retval EFI_SUCCESS In non-blocking mode, function has been
> dispatched
> + to all enabled CPUs.
> + @retval EFI_DEVICE_ERROR Caller processor is AP.
> + @retval EFI_NOT_READY Any enabled APs are busy.
> + @retval EFI_NOT_READY MP Initialize Library is not initialized.
> + @retval EFI_TIMEOUT In blocking mode, the timeout expired before
> + all enabled APs have finished.
> + @retval EFI_INVALID_PARAMETER Procedure is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MpInitLibStartupAllCPUs (
> + IN EFI_AP_PROCEDURE Procedure,
> + IN UINTN TimeoutInMicroseconds,
> + IN VOID *ProcedureArgument OPTIONAL
> + )
> +{
> + Procedure (ProcedureArgument);
> +
> + return EFI_SUCCESS;
> +}
> --
> 2.21.0.windows.1
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Patch v2 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI
2019-07-22 7:14 [Patch v2 0/6] UefiCpuPkg: Enable Edkii Mp Services2 Ppi Dong, Eric
` (2 preceding siblings ...)
2019-07-22 7:14 ` [Patch v2 3/6] UefiCpuPkg/MpInitLibUp: " Dong, Eric
@ 2019-07-22 7:14 ` Dong, Eric
2019-07-23 5:51 ` Ni, Ray
2019-07-22 7:14 ` [Patch v2 5/6] UefiCpuPkg/CpuMpPei: Produce EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
2019-07-22 7:14 ` [Patch v2 6/6] UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously Dong, Eric
5 siblings, 1 reply; 11+ messages in thread
From: Dong, Eric @ 2019-07-22 7:14 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Laszlo Ersek, Chandana Kumar, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
Add definition for new EDKII_PEI_MP_SERVICES2_PPI.
It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI
and add new API EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h | 72 +++++++++++++++++++++++
UefiCpuPkg/UefiCpuPkg.dec | 3 +
2 files changed, 75 insertions(+)
create mode 100644 UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h
diff --git a/UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h b/UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h
new file mode 100644
index 0000000000..c6b9712cc0
--- /dev/null
+++ b/UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h
@@ -0,0 +1,72 @@
+/** @file
+ This file declares edkii Multi-processor service PPI.
+
+ Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __EDKII_PEI_MP_SERVICES2_PPI_H__
+#define __EDKII_PEI_MP_SERVICES2_PPI_H__
+
+#include <Ppi/MpServices.h>
+
+#define EDKII_PEI_MP_SERVICES2_PPI_GUID \
+ { \
+ 0x5cb9cb3d, 0x31a4, 0x480c, { 0x94, 0x98, 0x29, 0xd2, 0x69, 0xba, 0xcf, 0xba} \
+ }
+
+typedef struct _EDKII_PEI_MP_SERVICES2_PPI EDKII_PEI_MP_SERVICES2_PPI;
+
+typedef EFI_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS EDKII_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS;
+typedef EFI_PEI_MP_SERVICES_GET_PROCESSOR_INFO EDKII_PEI_MP_SERVICES_GET_PROCESSOR_INFO;
+typedef EFI_PEI_MP_SERVICES_STARTUP_ALL_APS EDKII_PEI_MP_SERVICES_STARTUP_ALL_APS;
+typedef EFI_PEI_MP_SERVICES_STARTUP_THIS_AP EDKII_PEI_MP_SERVICES_STARTUP_THIS_AP;
+typedef EFI_PEI_MP_SERVICES_SWITCH_BSP EDKII_PEI_MP_SERVICES_SWITCH_BSP;
+typedef EFI_PEI_MP_SERVICES_ENABLEDISABLEAP EDKII_PEI_MP_SERVICES_ENABLEDISABLEAP;
+typedef EFI_PEI_MP_SERVICES_WHOAMI EDKII_PEI_MP_SERVICES_WHOAMI;
+
+/**
+ Activate all of the application proessors.
+
+ @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
+ @param[in] Procedure A pointer to the function to be run on enabled APs of
+ the system.
+ @param[in] TimeoutInMicroSeconds
+ Indicates the time limit in microseconds for APs to
+ return from Procedure, for blocking mode only. Zero
+ means infinity. If the timeout expires in blocking
+ mode, BSP returns EFI_TIMEOUT.
+ @param[in] ProcedureArgument The parameter passed into Procedure for all CPUs.
+
+ @retval EFI_SUCCESS In blocking mode, all APs have finished before the
+ timeout expired.
+ @retval EFI_DEVICE_ERROR Caller processor is AP.
+ @retval EFI_NOT_READY Any enabled APs are busy.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before all
+ enabled APs have finished.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS) (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN TimeoutInMicroSeconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ );
+
+struct _EDKII_PEI_MP_SERVICES2_PPI {
+ EDKII_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS GetNumberOfProcessors;
+ EDKII_PEI_MP_SERVICES_GET_PROCESSOR_INFO GetProcessorInfo;
+ EDKII_PEI_MP_SERVICES_STARTUP_ALL_APS StartupAllAPs;
+ EDKII_PEI_MP_SERVICES_STARTUP_THIS_AP StartupThisAP;
+ EDKII_PEI_MP_SERVICES_SWITCH_BSP SwitchBSP;
+ EDKII_PEI_MP_SERVICES_ENABLEDISABLEAP EnableDisableAP;
+ EDKII_PEI_MP_SERVICES_WHOAMI WhoAmI;
+ EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS StartupAllCPUs;
+};
+
+extern EFI_GUID gEdkiiPeiMpServices2PpiGuid;
+
+#endif
diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index 6ddf0cd224..5a555644b7 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -75,6 +75,9 @@
# 0x80000001 | Invalid value provided.
#
+[Ppis]
+ gEdkiiPeiMpServices2PpiGuid = { 0x5cb9cb3d, 0x31a4, 0x480c, { 0x94, 0x98, 0x29, 0xd2, 0x69, 0xba, 0xcf, 0xba}}
+
[PcdsFeatureFlag]
## Indicates if SMM Profile will be enabled.
# If enabled, instruction executions in and data accesses to memory outside of SMRAM will be logged.
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Patch v2 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI
2019-07-22 7:14 ` [Patch v2 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
@ 2019-07-23 5:51 ` Ni, Ray
0 siblings, 0 replies; 11+ messages in thread
From: Ni, Ray @ 2019-07-23 5:51 UTC (permalink / raw)
To: Dong, Eric, devel@edk2.groups.io
Cc: Laszlo Ersek, Kumar, Chandana C, Zeng, Star
Reviewed-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: Dong, Eric
> Sent: Monday, July 22, 2019 3:14 PM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>; Laszlo Ersek <lersek@redhat.com>; Kumar,
> Chandana C <chandana.c.kumar@intel.com>; Zeng, Star
> <star.zeng@intel.com>
> Subject: [Patch v2 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
>
> Add definition for new EDKII_PEI_MP_SERVICES2_PPI.
>
> It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI and add new API
> EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS.
>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Chandana Kumar <chandana.c.kumar@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Eric Dong <eric.dong@intel.com>
> ---
> UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h | 72
> +++++++++++++++++++++++
> UefiCpuPkg/UefiCpuPkg.dec | 3 +
> 2 files changed, 75 insertions(+)
> create mode 100644 UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h
>
> diff --git a/UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h
> b/UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h
> new file mode 100644
> index 0000000000..c6b9712cc0
> --- /dev/null
> +++ b/UefiCpuPkg/Include/Ppi/EdkiiMpServices2.h
> @@ -0,0 +1,72 @@
> +/** @file
> + This file declares edkii Multi-processor service PPI.
> +
> + Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
> + SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef __EDKII_PEI_MP_SERVICES2_PPI_H__ #define
> +__EDKII_PEI_MP_SERVICES2_PPI_H__
> +
> +#include <Ppi/MpServices.h>
> +
> +#define EDKII_PEI_MP_SERVICES2_PPI_GUID \
> + { \
> + 0x5cb9cb3d, 0x31a4, 0x480c, { 0x94, 0x98, 0x29, 0xd2, 0x69, 0xba,
> +0xcf, 0xba} \
> + }
> +
> +typedef struct _EDKII_PEI_MP_SERVICES2_PPI
> EDKII_PEI_MP_SERVICES2_PPI;
> +
> +typedef EFI_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS
> EDKII_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS;
> +typedef EFI_PEI_MP_SERVICES_GET_PROCESSOR_INFO
> EDKII_PEI_MP_SERVICES_GET_PROCESSOR_INFO;
> +typedef EFI_PEI_MP_SERVICES_STARTUP_ALL_APS
> EDKII_PEI_MP_SERVICES_STARTUP_ALL_APS;
> +typedef EFI_PEI_MP_SERVICES_STARTUP_THIS_AP
> EDKII_PEI_MP_SERVICES_STARTUP_THIS_AP;
> +typedef EFI_PEI_MP_SERVICES_SWITCH_BSP
> EDKII_PEI_MP_SERVICES_SWITCH_BSP;
> +typedef EFI_PEI_MP_SERVICES_ENABLEDISABLEAP
> EDKII_PEI_MP_SERVICES_ENABLEDISABLEAP;
> +typedef EFI_PEI_MP_SERVICES_WHOAMI
> EDKII_PEI_MP_SERVICES_WHOAMI;
> +
> +/**
> + Activate all of the application proessors.
> +
> + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI
> instance.
> + @param[in] Procedure A pointer to the function to be run on
> enabled APs of
> + the system.
> + @param[in] TimeoutInMicroSeconds
> + Indicates the time limit in microseconds for APs to
> + return from Procedure, for blocking mode only. Zero
> + means infinity. If the timeout expires in blocking
> + mode, BSP returns EFI_TIMEOUT.
> + @param[in] ProcedureArgument The parameter passed into Procedure
> for all CPUs.
> +
> + @retval EFI_SUCCESS In blocking mode, all APs have finished before
> the
> + timeout expired.
> + @retval EFI_DEVICE_ERROR Caller processor is AP.
> + @retval EFI_NOT_READY Any enabled APs are busy.
> + @retval EFI_TIMEOUT In blocking mode, the timeout expired before
> all
> + enabled APs have finished.
> + @retval EFI_INVALID_PARAMETER Procedure is NULL.
> +**/
> +typedef
> +EFI_STATUS
> +(EFIAPI *EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS) (
> + IN EDKII_PEI_MP_SERVICES2_PPI *This,
> + IN EFI_AP_PROCEDURE Procedure,
> + IN UINTN TimeoutInMicroSeconds,
> + IN VOID *ProcedureArgument OPTIONAL
> + );
> +
> +struct _EDKII_PEI_MP_SERVICES2_PPI {
> + EDKII_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS
> GetNumberOfProcessors;
> + EDKII_PEI_MP_SERVICES_GET_PROCESSOR_INFO GetProcessorInfo;
> + EDKII_PEI_MP_SERVICES_STARTUP_ALL_APS StartupAllAPs;
> + EDKII_PEI_MP_SERVICES_STARTUP_THIS_AP StartupThisAP;
> + EDKII_PEI_MP_SERVICES_SWITCH_BSP SwitchBSP;
> + EDKII_PEI_MP_SERVICES_ENABLEDISABLEAP EnableDisableAP;
> + EDKII_PEI_MP_SERVICES_WHOAMI WhoAmI;
> + EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS StartupAllCPUs;
> +};
> +
> +extern EFI_GUID gEdkiiPeiMpServices2PpiGuid;
> +
> +#endif
> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
> index 6ddf0cd224..5a555644b7 100644
> --- a/UefiCpuPkg/UefiCpuPkg.dec
> +++ b/UefiCpuPkg/UefiCpuPkg.dec
> @@ -75,6 +75,9 @@
> # 0x80000001 | Invalid value provided.
> #
>
> +[Ppis]
> + gEdkiiPeiMpServices2PpiGuid = { 0x5cb9cb3d, 0x31a4, 0x480c, { 0x94,
> 0x98, 0x29, 0xd2, 0x69, 0xba, 0xcf, 0xba}}
> +
> [PcdsFeatureFlag]
> ## Indicates if SMM Profile will be enabled.
> # If enabled, instruction executions in and data accesses to memory
> outside of SMRAM will be logged.
> --
> 2.21.0.windows.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Patch v2 5/6] UefiCpuPkg/CpuMpPei: Produce EDKII_PEI_MP_SERVICES2_PPI.
2019-07-22 7:14 [Patch v2 0/6] UefiCpuPkg: Enable Edkii Mp Services2 Ppi Dong, Eric
` (3 preceding siblings ...)
2019-07-22 7:14 ` [Patch v2 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
@ 2019-07-22 7:14 ` Dong, Eric
2019-07-22 7:14 ` [Patch v2 6/6] UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously Dong, Eric
5 siblings, 0 replies; 11+ messages in thread
From: Dong, Eric @ 2019-07-22 7:14 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Laszlo Ersek, Chandana Kumar, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
Produce new EDKII_PEI_MP_SERVICES2_PPI service.
It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI
and add new API EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
UefiCpuPkg/CpuMpPei/CpuMpPei.c | 72 +++++++++++++++++++++++++++++---
UefiCpuPkg/CpuMpPei/CpuMpPei.h | 35 +++++++++++++++-
UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 1 +
3 files changed, 101 insertions(+), 7 deletions(-)
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
index 926541c937..c2f42d5016 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c
@@ -1,7 +1,7 @@
/** @file
CPU PEI Module installs CPU Multiple Processor PPI.
- Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -21,10 +21,31 @@ EFI_PEI_MP_SERVICES_PPI mMpServicesPpi = {
PeiWhoAmI,
};
-EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc = {
- (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
- &gEfiPeiMpServicesPpiGuid,
- &mMpServicesPpi
+//
+// CPU MP2 PPI to be installed
+//
+EDKII_PEI_MP_SERVICES2_PPI mMpServices2Ppi = {
+ PeiGetNumberOfProcessors,
+ PeiGetProcessorInfo,
+ PeiStartupAllAPs,
+ PeiStartupThisAP,
+ PeiSwitchBSP,
+ PeiEnableDisableAP,
+ PeiWhoAmI,
+ PeiStartupAllCPUs
+};
+
+EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiList[] = {
+ {
+ EFI_PEI_PPI_DESCRIPTOR_PPI,
+ &gEdkiiPeiMpServices2PpiGuid,
+ &mMpServices2Ppi
+ },
+ {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gEfiPeiMpServicesPpiGuid,
+ &mMpServicesPpi
+ }
};
/**
@@ -402,6 +423,45 @@ PeiWhoAmI (
return MpInitLibWhoAmI (ProcessorNumber);
}
+/**
+ This service executes a caller provided function on all enabled CPUs. CPUs can
+ run either simultaneously or one at a time in sequence. This service may only
+ be called from the BSP.
+
+ @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
+ @param[in] Procedure A pointer to the function to be run on enabled APs of
+ the system.
+ @param[in] TimeoutInMicroSeconds
+ Indicates the time limit in microseconds for APs to
+ return from Procedure, for blocking mode only. Zero
+ means infinity. If the timeout expires in blocking
+ mode, BSP returns EFI_TIMEOUT.
+ @param[in] ProcedureArgument The parameter passed into Procedure for all CPUs.
+
+ @retval EFI_SUCCESS In blocking mode, all APs have finished before the
+ timeout expired.
+ @retval EFI_DEVICE_ERROR Caller processor is AP.
+ @retval EFI_NOT_READY Any enabled APs are busy.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before all
+ enabled APs have finished.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+**/
+EFI_STATUS
+EFIAPI
+PeiStartupAllCPUs (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN TimeoutInMicroSeconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ )
+{
+ return MpInitLibStartupAllCPUs (
+ Procedure,
+ TimeoutInMicroSeconds,
+ ProcedureArgument
+ );
+}
+
/**
Get GDT register value.
@@ -667,7 +727,7 @@ InitializeCpuMpWorker (
//
// Install CPU MP PPI
//
- Status = PeiServicesInstallPpi(&mPeiCpuMpPpiDesc);
+ Status = PeiServicesInstallPpi(mPeiCpuMpPpiList);
ASSERT_EFI_ERROR (Status);
return Status;
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
index a5d8a755b2..b385c5088b 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h
@@ -1,7 +1,7 @@
/** @file
Definitions to install Multiple Processor PPI.
- Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -15,6 +15,7 @@
#include <Ppi/SecPlatformInformation.h>
#include <Ppi/SecPlatformInformation2.h>
#include <Ppi/EndOfPeiPhase.h>
+#include <Ppi/EdkiiMpServices2.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
@@ -431,6 +432,38 @@ MemoryDiscoveredPpiNotifyCallback (
IN VOID *Ppi
);
+/**
+ This service executes a caller provided function on all enabled CPUs. CPUs can
+ run either simultaneously or one at a time in sequence. This service may only
+ be called from the BSP.
+
+ @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
+ @param[in] Procedure A pointer to the function to be run on enabled APs of
+ the system.
+ @param[in] TimeoutInMicroSeconds
+ Indicates the time limit in microseconds for APs to
+ return from Procedure, for blocking mode only. Zero
+ means infinity. If the timeout expires in blocking
+ mode, BSP returns EFI_TIMEOUT.
+ @param[in] ProcedureArgument The parameter passed into Procedure for all CPUs.
+
+ @retval EFI_SUCCESS In blocking mode, all APs have finished before the
+ timeout expired.
+ @retval EFI_DEVICE_ERROR Caller processor is AP.
+ @retval EFI_NOT_READY Any enabled APs are busy.
+ @retval EFI_TIMEOUT In blocking mode, the timeout expired before all
+ enabled APs have finished.
+ @retval EFI_INVALID_PARAMETER Procedure is NULL.
+**/
+EFI_STATUS
+EFIAPI
+PeiStartupAllCPUs (
+ IN EDKII_PEI_MP_SERVICES2_PPI *This,
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN TimeoutInMicroSeconds,
+ IN VOID *ProcedureArgument OPTIONAL
+ );
+
extern EFI_PEI_NOTIFY_DESCRIPTOR mPostMemNotifyList[];
#endif
diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
index 4fc4ea77ba..e42ba824e4 100644
--- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
+++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf
@@ -54,6 +54,7 @@
gEfiSecPlatformInformation2PpiGuid
gEfiVectorHandoffInfoPpiGuid ## SOMETIMES_CONSUMES
gEfiPeiMemoryDiscoveredPpiGuid ## CONSUMES
+ gEdkiiPeiMpServices2PpiGuid ## PRODUCES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ## CONSUMES
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [Patch v2 6/6] UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously.
2019-07-22 7:14 [Patch v2 0/6] UefiCpuPkg: Enable Edkii Mp Services2 Ppi Dong, Eric
` (4 preceding siblings ...)
2019-07-22 7:14 ` [Patch v2 5/6] UefiCpuPkg/CpuMpPei: Produce EDKII_PEI_MP_SERVICES2_PPI Dong, Eric
@ 2019-07-22 7:14 ` Dong, Eric
5 siblings, 0 replies; 11+ messages in thread
From: Dong, Eric @ 2019-07-22 7:14 UTC (permalink / raw)
To: devel; +Cc: Ray Ni, Laszlo Ersek, Chandana Kumar, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1973
For semaphore type register, it required all processors to do the
task at the same time.
Current logic begins BSP's task after all APs have finished their tasks.
This will caused set semaphore task hang if semaphore has package
level type.
This patch use new EDKII_PEI_MP_SERVICES2_PPI to start all processors at
the same time to fix the potential hang issue.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Eric Dong <eric.dong@intel.com>
---
.../PeiRegisterCpuFeaturesLib.c | 62 ++++++++++++++-----
.../PeiRegisterCpuFeaturesLib.inf | 1 +
2 files changed, 47 insertions(+), 16 deletions(-)
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
index 8ad5a40e5a..9ed0fbf381 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
@@ -12,6 +12,8 @@
#include <Library/PeiServicesLib.h>
#include <Library/PeiServicesTablePointerLib.h>
#include <Ppi/MpServices.h>
+#include <Ppi/EdkiiMpServices2.h>
+
#include "RegisterCpuFeatures.h"
#define REGISTER_CPU_FEATURES_GUID \
@@ -180,6 +182,48 @@ StartupAPsWorker (
ASSERT_EFI_ERROR (Status);
}
+/**
+ Worker function to execute a caller provided function on all enabled APs.
+
+ @param[in] Procedure A pointer to the function to be run on
+ enabled APs of the system.
+ @param[in] MpEvent The Event used to sync the result.
+
+**/
+VOID
+StartupCPUsWorker (
+ IN EFI_AP_PROCEDURE Procedure
+ )
+{
+ EFI_STATUS Status;
+ EDKII_PEI_MP_SERVICES2_PPI *CpuMp2Ppi;
+ CPU_FEATURES_DATA *CpuFeaturesData;
+
+ CpuFeaturesData = GetCpuFeaturesData ();
+
+ //
+ // Get MP Services2 Ppi
+ //
+ Status = PeiServicesLocatePpi (
+ &gEdkiiPeiMpServices2PpiGuid,
+ 0,
+ NULL,
+ (VOID **)&CpuMp2Ppi
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Wakeup all APs for data collection.
+ //
+ Status = CpuMp2Ppi->StartupAllCPUs (
+ CpuMp2Ppi,
+ Procedure,
+ 0,
+ CpuFeaturesData
+ );
+ ASSERT_EFI_ERROR (Status);
+}
+
/**
Worker function to switch the requested AP to be the BSP from that point onward.
@@ -267,23 +311,9 @@ CpuFeaturesInitialize (
CpuFeaturesData->BspNumber = OldBspNumber;
//
- // Known limitation: In PEI phase, CpuFeatures driver not
- // support async mode execute tasks. So semaphore type
- // register can't been used for this instance, must use
- // DXE type instance.
- //
-
- if (CpuFeaturesData->NumberOfCpus > 1) {
- //
- // Wakeup all APs for programming.
- //
- StartupAPsWorker (SetProcessorRegister, NULL);
- }
-
- //
- // Programming BSP
+ // Start to program register for all CPUs.
//
- SetProcessorRegister (CpuFeaturesData);
+ StartupCPUsWorker (SetProcessorRegister);
//
// Switch to new BSP if required
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf
index 63091dfeb8..61f922bf63 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf
@@ -46,6 +46,7 @@
[Ppis]
gEfiPeiMpServicesPpiGuid ## CONSUMES
+ gEdkiiPeiMpServices2PpiGuid ## CONSUMES
[Pcd]
gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## CONSUMES
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 11+ messages in thread