public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: tien.hock.loh@intel.com
To: edk2-devel@lists.01.org
Cc: thloh85@gmail.com, "Loh, Tien Hock" <tien.hock.loh@intel.com>
Subject: [PATCH 4/4] EmbeddedPkg/DwEmmc: Check DMA completion in SendCommand
Date: Thu, 25 Oct 2018 13:52:24 +0800	[thread overview]
Message-ID: <e3530397d4a5a7fd0b0ed7f3f15aaaf0621b7f64.1540435686.git.tien.hock.loh@intel.com> (raw)
In-Reply-To: <cover.1540435686.git.tien.hock.loh@intel.com>
In-Reply-To: <cover.1540435686.git.tien.hock.loh@intel.com>

From: "Loh, Tien Hock" <tien.hock.loh@intel.com>

DwEmmcReadBlockData and DwEmmcWriteBlockData needs to check for the
transfer completion before returning. This also adds error checking
to the DMA transfer.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Loh Tien Hock <tien.hock.loh@intel.com>
---
 EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c
index c232309..baf299d 100644
--- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c
+++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c
@@ -563,8 +563,9 @@ DwEmmcReadBlockData (
   )
 {
   EFI_STATUS  Status;
-  UINT32      DescPages, CountPerPage, Count;
+  UINT32      DescPages, CountPerPage, Count, ErrMask;
   EFI_TPL     Tpl;
+  UINTN Rintsts;
 
   Tpl = gBS->RaiseTPL (TPL_NOTIFY);
 
@@ -587,6 +588,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);
@@ -602,8 +615,9 @@ DwEmmcWriteBlockData (
   )
 {
   EFI_STATUS  Status;
-  UINT32      DescPages, CountPerPage, Count;
+  UINT32      DescPages, CountPerPage, Count, ErrMask;
   EFI_TPL     Tpl;
+  UINTN Rintsts;
 
   Tpl = gBS->RaiseTPL (TPL_NOTIFY);
 
@@ -626,6 +640,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.2.2



  parent reply	other threads:[~2018-10-25  5:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25  5:52 [PATCH 0/4] EmbeddedPkg/DwEmmc: Fix bugs causing DwEmmc to fail to initialize tien.hock.loh
2018-10-25  5:52 ` [PATCH 1/4] EmbeddedPkg/DwEmmc: Remove unnecessary MicroSecondDelay tien.hock.loh
2018-10-25  5:52 ` [PATCH 2/4] EmbeddedPkg/DwEmmc: Fix SendCommand parameters tien.hock.loh
2018-10-25  5:52 ` [PATCH 3/4] EmbeddedPkg/DwEmmc: Fix DMA transfer length tien.hock.loh
2018-10-25  5:52 ` tien.hock.loh [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-02-22  7:52 [PATCH 0/4] EmbeddedPkg/DwEmmc: Fix bugs causing DwEmmc to fail to initialize tien.hock.loh
2019-02-22  7:52 ` [PATCH 4/4] EmbeddedPkg/DwEmmc: Check DMA completion in SendCommand tien.hock.loh
2019-02-22  8:06 [PATCH 0/4] EmbeddedPkg/DwEmmc: Fix bugs causing DwEmmc to fail to initialize tien.hock.loh
2019-02-22  8:06 ` [PATCH 4/4] EmbeddedPkg/DwEmmc: Check DMA completion in SendCommand tien.hock.loh

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=e3530397d4a5a7fd0b0ed7f3f15aaaf0621b7f64.1540435686.git.tien.hock.loh@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