]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously.
authorEric Dong <eric.dong@intel.com>
Thu, 20 Dec 2018 02:19:08 +0000 (10:19 +0800)
committerEric Dong <eric.dong@intel.com>
Mon, 29 Jul 2019 01:25:20 +0000 (09:25 +0800)
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>
Reviewed-by: Ray Ni <ray.ni@intel.com>
UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c
UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c
UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf
UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h

index 33752c1a9f0c0bbb955976751c04e23038e6e9c3..4e97e863c759f714fe30628fa799af9aca66c6e8 100644 (file)
@@ -1074,7 +1074,7 @@ CpuFeaturesDetect (
     //\r
     // Wakeup all APs for data collection.\r
     //\r
-    StartupAPsWorker (CollectProcessorData, NULL);\r
+    StartupAllAPsWorker (CollectProcessorData, NULL);\r
   }\r
 \r
   //\r
index f87b2892aaae439ac2f62d03b3fa7408249af848..e2e06e88e0a787a38edc6ba21078b2f1d57d50c4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU Register Table Library functions.\r
 \r
-  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -116,7 +116,7 @@ GetProcessorInformation (
                                       to check whether procedure has done.\r
 **/\r
 VOID\r
-StartupAPsWorker (\r
+StartupAllAPsWorker (\r
   IN  EFI_AP_PROCEDURE                 Procedure,\r
   IN  EFI_EVENT                        MpEvent\r
   )\r
@@ -248,7 +248,7 @@ CpuFeaturesInitialize (
     //\r
     // Wakeup all APs for programming.\r
     //\r
-    StartupAPsWorker (SetProcessorRegister, MpEvent);\r
+    StartupAllAPsWorker (SetProcessorRegister, MpEvent);\r
   }\r
 \r
   //\r
index 8ad5a40e5a44021bfad3cd2a5b218a4c88ce1aa9..64768f7a74b055891e52041d32ee3bb526de6d83 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU Register Table Library functions.\r
 \r
-  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -12,6 +12,8 @@
 #include <Library/PeiServicesLib.h>\r
 #include <Library/PeiServicesTablePointerLib.h>\r
 #include <Ppi/MpServices.h>\r
+#include <Ppi/MpServices2.h>\r
+\r
 #include "RegisterCpuFeatures.h"\r
 \r
 #define REGISTER_CPU_FEATURES_GUID \\r
@@ -154,7 +156,7 @@ GetProcessorInformation (
 \r
 **/\r
 VOID\r
-StartupAPsWorker (\r
+StartupAllAPsWorker (\r
   IN  EFI_AP_PROCEDURE                 Procedure,\r
   IN  EFI_EVENT                        MpEvent\r
   )\r
@@ -180,6 +182,47 @@ StartupAPsWorker (
   ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
+/**\r
+  Worker function to execute a caller provided function on all enabled CPUs.\r
+\r
+  @param[in]  Procedure               A pointer to the function to be run on\r
+                                      enabled CPUs of the system.\r
+\r
+**/\r
+VOID\r
+StartupAllCPUsWorker (\r
+  IN  EFI_AP_PROCEDURE                 Procedure\r
+  )\r
+{\r
+  EFI_STATUS                           Status;\r
+  EDKII_PEI_MP_SERVICES2_PPI           *CpuMp2Ppi;\r
+  CPU_FEATURES_DATA                    *CpuFeaturesData;\r
+\r
+  CpuFeaturesData = GetCpuFeaturesData ();\r
+\r
+  //\r
+  // Get MP Services2 Ppi\r
+  //\r
+  Status = PeiServicesLocatePpi (\r
+             &gEdkiiPeiMpServices2PpiGuid,\r
+             0,\r
+             NULL,\r
+             (VOID **)&CpuMp2Ppi\r
+             );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  //\r
+  // Wakeup all APs for data collection.\r
+  //\r
+  Status = CpuMp2Ppi->StartupAllCPUs (\r
+                 CpuMp2Ppi,\r
+                 Procedure,\r
+                 0,\r
+                 CpuFeaturesData\r
+                 );\r
+  ASSERT_EFI_ERROR (Status);\r
+}\r
+\r
 /**\r
   Worker function to switch the requested AP to be the BSP from that point onward.\r
 \r
@@ -267,23 +310,9 @@ CpuFeaturesInitialize (
   CpuFeaturesData->BspNumber = OldBspNumber;\r
 \r
   //\r
-  // Known limitation: In PEI phase, CpuFeatures driver not\r
-  // support async mode execute tasks. So semaphore type\r
-  // register can't been used for this instance, must use\r
-  // DXE type instance.\r
-  //\r
-\r
-  if (CpuFeaturesData->NumberOfCpus > 1) {\r
-    //\r
-    // Wakeup all APs for programming.\r
-    //\r
-    StartupAPsWorker (SetProcessorRegister, NULL);\r
-  }\r
-\r
-  //\r
-  // Programming BSP\r
+  // Start to program register for all CPUs.\r
   //\r
-  SetProcessorRegister (CpuFeaturesData);\r
+  StartupAllCPUsWorker (SetProcessorRegister);\r
 \r
   //\r
   // Switch to new BSP if required\r
index 63091dfeb8adae65fc882ad3ebb0f22ea8b89308..61f922bf6361e99e86b544f037e58e9789b96901 100644 (file)
@@ -46,6 +46,7 @@
 \r
 [Ppis]\r
   gEfiPeiMpServicesPpiGuid                                             ## CONSUMES\r
+  gEdkiiPeiMpServices2PpiGuid                                          ## CONSUMES\r
 \r
 [Pcd]\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress                        ## CONSUMES\r
index a18f926641fb801e966573d7394ddb7ad5809c8a..a25dd692927c1d4354c5987aad3a0aa41186df39 100644 (file)
@@ -145,7 +145,7 @@ GetProcessorInformation (
                                       to check whether procedure has done.\r
 **/\r
 VOID\r
-StartupAPsWorker (\r
+StartupAllAPsWorker (\r
   IN  EFI_AP_PROCEDURE                 Procedure,\r
   IN  EFI_EVENT                        MpEvent\r
   );\r