From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 08 Oct 2019 04:27:20 -0700 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26E6585A03; Tue, 8 Oct 2019 11:27:20 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-109.rdu2.redhat.com [10.10.120.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 041B3600CE; Tue, 8 Oct 2019 11:27:18 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Eric Dong , Igor Mammedov , Ray Ni Subject: [PATCH 1/4] UefiCpuPkg/MpInitLib: honor the platform's boot CPU count in AP detection Date: Tue, 8 Oct 2019 13:27:11 +0200 Message-Id: <20191008112714.6215-2-lersek@redhat.com> In-Reply-To: <20191008112714.6215-1-lersek@redhat.com> References: <20191008112714.6215-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 08 Oct 2019 11:27:20 +0000 (UTC) Content-Transfer-Encoding: quoted-printable If a platform boots with a CPU topology that is not fully populated (that is, the boot CPU count is smaller than PcdCpuMaxLogicalProcessorNumber), then the platform cannot use the "fast AP detection" logic added in commi= t 6e1987f19af7. Said logic depends on the boot CPU count being equal to PcdCpuMaxLogicalProcessorNumber. The platform may not be able to use the variant added in commit 0594ec417c89 either, for different reasons; see for example commit 861218740d6d. Allow platforms to specify the exact boot CPU count, independently of PcdCpuMaxLogicalProcessorNumber. Cc: Eric Dong Cc: Igor Mammedov Cc: Ray Ni Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1515 Signed-off-by: Laszlo Ersek --- UefiCpuPkg/UefiCpuPkg.dec | 11 +++++ UefiCpuPkg/UefiCpuPkg.uni | 4 ++ UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf | 1 + UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf | 3 +- UefiCpuPkg/Library/MpInitLib/MpLib.c | 42 ++++++++++++-------- 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index 031a2ccd680a..d6b33fd9b465 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -227,6 +227,17 @@ [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynami= c, PcdsDynamicEx] ## Specifies timeout value in microseconds for the BSP to detect all A= Ps for the first time. # @Prompt Timeout for the BSP to detect all APs for the first time. gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds|50000|UINT= 32|0x00000004 + ## Specifies the number of Logical Processors that are available in th= e + # preboot environment after platform reset, including BSP and APs. Po= ssible + # values:

+ # zero (default) - This PCD is ignored, and + # PcdCpuApInitTimeOutInMicroSeconds limits the initi= al AP + # detection by the BSP.
+ # nonzero - PcdCpuApInitTimeOutInMicroSeconds is ignored. The = initial + # AP detection finishes when the detected CPU count = (BSP + # plus APs) reaches the value of this PCD.
+ # @Prompt Number of Logical Processors available after platform reset. + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber|0|UINT32|0x= 00000008 ## Specifies the base address of the first microcode Patch in the micr= ocode Region. # @Prompt Microcode Region base address. gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress|0x0|UINT64|0x000= 00005 diff --git a/UefiCpuPkg/UefiCpuPkg.uni b/UefiCpuPkg/UefiCpuPkg.uni index fbf768072668..a7e279c5cb14 100644 --- a/UefiCpuPkg/UefiCpuPkg.uni +++ b/UefiCpuPkg/UefiCpuPkg.uni @@ -37,6 +37,10 @@ =20 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApInitTimeOutInMicroSeconds_= HELP #language en-US "Specifies timeout value in microseconds for the BS= P to detect all APs for the first time." =20 +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuBootLogicalProcessorNumber_P= ROMPT #language en-US "Number of Logical Processors available after plat= form reset." + +#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuBootLogicalProcessorNumber_H= ELP #language en-US "Specifies the number of Logical Processors that are= available in the preboot environment after platform reset, including BSP= and APs." + #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMicrocodePatchAddress_PROMPT= #language en-US "Microcode Region base address." =20 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuMicrocodePatchAddress_HELP = #language en-US "Specifies the base address of the first microcode Patch = in the microcode Region." diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf b/UefiCpuPkg/L= ibrary/MpInitLib/DxeMpInitLib.inf index 37b3f64e578a..cd912ab0c5ee 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf @@ -61,6 +61,7 @@ [Guids] =20 [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CO= NSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber ## CO= NSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## SO= METIMES_CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CO= NSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CO= NSUMES diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf b/UefiCpuPkg/L= ibrary/MpInitLib/PeiMpInitLib.inf index 82b77b63ea87..1538185ef99a 100644 --- a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf @@ -53,7 +53,8 @@ [LibraryClasses] =20 [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber ## CO= NSUMES - gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## CO= NSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber ## CO= NSUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds ## SO= METIMES_CONSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize ## CO= NSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress ## CO= NSUMES gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize ## CO= NSUMES diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/Mp= InitLib/MpLib.c index d6f84c6f45c0..f1bf8a7ba7cf 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -1044,24 +1044,32 @@ WakeUpAP ( SendInitSipiSipiAllExcludingSelf ((UINT32) ExchangeInfo->BufferSta= rt); } if (CpuMpData->InitFlag =3D=3D ApInitConfig) { - // - // Here support two methods to collect AP count through adjust - // PcdCpuApInitTimeOutInMicroSeconds values. - // - // one way is set a value to just let the first AP to start the - // initialization, then through the later while loop to wait all A= ps - // finsh the initialization. - // The other way is set a value to let all APs finished the initia= lzation. - // In this case, the later while loop is useless. - // - TimedWaitForApFinish ( - CpuMpData, - PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1, - PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds) - ); + if (PcdGet32 (PcdCpuBootLogicalProcessorNumber) > 0) { + TimedWaitForApFinish ( + CpuMpData, + PcdGet32 (PcdCpuBootLogicalProcessorNumber) - 1, + MAX_UINT32 // approx. 71 minutes + ); + } else { + // + // Here support two methods to collect AP count through adjust + // PcdCpuApInitTimeOutInMicroSeconds values. + // + // one way is set a value to just let the first AP to start the + // initialization, then through the later while loop to wait all= Aps + // finsh the initialization. + // The other way is set a value to let all APs finished the + // initialzation. In this case, the later while loop is useless. + // + TimedWaitForApFinish ( + CpuMpData, + PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1, + PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds) + ); =20 - while (CpuMpData->MpCpuExchangeInfo->NumApsExecuting !=3D 0) { - CpuPause(); + while (CpuMpData->MpCpuExchangeInfo->NumApsExecuting !=3D 0) { + CpuPause(); + } } } else { // --=20 2.19.1.3.g30247aa5d201