From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com []) by mx.groups.io with SMTP id smtpd.web12.6297.1578634668294041632 for ; Thu, 09 Jan 2020 21:37:51 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: hao.a.wu@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2020 21:37:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,415,1571727600"; d="scan'208";a="272302574" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by FMSMGA003.fm.intel.com with ESMTP; 09 Jan 2020 21:37:50 -0800 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 9 Jan 2020 21:37:50 -0800 Received: from shsmsx153.ccr.corp.intel.com (10.239.6.53) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 9 Jan 2020 21:37:50 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.197]) by SHSMSX153.ccr.corp.intel.com ([169.254.12.89]) with mapi id 14.03.0439.000; Fri, 10 Jan 2020 13:37:47 +0800 From: "Wu, Hao A" To: "Albecki, Mateusz" , "devel@edk2.groups.io" CC: Marcin Wojtas , "Gao, Zhichao" , "Gao, Liming" Subject: Re: [PATCH 2/3] MdeModulePkg/SdMmcPciHcDxe: Add retries for sync commands Thread-Topic: [PATCH 2/3] MdeModulePkg/SdMmcPciHcDxe: Add retries for sync commands Thread-Index: AQHVxUqTwfPHFjLGTUOof6i0gW2uuKfh/DrQ Date: Fri, 10 Jan 2020 05:37:46 +0000 Message-ID: References: <20200107110621.232-1-mateusz.albecki@intel.com> <20200107110621.232-3-mateusz.albecki@intel.com> In-Reply-To: <20200107110621.232-3-mateusz.albecki@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: hao.a.wu@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Albecki, Mateusz > Sent: Tuesday, January 07, 2020 7:06 PM > To: devel@edk2.groups.io > Cc: Albecki, Mateusz; Wu, Hao A; Marcin Wojtas; Gao, Zhichao; Gao, Liming > Subject: [PATCH 2/3] MdeModulePkg/SdMmcPciHcDxe: Add retries for sync > commands >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1140 >=20 > To increase the resiliency driver will now attempt to > retry the commands that failed due to the CRC error up > to 5 times. This should address the problems with the commands > that fail due to random condition on links. This should also > help the boards on which CMD13 is particularly unstable after > switching the link frequency. Reviewed-by: Hao A Wu Best Regards, Hao Wu >=20 > Cc: Hao A Wu > Cc: Marcin Wojtas > Cc: Zhichao Gao > Cc: Liming Gao >=20 > Signed-off-by: Mateusz Albecki > --- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c | 83 > ++++++++++++++-------- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h | 5 +- > MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 1 + > 3 files changed, 59 insertions(+), 30 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > index 373f1bed45..193b0f24e2 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.c > @@ -7,7 +7,7 @@ > It would expose EFI_SD_MMC_PASS_THRU_PROTOCOL for upper layer use. >=20 > Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. > - Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
> + Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > @@ -974,6 +974,58 @@ SdMmcPciHcDriverBindingStop ( > return Status; > } >=20 > +/** > + Execute TRB synchronously. > + > + @param[in] Private Pointer to driver private data. > + @param[in] Trb Pointer to TRB to execute. > + > + @retval EFI_SUCCESS TRB executed successfully. > + @retval Other TRB failed. > +**/ > +EFI_STATUS > +SdMmcPassThruExecSyncTrb ( > + IN SD_MMC_HC_PRIVATE_DATA *Private, > + IN SD_MMC_HC_TRB *Trb > + ) > +{ > + EFI_STATUS Status; > + EFI_TPL OldTpl; > + > + // > + // Wait async I/O list is empty before execute sync I/O operation. > + // > + while (TRUE) { > + OldTpl =3D gBS->RaiseTPL (TPL_NOTIFY); > + if (IsListEmpty (&Private->Queue)) { > + gBS->RestoreTPL (OldTpl); > + break; > + } > + gBS->RestoreTPL (OldTpl); > + } > + > + while (Trb->Retries) { > + Status =3D SdMmcWaitTrbEnv (Private, Trb); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + Status =3D SdMmcExecTrb (Private, Trb); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + Status =3D SdMmcWaitTrbResult (Private, Trb); > + if (Status =3D=3D EFI_CRC_ERROR) { > + Trb->Retries--; > + } else { > + return Status; > + } > + } > + > + return Status; > +} > + > /** > Sends SD command to an SD card that is attached to the SD controller. >=20 > @@ -1023,7 +1075,6 @@ SdMmcPassThruPassThru ( > EFI_STATUS Status; > SD_MMC_HC_PRIVATE_DATA *Private; > SD_MMC_HC_TRB *Trb; > - EFI_TPL OldTpl; >=20 > if ((This =3D=3D NULL) || (Packet =3D=3D NULL)) { > return EFI_INVALID_PARAMETER; > @@ -1066,34 +1117,8 @@ SdMmcPassThruPassThru ( > return EFI_SUCCESS; > } >=20 > - // > - // Wait async I/O list is empty before execute sync I/O operation. > - // > - while (TRUE) { > - OldTpl =3D gBS->RaiseTPL (TPL_NOTIFY); > - if (IsListEmpty (&Private->Queue)) { > - gBS->RestoreTPL (OldTpl); > - break; > - } > - gBS->RestoreTPL (OldTpl); > - } > - > - Status =3D SdMmcWaitTrbEnv (Private, Trb); > - if (EFI_ERROR (Status)) { > - goto Done; > - } > - > - Status =3D SdMmcExecTrb (Private, Trb); > - if (EFI_ERROR (Status)) { > - goto Done; > - } > + Status =3D SdMmcPassThruExecSyncTrb (Private, Trb); >=20 > - Status =3D SdMmcWaitTrbResult (Private, Trb); > - if (EFI_ERROR (Status)) { > - goto Done; > - } > - > -Done: > SdMmcFreeTrb (Trb); >=20 > return Status; > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > index 0304960132..5bc3577ba2 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHcDxe.h > @@ -3,7 +3,7 @@ > Provides some data structure definitions used by the SD/MMC host > controller driver. >=20 > Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. > -Copyright (c) 2015, Intel Corporation. All rights reserved.
> +Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
> SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > @@ -130,6 +130,8 @@ typedef struct { >=20 > #define SD_MMC_HC_TRB_SIG SIGNATURE_32 ('T', 'R', 'B', 'T') >=20 > +#define SD_MMC_TRB_RETRIES 5 > + > // > // TRB (Transfer Request Block) contains information for the cmd request= . > // > @@ -152,6 +154,7 @@ typedef struct { > EFI_EVENT Event; > BOOLEAN Started; > UINT64 Timeout; > + UINT32 Retries; >=20 > SD_MMC_HC_ADMA_32_DESC_LINE *Adma32Desc; > SD_MMC_HC_ADMA_64_V3_DESC_LINE *Adma64V3Desc; > diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > index 8b5e54f321..676ace847b 100644 > --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c > @@ -1683,6 +1683,7 @@ SdMmcCreateTrb ( > Trb->Event =3D Event; > Trb->Started =3D FALSE; > Trb->Timeout =3D Packet->Timeout; > + Trb->Retries =3D SD_MMC_TRB_RETRIES; > Trb->Private =3D Private; >=20 > if ((Packet->InTransferLength !=3D 0) && (Packet->InDataBuffer !=3D NU= LL)) { > -- > 2.14.1.windows.1