From 232eb4c82637e92b65ebbfc89a45e9daa8535171 Mon Sep 17 00:00:00 2001 From: Chen Fan Date: Thu, 13 Nov 2014 18:29:31 +0000 Subject: [PATCH] UefiCpuPkg/MpService: free the unused cpu data buffer Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen Fan Reviewed-by: Jeff Fan git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16367 6f19259b-4bc3-4df7-8a09-765794883524 --- UefiCpuPkg/CpuDxe/CpuMp.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c index 13fcda5859..10065762a2 100644 --- a/UefiCpuPkg/CpuDxe/CpuMp.c +++ b/UefiCpuPkg/CpuDxe/CpuMp.c @@ -25,7 +25,7 @@ VOID *mCommonStack = 0; VOID *mTopOfApCommonStack = 0; VOID *mApStackStart = 0; -BOOLEAN mAPsAlreadyInitFinished = FALSE; +volatile BOOLEAN mAPsAlreadyInitFinished = FALSE; volatile BOOLEAN mStopCheckAllAPsStatus = TRUE; EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = { @@ -1135,11 +1135,15 @@ ProcessorToIdleState ( EFI_AP_PROCEDURE Procedure; VOID *ProcedureArgument; + AsmApDoneWithCommonStack (); + + while (!mAPsAlreadyInitFinished) { + CpuPause (); + } + WhoAmI (&mMpServicesTemplate, &ProcessorNumber); CpuData = &mMpSystemData.CpuDatas[ProcessorNumber]; - AsmApDoneWithCommonStack (); - // // Avoid forcibly reset AP caused the AP State is not updated. // @@ -1486,6 +1490,11 @@ InitializeMpSupport ( return; } + mMpSystemData.CpuDatas = ReallocatePool ( + sizeof (CPU_DATA_BLOCK) * gMaxLogicalProcessorNumber, + sizeof (CPU_DATA_BLOCK) * mMpSystemData.NumberOfProcessors, + mMpSystemData.CpuDatas); + mAPsAlreadyInitFinished = TRUE; if (mMpSystemData.NumberOfProcessors < gMaxLogicalProcessorNumber) { -- 2.39.2