From nobody Wed Feb 11 02:07:15 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+106017+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106017+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1686577141; cv=none; d=zohomail.com; s=zohoarc; b=lAo044aQAZ1DIlpV/oHZvGCT/7hXqwIsK7ly4a3mJa+Ec9kBrzqo+cGYwhNL5AHdSOcD/I7SgKXTBehJd1zzabTiwcZoG96R1ssTun7uLs8YsxYkoJpj1xO7wf4rwHTXlU66Y4ojW42Q8CVBsw2XhE7+YJUvRvOtqHamxyxCGCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1686577141; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=CKmVOUpI7gk7wIKJmrO7Pi0YQNxidegYm31vjFNUZME=; b=IZTOZ6Ai2SZSmUvDYSd73yZVT2S0OlkryntctVwaf0iHeUNr39JPtnGXxjh6ZTIE9TJFkzqNjXrzx0DXD4ipoVUYxq0B26b12G2ym6YgKHVDxpFAlV+QRYMhDMJNkTO/6s8GuAY3E9YDE0C/+4ToWJo2ZXsrYWiHOjHWe40Z8cI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106017+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1686577141931670.9648090456537; Mon, 12 Jun 2023 06:39:01 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8ZsXYY1788612xSYBPSy79j6; Mon, 12 Jun 2023 06:39:01 -0700 X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web11.58885.1686577140495656780 for ; Mon, 12 Jun 2023 06:39:00 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="338400664" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="338400664" X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 06:37:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="958033011" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="958033011" X-Received: from shwdeopenlab705.ccr.corp.intel.com ([10.239.55.55]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2023 06:37:51 -0700 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Yuanhao Xie Subject: [edk2-devel] [PATCH 3/5] UefiCpuPkg: Refactor the logic for placing APs in Mwait/Runloop. Date: Mon, 12 Jun 2023 21:37:18 +0800 Message-Id: <20230612133720.15501-4-yuanhao.xie@intel.com> In-Reply-To: <20230612133720.15501-1-yuanhao.xie@intel.com> References: <20230612133720.15501-1-yuanhao.xie@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,yuanhao.xie@intel.com X-Gm-Message-State: NrX9hQCBsf1Bt2l0U66bp3a6x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1686577141; bh=OINWyCSxZcuQWEcA4qwAvcLdMdWgRiBHfmdL2WEI5N4=; h=Cc:Date:From:Reply-To:Subject:To; b=qvfn/BpSWfDCIMwdhtQ+xz1mgUVirLhTSXq6PkSG3uDOz6NzEf9FsH1cwzvRG25f+WY szSsUpHv+AklEdD7dC6Dbb0tPmEVbYJld5RA50+g+KQOFYZMnYAp/9P1wiPEG6u7jDOKP 69tLoxFFLaoS5hlIlWH7/R/OZG6ujqaWNWs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1686577143931100011 Content-Type: text/plain; charset="utf-8" Refactor the logic for placing APs in Mwait/Runloop into a separate function. Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Signed-off-by: Yuanhao Xie --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 83 ++++++++++++++++++++++++++++++++= ++++++++++++++++++--------------------------------- 1 file changed, 50 insertions(+), 33 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 4e517a9b19..8aecd29a94 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -659,6 +659,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 Buf= fer + @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) && (*ApStartupSig= nalBuffer !=3D MP_HAND_OFF_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) || (*ApStartupSig= nalBuffer =3D=3D MP_HAND_OFF_SIGNAL)) { + break; + } + } +} + /** This function will be called from AP reset code if BSP uses WakeUpAP. =20 @@ -839,39 +887,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, ApStartupSignalB= uffer, CpuMpData->ApTargetCState); } } } --=20 2.36.1.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 (#106017): https://edk2.groups.io/g/devel/message/106017 Mute This Topic: https://groups.io/mt/99483117/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-