Re: [edk2] [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.

2019-01-30 Thread Leif Lindholm
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 

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 
> ---
>  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   5000
>  #define SWITCH_CMD_SUCCESS_MASK 0x0f00
>  
> +#define SD_CARD_CAPACITY0x0002
> +
>  #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
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.

2019-01-29 Thread Meenakshi Aggarwal
Any comments?

> -Original Message-
> From: Meenakshi Aggarwal
> Sent: Tuesday, January 29, 2019 10:13 AM
> To: Meenakshi Aggarwal ;
> ard.biesheu...@linaro.org; leif.lindh...@linaro.org; edk2-devel@lists.01.org;
> jun@linaro.org; haojian.zhu...@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 
> > Sent: Thursday, January 24, 2019 7:35 PM
> > To: ard.biesheu...@linaro.org; leif.lindh...@linaro.org; edk2-
> > de...@lists.01.org; jun@linaro.org; haojian.zhu...@linaro.org
> > Cc: Meenakshi Aggarwal 
> > 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 
> > ---
> >  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   5000
> >  #define SWITCH_CMD_SUCCESS_MASK 0x0f00
> >
> > +#define SD_CARD_CAPACITY0x0002
> > +
> >  #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

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [edk2] [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.

2019-01-28 Thread Meenakshi Aggarwal
Hi,

Please share review comments.

Thanks,
Meenakshi

> -Original Message-
> From: Meenakshi Aggarwal 
> Sent: Thursday, January 24, 2019 7:35 PM
> To: ard.biesheu...@linaro.org; leif.lindh...@linaro.org; edk2-
> de...@lists.01.org; jun@linaro.org; haojian.zhu...@linaro.org
> Cc: Meenakshi Aggarwal 
> 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 
> ---
>  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   5000
>  #define SWITCH_CMD_SUCCESS_MASK 0x0f00
> 
> +#define SD_CARD_CAPACITY0x0002
> +
>  #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

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH v2] SD/eMMC : Fix Command Argument for SD/eMMC R/W operation.

2019-01-24 Thread Meenakshi Aggarwal
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 
---
 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   5000
 #define SWITCH_CMD_SUCCESS_MASK 0x0f00
 
+#define SD_CARD_CAPACITY0x0002
+
 #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

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel