From nobody Mon Apr 29 05:23:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+44291+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44291+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1563952056; cv=none; d=zoho.com; s=zohoarc; b=GJ38RCHLvIIHaeN0ZL+J7rAcbWIPnkczcWxdpFMmX1ssv+KJfwRFpkutu2uN6PLoWUZjjmXwsopnlQAz+J4nzmLYGo5fKI2+DQQVrzCu93e+NuwHMVTV8s0lL7EwTFtLuYWKH8AKkbmVd9ZKIxp3mY2RoN2gfaKQuCDcNntzZ70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563952056; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=CVXW4L1iJWo6bdl0PVLx90pRQ+vUpgahok4QbUAEOA4=; b=hDV4ZMBxAX0ECMOOK4+6yena92ICrxlkB/ed9SCfkLz3mOUKmhb/gmnd5IWDnPwrXZP2w3uZXGnhCJt3HdidDlVq25qqn5/F5M7ZnNWqhzmq1sYtmWtk0z3XJfJ1Fy+tDaR7XTRAcsb0dSGM1i4O7q5ipPUYQ5BjSNk8Q1DoXso= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44291+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1563952056511321.2261419583832; Wed, 24 Jul 2019 00:07:36 -0700 (PDT) Return-Path: X-Received: from mga09.intel.com (mga09.intel.com []) by groups.io with SMTP; Wed, 24 Jul 2019 00:07:35 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jul 2019 00:07:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,302,1559545200"; d="scan'208";a="172211081" X-Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.133]) by orsmga003.jf.intel.com with ESMTP; 24 Jul 2019 00:07:30 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Chandana Kumar , Star Zeng Subject: [edk2-devel] [Patch v3 1/6] UefiCpuPkg/Include/MpInitLib.h: Add MpInitLibStartupAllCPUs API. Date: Wed, 24 Jul 2019 15:07:22 +0800 Message-Id: <20190724070727.14976-2-eric.dong@intel.com> In-Reply-To: <20190724070727.14976-1-eric.dong@intel.com> References: <20190724070727.14976-1-eric.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,eric.dong@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1563952056; bh=2pnTcfcuRzXao5ucEg00MLLjroCyEaP5+xyLd1xoCcQ=; h=Cc:Date:From:Reply-To:Subject:To; b=qudlRLeWOibq3hY1MTOEj1WKipDDh9kVDOXcth/Xqo/1TNdSfGEFTNQA+hHWoNI6udO ka6vpTgyusAFcSF9hvPI/S41o5wM5PBbVM8T0d13Hfip/myDD8VqAPbHEiQKTfy8Dn44T gCp3CLTTww9M/m9TVrGAd0aL76n6aoVyOEk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1973 Add new MpInitLibStartupAllCPUs API uses to start all processors at the same time. Cc: Ray Ni Cc: Laszlo Ersek Cc: Chandana Kumar Cc: Star Zeng Signed-off-by: Eric Dong Reviewed-by: Ray Ni --- UefiCpuPkg/Include/Library/MpInitLib.h | 36 +++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Include/Library/MpInitLib.h b/UefiCpuPkg/Include/Li= brary/MpInitLib.h index fa82529373..31eb227f12 100644 --- a/UefiCpuPkg/Include/Library/MpInitLib.h +++ b/UefiCpuPkg/Include/Library/MpInitLib.h @@ -1,7 +1,7 @@ /** @file Multiple-Processor initialization Library. =20 - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -344,4 +344,38 @@ MpInitLibWhoAmI ( OUT UINTN *ProcessorNumber ); =20 +/** + This service executes a caller provided function on all enabled CPUs. + + @param[in] Procedure A pointer to the function to be run = on + enabled APs of the system. See type + EFI_AP_PROCEDURE. + @param[in] TimeoutInMicroseconds Indicates the time limit in microsec= onds for + APs to return from Procedure, either= for + blocking or non-blocking mode. Zero = means + infinity. TimeoutInMicroseconds is i= gnored + for BSP. + @param[in] ProcedureArgument The parameter passed into Procedure = for + all APs. + + @retval EFI_SUCCESS In blocking mode, all CPUs have finished= before + the timeout expired. + @retval EFI_SUCCESS In non-blocking mode, function has been = dispatched + to all enabled CPUs. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + @retval EFI_TIMEOUT In blocking mode, the timeout expired be= fore + all enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +MpInitLibStartupAllCPUs ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL + ); + #endif --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#44291): https://edk2.groups.io/g/devel/message/44291 Mute This Topic: https://groups.io/mt/32581675/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 05:23:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+44292+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44292+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1563952058; cv=none; d=zoho.com; s=zohoarc; b=blUVBS5KBFgYyUJR2LTO5kga94qlHZVw2TmZpyycZW6A9aNR3mesXJgQACHdj7HVdbrtnvq5XDlavYm42O81qLodIA+vmCFG/5T7u9CRZxFjRJmBDo1mGkbTFwOfc3uqC4RQDKIk4BebVtO+uD+gYtdLR9AS3FDEZJDgdHO2Ojo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563952058; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=vqiOaMHGNu5my0InNmCgrbbnJhhBv23DqmRjbpzhlVs=; b=bAF3qRUj/IS0SdrIUJO1lwr+p3U6QxTL+ezwQvoOUSvYVWYtlUrMPOTIdoHShXMY27tArgU3nfP7NXc2P4CY4NV71wZxbU0k44DDXSrKgIfr3aE8qT2ZtbGE3MQqu62bzSrErWK5LUfmUstpOb1+btBriOBvZr2mHqiKCRlfmZo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44292+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1563952058369532.2901606775026; Wed, 24 Jul 2019 00:07:38 -0700 (PDT) Return-Path: X-Received: from mga09.intel.com (mga09.intel.com []) by groups.io with SMTP; Wed, 24 Jul 2019 00:07:37 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jul 2019 00:07:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,302,1559545200"; d="scan'208";a="172211094" X-Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.133]) by orsmga003.jf.intel.com with ESMTP; 24 Jul 2019 00:07:31 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Chandana Kumar , Star Zeng Subject: [edk2-devel] [Patch v3 2/6] UefiCpuPkg/MpInitLib: Add MpInitLibStartupAllCPUs API. Date: Wed, 24 Jul 2019 15:07:23 +0800 Message-Id: <20190724070727.14976-3-eric.dong@intel.com> In-Reply-To: <20190724070727.14976-1-eric.dong@intel.com> References: <20190724070727.14976-1-eric.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,eric.dong@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1563952057; bh=9WqlJm4y++rKVx4NW1IbySrRABs6O8xggF5i+7JA7Ac=; h=Cc:Date:From:Reply-To:Subject:To; b=bO0gFiAg8rGr+0uq1UbhrYTWAR/pHGTsIgCG8gsBGPYghxUgejG8dUsU9B/dG8LQIHm dk28T0+LXunu+8rc+vWa3am6YnNIoCY9pLYQvVRZTB5AOEWoyTGTkCHYS/60W3WMeCo3B peGDZzl7mQlocFx0GCN16namNtegRz6uYgg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1973 Add new MpInitLibStartupAllCPUs API uses to start all processors at the same time. Cc: Ray Ni Cc: Laszlo Ersek Cc: Chandana Kumar Cc: Star Zeng Signed-off-by: Eric Dong Reviewed-by: Ray Ni --- UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 5 +- UefiCpuPkg/Library/MpInitLib/MpLib.c | 61 +++++++++++++++++++++++-- UefiCpuPkg/Library/MpInitLib/MpLib.h | 6 ++- UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 5 +- 4 files changed, 67 insertions(+), 10 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/M= pInitLib/DxeMpLib.c index 6be1bae464..b17e287bbf 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c @@ -1,7 +1,7 @@ /** @file MP initialize support functions for DXE phase. =20 - Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -568,9 +568,10 @@ MpInitLibStartupAllAPs ( // mStopCheckAllApsStatus =3D TRUE; =20 - Status =3D StartupAllAPsWorker ( + Status =3D StartupAllCPUsWorker ( Procedure, SingleThread, + TRUE, WaitEvent, TimeoutInMicroseconds, ProcedureArgument, diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 6f51bc4ebf..572495ec36 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -2130,6 +2130,7 @@ MpInitLibGetNumberOfProcessors ( number. If FALSE, then all the enab= led APs execute the function specified by Pr= ocedure simultaneously. + @param[in] ExcludeBsp Whether let BSP also trig this task. @param[in] WaitEvent The event created by the caller with= CreateEvent() service. @param[in] TimeoutInMicroseconds Indicates the time limit in microsec= onds for @@ -2151,9 +2152,10 @@ MpInitLibGetNumberOfProcessors ( =20 **/ EFI_STATUS -StartupAllAPsWorker ( +StartupAllCPUsWorker ( IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, + IN BOOLEAN ExcludeBsp, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, @@ -2175,7 +2177,7 @@ StartupAllAPsWorker ( *FailedCpuList =3D NULL; } =20 - if (CpuMpData->CpuCount =3D=3D 1) { + if (CpuMpData->CpuCount =3D=3D 1 && ExcludeBsp) { return EFI_NOT_STARTED; } =20 @@ -2218,9 +2220,9 @@ StartupAllAPsWorker ( } } =20 - if (!HasEnabledAp) { + if (!HasEnabledAp && ExcludeBsp) { // - // If no enabled AP exists, return EFI_NOT_STARTED. + // If no enabled AP exists and not include Bsp to do the procedure, re= turn EFI_NOT_STARTED. // return EFI_NOT_STARTED; } @@ -2266,6 +2268,13 @@ StartupAllAPsWorker ( } } =20 + if (!ExcludeBsp) { + // + // Start BSP. + // + Procedure (ProcedureArgument); + } + Status =3D EFI_SUCCESS; if (WaitEvent =3D=3D NULL) { do { @@ -2411,3 +2420,47 @@ GetCpuMpDataFromGuidedHob ( return CpuMpData; } =20 +/** + This service executes a caller provided function on all enabled CPUs. + + @param[in] Procedure A pointer to the function to be run = on + enabled APs of the system. See type + EFI_AP_PROCEDURE. + @param[in] TimeoutInMicroseconds Indicates the time limit in microsec= onds for + APs to return from Procedure, either= for + blocking or non-blocking mode. Zero = means + infinity. TimeoutInMicroseconds is i= gnored + for BSP. + @param[in] ProcedureArgument The parameter passed into Procedure = for + all APs. + + @retval EFI_SUCCESS In blocking mode, all CPUs have finished= before + the timeout expired. + @retval EFI_SUCCESS In non-blocking mode, function has been = dispatched + to all enabled CPUs. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_NOT_READY MP Initialize Library is not initialized. + @retval EFI_TIMEOUT In blocking mode, the timeout expired be= fore + all enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +MpInitLibStartupAllCPUs ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL + ) +{ + return StartupAllCPUsWorker ( + Procedure, + FALSE, + FALSE, + NULL, + TimeoutInMicroseconds, + ProcedureArgument, + NULL + ); +} diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpIn= itLib/MpLib.h index f89037c59e..effa235778 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h @@ -1,7 +1,7 @@ /** @file Common header file for MP Initialize Library. =20 - Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -405,6 +405,7 @@ InitMpGlobalData ( number. If FALSE, then all the enab= led APs execute the function specified by Pr= ocedure simultaneously. + @param[in] ExcludeBsp Whether let BSP also trig this task. @param[in] WaitEvent The event created by the caller with= CreateEvent() service. @param[in] TimeoutInMicroseconds Indicates the time limit in microsec= onds for @@ -426,9 +427,10 @@ InitMpGlobalData ( =20 **/ EFI_STATUS -StartupAllAPsWorker ( +StartupAllCPUsWorker ( IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, + IN BOOLEAN ExcludeBsp, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/M= pInitLib/PeiMpLib.c index 35dff91fd2..3999603c3e 100644 --- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c @@ -1,7 +1,7 @@ /** @file MP initialize support functions for PEI phase. =20 - Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -401,9 +401,10 @@ MpInitLibStartupAllAPs ( return EFI_UNSUPPORTED; } =20 - return StartupAllAPsWorker ( + return StartupAllCPUsWorker ( Procedure, SingleThread, + TRUE, NULL, TimeoutInMicroseconds, ProcedureArgument, --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#44292): https://edk2.groups.io/g/devel/message/44292 Mute This Topic: https://groups.io/mt/32581676/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 05:23:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+44290+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44290+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1563952056; cv=none; d=zoho.com; s=zohoarc; b=EF5J/bUHAsYRL2V0vDGCZwHVZp0J/yl7J7WrX77KkR+rABRauPFDN8yMvwZ5dUJReD7S78PTXw2Ia9wJdU2mUF5o+SjtlP6KaPMzsPKsxPn1A8uaiuHNdJiOnKtRi0aA9L5aVw8Z/ZfMa9j+gZ2TCC1DcmiFfA0Az0tIpIDj/KU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563952056; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=DgdB6BH1AEfyFa6D3xTkTRWFL04EzngOR/UtaxHV8BI=; b=Y54U9p2bkePjVUsVRkPHVy/jaJlk+1Ri4j4ux7sNC67He4mUqIEEkWMeMqzsc9fZ7xCTjoECFfA6cL3BcSq+JdUxQhKTNUNUj8bBRoU4wZNZUvgnAy1Ue3ZNArSSXuH4UUXDKaEZubHoHovqad5LWZwqwSDUqIa16NNwyzyHwFw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44290+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1563952056346561.1031394851227; Wed, 24 Jul 2019 00:07:36 -0700 (PDT) Return-Path: X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by groups.io with SMTP; Wed, 24 Jul 2019 00:07:35 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jul 2019 00:07:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,302,1559545200"; d="scan'208";a="172211103" X-Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.133]) by orsmga003.jf.intel.com with ESMTP; 24 Jul 2019 00:07:33 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Chandana Kumar , Star Zeng Subject: [edk2-devel] [Patch v3 3/6] UefiCpuPkg/MpInitLibUp: Add MpInitLibStartupAllCPUs API. Date: Wed, 24 Jul 2019 15:07:24 +0800 Message-Id: <20190724070727.14976-4-eric.dong@intel.com> In-Reply-To: <20190724070727.14976-1-eric.dong@intel.com> References: <20190724070727.14976-1-eric.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,eric.dong@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1563952056; bh=xSp5dn7U+DxcEfIJqyrN81sCz9RTvdzsQucZK/8Ozqs=; h=Cc:Date:From:Reply-To:Subject:To; b=X9S7KR4leAX2uN0KJC57Q6izaixt9Jfa7XAGMogl4bJjfki9JVTVxTSdRY/936N0lWr 3EyOJBWoF13DSp46VqQiIH9wOOyVgeaR9URbM4ue91mI/a33Js5FcmWXp50XM8vtScJtB Kj9lqtrzwLK6Dj9LA6/VDIsZCsq6mpeX4Kg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1973 Add new MpInitLibStartupAllCPUs API uses to start all processors at the same time. Cc: Ray Ni Cc: Laszlo Ersek Cc: Chandana Kumar Cc: Star Zeng Signed-off-by: Eric Dong Reviewed-by: Ray Ni --- UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c b/UefiCpuPkg/Libr= ary/MpInitLibUp/MpInitLibUp.c index 36c2bb5326..b4024ee1ae 100644 --- a/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c +++ b/UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.c @@ -405,3 +405,38 @@ MpInitLibWhoAmI ( *ProcessorNumber =3D 0; return EFI_SUCCESS; } + +/** + This service executes a caller provided function on all enabled CPUs. + + @param[in] Procedure A pointer to the function to be run = on + enabled APs of the system. See type + EFI_AP_PROCEDURE. + @param[in] TimeoutInMicroseconds Indicates the time limit in microsec= onds for + APs to return from Procedure, either= for + blocking or non-blocking mode. Zero = means + infinity. TimeoutInMicroseconds is i= gnored + for BSP. + @param[in] ProcedureArgument The parameter passed into Procedure = for + all APs. + + @retval EFI_SUCCESS CPU have finished the procedure. + @retval EFI_INVALID_PARAMETER Procedure is NULL. + +**/ +EFI_STATUS +EFIAPI +MpInitLibStartupAllCPUs ( + IN EFI_AP_PROCEDURE Procedure, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL + ) +{ + if (Procedure =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + Procedure (ProcedureArgument); + + return EFI_SUCCESS; +} --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#44290): https://edk2.groups.io/g/devel/message/44290 Mute This Topic: https://groups.io/mt/32581674/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 05:23:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+44293+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44293+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1563952058; cv=none; d=zoho.com; s=zohoarc; b=dhan9OsNdsSLHyCe99bdhOMToD+3x+iaTydy/KjrifphnVotrXDFU+m6thiQkSNete89x73DXDGKzdZG0n5+jdgGAVv5D4gW04oKg6DobPMtgjj+KO1qZvQ/HYTu++2zte7D3DT1iYpt9ZkjXs/WIFFjI5ZOQ6u4FSU4R4X9j0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563952058; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=iO6UEVoELLlA8PIxblIh86JeT2Nf+z7BwtKV9cRD8kw=; b=mi2nI+wp1Adk03jiuWDFdh5yoh3SDI8IDwL424UUznAblp0HgJQTSAwk4m8UkA84UsdFdUxOAoggbp/ZA2ftQBQha+AM57T18yc876PGBdzgqS+rO5IPuxX/qnMaIW9wmgVgLKsD2GqtjQ/mUo80+jNJ8ugZ992igjuipul2sUA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44293+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1563952058501245.69160580483162; Wed, 24 Jul 2019 00:07:38 -0700 (PDT) Return-Path: X-Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by groups.io with SMTP; Wed, 24 Jul 2019 00:07:37 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jul 2019 00:07:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,302,1559545200"; d="scan'208";a="172211112" X-Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.133]) by orsmga003.jf.intel.com with ESMTP; 24 Jul 2019 00:07:34 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Chandana Kumar , Star Zeng Subject: [edk2-devel] [Patch v3 4/6] UefiCpuPkg: Add new EDKII_PEI_MP_SERVICES2_PPI Date: Wed, 24 Jul 2019 15:07:25 +0800 Message-Id: <20190724070727.14976-5-eric.dong@intel.com> In-Reply-To: <20190724070727.14976-1-eric.dong@intel.com> References: <20190724070727.14976-1-eric.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,eric.dong@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1563952058; bh=sVYD5qoEQSFl0h/UdkMJN0M4N7rATTHGTogrIcTiiJI=; h=Cc:Date:From:Reply-To:Subject:To; b=a/MhrwB+8oRm+8uLAashjlDz8NpUVvOY64NoDiJS3bcxVWOaR3vo64pk3O04iKPYrAZ QD4zjZK4hajyEfb6wtryEfIQZPqFKGxtmHCrm1SSE2fWlDoiPFGp8QJgpBr8ua2r0BDVG zqpa3Dwo83wQyaPsKUIJCc3sZOI6BzwW10k= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1973 Add definition for new EDKII_PEI_MP_SERVICES2_PPI. It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI and add new API EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS. Cc: Ray Ni Cc: Laszlo Ersek Cc: Chandana Kumar Cc: Star Zeng Signed-off-by: Eric Dong --- UefiCpuPkg/Include/Ppi/MpServices2.h | 279 +++++++++++++++++++++++++++ UefiCpuPkg/UefiCpuPkg.dec | 3 + 2 files changed, 282 insertions(+) create mode 100644 UefiCpuPkg/Include/Ppi/MpServices2.h diff --git a/UefiCpuPkg/Include/Ppi/MpServices2.h b/UefiCpuPkg/Include/Ppi/= MpServices2.h new file mode 100644 index 0000000000..83a56588a5 --- /dev/null +++ b/UefiCpuPkg/Include/Ppi/MpServices2.h @@ -0,0 +1,279 @@ +/** @file + This file declares edkii Multi-processor service PPI. + + Copyright (c) 2019, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __EDKII_PEI_MP_SERVICES2_PPI_H__ +#define __EDKII_PEI_MP_SERVICES2_PPI_H__ + +#include + +#define EDKII_PEI_MP_SERVICES2_PPI_GUID \ + { \ + 0x5cb9cb3d, 0x31a4, 0x480c, { 0x94, 0x98, 0x29, 0xd2, 0x69, 0xba, 0xcf= , 0xba} \ + } + +typedef struct _EDKII_PEI_MP_SERVICES2_PPI EDKII_PEI_MP_SERVICES2_PPI; + +/** + Get the number of CPU's. + + @param[in] This Pointer to this instance of the PPI. + @param[out] NumberOfProcessors Pointer to the total number of logical p= rocessors in + the system, including the BSP and disabl= ed APs. + @param[out] NumberOfEnabledProcessors + Number of processors in the system that = are enabled. + + @retval EFI_SUCCESS The number of logical processors and ena= bled + logical processors was retrieved. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL. + NumberOfEnabledProcessors is NULL. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS) ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + OUT UINTN *NumberOfProcessors, + OUT UINTN *NumberOfEnabledProcessors + ); + +/** + Get information on a specific CPU. + + @param[in] This Pointer to this instance of the PPI. + @param[in] ProcessorNumber Pointer to the total number of logical p= rocessors in + the system, including the BSP and disabl= ed APs. + @param[out] ProcessorInfoBuffer Number of processors in the system that = are enabled. + + @retval EFI_SUCCESS Processor information was returned. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. + @retval EFI_NOT_FOUND The processor with the handle specified = by + ProcessorNumber does not exist in the pl= atform. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_PEI_MP_SERVICES_GET_PROCESSOR_INFO) ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer + ); + +/** + Activate all of the application proessors. + + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI= instance. + @param[in] Procedure A pointer to the function to be run on e= nabled APs of + the system. + @param[in] SingleThread If TRUE, then all the enabled APs execut= e the function + specified by Procedure one by one, in as= cending order + of processor handle number. If FALSE, th= en all the + enabled APs execute the function specifi= ed by Procedure + simultaneously. + @param[in] TimeoutInMicroSeconds + Indicates the time limit in microseconds= for APs to + return from Procedure, for blocking mode= only. Zero + means infinity. If the timeout expires b= efore all APs + return from Procedure, then Procedure on= the failed APs + is terminated. All enabled APs are avail= able for next + function assigned by EFI_PEI_MP_SERVICES= _PPI.StartupAllAPs() + or EFI_PEI_MP_SERVICES_PPI.StartupThisAP= (). If the + timeout expires in blocking mode, BSP re= turns + EFI_TIMEOUT. + @param[in] ProcedureArgument The parameter passed into Procedure for = all APs. + + @retval EFI_SUCCESS In blocking mode, all APs have finished = before the + timeout expired. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_STARTED No enabled APs exist in the system. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_TIMEOUT In blocking mode, the timeout expired be= fore all + enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_PEI_MP_SERVICES_STARTUP_ALL_APS) ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + IN EFI_AP_PROCEDURE Procedure, + IN BOOLEAN SingleThread, + IN UINTN TimeoutInMicroSeconds, + IN VOID *ProcedureArgument OPTIONAL + ); + +/** + Activate a specific application processor. + + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI= instance. + @param[in] Procedure A pointer to the function to be run on e= nabled APs of + the system. + @param[in] ProcessorNumber The handle number of the AP. The range i= s from 0 to the + total number of logical processors minus= 1. The total + number of logical processors can be retr= ieved by + EFI_PEI_MP_SERVICES_PPI.GetNumberOfProce= ssors(). + @param[in] TimeoutInMicroSeconds + Indicates the time limit in microseconds= for APs to + return from Procedure, for blocking mode= only. Zero + means infinity. If the timeout expires b= efore all APs + return from Procedure, then Procedure on= the failed APs + is terminated. All enabled APs are avail= able for next + function assigned by EFI_PEI_MP_SERVICES= _PPI.StartupAllAPs() + or EFI_PEI_MP_SERVICES_PPI.StartupThisAP= (). If the + timeout expires in blocking mode, BSP re= turns + EFI_TIMEOUT. + @param[in] ProcedureArgument The parameter passed into Procedure for = all APs. + + @retval EFI_SUCCESS In blocking mode, specified AP finished = before the + timeout expires. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_TIMEOUT In blocking mode, the timeout expired be= fore the + specified AP has finished. + @retval EFI_NOT_FOUND The processor with the handle specified = by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or dis= abled AP. + @retval EFI_INVALID_PARAMETER Procedure is NULL. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_PEI_MP_SERVICES_STARTUP_THIS_AP) ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + IN EFI_AP_PROCEDURE Procedure, + IN UINTN ProcessorNumber, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL + ); + +/** + Switch the boot strap processor. + + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI= instance. + @param[in] ProcessorNumber The handle number of the AP. The range i= s from 0 to the + total number of logical processors minus= 1. The total + number of logical processors can be retr= ieved by + EFI_PEI_MP_SERVICES_PPI.GetNumberOfProce= ssors(). + @param[in] EnableOldBSP If TRUE, then the old BSP will be listed= as an enabled + AP. Otherwise, it will be disabled. + + @retval EFI_SUCCESS BSP successfully switched. + @retval EFI_UNSUPPORTED Switching the BSP cannot be completed pr= ior to this + service returning. + @retval EFI_UNSUPPORTED Switching the BSP is not supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND The processor with the handle specified = by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BS= P or a disabled + AP. + @retval EFI_NOT_READY The specified AP is busy. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_PEI_MP_SERVICES_SWITCH_BSP) ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + IN UINTN ProcessorNumber, + IN BOOLEAN EnableOldBSP + ); + +/** + Enable or disable an application processor. + + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI= instance. + @param[in] ProcessorNumber The handle number of the AP. The range i= s from 0 to the + total number of logical processors minus= 1. The total + number of logical processors can be retr= ieved by + EFI_PEI_MP_SERVICES_PPI.GetNumberOfProce= ssors(). + @param[in] EnableAP Specifies the new state for the processo= r for enabled, + FALSE for disabled. + @param[in] HealthFlag If not NULL, a pointer to a value that s= pecifies the + new health status of the AP. This flag c= orresponds to + StatusFlag defined in EFI_PEI_MP_SERVICE= S_PPI.GetProcessorInfo(). + Only the PROCESSOR_HEALTH_STATUS_BIT is = used. All other + bits are ignored. If it is NULL, this pa= rameter is + ignored. + + @retval EFI_SUCCESS The specified AP was enabled or disabled= successfully. + @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be co= mpleted prior + to this service returning. + @retval EFI_UNSUPPORTED Enabling or disabling an AP is not suppo= rted. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND Processor with the handle specified by P= rocessorNumber + does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_PEI_MP_SERVICES_ENABLEDISABLEAP) ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + IN UINTN ProcessorNumber, + IN BOOLEAN EnableAP, + IN UINT32 *HealthFlag OPTIONAL + ); + +/** + Identify the currently executing processor. + + @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI= instance. + @param[out] ProcessorNumber The handle number of the AP. The range i= s from 0 to the + total number of logical processors minus= 1. The total + number of logical processors can be retr= ieved by + EFI_PEI_MP_SERVICES_PPI.GetNumberOfProce= ssors(). + + @retval EFI_SUCCESS The current processor handle number was = returned in + ProcessorNumber. + @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_PEI_MP_SERVICES_WHOAMI) ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + OUT UINTN *ProcessorNumber + ); + + +/** + Activate all of the application proessors. + + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_= PPI instance. + @param[in] Procedure A pointer to the function to be run on e= nabled APs of + the system. + @param[in] TimeoutInMicroSeconds + Indicates the time limit in microseconds= for APs to + return from Procedure, for blocking mode= only. Zero + means infinity. If the timeout expires = in blocking + mode, BSP returns EFI_TIMEOUT. + @param[in] ProcedureArgument The parameter passed into Procedure for = all CPUs. + + @retval EFI_SUCCESS In blocking mode, all APs have finished = before the + timeout expired. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_TIMEOUT In blocking mode, the timeout expired be= fore all + enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. +**/ +typedef +EFI_STATUS +(EFIAPI *EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS) ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + IN EFI_AP_PROCEDURE Procedure, + IN UINTN TimeoutInMicroSeconds, + IN VOID *ProcedureArgument OPTIONAL + ); + +struct _EDKII_PEI_MP_SERVICES2_PPI { + EDKII_PEI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS GetNumberOfProcessors; + EDKII_PEI_MP_SERVICES_GET_PROCESSOR_INFO GetProcessorInfo; + EDKII_PEI_MP_SERVICES_STARTUP_ALL_APS StartupAllAPs; + EDKII_PEI_MP_SERVICES_STARTUP_THIS_AP StartupThisAP; + EDKII_PEI_MP_SERVICES_SWITCH_BSP SwitchBSP; + EDKII_PEI_MP_SERVICES_ENABLEDISABLEAP EnableDisableAP; + EDKII_PEI_MP_SERVICES_WHOAMI WhoAmI; + EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS StartupAllCPUs; +}; + +extern EFI_GUID gEdkiiPeiMpServices2PpiGuid; + +#endif diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec index 6ddf0cd224..14ddaa8633 100644 --- a/UefiCpuPkg/UefiCpuPkg.dec +++ b/UefiCpuPkg/UefiCpuPkg.dec @@ -75,6 +75,9 @@ # 0x80000001 | Invalid value provided. # =20 +[Ppis] + gEdkiiPeiMpServices2PpiGuid =3D { 0x5cb9cb3d, 0x31a4, 0x480c, { 0x94,= 0x98, 0x29, 0xd2, 0x69, 0xba, 0xcf, 0xba}} + [PcdsFeatureFlag] ## Indicates if SMM Profile will be enabled. # If enabled, instruction executions in and data accesses to memory out= side of SMRAM will be logged. --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#44293): https://edk2.groups.io/g/devel/message/44293 Mute This Topic: https://groups.io/mt/32581677/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 05:23:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+44294+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44294+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1563952059; cv=none; d=zoho.com; s=zohoarc; b=IiB7blUnUOE0sxhuyaNcYH7DnAlkDJNBvTwbHtM73l3ww8jxIe7cnyi70h8jNLkPmK8nB8CWZkK35t1YWC+1Q77UukWEdDN8YQ8KUIOgQTs8ZW/Q2DX3CJMyDO3AzbLSWfUakTOlNIXQYx6ssmimTh/vk+5A7ylDjZD4Km3IGfM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563952059; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=8/xEDzYsm+rAwcaH1igy37xwNea+62/F+ELcmLjguMM=; b=C+1Tp8NdNNmVAgwx1dbEMRh2d6Xz36cZnseEISDZKckpG4gTgvr2Ldcbbl1lper93Cm76ifC7O29fYmVB2L84Am31+IETXOokYcg6k7I8NX5SXTMzjn8X8pSyh/reNC8nF3z1KaTEZWNPL7mGsrpZvWue1NTUsKKqSSeo0twxHo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44294+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 156395205951689.00996430602606; Wed, 24 Jul 2019 00:07:39 -0700 (PDT) Return-Path: X-Received: from mga05.intel.com (mga05.intel.com []) by groups.io with SMTP; Wed, 24 Jul 2019 00:07:38 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jul 2019 00:07:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,302,1559545200"; d="scan'208";a="172211128" X-Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.133]) by orsmga003.jf.intel.com with ESMTP; 24 Jul 2019 00:07:36 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Chandana Kumar , Star Zeng Subject: [edk2-devel] [Patch v3 5/6] UefiCpuPkg/CpuMpPei: Produce EDKII_PEI_MP_SERVICES2_PPI. Date: Wed, 24 Jul 2019 15:07:26 +0800 Message-Id: <20190724070727.14976-6-eric.dong@intel.com> In-Reply-To: <20190724070727.14976-1-eric.dong@intel.com> References: <20190724070727.14976-1-eric.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,eric.dong@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1563952059; bh=UdQhVYq2G10rm+vjJr3IbM0xVso3d0IGCtLhLpHGSHA=; h=Cc:Date:From:Reply-To:Subject:To; b=E8KUxalxmfQIbczJtsTGYU7U8kkiQ50NSs0GKQJCc8+BCnR0pWvo+qYa40uIdKBF2Qj vaWowt8Wrrr6wZqxhs5aRd9jjxKiVK5dScRlIZhLH0bu9KvZg8YpuDRWz66XU5luPdYMY G3aMHYQgySHfIgWz1uKcQ2q6y80P1leRl5Y= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1973 Produce new EDKII_PEI_MP_SERVICES2_PPI service. It includes all APIs existed in EFI_PEI_MP_SERVICES_PPI and add new API EDKII_PEI_MP_SERVICES_STARTUP_ALL_CPUS. Cc: Ray Ni Cc: Laszlo Ersek Cc: Chandana Kumar Cc: Star Zeng Signed-off-by: Eric Dong --- UefiCpuPkg/CpuMpPei/CpuMpPei.c | 21 +- UefiCpuPkg/CpuMpPei/CpuMpPei.h | 3 +- UefiCpuPkg/CpuMpPei/CpuMpPei.inf | 2 + UefiCpuPkg/CpuMpPei/Mp2Pei.c | 417 +++++++++++++++++++++++++++++++ 4 files changed, 436 insertions(+), 7 deletions(-) create mode 100644 UefiCpuPkg/CpuMpPei/Mp2Pei.c diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c index 926541c937..07ccbe7c6a 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -1,13 +1,15 @@ /** @file CPU PEI Module installs CPU Multiple Processor PPI. =20 - Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include "CpuMpPei.h" =20 +extern EDKII_PEI_MP_SERVICES2_PPI mMpServices2Ppi; + // // CPU MP PPI to be installed // @@ -21,10 +23,17 @@ EFI_PEI_MP_SERVICES_PPI mMpServicesPpi = =3D { PeiWhoAmI, }; =20 -EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiDesc =3D { - (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), - &gEfiPeiMpServicesPpiGuid, - &mMpServicesPpi +EFI_PEI_PPI_DESCRIPTOR mPeiCpuMpPpiList[] =3D { + { + EFI_PEI_PPI_DESCRIPTOR_PPI, + &gEdkiiPeiMpServices2PpiGuid, + &mMpServices2Ppi + }, + { + (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), + &gEfiPeiMpServicesPpiGuid, + &mMpServicesPpi + } }; =20 /** @@ -667,7 +676,7 @@ InitializeCpuMpWorker ( // // Install CPU MP PPI // - Status =3D PeiServicesInstallPpi(&mPeiCpuMpPpiDesc); + Status =3D PeiServicesInstallPpi(mPeiCpuMpPpiList); ASSERT_EFI_ERROR (Status); =20 return Status; diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.h b/UefiCpuPkg/CpuMpPei/CpuMpPei.h index a5d8a755b2..7d5c527d60 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.h +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.h @@ -1,7 +1,7 @@ /** @file Definitions to install Multiple Processor PPI. =20 - Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -15,6 +15,7 @@ #include #include #include +#include =20 #include #include diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf b/UefiCpuPkg/CpuMpPei/CpuMpPe= i.inf index 4fc4ea77ba..fb2db650e5 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.inf +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.inf @@ -26,6 +26,7 @@ CpuMpPei.c CpuBist.c CpuPaging.c + Mp2Pei.c =20 [Packages] MdePkg/MdePkg.dec @@ -54,6 +55,7 @@ gEfiSecPlatformInformation2PpiGuid gEfiVectorHandoffInfoPpiGuid ## SOMETIMES_CONSUMES gEfiPeiMemoryDiscoveredPpiGuid ## CONSUMES + gEdkiiPeiMpServices2PpiGuid ## PRODUCES =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask ##= CONSUMES diff --git a/UefiCpuPkg/CpuMpPei/Mp2Pei.c b/UefiCpuPkg/CpuMpPei/Mp2Pei.c new file mode 100644 index 0000000000..c1116a5b77 --- /dev/null +++ b/UefiCpuPkg/CpuMpPei/Mp2Pei.c @@ -0,0 +1,417 @@ +/** @file + EDKII_PEI_MP_SERVICES2_PPI Implementation code. + + Copyright (c) 2019, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "CpuMpPei.h" + +/** + This service retrieves the number of logical processor in the platform + and the number of those logical processors that are enabled on this boot. + This service may only be called from the BSP. + + This function is used to retrieve the following information: + - The number of logical processors that are present in the system. + - The number of enabled logical processors in the system at the instant + this call is made. + + Because MP Service Ppi provides services to enable and disable processors + dynamically, the number of enabled logical processors may vary during the + course of a boot session. + + If this service is called from an AP, then EFI_DEVICE_ERROR is returned. + If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then + EFI_INVALID_PARAMETER is returned. Otherwise, the total number of proces= sors + is returned in NumberOfProcessors, the number of currently enabled proce= ssor + is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned. + + @param[in] This Pointer to this instance of the PPI. + @param[out] NumberOfProcessors Pointer to the total number of logical p= rocessors in + the system, including the BSP and disabl= ed APs. + @param[out] NumberOfEnabledProcessors + Number of processors in the system that = are enabled. + + @retval EFI_SUCCESS The number of logical processors and ena= bled + logical processors was retrieved. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL. + NumberOfEnabledProcessors is NULL. +**/ +EFI_STATUS +EFIAPI +EdkiiPeiGetNumberOfProcessors ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + OUT UINTN *NumberOfProcessors, + OUT UINTN *NumberOfEnabledProcessors + ) +{ + if ((NumberOfProcessors =3D=3D NULL) || (NumberOfEnabledProcessors =3D= =3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + return MpInitLibGetNumberOfProcessors ( + NumberOfProcessors, + NumberOfEnabledProcessors + ); +} + +/** + Gets detailed MP-related information on the requested processor at the + instant this call is made. This service may only be called from the BSP. + + This service retrieves detailed MP-related information about any process= or + on the platform. Note the following: + - The processor information may change during the course of a boot ses= sion. + - The information presented here is entirely MP related. + + Information regarding the number of caches and their sizes, frequency of= operation, + slot numbers is all considered platform-related information and is not p= rovided + by this service. + + @param[in] This Pointer to this instance of the PPI. + @param[in] ProcessorNumber Pointer to the total number of logical p= rocessors in + the system, including the BSP and disabl= ed APs. + @param[out] ProcessorInfoBuffer Number of processors in the system that = are enabled. + + @retval EFI_SUCCESS Processor information was returned. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL. + @retval EFI_NOT_FOUND The processor with the handle specified = by + ProcessorNumber does not exist in the pl= atform. +**/ +EFI_STATUS +EFIAPI +EdkiiPeiGetProcessorInfo ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + IN UINTN ProcessorNumber, + OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer + ) +{ + return MpInitLibGetProcessorInfo (ProcessorNumber, ProcessorInfoBuffer, = NULL); +} + +/** + This service executes a caller provided function on all enabled APs. APs= can + run either simultaneously or one at a time in sequence. This service sup= ports + both blocking requests only. This service may only + be called from the BSP. + + This function is used to dispatch all the enabled APs to the function sp= ecified + by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned + immediately and Procedure is not started on any AP. + + If SingleThread is TRUE, all the enabled APs execute the function specif= ied by + Procedure one by one, in ascending order of processor handle number. Oth= erwise, + all the enabled APs execute the function specified by Procedure simultan= eously. + + If the timeout specified by TimeoutInMicroSeconds expires before all APs= return + from Procedure, then Procedure on the failed APs is terminated. All enab= led APs + are always available for further calls to EDKII_PEI_MP_SERVICES2_PPI.Sta= rtupAllAPs() + and EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). If FailedCpuList is not = NULL, its + content points to the list of processor handle numbers in which Procedur= e was + terminated. + + Note: It is the responsibility of the consumer of the EDKII_PEI_MP_SERVI= CES2_PPI.StartupAllAPs() + to make sure that the nature of the code that is executed on the BSP and= the + dispatched APs is well controlled. The MP Services Ppi does not guarantee + that the Procedure function is MP-safe. Hence, the tasks that can be run= in + parallel are limited to certain independent tasks and well-controlled ex= clusive + code. PEI services and Ppis may not be called by APs unless otherwise + specified. + + In blocking execution mode, BSP waits until all APs finish or + TimeoutInMicroSeconds expires. + + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_= PPI instance. + @param[in] Procedure A pointer to the function to be run on e= nabled APs of + the system. + @param[in] SingleThread If TRUE, then all the enabled APs execut= e the function + specified by Procedure one by one, in as= cending order + of processor handle number. If FALSE, th= en all the + enabled APs execute the function specifi= ed by Procedure + simultaneously. + @param[in] TimeoutInMicroSeconds + Indicates the time limit in microseconds= for APs to + return from Procedure, for blocking mode= only. Zero + means infinity. If the timeout expires b= efore all APs + return from Procedure, then Procedure on= the failed APs + is terminated. All enabled APs are avail= able for next + function assigned by EDKII_PEI_MP_SERVIC= ES2_PPI.StartupAllAPs() + or EDKII_PEI_MP_SERVICES2_PPI.StartupThi= sAP(). If the + timeout expires in blocking mode, BSP re= turns + EFI_TIMEOUT. + @param[in] ProcedureArgument The parameter passed into Procedure for = all APs. + + @retval EFI_SUCCESS In blocking mode, all APs have finished = before the + timeout expired. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_STARTED No enabled APs exist in the system. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_TIMEOUT In blocking mode, the timeout expired be= fore all + enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. +**/ +EFI_STATUS +EFIAPI +EdkiiPeiStartupAllAPs ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + IN EFI_AP_PROCEDURE Procedure, + IN BOOLEAN SingleThread, + IN UINTN TimeoutInMicroSeconds, + IN VOID *ProcedureArgument OPTIONAL + ) +{ + return MpInitLibStartupAllAPs ( + Procedure, + SingleThread, + NULL, + TimeoutInMicroSeconds, + ProcedureArgument, + NULL + ); +} + +/** + This service lets the caller get one enabled AP to execute a caller-prov= ided + function. The caller can request the BSP to wait for the completion + of the AP. This service may only be called from the BSP. + + This function is used to dispatch one enabled AP to the function specifi= ed by + Procedure passing in the argument specified by ProcedureArgument. + The execution is in blocking mode. The BSP waits until the AP finishes or + TimeoutInMicroSecondss expires. + + If the timeout specified by TimeoutInMicroseconds expires before the AP = returns + from Procedure, then execution of Procedure by the AP is terminated. The= AP is + available for subsequent calls to EDKII_PEI_MP_SERVICES2_PPI.StartupAllA= Ps() and + EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). + + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_= PPI instance. + @param[in] Procedure A pointer to the function to be run on e= nabled APs of + the system. + @param[in] ProcessorNumber The handle number of the AP. The range i= s from 0 to the + total number of logical processors minus= 1. The total + number of logical processors can be retr= ieved by + EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfPr= ocessors(). + @param[in] TimeoutInMicroseconds + Indicates the time limit in microseconds= for APs to + return from Procedure, for blocking mode= only. Zero + means infinity. If the timeout expires b= efore all APs + return from Procedure, then Procedure on= the failed APs + is terminated. All enabled APs are avail= able for next + function assigned by EDKII_PEI_MP_SERVIC= ES2_PPI.StartupAllAPs() + or EDKII_PEI_MP_SERVICES2_PPI.StartupThi= sAP(). If the + timeout expires in blocking mode, BSP re= turns + EFI_TIMEOUT. + @param[in] ProcedureArgument The parameter passed into Procedure for = all APs. + + @retval EFI_SUCCESS In blocking mode, specified AP finished = before the + timeout expires. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_TIMEOUT In blocking mode, the timeout expired be= fore the + specified AP has finished. + @retval EFI_NOT_FOUND The processor with the handle specified = by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or dis= abled AP. + @retval EFI_INVALID_PARAMETER Procedure is NULL. +**/ +EFI_STATUS +EFIAPI +EdkiiPeiStartupThisAP ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + IN EFI_AP_PROCEDURE Procedure, + IN UINTN ProcessorNumber, + IN UINTN TimeoutInMicroseconds, + IN VOID *ProcedureArgument OPTIONAL + ) +{ + return MpInitLibStartupThisAP ( + Procedure, + ProcessorNumber, + NULL, + TimeoutInMicroseconds, + ProcedureArgument, + NULL + ); +} + +/** + This service switches the requested AP to be the BSP from that point onw= ard. + This service changes the BSP for all purposes. This call can only be p= erformed + by the current BSP. + + This service switches the requested AP to be the BSP from that point onw= ard. + This service changes the BSP for all purposes. The new BSP can take over= the + execution of the old BSP and continue seamlessly from where the old one = left + off. + + If the BSP cannot be switched prior to the return from this service, then + EFI_UNSUPPORTED must be returned. + + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_= PPI instance. + @param[in] ProcessorNumber The handle number of the AP. The range i= s from 0 to the + total number of logical processors minus= 1. The total + number of logical processors can be retr= ieved by + EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfPr= ocessors(). + @param[in] EnableOldBSP If TRUE, then the old BSP will be listed= as an enabled + AP. Otherwise, it will be disabled. + + @retval EFI_SUCCESS BSP successfully switched. + @retval EFI_UNSUPPORTED Switching the BSP cannot be completed pr= ior to this + service returning. + @retval EFI_UNSUPPORTED Switching the BSP is not supported. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND The processor with the handle specified = by + ProcessorNumber does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BS= P or a disabled + AP. + @retval EFI_NOT_READY The specified AP is busy. +**/ +EFI_STATUS +EFIAPI +EdkiiPeiSwitchBSP ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + IN UINTN ProcessorNumber, + IN BOOLEAN EnableOldBSP + ) +{ + return MpInitLibSwitchBSP (ProcessorNumber, EnableOldBSP); +} + +/** + This service lets the caller enable or disable an AP from this point onw= ard. + This service may only be called from the BSP. + + This service allows the caller enable or disable an AP from this point o= nward. + The caller can optionally specify the health status of the AP by Health.= If + an AP is being disabled, then the state of the disabled AP is implementa= tion + dependent. If an AP is enabled, then the implementation must guarantee t= hat a + complete initialization sequence is performed on the AP, so the AP is in= a state + that is compatible with an MP operating system. + + If the enable or disable AP operation cannot be completed prior to the r= eturn + from this service, then EFI_UNSUPPORTED must be returned. + + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_= PPI instance. + @param[in] ProcessorNumber The handle number of the AP. The range i= s from 0 to the + total number of logical processors minus= 1. The total + number of logical processors can be retr= ieved by + EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfPr= ocessors(). + @param[in] EnableAP Specifies the new state for the processo= r for enabled, + FALSE for disabled. + @param[in] HealthFlag If not NULL, a pointer to a value that s= pecifies the + new health status of the AP. This flag c= orresponds to + StatusFlag defined in EDKII_PEI_MP_SERVI= CES2_PPI.GetProcessorInfo(). + Only the PROCESSOR_HEALTH_STATUS_BIT is = used. All other + bits are ignored. If it is NULL, this pa= rameter is + ignored. + + @retval EFI_SUCCESS The specified AP was enabled or disabled= successfully. + @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be co= mpleted prior + to this service returning. + @retval EFI_UNSUPPORTED Enabling or disabling an AP is not suppo= rted. + @retval EFI_DEVICE_ERROR The calling processor is an AP. + @retval EFI_NOT_FOUND Processor with the handle specified by P= rocessorNumber + does not exist. + @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP. +**/ +EFI_STATUS +EFIAPI +EdkiiPeiEnableDisableAP ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + IN UINTN ProcessorNumber, + IN BOOLEAN EnableAP, + IN UINT32 *HealthFlag OPTIONAL + ) +{ + return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP, HealthFlag); +} + +/** + This return the handle number for the calling processor. This service m= ay be + called from the BSP and APs. + + This service returns the processor handle number for the calling process= or. + The returned value is in the range from 0 to the total number of logical + processors minus 1. The total number of logical processors can be retrie= ved + with EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors(). This service ma= y be + called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALI= D_PARAMETER + is returned. Otherwise, the current processors handle number is returned= in + ProcessorNumber, and EFI_SUCCESS is returned. + + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_= PPI instance. + @param[out] ProcessorNumber The handle number of the AP. The range i= s from 0 to the + total number of logical processors minus= 1. The total + number of logical processors can be retr= ieved by + EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfPr= ocessors(). + + @retval EFI_SUCCESS The current processor handle number was = returned in + ProcessorNumber. + @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL. +**/ +EFI_STATUS +EFIAPI +EdkiiPeiWhoAmI ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + OUT UINTN *ProcessorNumber + ) +{ + return MpInitLibWhoAmI (ProcessorNumber); +} + +/** + This service executes a caller provided function on all enabled CPUs. CP= Us can + run either simultaneously or one at a time in sequence. This service may= only + be called from the BSP. + + @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_= PPI instance. + @param[in] Procedure A pointer to the function to be run on e= nabled APs of + the system. + @param[in] TimeoutInMicroSeconds + Indicates the time limit in microseconds= for APs to + return from Procedure, for blocking mode= only. Zero + means infinity. If the timeout expires = in blocking + mode, BSP returns EFI_TIMEOUT. + @param[in] ProcedureArgument The parameter passed into Procedure for = all CPUs. + + @retval EFI_SUCCESS In blocking mode, all APs have finished = before the + timeout expired. + @retval EFI_DEVICE_ERROR Caller processor is AP. + @retval EFI_NOT_READY Any enabled APs are busy. + @retval EFI_TIMEOUT In blocking mode, the timeout expired be= fore all + enabled APs have finished. + @retval EFI_INVALID_PARAMETER Procedure is NULL. +**/ +EFI_STATUS +EFIAPI +EdkiiPeiStartupAllCPUs ( + IN EDKII_PEI_MP_SERVICES2_PPI *This, + IN EFI_AP_PROCEDURE Procedure, + IN UINTN TimeoutInMicroSeconds, + IN VOID *ProcedureArgument OPTIONAL + ) +{ + return MpInitLibStartupAllCPUs ( + Procedure, + TimeoutInMicroSeconds, + ProcedureArgument + ); +} + +// +// CPU MP2 PPI to be installed +// +EDKII_PEI_MP_SERVICES2_PPI mMpServices2Ppi =3D { + EdkiiPeiGetNumberOfProcessors, + EdkiiPeiGetProcessorInfo, + EdkiiPeiStartupAllAPs, + EdkiiPeiStartupThisAP, + EdkiiPeiSwitchBSP, + EdkiiPeiEnableDisableAP, + EdkiiPeiWhoAmI, + EdkiiPeiStartupAllCPUs +}; + --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#44294): https://edk2.groups.io/g/devel/message/44294 Mute This Topic: https://groups.io/mt/32581678/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 05:23:27 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+44295+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44295+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1563952061; cv=none; d=zoho.com; s=zohoarc; b=i5SXYLdiqX7bSvOqTV5CM+e9vEgz3OAPuQFGAVFw6Q0x48Wa3C4QKl9g2S/kdFX51C802ysfb5JdMihj1bUgJ+Jb7/q3SOAliHhHoyCNX2FgV6LtNtGpbvSGELELihwsiUh6WxrZgNr63VY3GxCnXjFHscSMRI+ggLozFpslLCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563952061; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=EJkxJhDX5ijl2FGqNPC1u+edg1hHS3FtOZeF9B0VUzE=; b=SyLlWZHHqx5w1E2IpYCfTs8tPyxt8qMxs5J2xG5YTYBETTXgRMgWJon7yuvRVsEzJAvrYGFGH7PHbyTV+iQT6JeiTBK9PPKSpUWERYMRUPj/nSmd5GAXDIsKrQpqXINugqV2216uxjh9b2vcyEOB8xkjtKSZuutKTB19p175xOw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+44295+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1563952061265644.3824858088252; Wed, 24 Jul 2019 00:07:41 -0700 (PDT) Return-Path: X-Received: from mga05.intel.com (mga05.intel.com []) by groups.io with SMTP; Wed, 24 Jul 2019 00:07:40 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jul 2019 00:07:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,302,1559545200"; d="scan'208";a="172211142" X-Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.133]) by orsmga003.jf.intel.com with ESMTP; 24 Jul 2019 00:07:38 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Chandana Kumar , Star Zeng Subject: [edk2-devel] [Patch v3 6/6] UefiCpuPkg/RegisterCpuFeaturesLib: Start all processors simultaneously. Date: Wed, 24 Jul 2019 15:07:27 +0800 Message-Id: <20190724070727.14976-7-eric.dong@intel.com> In-Reply-To: <20190724070727.14976-1-eric.dong@intel.com> References: <20190724070727.14976-1-eric.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,eric.dong@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1563952060; bh=eyvklcynN7ctHgcKgoFnsmyEngkssJLqX5ntDGI0si8=; h=Cc:Date:From:Reply-To:Subject:To; b=Y9Fe93/FJ80iSoLdkVJoYec3sQTeOhjpFK9jbUqlxzwmE7puEVetPaiNaECcob8EqL8 uIS4848+qSWcgOBbXkSjDyKrYD8+1wDFotYjhk4DgO2Jj1TnNUJyZQEbr3WVn8lNCASeN 5JYzaXY32ROWYvgvnsm2KLDyhpNTKjF4ScQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1973 For semaphore type register, it required all processors to do the task at the same time. Current logic begins BSP's task after all APs have finished their tasks. This will caused set semaphore task hang if semaphore has package level type. This patch use new EDKII_PEI_MP_SERVICES2_PPI to start all processors at the same time to fix the potential hang issue. Cc: Ray Ni Cc: Laszlo Ersek Cc: Chandana Kumar Cc: Star Zeng Signed-off-by: Eric Dong Reviewed-by: Ray Ni --- .../CpuFeaturesInitialize.c | 2 +- .../DxeRegisterCpuFeaturesLib.c | 6 +- .../PeiRegisterCpuFeaturesLib.c | 66 ++++++++++++++----- .../PeiRegisterCpuFeaturesLib.inf | 1 + .../RegisterCpuFeatures.h | 2 +- 5 files changed, 54 insertions(+), 23 deletions(-) diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ= e.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c index 33752c1a9f..4e97e863c7 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c @@ -1074,7 +1074,7 @@ CpuFeaturesDetect ( // // Wakeup all APs for data collection. // - StartupAPsWorker (CollectProcessorData, NULL); + StartupAllAPsWorker (CollectProcessorData, NULL); } =20 // diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeatur= esLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesL= ib.c index f87b2892aa..e2e06e88e0 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c @@ -1,7 +1,7 @@ /** @file CPU Register Table Library functions. =20 - Copyright (c) 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -116,7 +116,7 @@ GetProcessorInformation ( to check whether procedure has done. **/ VOID -StartupAPsWorker ( +StartupAllAPsWorker ( IN EFI_AP_PROCEDURE Procedure, IN EFI_EVENT MpEvent ) @@ -248,7 +248,7 @@ CpuFeaturesInitialize ( // // Wakeup all APs for programming. // - StartupAPsWorker (SetProcessorRegister, MpEvent); + StartupAllAPsWorker (SetProcessorRegister, MpEvent); } =20 // diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeatur= esLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesL= ib.c index 8ad5a40e5a..52b849ce13 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.c @@ -1,7 +1,7 @@ /** @file CPU Register Table Library functions. =20 - Copyright (c) 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -12,6 +12,8 @@ #include #include #include +#include + #include "RegisterCpuFeatures.h" =20 #define REGISTER_CPU_FEATURES_GUID \ @@ -154,7 +156,7 @@ GetProcessorInformation ( =20 **/ VOID -StartupAPsWorker ( +StartupAllAPsWorker ( IN EFI_AP_PROCEDURE Procedure, IN EFI_EVENT MpEvent ) @@ -180,6 +182,48 @@ StartupAPsWorker ( ASSERT_EFI_ERROR (Status); } =20 +/** + Worker function to execute a caller provided function on all enabled APs. + + @param[in] Procedure A pointer to the function to be run = on + enabled APs of the system. + @param[in] MpEvent The Event used to sync the result. + +**/ +VOID +StartupAllCPUsWorker ( + IN EFI_AP_PROCEDURE Procedure + ) +{ + EFI_STATUS Status; + EDKII_PEI_MP_SERVICES2_PPI *CpuMp2Ppi; + CPU_FEATURES_DATA *CpuFeaturesData; + + CpuFeaturesData =3D GetCpuFeaturesData (); + + // + // Get MP Services2 Ppi + // + Status =3D PeiServicesLocatePpi ( + &gEdkiiPeiMpServices2PpiGuid, + 0, + NULL, + (VOID **)&CpuMp2Ppi + ); + ASSERT_EFI_ERROR (Status); + + // + // Wakeup all APs for data collection. + // + Status =3D CpuMp2Ppi->StartupAllCPUs ( + CpuMp2Ppi, + Procedure, + 0, + CpuFeaturesData + ); + ASSERT_EFI_ERROR (Status); +} + /** Worker function to switch the requested AP to be the BSP from that point= onward. =20 @@ -267,23 +311,9 @@ CpuFeaturesInitialize ( CpuFeaturesData->BspNumber =3D OldBspNumber; =20 // - // Known limitation: In PEI phase, CpuFeatures driver not - // support async mode execute tasks. So semaphore type - // register can't been used for this instance, must use - // DXE type instance. - // - - if (CpuFeaturesData->NumberOfCpus > 1) { - // - // Wakeup all APs for programming. - // - StartupAPsWorker (SetProcessorRegister, NULL); - } - - // - // Programming BSP + // Start to program register for all CPUs. // - SetProcessorRegister (CpuFeaturesData); + StartupAllCPUsWorker (SetProcessorRegister); =20 // // Switch to new BSP if required diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeatur= esLib.inf b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeature= sLib.inf index 63091dfeb8..61f922bf63 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.i= nf +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.i= nf @@ -46,6 +46,7 @@ =20 [Ppis] gEfiPeiMpServicesPpiGuid ## = CONSUMES + gEdkiiPeiMpServices2PpiGuid ## = CONSUMES =20 [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress ## = CONSUMES diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.= h b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h index a18f926641..a25dd69292 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h @@ -145,7 +145,7 @@ GetProcessorInformation ( to check whether procedure has done. **/ VOID -StartupAPsWorker ( +StartupAllAPsWorker ( IN EFI_AP_PROCEDURE Procedure, IN EFI_EVENT MpEvent ); --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#44295): https://edk2.groups.io/g/devel/message/44295 Mute This Topic: https://groups.io/mt/32581679/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-