public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Hao A" <hao.a.wu@intel.com>
To: "Albecki, Mateusz" <mateusz.albecki@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Marcin Wojtas <mw@semihalf.com>,
	"Gao, Zhichao" <zhichao.gao@intel.com>,
	"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [PATCH 2/3] MdeModulePkg/SdMmcPciHcDxe: Add retries for sync commands
Date: Fri, 10 Jan 2020 05:37:46 +0000	[thread overview]
Message-ID: <B80AF82E9BFB8E4FBD8C89DA810C6A093C9923E6@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20200107110621.232-3-mateusz.albecki@intel.com>

> -----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
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1140
> 
> 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 <hao.a.wu@intel.com>

Best Regards,
Hao Wu


> 
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Marcin Wojtas <mw@semihalf.com>
> Cc: Zhichao Gao <zhichao.gao@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> 
> Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com>
> ---
>  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(-)
> 
> 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.
> 
>    Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
> -  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.<BR>
>    SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -974,6 +974,58 @@ SdMmcPciHcDriverBindingStop (
>    return Status;
>  }
> 
> +/**
> +  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 = gBS->RaiseTPL (TPL_NOTIFY);
> +    if (IsListEmpty (&Private->Queue)) {
> +      gBS->RestoreTPL (OldTpl);
> +      break;
> +    }
> +    gBS->RestoreTPL (OldTpl);
> +  }
> +
> +  while (Trb->Retries) {
> +    Status = SdMmcWaitTrbEnv (Private, Trb);
> +    if (EFI_ERROR (Status)) {
> +      return Status;
> +    }
> +
> +    Status = SdMmcExecTrb (Private, Trb);
> +    if (EFI_ERROR (Status)) {
> +      return Status;
> +    }
> +
> +    Status = SdMmcWaitTrbResult (Private, Trb);
> +    if (Status == EFI_CRC_ERROR) {
> +      Trb->Retries--;
> +    } else {
> +      return Status;
> +    }
> +  }
> +
> +  return Status;
> +}
> +
>  /**
>    Sends SD command to an SD card that is attached to the SD controller.
> 
> @@ -1023,7 +1075,6 @@ SdMmcPassThruPassThru (
>    EFI_STATUS                      Status;
>    SD_MMC_HC_PRIVATE_DATA          *Private;
>    SD_MMC_HC_TRB                   *Trb;
> -  EFI_TPL                         OldTpl;
> 
>    if ((This == NULL) || (Packet == NULL)) {
>      return EFI_INVALID_PARAMETER;
> @@ -1066,34 +1117,8 @@ SdMmcPassThruPassThru (
>      return EFI_SUCCESS;
>    }
> 
> -  //
> -  // Wait async I/O list is empty before execute sync I/O operation.
> -  //
> -  while (TRUE) {
> -    OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
> -    if (IsListEmpty (&Private->Queue)) {
> -      gBS->RestoreTPL (OldTpl);
> -      break;
> -    }
> -    gBS->RestoreTPL (OldTpl);
> -  }
> -
> -  Status = SdMmcWaitTrbEnv (Private, Trb);
> -  if (EFI_ERROR (Status)) {
> -    goto Done;
> -  }
> -
> -  Status = SdMmcExecTrb (Private, Trb);
> -  if (EFI_ERROR (Status)) {
> -    goto Done;
> -  }
> +  Status = SdMmcPassThruExecSyncTrb (Private, Trb);
> 
> -  Status = SdMmcWaitTrbResult (Private, Trb);
> -  if (EFI_ERROR (Status)) {
> -    goto Done;
> -  }
> -
> -Done:
>    SdMmcFreeTrb (Trb);
> 
>    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.
> 
>  Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved.
> -Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.<BR>
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -130,6 +130,8 @@ typedef struct {
> 
>  #define SD_MMC_HC_TRB_SIG             SIGNATURE_32 ('T', 'R', 'B', 'T')
> 
> +#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;
> 
>    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     = Event;
>    Trb->Started   = FALSE;
>    Trb->Timeout   = Packet->Timeout;
> +  Trb->Retries   = SD_MMC_TRB_RETRIES;
>    Trb->Private   = Private;
> 
>    if ((Packet->InTransferLength != 0) && (Packet->InDataBuffer != NULL)) {
> --
> 2.14.1.windows.1


  reply	other threads:[~2020-01-10  5:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 11:06 [PATCH 0/3] MdeModulePkg/SdMmcPciHcDxe: Retry the commands that failed due to CRC error Albecki, Mateusz
2020-01-07 11:06 ` [PATCH 1/3] MdeModulePkg/SdMmcPciHcDxe: Refactor command error detection Albecki, Mateusz
2020-01-10  5:37   ` Wu, Hao A
2020-01-13 13:48     ` Albecki, Mateusz
2020-01-14  4:16       ` Wu, Hao A
2020-01-07 11:06 ` [PATCH 2/3] MdeModulePkg/SdMmcPciHcDxe: Add retries for sync commands Albecki, Mateusz
2020-01-10  5:37   ` Wu, Hao A [this message]
2020-01-07 11:06 ` [PATCH 3/3] MdeModulePkg/SdMmcPciHcDxe: Add retries for async commands Albecki, Mateusz
2020-01-10  5:37   ` Wu, Hao A
2020-01-07 11:09 ` [PATCH 0/3] MdeModulePkg/SdMmcPciHcDxe: Retry the commands that failed due to CRC error Albecki, Mateusz
2020-01-08  7:38 ` Wu, Hao A

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B80AF82E9BFB8E4FBD8C89DA810C6A093C9923E6@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox