From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=M9KGhyYI; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: yuanhao.xie@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686577140; x=1718113140; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h+WluUdjoKReyjvaM8z/i3QyPHa/92LPu06v59rWt9o=; b=M9KGhyYIRLP/svcNbgzpR+ODo9+8UIF+VukRi4LfieaS/m5gmrJzOj/1 jWAazFDuXAK+57HEqlUsXnU6+3r+vEU75BPOIK+K6S+qqysxtZTMoGCUl qbQv5/MXCbi8HNis2fRtX/evA86EAi06Mt5tygBHPFtNtiWY5fWNOmJ3r b6iTBgt4uB8ip28Ww2kMDTGCsHZQ0QZ1xBz+bddWl1LNXg7vv4ugTEdy4 QbCc61/Hn/xInfCvZNkCkyyM+tdtOA5LZlS6eNF77JN8cH6OaGN7lJWKc YJp3YU2SQv3lTVpyjgKsDMDf72O6uGh3iCEB58BCaZ6hl04i9SRYFAvPv w==; X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="338400657" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="338400657" 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:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10739"; a="958033001" X-IronPort-AV: E=Sophos;i="6.00,236,1681196400"; d="scan'208";a="958033001" 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:48 -0700 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni , Rahul Kumar , Yuanhao Xie Subject: [PATCH 2/5] UefiCpuPkg: Refactor the logic for placing APs in HltLoop. Date: Mon, 12 Jun 2023 21:37:17 +0800 Message-Id: <20230612133720.15501-3-yuanhao.xie@intel.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20230612133720.15501-1-yuanhao.xie@intel.com> References: <20230612133720.15501-1-yuanhao.xie@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Refactor the logic for placing APs in HltLoop into a separate function. Cc: Eric Dong Cc: Ray Ni Cc: Rahul Kumar Signed-off-by: Yuanhao Xie --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index c55150e7b6..4e517a9b19 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -637,6 +637,28 @@ InitializeApData ( SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateIdle); } +/** + This function place APs in Halt loop. + + @param[in] CpuMpData Pointer to CPU MP Data +**/ +VOID +PlaceAPInHltLoop ( + IN CPU_MP_DATA *CpuMpData + ) +{ + while (TRUE) { + DisableInterrupts (); + if (CpuMpData->UseSevEsAPMethod) { + SevEsPlaceApHlt (CpuMpData); + } else { + CpuSleep (); + } + + CpuPause (); + } +} + /** This function will be called from AP reset code if BSP uses WakeUpAP. @@ -813,19 +835,10 @@ ApWakeupFunction ( // Place AP is specified loop mode // if (CpuMpData->ApLoopMode == ApInHltLoop) { + PlaceAPInHltLoop (CpuMpData); // - // Place AP in HLT-loop + // Never run here // - while (TRUE) { - DisableInterrupts (); - if (CpuMpData->UseSevEsAPMethod) { - SevEsPlaceApHlt (CpuMpData); - } else { - CpuSleep (); - } - - CpuPause (); - } } while (TRUE) { -- 2.36.1.windows.1