From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com []) by mx.groups.io with SMTP id smtpd.web09.2899.1578358402523485664 for ; Mon, 06 Jan 2020 16:53:24 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: eric.dong@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jan 2020 16:53:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,404,1571727600"; d="scan'208";a="217568781" Received: from ydong10-desktop.ccr.corp.intel.com ([10.239.158.133]) by fmsmga008.fm.intel.com with ESMTP; 06 Jan 2020 16:53:23 -0800 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Laszlo Ersek , Ray Ni Subject: [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: improve the coding style Date: Tue, 7 Jan 2020 08:53:19 +0800 Message-Id: <20200107005319.937-3-eric.dong@intel.com> X-Mailer: git-send-email 2.23.0.windows.1 In-Reply-To: <20200107005319.937-1-eric.dong@intel.com> References: <20200107005319.937-1-eric.dong@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2434 Current code use below loops to enumerate the CPUs: for (Index =3D mMaxNumberOfCpus; Index-- > 0;) { it has no issue but not easy for the developers to read the code. Update above code to below style, for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { It make the developers easy to read and consistent with other similar cases in this driver. Cc: Laszlo Ersek Cc: Ray Ni Signed-off-by: Eric Dong --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxe= Smm/MpService.c index f445d7b030..35a6996ba3 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -1,7 +1,7 @@ /** @file=0D SMM MP service implementation=0D =0D -Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.
=0D Copyright (c) 2017, AMD Incorporated. All rights reserved.
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -137,7 +137,7 @@ ReleaseAllAPs ( {=0D UINTN Index;=0D =0D - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) {=0D + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) {=0D if (IsPresentAp (Index)) {=0D ReleaseSemaphore (mSmmMpSyncData->CpuData[Index].Run);=0D }=0D @@ -170,7 +170,7 @@ AllCpusInSmmWithExceptions ( =0D CpuData =3D mSmmMpSyncData->CpuData;=0D ProcessorInfo =3D gSmmCpuPrivate->ProcessorInfo;=0D - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) {=0D + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) {=0D if (!(*(CpuData[Index].Present)) && ProcessorInfo[Index].ProcessorId != =3D INVALID_APIC_ID) {=0D if (((Exceptions & ARRIVAL_EXCEPTION_DELAYED) !=3D 0) && SmmCpuFeatu= resGetSmmRegister (Index, SmmRegSmmDelayed) !=3D 0) {=0D continue;=0D @@ -305,7 +305,7 @@ SmmWaitForApArrival ( //=0D // Send SMI IPIs to bring outside processors in=0D //=0D - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) {=0D + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) {=0D if (!(*(mSmmMpSyncData->CpuData[Index].Present)) && gSmmCpuPrivate->= ProcessorInfo[Index].ProcessorId !=3D INVALID_APIC_ID) {=0D SendSmiIpi ((UINT32)gSmmCpuPrivate->ProcessorInfo[Index].Processor= Id);=0D }=0D @@ -361,7 +361,7 @@ WaitForAllAPsNotBusy ( {=0D UINTN Index;=0D =0D - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) {=0D + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) {=0D //=0D // Ignore BSP and APs which not call in SMM.=0D //=0D @@ -608,7 +608,7 @@ BSPHandler ( //=0D while (TRUE) {=0D PresentCount =3D 0;=0D - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) {=0D + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) {=0D if (*(mSmmMpSyncData->CpuData[Index].Present)) {=0D PresentCount ++;=0D }=0D @@ -1343,7 +1343,7 @@ InternalSmmStartupAllAPs ( }=0D =0D CpuCount =3D 0;=0D - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) {=0D + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) {=0D if (IsPresentAp (Index)) {=0D CpuCount ++;=0D =0D @@ -1375,13 +1375,13 @@ InternalSmmStartupAllAPs ( // Here code always use AcquireSpinLock instead of AcquireSpinLockOrFail= for not=0D // block mode.=0D //=0D - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) {=0D + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) {=0D if (IsPresentAp (Index)) {=0D AcquireSpinLock (mSmmMpSyncData->CpuData[Index].Busy);=0D }=0D }=0D =0D - for (Index =3D mMaxNumberOfCpus; Index-- > 0;) {=0D + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) {=0D if (IsPresentAp (Index)) {=0D mSmmMpSyncData->CpuData[Index].Procedure =3D (EFI_AP_PROCEDURE2) Pro= cedure;=0D mSmmMpSyncData->CpuData[Index].Parameter =3D ProcedureArguments;=0D --=20 2.23.0.windows.1