UefiCpuPkg RegisterCpuFeaturesLib: Fix an ASSERTION issue

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1968

We met assertion like below, it happens when there is only
one processor.

ASSERT_EFI_ERROR (Status = Not started)
ASSERT [CpuFeaturesDxe] X:\XXX\XXX\RegisterCpuFeaturesLib\
  DxeRegisterCpuFeaturesLib.c(149): !EFI_ERROR (Status)

The code should not call StartupAllAPs when there is only one processor.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Kevin Li <kevin.y.li@intel.com>
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
This commit is contained in:
Star Zeng 2019-07-10 19:40:05 +08:00
parent 28781fd52a
commit 7a0df266e5
3 changed files with 37 additions and 27 deletions

View File

@ -1071,10 +1071,12 @@ CpuFeaturesDetect (
CpuInitDataInitialize (); CpuInitDataInitialize ();
// if (CpuFeaturesData->NumberOfCpus > 1) {
// Wakeup all APs for data collection. //
// // Wakeup all APs for data collection.
StartupAPsWorker (CollectProcessorData, NULL); //
StartupAPsWorker (CollectProcessorData, NULL);
}
// //
// Collect data on BSP // Collect data on BSP

View File

@ -229,31 +229,36 @@ CpuFeaturesInitialize (
OldBspNumber = GetProcessorIndex (CpuFeaturesData); OldBspNumber = GetProcessorIndex (CpuFeaturesData);
CpuFeaturesData->BspNumber = OldBspNumber; CpuFeaturesData->BspNumber = OldBspNumber;
Status = gBS->CreateEvent ( if (CpuFeaturesData->NumberOfCpus > 1) {
EVT_NOTIFY_WAIT, Status = gBS->CreateEvent (
TPL_CALLBACK, EVT_NOTIFY_WAIT,
EfiEventEmptyFunction, TPL_CALLBACK,
NULL, EfiEventEmptyFunction,
&MpEvent NULL,
); &MpEvent
ASSERT_EFI_ERROR (Status); );
ASSERT_EFI_ERROR (Status);
//
// Wakeup all APs for programming.
//
StartupAPsWorker (SetProcessorRegister, MpEvent);
}
//
// Wakeup all APs for programming.
//
StartupAPsWorker (SetProcessorRegister, MpEvent);
// //
// Programming BSP // Programming BSP
// //
SetProcessorRegister (CpuFeaturesData); SetProcessorRegister (CpuFeaturesData);
// if (CpuFeaturesData->NumberOfCpus > 1) {
// Wait all processors to finish the task. //
// // Wait all processors to finish the task.
do { //
Status = gBS->CheckEvent (MpEvent); do {
} while (Status == EFI_NOT_READY); Status = gBS->CheckEvent (MpEvent);
ASSERT_EFI_ERROR (Status); } while (Status == EFI_NOT_READY);
ASSERT_EFI_ERROR (Status);
}
// //
// Switch to new BSP if required // Switch to new BSP if required

View File

@ -273,10 +273,13 @@ CpuFeaturesInitialize (
// DXE type instance. // DXE type instance.
// //
// if (CpuFeaturesData->NumberOfCpus > 1) {
// Wakeup all APs for programming. //
// // Wakeup all APs for programming.
StartupAPsWorker (SetProcessorRegister, NULL); //
StartupAPsWorker (SetProcessorRegister, NULL);
}
// //
// Programming BSP // Programming BSP
// //