[edk2-devel] [PATCH v2 3/7] EmbeddedPkg: Send command when MMC ask for response

Loh, Tien Hock posted 7 patches 6 years, 8 months ago
[edk2-devel] [PATCH v2 3/7] EmbeddedPkg: Send command when MMC ask for response
Posted by Loh, Tien Hock 6 years, 8 months ago
From: "Tien Hock, Loh" <tien.hock.loh@intel.com>

Send command when MMC ask for response in DwEmmcReceiveResponse, and
command is a pending command (eg. DMA needs to be set up first)

Signed-off-by: "Tien Hock, Loh" <tien.hock.loh@intel.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c
index fd3a5bf685..c44e310c04 100644
--- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c
+++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c
@@ -400,6 +400,8 @@ DwEmmcSendCommand (
     mDwEmmcCommand = Cmd;
     mDwEmmcArgument = Argument;
   } else {
+    mDwEmmcCommand = Cmd;
+    mDwEmmcArgument = Argument;
     Status = SendCommand (Cmd, Argument);
   }
   return Status;
@@ -412,10 +414,15 @@ DwEmmcReceiveResponse (
   IN UINT32*                    Buffer
   )
 {
+  EFI_STATUS Status = EFI_SUCCESS;
+
   if (Buffer == NULL) {
     return EFI_INVALID_PARAMETER;
   }
 
+  if(IsPendingReadCommand (mDwEmmcCommand) || IsPendingWriteCommand(mDwEmmcCommand))
+    Status = SendCommand (mDwEmmcCommand, mDwEmmcArgument);
+
   if (   (Type == MMC_RESPONSE_TYPE_R1)
       || (Type == MMC_RESPONSE_TYPE_R1b)
       || (Type == MMC_RESPONSE_TYPE_R3)
@@ -429,7 +436,7 @@ DwEmmcReceiveResponse (
     Buffer[2] = MmioRead32 (DWEMMC_RESP2);
     Buffer[3] = MmioRead32 (DWEMMC_RESP3);
   }
-  return EFI_SUCCESS;
+  return Status;
 }
 
 VOID
-- 
2.19.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#41411): https://edk2.groups.io/g/devel/message/41411
Mute This Topic: https://groups.io/mt/31807962/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v2 3/7] EmbeddedPkg: Send command when MMC ask for response
Posted by Leif Lindholm 6 years, 8 months ago
On Mon, May 27, 2019 at 05:30:24PM +0800, tien.hock.loh@intel.com wrote:
> From: "Tien Hock, Loh" <tien.hock.loh@intel.com>
> 
> Send command when MMC ask for response in DwEmmcReceiveResponse, and
> command is a pending command (eg. DMA needs to be set up first)
> 
> Signed-off-by: "Tien Hock, Loh" <tien.hock.loh@intel.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c
> index fd3a5bf685..c44e310c04 100644
> --- a/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c
> +++ b/EmbeddedPkg/Drivers/DwEmmcDxe/DwEmmcDxe.c
> @@ -400,6 +400,8 @@ DwEmmcSendCommand (
>      mDwEmmcCommand = Cmd;
>      mDwEmmcArgument = Argument;
>    } else {
> +    mDwEmmcCommand = Cmd;
> +    mDwEmmcArgument = Argument;

OK, sorry, I didn't spot this last time around - but these two lines
are now present for both sides of the conditional, so should be moved
outside. Which (I think) would turn it into

  mDwEmmcCommand = Cmd;
  mDwEmmcArgument = Argument;
  if (!IsPendingReadCommand (Cmd) && !IsPendingWriteCommand (Cmd)) {
    Status = SendCommand (Cmd, Argument);
  }


>      Status = SendCommand (Cmd, Argument);
>    }
>    return Status;
> @@ -412,10 +414,15 @@ DwEmmcReceiveResponse (
>    IN UINT32*                    Buffer
>    )
>  {
> +  EFI_STATUS Status = EFI_SUCCESS;
> +
>    if (Buffer == NULL) {
>      return EFI_INVALID_PARAMETER;
>    }
>  
> +  if(IsPendingReadCommand (mDwEmmcCommand) || IsPendingWriteCommand(mDwEmmcCommand))

Space after if. Space after IsPendingWriteCommand.

/
    Leif

> +    Status = SendCommand (mDwEmmcCommand, mDwEmmcArgument);
> +
>    if (   (Type == MMC_RESPONSE_TYPE_R1)
>        || (Type == MMC_RESPONSE_TYPE_R1b)
>        || (Type == MMC_RESPONSE_TYPE_R3)
> @@ -429,7 +436,7 @@ DwEmmcReceiveResponse (
>      Buffer[2] = MmioRead32 (DWEMMC_RESP2);
>      Buffer[3] = MmioRead32 (DWEMMC_RESP3);
>    }
> -  return EFI_SUCCESS;
> +  return Status;
>  }
>  
>  VOID
> -- 
> 2.19.0
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#41536): https://edk2.groups.io/g/devel/message/41536
Mute This Topic: https://groups.io/mt/31807962/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-