mirror of https://github.com/acidanthera/audk.git
UefiCpuPkg/MpInitLib: Remove global variable X2ApicEnable
MpInitLib sets X2ApicEnable in two places. 1. CollectProcessorCount() This function is called when MpInitLibInitialize() hasn't been called before. It sets X2ApicEnable and later in the same function it configures all CPUs to operate in X2 APIC mode. 2. MpInitLibInitialize() The X2ApicEnable setting happens when this function is called in second time. But after that setting, no code consumes that flag. With the above analysis and with the purpose of simplifying the code, the X2ApicEnable in #1 is changed to local variable and the #2 can be changed to remove the setting of X2ApicEnable. Signed-off-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
parent
54d1e76f4e
commit
fe3ca5fd25
|
@ -459,12 +459,12 @@ CollectProcessorCount (
|
||||||
{
|
{
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
CPU_INFO_IN_HOB *CpuInfoInHob;
|
CPU_INFO_IN_HOB *CpuInfoInHob;
|
||||||
|
BOOLEAN X2Apic;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Send 1st broadcast IPI to APs to wakeup APs
|
// Send 1st broadcast IPI to APs to wakeup APs
|
||||||
//
|
//
|
||||||
CpuMpData->InitFlag = ApInitConfig;
|
CpuMpData->InitFlag = ApInitConfig;
|
||||||
CpuMpData->X2ApicEnable = FALSE;
|
|
||||||
WakeUpAP (CpuMpData, TRUE, 0, NULL, NULL, TRUE);
|
WakeUpAP (CpuMpData, TRUE, 0, NULL, NULL, TRUE);
|
||||||
CpuMpData->InitFlag = ApInitDone;
|
CpuMpData->InitFlag = ApInitDone;
|
||||||
ASSERT (CpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
|
ASSERT (CpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
|
||||||
|
@ -481,22 +481,23 @@ CollectProcessorCount (
|
||||||
// 1. Number of CPU is greater than 255; or
|
// 1. Number of CPU is greater than 255; or
|
||||||
// 2. There are any logical processors reporting an Initial APIC ID of 255 or greater.
|
// 2. There are any logical processors reporting an Initial APIC ID of 255 or greater.
|
||||||
//
|
//
|
||||||
|
X2Apic = FALSE;
|
||||||
if (CpuMpData->CpuCount > 255) {
|
if (CpuMpData->CpuCount > 255) {
|
||||||
//
|
//
|
||||||
// If there are more than 255 processor found, force to enable X2APIC
|
// If there are more than 255 processor found, force to enable X2APIC
|
||||||
//
|
//
|
||||||
CpuMpData->X2ApicEnable = TRUE;
|
X2Apic = TRUE;
|
||||||
} else {
|
} else {
|
||||||
CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob;
|
CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob;
|
||||||
for (Index = 0; Index < CpuMpData->CpuCount; Index++) {
|
for (Index = 0; Index < CpuMpData->CpuCount; Index++) {
|
||||||
if (CpuInfoInHob[Index].InitialApicId >= 0xFF) {
|
if (CpuInfoInHob[Index].InitialApicId >= 0xFF) {
|
||||||
CpuMpData->X2ApicEnable = TRUE;
|
X2Apic = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CpuMpData->X2ApicEnable) {
|
if (X2Apic) {
|
||||||
DEBUG ((DEBUG_INFO, "Force x2APIC mode!\n"));
|
DEBUG ((DEBUG_INFO, "Force x2APIC mode!\n"));
|
||||||
//
|
//
|
||||||
// Wakeup all APs to enable x2APIC mode
|
// Wakeup all APs to enable x2APIC mode
|
||||||
|
@ -1780,9 +1781,6 @@ MpInitLibInitialize (
|
||||||
CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob;
|
CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob;
|
||||||
for (Index = 0; Index < CpuMpData->CpuCount; Index++) {
|
for (Index = 0; Index < CpuMpData->CpuCount; Index++) {
|
||||||
InitializeSpinLock(&CpuMpData->CpuData[Index].ApLock);
|
InitializeSpinLock(&CpuMpData->CpuData[Index].ApLock);
|
||||||
if (CpuInfoInHob[Index].InitialApicId >= 255 || Index > 254) {
|
|
||||||
CpuMpData->X2ApicEnable = TRUE;
|
|
||||||
}
|
|
||||||
CpuMpData->CpuData[Index].CpuHealthy = (CpuInfoInHob[Index].Health == 0)? TRUE:FALSE;
|
CpuMpData->CpuData[Index].CpuHealthy = (CpuInfoInHob[Index].Health == 0)? TRUE:FALSE;
|
||||||
CpuMpData->CpuData[Index].ApFunction = 0;
|
CpuMpData->CpuData[Index].ApFunction = 0;
|
||||||
CopyMem (&CpuMpData->CpuData[Index].VolatileRegisters, &VolatileRegisters, sizeof (CPU_VOLATILE_REGISTERS));
|
CopyMem (&CpuMpData->CpuData[Index].VolatileRegisters, &VolatileRegisters, sizeof (CPU_VOLATILE_REGISTERS));
|
||||||
|
|
|
@ -227,7 +227,6 @@ struct _CPU_MP_DATA {
|
||||||
UINTN **FailedCpuList;
|
UINTN **FailedCpuList;
|
||||||
|
|
||||||
AP_INIT_STATE InitFlag;
|
AP_INIT_STATE InitFlag;
|
||||||
BOOLEAN X2ApicEnable;
|
|
||||||
BOOLEAN SwitchBspFlag;
|
BOOLEAN SwitchBspFlag;
|
||||||
UINTN NewBspNumber;
|
UINTN NewBspNumber;
|
||||||
CPU_EXCHANGE_ROLE_INFO BSPInfo;
|
CPU_EXCHANGE_ROLE_INFO BSPInfo;
|
||||||
|
|
Loading…
Reference in New Issue