From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.3787.1687770622521553968 for ; Mon, 26 Jun 2023 02:10:27 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=ABT3fk3r; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687770627; x=1719306627; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=SoWlwhoZnb7ZPGtuaYaTK3Yz+eTERyrGdZ1E543ashg=; b=ABT3fk3rczZBUtE1iAdUda9mfXXZPksYwtIMDKGGu+Ht24ts3Vhkqlk3 ghnvXT1g7/ZMslowZ3b9L4xK/2zqR4e1Edn/gwhexEkytH8gtgoXmFhXR TnwB7a5whK1HzQOJO6egIJMQnwwmRTAESZEqctypzmae+SvQcWxhzE58T KyZQTPHWM12oCqsVneIHkT1iQh6yGMlnrLkQAzSItvIywHSmfq5vfztds niuUVXDF7mtrw0QMWFmzRS6anY5YWTwsXh+ri/6qmRGh2aciSLfbGfNxt u6dXoSy0rJIKGxaxpiOBwSYdYjUO0PJDknqg6msFf3AXgELdd7LEWiVVH g==; X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="340811507" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="340811507" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 02:10:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="719274544" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="719274544" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga007.fm.intel.com with ESMTP; 26 Jun 2023 02:10:25 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 26 Jun 2023 02:10:25 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Mon, 26 Jun 2023 02:10:25 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Mon, 26 Jun 2023 02:10:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dIw3ceA9FBvpO4gT37xd/z9Tf19o1DAlBKfjpEzq3hHGOrdLctNGlejMHkUOlq5zuw5Tda7n9hLcCwB27PWpleUIVUK8p31RZLyi6pG56S/CA1oNoGPEpdqEkbWj1ukHTDBQHSs+cpKyX76g7OepvI0zqww01sqNxc4FFra5bz/7jn1D73WZ+pZsKSojJd5VMJsZpWljgPDyqQktjB8Ix06Gt5nZek/fmGANesWA0RfhbajeXdBN/61ZOZ/y3GV3TySE85tDu7mIcxTk1oxLJbpVlLPlK2GfCldCHZ6s/H6P246GsFcfw6yLStOTXNIMAkgprhcXzgFSDHu2gXC2tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=L6wo3XOPZ+8/8iyN4JP2aiam9tRm6QC1nVpgHniVFr0=; b=Wu33Ed+Vg94dSsEwCFSyi/sju/0fMDSKGCICEC645bypkBBXQZkFF3qZN1whLWJ9ZEr0EYKO1xoyRENrBlj2K/4cD7TI1ZCq9AdV4+SXv1XHamIA1ulm5/G2ANupsTxfJ9J10qXx1zMzTfjILlajTe5wbHvklC19/Ho9TWEqtruWPHidFxfn0LUCnhSeLdiQSlRJCiZjTGugEEwSCqLnoO1OP/evGznbZ86TUy3cyetVrpEEJi+E/P8kd6rNfuCFDVF+iykv0b/RlQI9TKHCBR6zEnnJWt//TMRmgZY5bCxrQEFSHaoj9p4MdvEusQaRjXyIlPxOWmLmgHZE8sn/hA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by DS0PR11MB8161.namprd11.prod.outlook.com (2603:10b6:8:164::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.23; Mon, 26 Jun 2023 09:10:22 +0000 Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::892b:b8e6:bab7:635d]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::892b:b8e6:bab7:635d%2]) with mapi id 15.20.6521.023; Mon, 26 Jun 2023 09:10:22 +0000 From: "Ni, Ray" To: "Xie, Yuanhao" , "devel@edk2.groups.io" CC: Gerd Hoffmann , "Dong, Eric" , "Kumar, Rahul R" , Tom Lendacky Subject: Re: [Patch V3 2/5] UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop. Thread-Topic: [Patch V3 2/5] UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop. Thread-Index: AQHZp/McYcdYM7I+gkucjyOa4vJ/Wa+czCNg Date: Mon, 26 Jun 2023 09:10:22 +0000 Message-ID: References: <20230626055705.57145-1-yuanhao.xie@intel.com> <20230626055705.57145-3-yuanhao.xie@intel.com> In-Reply-To: <20230626055705.57145-3-yuanhao.xie@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|DS0PR11MB8161:EE_ x-ms-office365-filtering-correlation-id: ff9fcc23-1404-402d-a32a-08db76252b98 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ukIkH6kpGhVgRrIM9mqeVVSYh04tA4Y5SywL4ooGJx3GiOAIjxcEOeMrbviRuhPhzSlFpzIu+j4GYFVxz8nNifXSf7mn8kenyDBal77GRalnCJpTYhicFBTWa5/gCY8ZiRbC0i0wHJ7XguVPTuhYrz8F0Oqpjz3P0wh7Ca1VEur1vruoKZs8rnE+C7ix5WfvJDx3eVNeMaGB+MxqDvuCzQg7mDRsnXMI17/96EIKFcCXZYEeYkgEaeQTiLpYkefuD7jW2DGRJ6Z6smr8jQj90scyFJk7XnqJ1jzlkdakuf5H2qFEK5l/uv3JhQdyUzzFq9s1WzA9snZu0eC4O9+95al0uxa40GzyX+dRUupx+boOK9K2pMgVWEGbLEAE3jmYLhP5AusiUxksfpaW5D1AvMXjJ9nCGay4iBW8bAGMc5nlvU/8f76gwSeUb4EkxYWXbn04zOnb8zspLlYUZZNeym7T9fvkLDSLXp1Hi28DGuMB3VbPSYpPs/tK6kWcnmljs/aF1pXk8Y5kcgyo9kDhKMGGGKwBmt+cqvm/tlrGN+sLf7EE0KdgwTauH+ag9VSHMrRP80QnJF3lZlWMssYT/G1TvL+k7pUJULPLp7M/ITCGK306xTWlS18+WnioR30G x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN6PR11MB8244.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(376002)(39860400002)(396003)(136003)(366004)(451199021)(478600001)(54906003)(7696005)(71200400001)(110136005)(83380400001)(26005)(186003)(9686003)(6506007)(53546011)(66446008)(2906002)(5660300002)(52536014)(33656002)(38100700002)(122000001)(76116006)(4326008)(66946007)(55016003)(82960400001)(316002)(86362001)(8936002)(8676002)(41300700001)(38070700005)(66476007)(66556008)(64756008);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?5LDtOs/pJ5Fpr7gSVvPsE45OI+d5vkqntuMcRXyloO85p8lZCZM+08HPzzfH?= =?us-ascii?Q?eK7IjbDuHr+DSzyMHrC0Yx1u1c1tvmAtQ2YliL16zBMgEIUUpjmD7t2V1BIv?= =?us-ascii?Q?11GLHwl+l4ibnw2QoPvxea98QTHwvF5hCoj9mY6ytqyrfCf4KZg3/5IF1mBF?= =?us-ascii?Q?6qWPNKzElEhJPCEydfWMsaCLqHjluC8GBAo15gHABqL2G+x7dO2dQCnudzFX?= =?us-ascii?Q?qcxyI44E7HaRa4XzP5t9ulFbqBWywW4FZOXpltjaiprN6sZF521XRt95aHiH?= =?us-ascii?Q?OCuaw435Ee1oumynKZJD4zwQ0oajoDMTJ1icXQH6cGKRBWUnnvvSziy0VRpf?= =?us-ascii?Q?fGEt8iJkU12NJcUGbMEiwVulZ3hBE8cJ+dmH6PtjvQlEnvyynvGeps3Jqr4b?= =?us-ascii?Q?y8T2UTcqIKBbaPEOANd841/J8jtJ7tKxLjOJDkYk/TLrLnNffW4iFZNhdHMR?= =?us-ascii?Q?VjFsMQGu/R4kUTCoc/C0LG1lw7rLCseX9gbSZ8kuTNSLLvVjdZc93aErCncu?= =?us-ascii?Q?7qrSy2N7Jzk8bqUGZEphoQoF3TvNfr1aN3Yk1Kk4k9gS1nE11LGfxhwGhLhQ?= =?us-ascii?Q?NeKaHOdavRJ9h4T8233gmuhG2WUmf+DMHj3kWIXFAmBkWSr9q3StSTaNPSFq?= =?us-ascii?Q?QM3rk70M7A5t7K3qRZL8wwcff4Ba82Z/N+aA5ABucnAQU6K8HZ8l1/Sj6Efu?= =?us-ascii?Q?iFKabKFbYWpnlSef/JnbeAMPr7fVwXCkjP2Oos5Wps5wpTA9560O1s8/kBgo?= =?us-ascii?Q?7/gHN/3yW33nA1D9cfqTns0P44daCZC9lgaDpqYl/ouEFvs6DncxLKfYQcOv?= =?us-ascii?Q?8NBwFs0AU/x1Il4mXtDMpw7SgOMaz/eURIfIzTz/ymv8fDcJOxHadFeETXoU?= =?us-ascii?Q?O2VeYogSt+9MARjXp1ndjYm++CnUff15f2zEnF3MX1rU11KhzV4C1liK+FM8?= =?us-ascii?Q?OBoEIzdylP8zQN0GO1QKgLGbAwbndSzTmBIpTkJ9En0zZ2G+Qyp5veqSamsN?= =?us-ascii?Q?KWcC0S2ZFQSytXslHNUAgMdc/jA9lpJEbeTkC8e9KdkVFYTLC+vmWFwLDPn7?= =?us-ascii?Q?cZXCFd/QdWQu/neuOShOPmKSVTxPq9r/JyFE5BxadST36QD2RSg5h68nRO/Y?= =?us-ascii?Q?W/il+AwmZV0rgLCPX5IAYDj4JVmUXy6QzGHpsqrp/9H0DIDhCcqTABueX+1N?= =?us-ascii?Q?c1CS7hQP04B11dfr0Rb77rforFtABK6RHze6DDU3SugfU5YzM3ScZyjjvf3U?= =?us-ascii?Q?6AmHO6jmDVv11YrxUPquIYbI7bZNFiaNigJkfncKkcNwZUqcYOGhTlGr0/+M?= =?us-ascii?Q?ZfCPF7RP+SkSzseo1rec+nm1/gyykDzRgore8adq0lomddAYdpZ91jLIQ8CA?= =?us-ascii?Q?c3gwEjOrQ01wSbDzJJjrkNssERMSeDpgVtDKc5kza5M1Ho79I8rgw4wUfPw0?= =?us-ascii?Q?AFxlTzESVGRb5idVcqmnFDz48S5o8OMSKi2sasysQ02ogr5VgRwvr9yJAAMa?= =?us-ascii?Q?xjPxcvbA239ISnzd90WZtOLyeMD/hOflKb+EthmAb1gScO9dYtyU8aPgSGNO?= =?us-ascii?Q?tDy4ZSqxqho2c3+8G0s=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff9fcc23-1404-402d-a32a-08db76252b98 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jun 2023 09:10:22.0189 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: uRzYKLC/oqzBs6M2Uw0DQGnMuoy4bHfPvK/KeEOEYwZFLxRvJDYE/c6Hf/jkROK2rlyXIP+un+tlG+M2XfmsKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB8161 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: Xie, Yuanhao > Sent: Monday, June 26, 2023 1:57 PM > To: devel@edk2.groups.io > Cc: Gerd Hoffmann ; Dong, Eric ; = Ni, > Ray ; Kumar, Rahul R ; Tom > Lendacky ; Xie, Yuanhao > > Subject: [Patch V3 2/5] UefiCpuPkg: Refactor the logic for placing APs in > Mwait/Runloop. >=20 > Refactor the logic for placing APs in > Mwait/Runloop into a separate function. >=20 > Cc: Gerd Hoffmann > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > Cc: Tom Lendacky > Signed-off-by: Yuanhao Xie > --- > UefiCpuPkg/Library/MpInitLib/MpLib.c | 83 > ++++++++++++++++++++++++++++++++++++++++++++++++++----------------------- > ---------- > 1 file changed, 50 insertions(+), 33 deletions(-) >=20 > diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c > b/UefiCpuPkg/Library/MpInitLib/MpLib.c > index 9560b39220..e8dd640f9b 100644 > --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c > +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c > @@ -658,6 +658,54 @@ PlaceAPInHltLoop ( > } > } >=20 > +/** > + This function place APs in Mwait or Run loop. > + > + @param[in] ApLoopMode Ap Loop Mode > + @param[in] ApStartupSignalBuffer Pointer to Ap Startup Signal B= uffer > + @param[in] ApTargetCState Ap Target CState > +**/ > +VOID > +PlaceAPInMwaitLoopOrRunLoop ( > + IN UINT8 ApLoopMode, > + IN volatile UINT32 *ApStartupSignalBuffer, > + IN UINT8 ApTargetCState > + ) > +{ > + while (TRUE) { > + DisableInterrupts (); > + if (ApLoopMode =3D=3D ApInMwaitLoop) { > + // > + // Place AP in MWAIT-loop > + // > + AsmMonitor ((UINTN)ApStartupSignalBuffer, 0, 0); > + if (*ApStartupSignalBuffer !=3D WAKEUP_AP_SIGNAL) { > + // > + // Check AP start-up signal again. > + // If AP start-up signal is not set, place AP into > + // the specified C-state > + // > + AsmMwait (ApTargetCState << 4, 0); > + } > + } else if (ApLoopMode =3D=3D ApInRunLoop) { > + // > + // Place AP in Run-loop > + // > + CpuPause (); > + } else { > + ASSERT (FALSE); > + } > + > + // > + // If AP start-up signal is written, AP is waken up > + // otherwise place AP in loop again > + // > + if (*ApStartupSignalBuffer =3D=3D WAKEUP_AP_SIGNAL) { > + break; > + } > + } > +} > + > /** > This function will be called from AP reset code if BSP uses WakeUpAP. >=20 > @@ -838,39 +886,8 @@ ApWakeupFunction ( > // > // Never run here > // > - } > - > - while (TRUE) { > - DisableInterrupts (); > - if (CpuMpData->ApLoopMode =3D=3D ApInMwaitLoop) { > - // > - // Place AP in MWAIT-loop > - // > - AsmMonitor ((UINTN)ApStartupSignalBuffer, 0, 0); > - if (*ApStartupSignalBuffer !=3D WAKEUP_AP_SIGNAL) { > - // > - // Check AP start-up signal again. > - // If AP start-up signal is not set, place AP into > - // the specified C-state > - // > - AsmMwait (CpuMpData->ApTargetCState << 4, 0); > - } > - } else if (CpuMpData->ApLoopMode =3D=3D ApInRunLoop) { > - // > - // Place AP in Run-loop > - // > - CpuPause (); > - } else { > - ASSERT (FALSE); > - } > - > - // > - // If AP start-up signal is written, AP is waken up > - // otherwise place AP in loop again > - // > - if (*ApStartupSignalBuffer =3D=3D WAKEUP_AP_SIGNAL) { > - break; > - } > + } else { > + PlaceAPInMwaitLoopOrRunLoop (CpuMpData->ApLoopMode, > ApStartupSignalBuffer, CpuMpData->ApTargetCState); > } > } > } > -- > 2.36.1.windows.1