From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: tien.hock.loh@intel.com) Received: from mga02.intel.com (mga02.intel.com []) by groups.io with SMTP; Mon, 27 May 2019 02:31:59 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 May 2019 02:31:58 -0700 X-ExtLoop1: 1 Received: from pg-nx11.altera.com ([10.104.4.26]) by orsmga008.jf.intel.com with ESMTP; 27 May 2019 02:31:57 -0700 From: "Loh, Tien Hock" To: devel@edk2.groups.io, thloh85@gmail.com Cc: "Tien Hock, Loh" , Leif Lindholm , Ard Biesheuvel Subject: [PATCH v2 6/7] EmbeddedPkg: Fix DwEmmc SendCommand polling Date: Mon, 27 May 2019 17:30:27 +0800 Message-Id: <1558949428-190715-7-git-send-email-tien.hock.loh@intel.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1558949428-190715-1-git-send-email-tien.hock.loh@intel.com> References: <1558949428-190715-1-git-send-email-tien.hock.loh@intel.com> From: "Tien Hock, Loh" Change SendCommand polling mode to remove unnecessary delay, and check for transfer done only when block data is to be read/write. This would also increase performance slightly. Signed-off-by: "Tien Hock, Loh" Cc: Leif Lindholm Cc: Ard Biesheuvel --- EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c | 43 +++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c index c6c8e04917..b57833458f 100644 --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c @@ -286,16 +286,13 @@ SendCommand ( DWEMMC_INT_RCRC | DWEMMC_INT_RE; ErrMask |= DWEMMC_INT_DCRC | DWEMMC_INT_DRT | DWEMMC_INT_SBE; do { - MicroSecondDelay(500); Data = MmioRead32 (DWEMMC_RINTSTS); - - if (Data & ErrMask) { - return EFI_DEVICE_ERROR; - } - if (Data & DWEMMC_INT_DTO) { // Transfer Done - break; - } } while (!(Data & DWEMMC_INT_CMD_DONE)); + + if (Data & ErrMask) { + return EFI_DEVICE_ERROR; + } + return EFI_SUCCESS; } @@ -550,8 +547,9 @@ DwEmmcReadBlockData ( ) { EFI_STATUS Status; - UINT32 DescPages, CountPerPage, Count; + UINT32 DescPages, CountPerPage, Count, ErrMask; EFI_TPL Tpl; + UINTN Rintsts = 0; Tpl = gBS->RaiseTPL (TPL_NOTIFY); @@ -574,6 +572,18 @@ DwEmmcReadBlockData ( DEBUG ((DEBUG_ERROR, "Failed to read data, mDwEmmcCommand:%x, mDwEmmcArgument:%x, Status:%r\n", mDwEmmcCommand, mDwEmmcArgument, Status)); goto out; } + + while(!((MmioRead32(DWEMMC_RINTSTS) & (DWEMMC_INT_DTO)))) { + Rintsts = MmioRead32 (DWEMMC_RINTSTS); + } + ErrMask = DWEMMC_INT_EBE | DWEMMC_INT_HLE | DWEMMC_INT_RTO | + DWEMMC_INT_RCRC | DWEMMC_INT_RE | DWEMMC_INT_DCRC | + DWEMMC_INT_DRT | DWEMMC_INT_SBE; + + if (Rintsts & ErrMask) { + Status = EFI_DEVICE_ERROR; + goto out; + } out: // Restore Tpl gBS->RestoreTPL (Tpl); @@ -589,8 +599,9 @@ DwEmmcWriteBlockData ( ) { EFI_STATUS Status; - UINT32 DescPages, CountPerPage, Count; + UINT32 DescPages, CountPerPage, Count, ErrMask; EFI_TPL Tpl; + UINTN Rintsts = 0; Tpl = gBS->RaiseTPL (TPL_NOTIFY); @@ -613,6 +624,18 @@ DwEmmcWriteBlockData ( DEBUG ((DEBUG_ERROR, "Failed to write data, mDwEmmcCommand:%x, mDwEmmcArgument:%x, Status:%r\n", mDwEmmcCommand, mDwEmmcArgument, Status)); goto out; } + + while(!((MmioRead32(DWEMMC_RINTSTS) & (DWEMMC_INT_DTO)))) { + Rintsts = MmioRead32 (DWEMMC_RINTSTS); + } + ErrMask = DWEMMC_INT_EBE | DWEMMC_INT_HLE | DWEMMC_INT_RTO | + DWEMMC_INT_RCRC | DWEMMC_INT_RE | DWEMMC_INT_DCRC | + DWEMMC_INT_DRT | DWEMMC_INT_SBE; + + if (Rintsts & ErrMask) { + Status = EFI_DEVICE_ERROR; + goto out; + } out: // Restore Tpl gBS->RestoreTPL (Tpl); -- 2.19.0