From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web10.15410.1572918482975166869 for ; Mon, 04 Nov 2019 17:48:03 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: eric.dong@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Nov 2019 17:48:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,269,1569308400"; d="scan'208";a="401820152" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga005.fm.intel.com with ESMTP; 04 Nov 2019 17:48:02 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 4 Nov 2019 17:48:01 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 4 Nov 2019 17:48:01 -0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.108]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.2]) with mapi id 14.03.0439.000; Tue, 5 Nov 2019 09:47:59 +0800 From: "Dong, Eric" To: "devel@edk2.groups.io" , "Ni, Ray" CC: Laszlo Ersek Subject: Re: [edk2-devel] [PATCH 2/2] UefiCpuPkg/MpInitLib: Remove global variable X2ApicEnable Thread-Topic: [edk2-devel] [PATCH 2/2] UefiCpuPkg/MpInitLib: Remove global variable X2ApicEnable Thread-Index: AQHVjwf0BMUIx+zNq0CjFKf4zSf3TKd72AXg Date: Tue, 5 Nov 2019 01:47:59 +0000 Message-ID: References: <20191030095233.565420-1-ray.ni@intel.com> <20191030095233.565420-3-ray.ni@intel.com> In-Reply-To: <20191030095233.565420-3-ray.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: eric.dong@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Eric Dong -----Original Message----- From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Ni, = Ray Sent: Wednesday, October 30, 2019 5:53 PM To: devel@edk2.groups.io Cc: Dong, Eric ; Laszlo Ersek Subject: [edk2-devel] [PATCH 2/2] UefiCpuPkg/MpInitLib: Remove global vari= able 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 t= o remove the setting of X2ApicEnable. Signed-off-by: Ray Ni Cc: Eric Dong Cc: Laszlo Ersek --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 14 ++++++-------- UefiCpuPkg/Libr= ary/MpInitLib/MpLib.h | 1 - 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpI= nitLib/MpLib.c index 8f62a8d965..49be5d5385 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -459,12 +459,12 @@ CollectProcessorCount ( { UINTN Index; CPU_INFO_IN_HOB *CpuInfoInHob; + BOOLEAN X2Apic; =20 // // Send 1st broadcast IPI to APs to wakeup APs // - CpuMpData->InitFlag =3D ApInitConfig; - CpuMpData->X2ApicEnable =3D FALSE; + CpuMpData->InitFlag =3D ApInitConfig; WakeUpAP (CpuMpData, TRUE, 0, NULL, NULL, TRUE); CpuMpData->InitFlag =3D ApInitDone; ASSERT (CpuMpData->CpuCount <=3D PcdGet32 (PcdCpuMaxLogicalProcessorNum= ber)); @@ -481,22 +481,23 @@ CollectProcessorCount ( // 1. Number of CPU is greater than 255; or // 2. There are any logical processors reporting an Initial APIC ID of= 255 or greater. // + X2Apic =3D FALSE; if (CpuMpData->CpuCount > 255) { // // If there are more than 255 processor found, force to enable X2APIC // - CpuMpData->X2ApicEnable =3D TRUE; + X2Apic =3D TRUE; } else { CpuInfoInHob =3D (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; for (Index =3D 0; Index < CpuMpData->CpuCount; Index++) { if (CpuInfoInHob[Index].InitialApicId >=3D 0xFF) { - CpuMpData->X2ApicEnable =3D TRUE; + X2Apic =3D TRUE; break; } } } =20 - if (CpuMpData->X2ApicEnable) { + if (X2Apic) { DEBUG ((DEBUG_INFO, "Force x2APIC mode!\n")); // // Wakeup all APs to enable x2APIC mode @@ -1780,9 +1781,6 @@ MpInitL= ibInitialize ( CpuInfoInHob =3D (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob; for (Index =3D 0; Index < CpuMpData->CpuCount; Index++) { InitializeSpinLock(&CpuMpData->CpuData[Index].ApLock); - if (CpuInfoInHob[Index].InitialApicId >=3D 255 || Index > 254) { - CpuMpData->X2ApicEnable =3D TRUE; - } CpuMpData->CpuData[Index].CpuHealthy =3D (CpuInfoInHob[Index].Healt= h =3D=3D 0)? TRUE:FALSE; CpuMpData->CpuData[Index].ApFunction =3D 0; CopyMem (&CpuMpData->CpuData[Index].VolatileRegisters, &VolatileReg= isters, sizeof (CPU_VOLATILE_REGISTERS)); diff --git a/UefiCpuPkg/Library/M= pInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h index 107872b367..8fa07b12c5 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h @@ -227,7 +227,6 @@ struct _CPU_MP_DATA { UINTN **FailedCpuList; =20 AP_INIT_STATE InitFlag; - BOOLEAN X2ApicEnable; BOOLEAN SwitchBspFlag; UINTN NewBspNumber; CPU_EXCHANGE_ROLE_INFO BSPInfo; -- 2.21.0.windows.1