public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.
@ 2019-01-16 13:21 Meenakshi Aggarwal
  2019-01-17 11:23 ` Leif Lindholm
  2019-01-24 14:05 ` [PATCH v2] " Meenakshi Aggarwal
  0 siblings, 2 replies; 8+ messages in thread
From: Meenakshi Aggarwal @ 2019-01-16 13:21 UTC (permalink / raw)
  To: ard.biesheuvel, leif.lindholm, edk2-devel

Issue : SD read failure for high capacity cards e.g. 64 GB
i
Reason : Command argument value exceeds 32 bit for block number 0x3787FFF
and cant be fit into 32 bit wide SD host controller register.

Fix :
AccessMode bits [29:30] of OCR is a valid definition to calculate
data address for eMMC cards.

For SD cards, data address is calculated on the basis of
card capacity status bit[30] of OCR.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
 EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
index a2b9232..625a59e 100644
--- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
@@ -148,12 +148,21 @@ MmcTransferBlock (
   MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
   MmcHost = MmcHostInstance->MmcHost;
 
-  //Set command argument based on the card access mode (Byte mode or Block mode)
-  if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
-      MMC_OCR_ACCESS_SECTOR) {
-    CmdArg = Lba;
+  if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
+    //Set command argument based on the card capacity (SDSC or SDXC/SDHC)
+    if (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1) {
+      CmdArg = Lba;
+    } else {
+      CmdArg = Lba * This->Media->BlockSize;
+    }
   } else {
-    CmdArg = Lba * This->Media->BlockSize;
+    //Set command argument based on the card access mode (Byte mode or Block mode)
+    if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
+        MMC_OCR_ACCESS_SECTOR) {
+      CmdArg = Lba;
+    } else {
+      CmdArg = Lba * This->Media->BlockSize;
+    }
   }
 
   Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.
  2019-01-16 13:21 [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation Meenakshi Aggarwal
@ 2019-01-17 11:23 ` Leif Lindholm
  2019-01-22  4:29   ` Meenakshi Aggarwal
  2019-01-24 14:05 ` [PATCH v2] " Meenakshi Aggarwal
  1 sibling, 1 reply; 8+ messages in thread
From: Leif Lindholm @ 2019-01-17 11:23 UTC (permalink / raw)
  To: Meenakshi Aggarwal; +Cc: ard.biesheuvel, edk2-devel, Jun Nie, Haojian Zhuang

Jun, Haojian - any comments?

On Wed, Jan 16, 2019 at 06:51:36PM +0530, Meenakshi Aggarwal wrote:
> Issue : SD read failure for high capacity cards e.g. 64 GB
> i
> Reason : Command argument value exceeds 32 bit for block number 0x3787FFF
> and cant be fit into 32 bit wide SD host controller register.
> 
> Fix :
> AccessMode bits [29:30] of OCR is a valid definition to calculate
> data address for eMMC cards.
> 
> For SD cards, data address is calculated on the basis of
> card capacity status bit[30] of OCR.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> ---
>  EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 19 ++++++++++++++-----
>  1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> index a2b9232..625a59e 100644
> --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> @@ -148,12 +148,21 @@ MmcTransferBlock (
>    MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
>    MmcHost = MmcHostInstance->MmcHost;
>  
> -  //Set command argument based on the card access mode (Byte mode or Block mode)
> -  if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
> -      MMC_OCR_ACCESS_SECTOR) {
> -    CmdArg = Lba;
> +  if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
> +    //Set command argument based on the card capacity (SDSC or SDXC/SDHC)
> +    if (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1) {
> +      CmdArg = Lba;
> +    } else {
> +      CmdArg = Lba * This->Media->BlockSize;
> +    }
>    } else {
> -    CmdArg = Lba * This->Media->BlockSize;
> +    //Set command argument based on the card access mode (Byte mode or Block mode)
> +    if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
> +        MMC_OCR_ACCESS_SECTOR) {
> +      CmdArg = Lba;
> +    } else {
> +      CmdArg = Lba * This->Media->BlockSize;
> +    }
>    }
>  
>    Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.
  2019-01-17 11:23 ` Leif Lindholm
@ 2019-01-22  4:29   ` Meenakshi Aggarwal
  2019-01-23 15:04     ` Leif Lindholm
  0 siblings, 1 reply; 8+ messages in thread
From: Meenakshi Aggarwal @ 2019-01-22  4:29 UTC (permalink / raw)
  To: Leif Lindholm, Jun Nie, Haojian Zhuang
  Cc: ard.biesheuvel@linaro.org, edk2-devel@lists.01.org

Hi Jun, Haojian,

Please review the patch.

Thanks,
Meenakshi

> -----Original Message-----
> From: Leif Lindholm <leif.lindholm@linaro.org>
> Sent: Thursday, January 17, 2019 4:54 PM
> To: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> Cc: ard.biesheuvel@linaro.org; edk2-devel@lists.01.org; Jun Nie
> <jun.nie@linaro.org>; Haojian Zhuang <haojian.zhuang@linaro.org>
> Subject: Re: [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W
> operation.
> 
> Jun, Haojian - any comments?
> 
> On Wed, Jan 16, 2019 at 06:51:36PM +0530, Meenakshi Aggarwal wrote:
> > Issue : SD read failure for high capacity cards e.g. 64 GB i Reason :
> > Command argument value exceeds 32 bit for block number 0x3787FFF and
> > cant be fit into 32 bit wide SD host controller register.
> >
> > Fix :
> > AccessMode bits [29:30] of OCR is a valid definition to calculate data
> > address for eMMC cards.
> >
> > For SD cards, data address is calculated on the basis of card capacity
> > status bit[30] of OCR.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > ---
> >  EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 19 ++++++++++++++-----
> >  1 file changed, 14 insertions(+), 5 deletions(-)
> >
> > diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> > b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> > index a2b9232..625a59e 100644
> > --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> > +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> > @@ -148,12 +148,21 @@ MmcTransferBlock (
> >    MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
> >    MmcHost = MmcHostInstance->MmcHost;
> >
> > -  //Set command argument based on the card access mode (Byte mode or
> > Block mode)
> > -  if ((MmcHostInstance->CardInfo.OCRData.AccessMode &
> MMC_OCR_ACCESS_MASK) ==
> > -      MMC_OCR_ACCESS_SECTOR) {
> > -    CmdArg = Lba;
> > +  if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
> > +    //Set command argument based on the card capacity (SDSC or SDXC/SDHC)
> > +    if (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1) {
> > +      CmdArg = Lba;
> > +    } else {
> > +      CmdArg = Lba * This->Media->BlockSize;
> > +    }
> >    } else {
> > -    CmdArg = Lba * This->Media->BlockSize;
> > +    //Set command argument based on the card access mode (Byte mode or
> Block mode)
> > +    if ((MmcHostInstance->CardInfo.OCRData.AccessMode &
> MMC_OCR_ACCESS_MASK) ==
> > +        MMC_OCR_ACCESS_SECTOR) {
> > +      CmdArg = Lba;
> > +    } else {
> > +      CmdArg = Lba * This->Media->BlockSize;
> > +    }
> >    }
> >
> >    Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
> > --
> > 1.9.1
> >


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.
  2019-01-22  4:29   ` Meenakshi Aggarwal
@ 2019-01-23 15:04     ` Leif Lindholm
  0 siblings, 0 replies; 8+ messages in thread
From: Leif Lindholm @ 2019-01-23 15:04 UTC (permalink / raw)
  To: Meenakshi Aggarwal
  Cc: Jun Nie, Haojian Zhuang, ard.biesheuvel@linaro.org,
	edk2-devel@lists.01.org

Well, if we don't hear back, I can just commit it anyway before the
end of the week. One question/comment inline below:

On Tue, Jan 22, 2019 at 04:29:50AM +0000, Meenakshi Aggarwal wrote:
> Hi Jun, Haojian,
> 
> Please review the patch.
> 
> Thanks,
> Meenakshi
> 
> > -----Original Message-----
> > From: Leif Lindholm <leif.lindholm@linaro.org>
> > Sent: Thursday, January 17, 2019 4:54 PM
> > To: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > Cc: ard.biesheuvel@linaro.org; edk2-devel@lists.01.org; Jun Nie
> > <jun.nie@linaro.org>; Haojian Zhuang <haojian.zhuang@linaro.org>
> > Subject: Re: [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W
> > operation.
> > 
> > Jun, Haojian - any comments?
> > 
> > On Wed, Jan 16, 2019 at 06:51:36PM +0530, Meenakshi Aggarwal wrote:
> > > Issue : SD read failure for high capacity cards e.g. 64 GB i Reason :
> > > Command argument value exceeds 32 bit for block number 0x3787FFF and
> > > cant be fit into 32 bit wide SD host controller register.
> > >
> > > Fix :
> > > AccessMode bits [29:30] of OCR is a valid definition to calculate data
> > > address for eMMC cards.
> > >
> > > For SD cards, data address is calculated on the basis of card capacity
> > > status bit[30] of OCR.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > > ---
> > >  EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 19 ++++++++++++++-----
> > >  1 file changed, 14 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> > > b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> > > index a2b9232..625a59e 100644
> > > --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> > > +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> > > @@ -148,12 +148,21 @@ MmcTransferBlock (
> > >    MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
> > >    MmcHost = MmcHostInstance->MmcHost;
> > >
> > > -  //Set command argument based on the card access mode (Byte mode or
> > > Block mode)
> > > -  if ((MmcHostInstance->CardInfo.OCRData.AccessMode &
> > MMC_OCR_ACCESS_MASK) ==
> > > -      MMC_OCR_ACCESS_SECTOR) {
> > > -    CmdArg = Lba;
> > > +  if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
> > > +    //Set command argument based on the card capacity (SDSC or SDXC/SDHC)
> > > +    if (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1) {

What is BIT1? Can we add a #define for it?
(The comment _nearly_ but not quite explains it to me.)

/
    Leif

> > > +      CmdArg = Lba;
> > > +    } else {
> > > +      CmdArg = Lba * This->Media->BlockSize;
> > > +    }
> > >    } else {
> > > -    CmdArg = Lba * This->Media->BlockSize;
> > > +    //Set command argument based on the card access mode (Byte mode or
> > Block mode)
> > > +    if ((MmcHostInstance->CardInfo.OCRData.AccessMode &
> > MMC_OCR_ACCESS_MASK) ==
> > > +        MMC_OCR_ACCESS_SECTOR) {
> > > +      CmdArg = Lba;
> > > +    } else {
> > > +      CmdArg = Lba * This->Media->BlockSize;
> > > +    }
> > >    }
> > >
> > >    Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
> > > --
> > > 1.9.1
> > >


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.
  2019-01-16 13:21 [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation Meenakshi Aggarwal
  2019-01-17 11:23 ` Leif Lindholm
@ 2019-01-24 14:05 ` Meenakshi Aggarwal
  2019-01-29  4:43   ` Meenakshi Aggarwal
  2019-01-30 17:49   ` Leif Lindholm
  1 sibling, 2 replies; 8+ messages in thread
From: Meenakshi Aggarwal @ 2019-01-24 14:05 UTC (permalink / raw)
  To: ard.biesheuvel, leif.lindholm, edk2-devel, jun.nie,
	haojian.zhuang

Issue : SD read failure for high capacity cards e.g. 64 GB
i
Reason : Command argument value exceeds 32 bit for block number 0x3787FFF
and cant be fit into 32 bit wide SD host controller register.

Fix :
AccessMode bits [29:30] of OCR is a valid definition to calculate
data address for eMMC cards.

For SD cards, data address is calculated on the basis of
card capacity status bit[30] of OCR.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
---
 EmbeddedPkg/Universal/MmcDxe/Mmc.h        |  2 ++
 EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 21 ++++++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
index a77ba41..62de2c8 100644
--- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h
+++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
@@ -70,6 +70,8 @@
 #define SD_HIGH_SPEED                       50000000
 #define SWITCH_CMD_SUCCESS_MASK             0x0f000000
 
+#define SD_CARD_CAPACITY                    0x00000002
+
 #define BUSWIDTH_4                          4
 
 typedef enum {
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
index a2b9232..1dea7d3 100644
--- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
@@ -148,12 +148,23 @@ MmcTransferBlock (
   MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
   MmcHost = MmcHostInstance->MmcHost;
 
-  //Set command argument based on the card access mode (Byte mode or Block mode)
-  if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
-      MMC_OCR_ACCESS_SECTOR) {
-    CmdArg = Lba;
+  if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
+    //Set command argument based on the card capacity
+    //if 0 : SDSC card
+    //if 1 : SDXC/SDHC
+    if (MmcHostInstance->CardInfo.OCRData.AccessMode & SD_CARD_CAPACITY) {
+      CmdArg = Lba;
+    } else {
+      CmdArg = Lba * This->Media->BlockSize;
+    }
   } else {
-    CmdArg = Lba * This->Media->BlockSize;
+    //Set command argument based on the card access mode (Byte mode or Block mode)
+    if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
+        MMC_OCR_ACCESS_SECTOR) {
+      CmdArg = Lba;
+    } else {
+      CmdArg = Lba * This->Media->BlockSize;
+    }
   }
 
   Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.
  2019-01-24 14:05 ` [PATCH v2] " Meenakshi Aggarwal
@ 2019-01-29  4:43   ` Meenakshi Aggarwal
  2019-01-30  4:26     ` Meenakshi Aggarwal
  2019-01-30 17:49   ` Leif Lindholm
  1 sibling, 1 reply; 8+ messages in thread
From: Meenakshi Aggarwal @ 2019-01-29  4:43 UTC (permalink / raw)
  To: Meenakshi Aggarwal, ard.biesheuvel@linaro.org,
	leif.lindholm@linaro.org, edk2-devel@lists.01.org,
	jun.nie@linaro.org, haojian.zhuang@linaro.org

Hi,

Please share review comments.

Thanks,
Meenakshi

> -----Original Message-----
> From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> Sent: Thursday, January 24, 2019 7:35 PM
> To: ard.biesheuvel@linaro.org; leif.lindholm@linaro.org; edk2-
> devel@lists.01.org; jun.nie@linaro.org; haojian.zhuang@linaro.org
> Cc: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> Subject: [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W
> operation.
> 
> Issue : SD read failure for high capacity cards e.g. 64 GB i Reason : Command
> argument value exceeds 32 bit for block number 0x3787FFF and cant be fit into
> 32 bit wide SD host controller register.
> 
> Fix :
> AccessMode bits [29:30] of OCR is a valid definition to calculate data address for
> eMMC cards.
> 
> For SD cards, data address is calculated on the basis of card capacity status
> bit[30] of OCR.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> ---
>  EmbeddedPkg/Universal/MmcDxe/Mmc.h        |  2 ++
>  EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 21 ++++++++++++++++-----
>  2 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> index a77ba41..62de2c8 100644
> --- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> +++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> @@ -70,6 +70,8 @@
>  #define SD_HIGH_SPEED                       50000000
>  #define SWITCH_CMD_SUCCESS_MASK             0x0f000000
> 
> +#define SD_CARD_CAPACITY                    0x00000002
> +
>  #define BUSWIDTH_4                          4
> 
>  typedef enum {
> diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> index a2b9232..1dea7d3 100644
> --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> @@ -148,12 +148,23 @@ MmcTransferBlock (
>    MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
>    MmcHost = MmcHostInstance->MmcHost;
> 
> -  //Set command argument based on the card access mode (Byte mode or Block
> mode)
> -  if ((MmcHostInstance->CardInfo.OCRData.AccessMode &
> MMC_OCR_ACCESS_MASK) ==
> -      MMC_OCR_ACCESS_SECTOR) {
> -    CmdArg = Lba;
> +  if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
> +    //Set command argument based on the card capacity
> +    //if 0 : SDSC card
> +    //if 1 : SDXC/SDHC
> +    if (MmcHostInstance->CardInfo.OCRData.AccessMode &
> SD_CARD_CAPACITY) {
> +      CmdArg = Lba;
> +    } else {
> +      CmdArg = Lba * This->Media->BlockSize;
> +    }
>    } else {
> -    CmdArg = Lba * This->Media->BlockSize;
> +    //Set command argument based on the card access mode (Byte mode or
> Block mode)
> +    if ((MmcHostInstance->CardInfo.OCRData.AccessMode &
> MMC_OCR_ACCESS_MASK) ==
> +        MMC_OCR_ACCESS_SECTOR) {
> +      CmdArg = Lba;
> +    } else {
> +      CmdArg = Lba * This->Media->BlockSize;
> +    }
>    }
> 
>    Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
> --
> 1.9.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.
  2019-01-29  4:43   ` Meenakshi Aggarwal
@ 2019-01-30  4:26     ` Meenakshi Aggarwal
  0 siblings, 0 replies; 8+ messages in thread
From: Meenakshi Aggarwal @ 2019-01-30  4:26 UTC (permalink / raw)
  To: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org,
	edk2-devel@lists.01.org, jun.nie@linaro.org,
	haojian.zhuang@linaro.org

Any comments?

> -----Original Message-----
> From: Meenakshi Aggarwal
> Sent: Tuesday, January 29, 2019 10:13 AM
> To: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>;
> ard.biesheuvel@linaro.org; leif.lindholm@linaro.org; edk2-devel@lists.01.org;
> jun.nie@linaro.org; haojian.zhuang@linaro.org
> Subject: RE: [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W
> operation.
> 
> Hi,
> 
> Please share review comments.
> 
> Thanks,
> Meenakshi
> 
> > -----Original Message-----
> > From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > Sent: Thursday, January 24, 2019 7:35 PM
> > To: ard.biesheuvel@linaro.org; leif.lindholm@linaro.org; edk2-
> > devel@lists.01.org; jun.nie@linaro.org; haojian.zhuang@linaro.org
> > Cc: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > Subject: [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W
> > operation.
> >
> > Issue : SD read failure for high capacity cards e.g. 64 GB i Reason :
> > Command argument value exceeds 32 bit for block number 0x3787FFF and
> > cant be fit into
> > 32 bit wide SD host controller register.
> >
> > Fix :
> > AccessMode bits [29:30] of OCR is a valid definition to calculate data
> > address for eMMC cards.
> >
> > For SD cards, data address is calculated on the basis of card capacity
> > status bit[30] of OCR.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> > ---
> >  EmbeddedPkg/Universal/MmcDxe/Mmc.h        |  2 ++
> >  EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 21 ++++++++++++++++----
> -
> >  2 files changed, 18 insertions(+), 5 deletions(-)
> >
> > diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> > b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> > index a77ba41..62de2c8 100644
> > --- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> > +++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> > @@ -70,6 +70,8 @@
> >  #define SD_HIGH_SPEED                       50000000
> >  #define SWITCH_CMD_SUCCESS_MASK             0x0f000000
> >
> > +#define SD_CARD_CAPACITY                    0x00000002
> > +
> >  #define BUSWIDTH_4                          4
> >
> >  typedef enum {
> > diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> > b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> > index a2b9232..1dea7d3 100644
> > --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> > +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> > @@ -148,12 +148,23 @@ MmcTransferBlock (
> >    MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
> >    MmcHost = MmcHostInstance->MmcHost;
> >
> > -  //Set command argument based on the card access mode (Byte mode or
> > Block
> > mode)
> > -  if ((MmcHostInstance->CardInfo.OCRData.AccessMode &
> > MMC_OCR_ACCESS_MASK) ==
> > -      MMC_OCR_ACCESS_SECTOR) {
> > -    CmdArg = Lba;
> > +  if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
> > +    //Set command argument based on the card capacity
> > +    //if 0 : SDSC card
> > +    //if 1 : SDXC/SDHC
> > +    if (MmcHostInstance->CardInfo.OCRData.AccessMode &
> > SD_CARD_CAPACITY) {
> > +      CmdArg = Lba;
> > +    } else {
> > +      CmdArg = Lba * This->Media->BlockSize;
> > +    }
> >    } else {
> > -    CmdArg = Lba * This->Media->BlockSize;
> > +    //Set command argument based on the card access mode (Byte mode
> > + or
> > Block mode)
> > +    if ((MmcHostInstance->CardInfo.OCRData.AccessMode &
> > MMC_OCR_ACCESS_MASK) ==
> > +        MMC_OCR_ACCESS_SECTOR) {
> > +      CmdArg = Lba;
> > +    } else {
> > +      CmdArg = Lba * This->Media->BlockSize;
> > +    }
> >    }
> >
> >    Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
> > --
> > 1.9.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.
  2019-01-24 14:05 ` [PATCH v2] " Meenakshi Aggarwal
  2019-01-29  4:43   ` Meenakshi Aggarwal
@ 2019-01-30 17:49   ` Leif Lindholm
  1 sibling, 0 replies; 8+ messages in thread
From: Leif Lindholm @ 2019-01-30 17:49 UTC (permalink / raw)
  To: Meenakshi Aggarwal; +Cc: ard.biesheuvel, edk2-devel, jun.nie, haojian.zhuang

I updated the subject line to start with EmbeddedPkg: instead.

On Thu, Jan 24, 2019 at 07:35:18PM +0530, Meenakshi Aggarwal wrote:
> Issue : SD read failure for high capacity cards e.g. 64 GB
> i

And I dropped the above stray i.
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>

Pushed as b566259c8a.

Thanks!

> Reason : Command argument value exceeds 32 bit for block number 0x3787FFF
> and cant be fit into 32 bit wide SD host controller register.
> 
> Fix :
> AccessMode bits [29:30] of OCR is a valid definition to calculate
> data address for eMMC cards.
> 
> For SD cards, data address is calculated on the basis of
> card capacity status bit[30] of OCR.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
> ---
>  EmbeddedPkg/Universal/MmcDxe/Mmc.h        |  2 ++
>  EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c | 21 ++++++++++++++++-----
>  2 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/EmbeddedPkg/Universal/MmcDxe/Mmc.h b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> index a77ba41..62de2c8 100644
> --- a/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> +++ b/EmbeddedPkg/Universal/MmcDxe/Mmc.h
> @@ -70,6 +70,8 @@
>  #define SD_HIGH_SPEED                       50000000
>  #define SWITCH_CMD_SUCCESS_MASK             0x0f000000
>  
> +#define SD_CARD_CAPACITY                    0x00000002
> +
>  #define BUSWIDTH_4                          4
>  
>  typedef enum {
> diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> index a2b9232..1dea7d3 100644
> --- a/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> +++ b/EmbeddedPkg/Universal/MmcDxe/MmcBlockIo.c
> @@ -148,12 +148,23 @@ MmcTransferBlock (
>    MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
>    MmcHost = MmcHostInstance->MmcHost;
>  
> -  //Set command argument based on the card access mode (Byte mode or Block mode)
> -  if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
> -      MMC_OCR_ACCESS_SECTOR) {
> -    CmdArg = Lba;
> +  if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
> +    //Set command argument based on the card capacity
> +    //if 0 : SDSC card
> +    //if 1 : SDXC/SDHC
> +    if (MmcHostInstance->CardInfo.OCRData.AccessMode & SD_CARD_CAPACITY) {
> +      CmdArg = Lba;
> +    } else {
> +      CmdArg = Lba * This->Media->BlockSize;
> +    }
>    } else {
> -    CmdArg = Lba * This->Media->BlockSize;
> +    //Set command argument based on the card access mode (Byte mode or Block mode)
> +    if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
> +        MMC_OCR_ACCESS_SECTOR) {
> +      CmdArg = Lba;
> +    } else {
> +      CmdArg = Lba * This->Media->BlockSize;
> +    }
>    }
>  
>    Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
> -- 
> 1.9.1
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-01-30 17:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-16 13:21 [PATCH] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation Meenakshi Aggarwal
2019-01-17 11:23 ` Leif Lindholm
2019-01-22  4:29   ` Meenakshi Aggarwal
2019-01-23 15:04     ` Leif Lindholm
2019-01-24 14:05 ` [PATCH v2] " Meenakshi Aggarwal
2019-01-29  4:43   ` Meenakshi Aggarwal
2019-01-30  4:26     ` Meenakshi Aggarwal
2019-01-30 17:49   ` Leif Lindholm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox