From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ml01.01.org (Postfix) with ESMTP id 04E651A1E80 for ; Tue, 2 Aug 2016 02:00:26 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 02 Aug 2016 02:00:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,459,1464678000"; d="scan'208";a="743019302" Received: from jfan12-desk.ccr.corp.intel.com ([10.239.9.5]) by FMSMGA003.fm.intel.com with ESMTP; 02 Aug 2016 02:00:25 -0700 From: Jeff Fan To: edk2-devel@lists.01.org Cc: Michael Kinney , Feng Tian , Giri P Mudusuru , Laszlo Ersek Date: Tue, 2 Aug 2016 16:59:26 +0800 Message-Id: <1470128388-17960-27-git-send-email-jeff.fan@intel.com> X-Mailer: git-send-email 2.7.4.windows.1 In-Reply-To: <1470128388-17960-1-git-send-email-jeff.fan@intel.com> References: <1470128388-17960-1-git-send-email-jeff.fan@intel.com> Subject: [Patch v5 26/48] UefiCpuPkg/MpInitLib: Skip collect processor count if GUIDed HOB exist X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2016 09:00:27 -0000 If GUIDed HOB mCpuInitMpLibHobGuid exists, we could get the processor count and processor APICID and Initial APICID from CPU_INFO_IN_HOB. We needn't to delay for broadcast INIT-SIPI-SIPI results and could improve performance. Cc: Michael Kinney Cc: Feng Tian Cc: Giri P Mudusuru Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 60 +++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index d6eef13..7ae6559 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -765,6 +765,8 @@ MpInitLibInitialize ( VOID ) { + CPU_MP_DATA *OldCpuMpData; + CPU_INFO_IN_HOB *CpuInfoInHob; UINT32 MaxLogicalProcessorNumber; UINT32 ApStackSize; MP_ASSEMBLY_ADDRESS_MAP AddressMap; @@ -778,7 +780,13 @@ MpInitLibInitialize ( UINTN Index; UINTN ApResetVectorSize; UINTN BackupBufferAddr; - MaxLogicalProcessorNumber = PcdGet32(PcdCpuMaxLogicalProcessorNumber); + + OldCpuMpData = GetCpuMpDataFromGuidedHob (); + if (OldCpuMpData == NULL) { + MaxLogicalProcessorNumber = PcdGet32(PcdCpuMaxLogicalProcessorNumber); + } else { + MaxLogicalProcessorNumber = OldCpuMpData->CpuCount; + } AsmGetAddressMap (&AddressMap); ApResetVectorSize = AddressMap.RendezvousFunnelSize + sizeof (MP_CPU_EXCHANGE_INFO); @@ -843,12 +851,53 @@ MpInitLibInitialize ( // MtrrGetAllMtrrs (&CpuMpData->MtrrTable); + if (OldCpuMpData == NULL) { + // + // Wakeup all APs and calculate the processor count in system + // + CollectProcessorCount (CpuMpData); + } else { + // + // APs have been wakeup before, just get the CPU Information + // from HOB + // + CpuMpData->CpuCount = OldCpuMpData->CpuCount; + CpuMpData->BspNumber = OldCpuMpData->BspNumber; + CpuMpData->InitFlag = ApInitReconfig; + CpuInfoInHob = (CPU_INFO_IN_HOB *) (UINTN) OldCpuMpData->CpuInfoInHob; + for (Index = 0; Index < CpuMpData->CpuCount; Index++) { + InitializeSpinLock(&CpuMpData->CpuData[Index].ApLock); + CpuMpData->CpuData[Index].ApicId = CpuInfoInHob[Index].ApicId; + CpuMpData->CpuData[Index].InitialApicId = CpuInfoInHob[Index].InitialApicId; + if (CpuMpData->CpuData[Index].InitialApicId >= 255) { + CpuMpData->X2ApicEnable = TRUE; + } + CpuMpData->CpuData[Index].Health = CpuInfoInHob[Index].Health; + CpuMpData->CpuData[Index].CpuHealthy = (CpuMpData->CpuData[Index].Health == 0)? TRUE:FALSE; + CpuMpData->CpuData[Index].ApFunction = 0; + CopyMem ( + &CpuMpData->CpuData[Index].VolatileRegisters, + &CpuMpData->CpuData[0].VolatileRegisters, + sizeof (CPU_VOLATILE_REGISTERS) + ); + } + // + // Wakeup APs to do some AP initialize sync + // + WakeUpAP (CpuMpData, TRUE, 0, ApInitializeSync, CpuMpData); + // + // Wait for all APs finished initialization + // + while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) { + CpuPause (); + } + CpuMpData->InitFlag = ApInitDone; + for (Index = 0; Index < CpuMpData->CpuCount; Index++) { + SetApState (&CpuMpData->CpuData[Index], CpuStateIdle); + } + } // - // Wakeup all APs and calculate the processor count in system - // - CollectProcessorCount (CpuMpData); - // // Initialize global data for MP support // InitMpGlobalData (CpuMpData); @@ -936,6 +985,7 @@ MpInitLibGetNumberOfProcessors ( { return EFI_UNSUPPORTED; } + /** Get pointer to CPU MP Data structure from GUIDed HOB. -- 2.7.4.windows.1