]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: Remove global variable X2ApicEnable
authorRay Ni <ray.ni@intel.com>
Wed, 23 Oct 2019 06:54:57 +0000 (14:54 +0800)
committerRay Ni <ray.ni@intel.com>
Tue, 5 Nov 2019 02:03:44 +0000 (10:03 +0800)
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>
UefiCpuPkg/Library/MpInitLib/MpLib.c
UefiCpuPkg/Library/MpInitLib/MpLib.h

index 8f62a8d965594065bd574486f02b1ede33810034..49be5d5385d98e2895d295fad1759104a9b45934 100644 (file)
@@ -459,12 +459,12 @@ CollectProcessorCount (
 {\r
   UINTN                  Index;\r
   CPU_INFO_IN_HOB        *CpuInfoInHob;\r
+  BOOLEAN                X2Apic;\r
 \r
   //\r
   // Send 1st broadcast IPI to APs to wakeup APs\r
   //\r
-  CpuMpData->InitFlag     = ApInitConfig;\r
-  CpuMpData->X2ApicEnable = FALSE;\r
+  CpuMpData->InitFlag = ApInitConfig;\r
   WakeUpAP (CpuMpData, TRUE, 0, NULL, NULL, TRUE);\r
   CpuMpData->InitFlag = ApInitDone;\r
   ASSERT (CpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));\r
@@ -481,22 +481,23 @@ CollectProcessorCount (
   //  1. Number of CPU is greater than 255; or\r
   //  2. There are any logical processors reporting an Initial APIC ID of 255 or greater.\r
   //\r
+  X2Apic = FALSE;\r
   if (CpuMpData->CpuCount > 255) {\r
     //\r
     // If there are more than 255 processor found, force to enable X2APIC\r
     //\r
-    CpuMpData->X2ApicEnable = TRUE;\r
+    X2Apic = TRUE;\r
   } else {\r
     CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob;\r
     for (Index = 0; Index < CpuMpData->CpuCount; Index++) {\r
       if (CpuInfoInHob[Index].InitialApicId >= 0xFF) {\r
-        CpuMpData->X2ApicEnable = TRUE;\r
+        X2Apic = TRUE;\r
         break;\r
       }\r
     }\r
   }\r
 \r
-  if (CpuMpData->X2ApicEnable) {\r
+  if (X2Apic) {\r
     DEBUG ((DEBUG_INFO, "Force x2APIC mode!\n"));\r
     //\r
     // Wakeup all APs to enable x2APIC mode\r
@@ -1780,9 +1781,6 @@ MpInitLibInitialize (
     CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob;\r
     for (Index = 0; Index < CpuMpData->CpuCount; Index++) {\r
       InitializeSpinLock(&CpuMpData->CpuData[Index].ApLock);\r
-      if (CpuInfoInHob[Index].InitialApicId >= 255 || Index > 254) {\r
-        CpuMpData->X2ApicEnable = TRUE;\r
-      }\r
       CpuMpData->CpuData[Index].CpuHealthy = (CpuInfoInHob[Index].Health == 0)? TRUE:FALSE;\r
       CpuMpData->CpuData[Index].ApFunction = 0;\r
       CopyMem (&CpuMpData->CpuData[Index].VolatileRegisters, &VolatileRegisters, sizeof (CPU_VOLATILE_REGISTERS));\r
index 107872b3679c9b6aa23c5318c4a7a8c1054c9493..8fa07b12c5e11aa4a17c958546a6b7d3d886e7e1 100644 (file)
@@ -227,7 +227,6 @@ struct _CPU_MP_DATA {
   UINTN                          **FailedCpuList;\r
 \r
   AP_INIT_STATE                  InitFlag;\r
-  BOOLEAN                        X2ApicEnable;\r
   BOOLEAN                        SwitchBspFlag;\r
   UINTN                          NewBspNumber;\r
   CPU_EXCHANGE_ROLE_INFO         BSPInfo;\r