public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Hector Palacios <hector.palacios@digi.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mmc: update MMC_ERASE argument to match Linux kernel.
Date: Wed, 9 Dec 2015 11:55:02 +0100	[thread overview]
Message-ID: <56680886.8080404@digi.com> (raw)
In-Reply-To: <1449499801-3900-1-git-send-email-eric@nelint.com>

Hi Eric and Fabio,

On 12/07/2015 03:50 PM, Eric Nelson wrote:
> Table 41 of the JEDEC standard for eMMC says that bit 31 of
> the command argument is obsolete when issuing the ERASE
> command (CMD38) on page 115 of this document:
> 	http://www.jedec.org/sites/default/files/docs/jesd84-B45.pdf
> 
> The SD Card Association Physical Layer Simplified Specification also
> makes no mention of the use of bit 31.
> 	https://www.sdcard.org/downloads/pls/part1_410.pdf
> 
> The Linux kernel distinguishes between secure (bit 31 set) and
> non-secure erase, and this patch copies the macro names from
> include/linux/mmc/core.h.
> 
> Tested-by: Fabio Estevam <fabio.estevam@freescale.com>
> Signed-off-by: Eric Nelson <eric@nelint.com>
> ---
>  drivers/mmc/mmc_write.c | 2 +-
>  include/mmc.h           | 7 ++++++-
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c
> index 7aea7e9..221bf30 100644
> --- a/drivers/mmc/mmc_write.c
> +++ b/drivers/mmc/mmc_write.c
> @@ -51,7 +51,7 @@ static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt)
>  		goto err_out;
>  
>  	cmd.cmdidx = MMC_CMD_ERASE;
> -	cmd.cmdarg = SECURE_ERASE;
> +	cmd.cmdarg = MMC_ERASE_ARG;
>  	cmd.resp_type = MMC_RSP_R1b;
>  
>  	err = mmc_send_cmd(mmc, &cmd, NULL);
> diff --git a/include/mmc.h b/include/mmc.h
> index cda9a19..b89962a 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -121,7 +121,12 @@
>  #define OCR_VOLTAGE_MASK	0x007FFF80
>  #define OCR_ACCESS_MODE		0x60000000
>  
> -#define SECURE_ERASE		0x80000000
> +#define MMC_ERASE_ARG		0x00000000
> +#define MMC_SECURE_ERASE_ARG	0x80000000
> +#define MMC_TRIM_ARG		0x00000001
> +#define MMC_DISCARD_ARG		0x00000003
> +#define MMC_SECURE_TRIM1_ARG	0x80000001
> +#define MMC_SECURE_TRIM2_ARG	0x80008000
>  
>  #define MMC_STATUS_MASK		(~0x0206BF7F)
>  #define MMC_STATUS_SWITCH_ERROR	(1 << 7)
> 

This fixes the issue on eMMC. Very good job! Thank you.

Tested-by: Hector Palacios <hector.palacios@digi.com>

On the uSD card, it occasionally works (when it didn't before), but it still fails
many times, after erasing a random number of blocks (at random times).
I guess this must be a different issue, though.
I could reproduce it on my board (4 data lines) and on the SabreSD (8 data lines) with
v2015.04. Here is an output from the SabreSD:

=> time mmc erase 200000 100

MMC erase: dev # 1, block # 2097152, count 256 ... 256 blocks erased: OK

time: 1.866 seconds
=> time mmc erase 200000 1000

MMC erase: dev # 1, block # 2097152, count 4096 ... Timeout waiting for DAT0 to go high!
mmc erase failed
1409 blocks erased: ERROR

time: 11.263 seconds
=> time mmc erase 200000 10000

MMC erase: dev # 1, block # 2097152, count 65536 ... Timeout waiting for DAT0 to go high!
mmc erase failed
8192 blocks erased: ERROR

time: 59.139 seconds


Thank you
--
Hector Palacios

  reply	other threads:[~2015-12-09 10:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-16 11:46 [U-Boot] mmc erase fails from U-Boot command line Cliff Brust
2015-10-19 11:06 ` Hector Palacios
2015-11-12 20:56   ` Fabio Estevam
2015-11-13 12:26     ` Palacios, Hector
2015-11-13 14:37       ` Fabio Estevam
2015-11-16 15:23         ` Fabio Estevam
2015-11-16 15:30           ` Fabio Estevam
2015-12-01 19:05             ` Eric Nelson
2015-12-02 17:23               ` Fabio Estevam
2015-12-02 18:47                 ` Eric Nelson
2015-12-02 18:52                   ` Fabio Estevam
2015-12-02 19:28                     ` Eric Nelson
2015-12-02 19:53                       ` Fabio Estevam
2015-12-04 16:35                         ` Eric Nelson
2015-12-04 16:37                           ` Fabio Estevam
2015-12-04 22:42                           ` Eric Nelson
2015-12-05  0:19                             ` Fabio Estevam
2015-12-07  0:21                             ` Fabio Estevam
2015-12-07 14:36                               ` Eric Nelson
2015-12-02 19:37                     ` Michael Trimarchi
2015-12-02 19:54                       ` Fabio Estevam
2015-12-02 20:00                         ` Michael Trimarchi
2015-12-04 16:08                           ` Eric Nelson
2015-12-04 16:50                             ` Eric Nelson
2015-12-04 17:06                               ` Michael Trimarchi
2015-12-07 14:50                               ` [U-Boot] [PATCH] mmc: update MMC_ERASE argument to match Linux kernel Eric Nelson
2015-12-09 10:55                                 ` Hector Palacios [this message]
2015-12-22  9:55                                   ` Fabio Estevam
2016-01-04 22:23                                 ` [U-Boot] " Tom Rini

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-all 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=56680886.8080404@digi.com \
    --to=hector.palacios@digi.com \
    --cc=u-boot@lists.denx.de \
    /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