2012-06-11 02:48:17

by Ming Lei

[permalink] [raw]
Subject: MMC: commit dba3c29 ruins mmc card data on beagle-xm revB

Hi,

After bisecting, I found that the commit below can ruin the mmc card data
(writing incorrect file, or fs is corrupt) on my beagle-xm revB, and reverting
the commit below will fix the problem.


commit dba3c29ea4a1d5d544f59b94fd8a41662135e071
Author: Balaji T K <[email protected]>
Date: Mon Apr 9 12:08:32 2012 +0530

mmc: omap_hsmmc: Enable Auto CMD12

Enable Auto-CMD12 for multi block read/write on HSMMC.
Tested on OMAP4430, OMAP3430 and OMAP2430 SDP


Thanks,
--
Ming Lei


2012-06-11 07:20:27

by Ming Lei

[permalink] [raw]
Subject: Re: MMC: commit dba3c29 ruins mmc card data on beagle-xm revB

On Mon, Jun 11, 2012 at 2:21 PM, T Krishnamoorthy, Balaji
<[email protected]> wrote:
> Hi Ming Lei,
> Can you let me know if you noticed any write/timeout errors ?

Nothing error logs found during writing.

Below is one of my test case.

root@beagleboard:~# upk
updateing kernel...
flush storage...
root@beagleboard:~# cat bin/upk
#!/bin/sh

echo "updateing kernel..."
cp -f /mnt/nfs/t/uImage /media/mmcblk0p1/

echo "flush storage..."
sync
root@beagleboard:~# diff /mnt/nfs/t/uImage /media/mmcblk0p1/uImage
Binary files /mnt/nfs/t/uImage and /media/mmcblk0p1/uImage differ
root@beagleboard:~# umount /media/mmcblk0p1
root@beagleboard:~# mount -t vfat /dev/mmcblk0p1 /media/mmcblk0p1
root@beagleboard:~#
root@beagleboard:~#
root@beagleboard:~# diff /mnt/nfs/t/uImage /media/mmcblk0p1/uImage
Binary files /mnt/nfs/t/uImage and /media/mmcblk0p1/uImage differ


Thanks,
--
Ming Lei

2012-06-13 05:26:53

by Venkatraman S

[permalink] [raw]
Subject: Re: MMC: commit dba3c29 ruins mmc card data on beagle-xm revB

On Mon, Jun 11, 2012 at 12:50 PM, Ming Lei <[email protected]> wrote:
> On Mon, Jun 11, 2012 at 2:21 PM, T Krishnamoorthy, Balaji
> <[email protected]> wrote:
>> Hi Ming Lei,
>> Can you let me know if you noticed any write/timeout errors ?
>
> Nothing error logs found during writing.
>
> Below is one of my test case.
>
> root@beagleboard:~# upk
> updateing kernel...
> flush storage...
> root@beagleboard:~# cat bin/upk
> #!/bin/sh
>
> echo "updateing kernel..."
> cp -f /mnt/nfs/t/uImage /media/mmcblk0p1/
>
> echo "flush storage..."
> sync
> root@beagleboard:~# diff /mnt/nfs/t/uImage /media/mmcblk0p1/uImage
> Binary files /mnt/nfs/t/uImage and /media/mmcblk0p1/uImage differ
> root@beagleboard:~# umount /media/mmcblk0p1
> root@beagleboard:~# mount -t vfat /dev/mmcblk0p1 /media/mmcblk0p1
> root@beagleboard:~#
> root@beagleboard:~#
> root@beagleboard:~# diff /mnt/nfs/t/uImage /media/mmcblk0p1/uImage
> Binary files /mnt/nfs/t/uImage and /media/mmcblk0p1/uImage differ
>
Ming,
Just to keep you posted, Balaji and myself are trying to reproduce
the issue and haven't hit the problem yet.
This patch was in use internaly for sometime before we sent it upstream.
Meanwhile, is is possible for you to reproduce this problem with
MMC_DEBUG enabled ? That would be helpful.
~Venkat.

2012-06-13 15:29:00

by Balaji T K

[permalink] [raw]
Subject: Re: MMC: commit dba3c29 ruins mmc card data on beagle-xm revB

On Mon, Jun 11, 2012 at 12:50 PM, Ming Lei <[email protected]> wrote:
>
> On Mon, Jun 11, 2012 at 2:21 PM, T Krishnamoorthy, Balaji
> <[email protected]> wrote:
> > Hi Ming Lei,
> > Can you let me know if you noticed any write/timeout errors ?
>
> Nothing error logs found during writing.
Hi,

Couldn't reproduce the issue with BeagleXM rev C, Might be a combination
of rev and SD card. How often do you see mis-match in file content?

Can you please try the inlined patch to get more info?

---
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 9a7a60a..77aabe6 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -60,6 +60,7 @@
#define OMAP_HSMMC_STAT 0x0130
#define OMAP_HSMMC_IE 0x0134
#define OMAP_HSMMC_ISE 0x0138
+#define OMAP_HSMMC_AC12 0x013C
#define OMAP_HSMMC_CAPA 0x0140

#define VS18 (1 << 26)
@@ -177,6 +178,7 @@ struct omap_hsmmc_host {
int reqs_blocked;
int use_reg;
int req_in_progress;
+ int autocmd_err;
unsigned int flags;
struct omap_hsmmc_next next_data;

@@ -983,6 +985,7 @@ static void omap_hsmmc_do_irq(struct
omap_hsmmc_host *host, int status)
{
struct mmc_data *data;
int end_cmd = 0, end_trans = 0;
+ u32 autocmd12;

if (!host->req_in_progress) {
do {
@@ -998,6 +1001,13 @@ static void omap_hsmmc_do_irq(struct
omap_hsmmc_host *host, int status)

if (status & ERR) {
omap_hsmmc_dbg_report_irq(host, status);
+ if (status & (1 << 24)) {
+ host->autocmd_err = 1;
+ dev_err(mmc_dev(host->mmc), "AutoCMD error STAT 0x%x\n", status);
+ autocmd12 = OMAP_HSMMC_READ(host->base, AC12);
+ dev_err(mmc_dev(host->mmc), "AutoCMD error 0x%x\n", autocmd12);
+ }
+
if ((status & CMD_TIMEOUT) ||
(status & CMD_CRC)) {
if (host->cmd) {
---
>
> Below is one of my test case.
>
> root@beagleboard:~# upk
> updateing kernel...
> flush storage...
> root@beagleboard:~# cat bin/upk
> #!/bin/sh
>
> echo "updateing kernel..."
> cp -f /mnt/nfs/t/uImage /media/mmcblk0p1/
>
> echo "flush storage..."
> sync
> root@beagleboard:~# diff /mnt/nfs/t/uImage /media/mmcblk0p1/uImage
> Binary files /mnt/nfs/t/uImage and /media/mmcblk0p1/uImage differ
> root@beagleboard:~# umount /media/mmcblk0p1
> root@beagleboard:~# mount -t vfat /dev/mmcblk0p1 /media/mmcblk0p1
> root@beagleboard:~#
> root@beagleboard:~#
> root@beagleboard:~# diff /mnt/nfs/t/uImage /media/mmcblk0p1/uImage
> Binary files /mnt/nfs/t/uImage and /media/mmcblk0p1/uImage differ
>
>
> Thanks,
> --
> Ming Lei

2012-06-14 05:18:09

by Ming Lei

[permalink] [raw]
Subject: Re: MMC: commit dba3c29 ruins mmc card data on beagle-xm revB

On Wed, Jun 13, 2012 at 1:26 PM, S, Venkatraman <[email protected]> wrote:
> Ming,
> ?Just to keep you posted, Balaji and myself are trying to reproduce
> the issue and haven't hit the problem yet.
> This patch was in use internaly for sometime before we sent it upstream.
> Meanwhile, is is possible for you to reproduce this problem with
> MMC_DEBUG enabled ? That would be helpful.

See attachment.

On Wed, Jun 13, 2012 at 11:28 PM, T Krishnamoorthy, Balaji
> Hi,
>
> Couldn't reproduce the issue with BeagleXM rev C, Might be a combination

Maybe, the problem can't be observed on my beagle revC and Panda,
but can be observed on the beagle XM revB.

Also it is only triggered on my two 8GB kingston mmc cards(class 4).
Looks no such problem on another 4GB kingston mmc card(class 4).

> of rev and SD card. How often do you see mis-match in file content?
>
> Can you please try the inlined patch to get more info?

No any extra info got after applying your patch.

>
> ---
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 9a7a60a..77aabe6 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -60,6 +60,7 @@
> ?#define OMAP_HSMMC_STAT ? ? ? ? ? ? ? ?0x0130
> ?#define OMAP_HSMMC_IE ? ? ? ? ?0x0134
> ?#define OMAP_HSMMC_ISE ? ? ? ? 0x0138
> +#define OMAP_HSMMC_AC12 ? ? ? ? ? ? ? ?0x013C
> ?#define OMAP_HSMMC_CAPA ? ? ? ? ? ? ? ?0x0140
>
> ?#define VS18 ? ? ? ? ? ? ? ? ? (1 << 26)
> @@ -177,6 +178,7 @@ struct omap_hsmmc_host {
> ? ? ? ?int ? ? ? ? ? ? ? ? ? ? reqs_blocked;
> ? ? ? ?int ? ? ? ? ? ? ? ? ? ? use_reg;
> ? ? ? ?int ? ? ? ? ? ? ? ? ? ? req_in_progress;
> + ? ? ? int ? ? ? ? ? ? ? ? ? ? autocmd_err;
> ? ? ? ?unsigned int ? ? ? ? ? ?flags;
> ? ? ? ?struct omap_hsmmc_next ?next_data;
>
> @@ -983,6 +985,7 @@ static void omap_hsmmc_do_irq(struct
> omap_hsmmc_host *host, int status)
> ?{
> ? ? ? ?struct mmc_data *data;
> ? ? ? ?int end_cmd = 0, end_trans = 0;
> + ? ? ? u32 autocmd12;
>
> ? ? ? ?if (!host->req_in_progress) {
> ? ? ? ? ? ? ? ?do {
> @@ -998,6 +1001,13 @@ static void omap_hsmmc_do_irq(struct
> omap_hsmmc_host *host, int status)
>
> ? ? ? ?if (status & ERR) {
> ? ? ? ? ? ? ? ?omap_hsmmc_dbg_report_irq(host, status);
> + ? ? ? ? ? ? ? if (status & (1 << 24)) {
> + ? ? ? ? ? ? ? ? ? ? ? host->autocmd_err = 1;
> + ? ? ? ? ? ? ? ? ? ? ? dev_err(mmc_dev(host->mmc), "AutoCMD error STAT 0x%x\n", status);
> + ? ? ? ? ? ? ? ? ? ? ? autocmd12 = OMAP_HSMMC_READ(host->base, AC12);
> + ? ? ? ? ? ? ? ? ? ? ? dev_err(mmc_dev(host->mmc), "AutoCMD error 0x%x\n", autocmd12);
> + ? ? ? ? ? ? ? }
> +
> ? ? ? ? ? ? ? ?if ((status & CMD_TIMEOUT) ||
> ? ? ? ? ? ? ? ? ? ? ? ?(status & CMD_CRC)) {
> ? ? ? ? ? ? ? ? ? ? ? ?if (host->cmd) {
> ---
>>

Thanks,
--
Ming Lei


Attachments:
mmc-ruin.tar.gz (114.43 kB)

2012-06-14 10:25:41

by Ming Lei

[permalink] [raw]
Subject: Re: MMC: commit dba3c29 ruins mmc card data on beagle-xm revB

Also attach my .config.

On Wed, Jun 13, 2012 at 11:28 PM, T Krishnamoorthy, Balaji
<[email protected]> wrote:
> On Mon, Jun 11, 2012 at 12:50 PM, Ming Lei <[email protected]> wrote:
>>
>> On Mon, Jun 11, 2012 at 2:21 PM, T Krishnamoorthy, Balaji
>> <[email protected]> wrote:
>> > Hi Ming Lei,
>> > Can you let me know if you noticed any write/timeout errors ?
>>
>> Nothing error logs found during writing.
> Hi,
>
> Couldn't reproduce the issue with BeagleXM rev C, Might be a combination
> of rev and SD card. How often do you see mis-match in file content?
>
> Can you please try the inlined patch to get more info?
>
> ---
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index 9a7a60a..77aabe6 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -60,6 +60,7 @@
> ?#define OMAP_HSMMC_STAT ? ? ? ? ? ? ? ?0x0130
> ?#define OMAP_HSMMC_IE ? ? ? ? ?0x0134
> ?#define OMAP_HSMMC_ISE ? ? ? ? 0x0138
> +#define OMAP_HSMMC_AC12 ? ? ? ? ? ? ? ?0x013C
> ?#define OMAP_HSMMC_CAPA ? ? ? ? ? ? ? ?0x0140
>
> ?#define VS18 ? ? ? ? ? ? ? ? ? (1 << 26)
> @@ -177,6 +178,7 @@ struct omap_hsmmc_host {
> ? ? ? ?int ? ? ? ? ? ? ? ? ? ? reqs_blocked;
> ? ? ? ?int ? ? ? ? ? ? ? ? ? ? use_reg;
> ? ? ? ?int ? ? ? ? ? ? ? ? ? ? req_in_progress;
> + ? ? ? int ? ? ? ? ? ? ? ? ? ? autocmd_err;
> ? ? ? ?unsigned int ? ? ? ? ? ?flags;
> ? ? ? ?struct omap_hsmmc_next ?next_data;
>
> @@ -983,6 +985,7 @@ static void omap_hsmmc_do_irq(struct
> omap_hsmmc_host *host, int status)
> ?{
> ? ? ? ?struct mmc_data *data;
> ? ? ? ?int end_cmd = 0, end_trans = 0;
> + ? ? ? u32 autocmd12;
>
> ? ? ? ?if (!host->req_in_progress) {
> ? ? ? ? ? ? ? ?do {
> @@ -998,6 +1001,13 @@ static void omap_hsmmc_do_irq(struct
> omap_hsmmc_host *host, int status)
>
> ? ? ? ?if (status & ERR) {
> ? ? ? ? ? ? ? ?omap_hsmmc_dbg_report_irq(host, status);
> + ? ? ? ? ? ? ? if (status & (1 << 24)) {
> + ? ? ? ? ? ? ? ? ? ? ? host->autocmd_err = 1;
> + ? ? ? ? ? ? ? ? ? ? ? dev_err(mmc_dev(host->mmc), "AutoCMD error STAT 0x%x\n", status);
> + ? ? ? ? ? ? ? ? ? ? ? autocmd12 = OMAP_HSMMC_READ(host->base, AC12);
> + ? ? ? ? ? ? ? ? ? ? ? dev_err(mmc_dev(host->mmc), "AutoCMD error 0x%x\n", autocmd12);
> + ? ? ? ? ? ? ? }
> +
> ? ? ? ? ? ? ? ?if ((status & CMD_TIMEOUT) ||
> ? ? ? ? ? ? ? ? ? ? ? ?(status & CMD_CRC)) {
> ? ? ? ? ? ? ? ? ? ? ? ?if (host->cmd) {
> ---
>>
>> Below is one of my test case.
>>
>> root@beagleboard:~# upk
>> updateing kernel...
>> flush storage...
>> root@beagleboard:~# cat bin/upk
>> #!/bin/sh
>>
>> echo "updateing kernel..."
>> cp -f /mnt/nfs/t/uImage /media/mmcblk0p1/
>>
>> echo "flush storage..."
>> sync
>> root@beagleboard:~# diff /mnt/nfs/t/uImage /media/mmcblk0p1/uImage
>> Binary files /mnt/nfs/t/uImage and /media/mmcblk0p1/uImage differ
>> root@beagleboard:~# umount /media/mmcblk0p1
>> root@beagleboard:~# mount -t vfat /dev/mmcblk0p1 /media/mmcblk0p1
>> root@beagleboard:~#
>> root@beagleboard:~#
>> root@beagleboard:~# diff /mnt/nfs/t/uImage /media/mmcblk0p1/uImage
>> Binary files /mnt/nfs/t/uImage and /media/mmcblk0p1/uImage differ
>>
>>
>> Thanks,
>> --
>> Ming Lei
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at ?http://www.tux.org/lkml/


Attachments:
.config (68.32 kB)

2012-06-15 01:55:39

by Ming Lei

[permalink] [raw]
Subject: Re: MMC: commit dba3c29 ruins mmc card data on beagle-xm revB

On Wed, Jun 13, 2012 at 11:28 PM, T Krishnamoorthy, Balaji
>
> Couldn't reproduce the issue with BeagleXM rev C, Might be a combination
> of rev and SD card. How often do you see mis-match in file content?

Every time after writing file on file system. After umount and mount again,
the file will be found mismatch with original.

>From TRM of OMAP3/OMAP4/DM37x, the below is mentioned about
the Auto CMD12 Enable bit.

- SDIO does not support this feature.
- SD card only.

So I am wondering if it is suitable to always enable the bit for
multiple block transfer in host controller driver. You mean that
only SD card is supported by OMAP3/4 and DM37x MMC?

I am just confused with the above, even though it may be not
related with the problem reported here.


Thanks,
--
Ming Lei

2012-06-19 16:53:24

by Paolo Pisati

[permalink] [raw]
Subject: Re: MMC: commit dba3c29 ruins mmc card data on beagle-xm revB

On 06/13/2012 05:28 PM, T Krishnamoorthy, Balaji wrote:
> On Mon, Jun 11, 2012 at 12:50 PM, Ming Lei <[email protected]> wrote:
>>
>> On Mon, Jun 11, 2012 at 2:21 PM, T Krishnamoorthy, Balaji
>> <[email protected]> wrote:
>>> Hi Ming Lei,
>>> Can you let me know if you noticed any write/timeout errors ?
>>
>> Nothing error logs found during writing.
> Hi,
>
> Couldn't reproduce the issue with BeagleXM rev C, Might be a combination
> of rev and SD card. How often do you see mis-match in file content?

i just want to say that i'm affected by this too, and i can reproduce it
100%.

do you want me to run that patch or you already have enough data?
--
bye,
p.

2012-06-20 02:02:39

by Ming Lei

[permalink] [raw]
Subject: Re: MMC: commit dba3c29 ruins mmc card data on beagle-xm revB

On Wed, Jun 20, 2012 at 12:53 AM, Paolo Pisati <[email protected]> wrote:
> On 06/13/2012 05:28 PM, T Krishnamoorthy, Balaji wrote:
>> Couldn't reproduce the issue with BeagleXM rev C, Might be a combination
>> of rev and SD card. How often do you see mis-match in file content?
>
> i just want to say that i'm affected by this too, and i can reproduce it
> 100%.

So it is not only me affected by the commit.

Considered it is a serious problem(just several kernel boots may
destroy the rootfs on my board) and no any progress obtained since
report, I will send a patch to revert the commit to avoid more victims.


Thanks,
--
Ming Lei

2012-06-20 07:23:47

by Balaji T K

[permalink] [raw]
Subject: Re: MMC: commit dba3c29 ruins mmc card data on beagle-xm revB

On Tue, Jun 19, 2012 at 10:23 PM, Paolo Pisati <[email protected]> wrote:
> On 06/13/2012 05:28 PM, T Krishnamoorthy, Balaji wrote:
>> On Mon, Jun 11, 2012 at 12:50 PM, Ming Lei <[email protected]> wrote:
>>>
>>> On Mon, Jun 11, 2012 at 2:21 PM, T Krishnamoorthy, Balaji
>>> <[email protected]> wrote:
>>>> Hi Ming Lei,
>>>> Can you let me know if you noticed any write/timeout errors ?
>>>
>>> Nothing error logs found during writing.
>> Hi,
>>
>> Couldn't reproduce the issue with BeagleXM rev C, Might be a combination
>> of rev and SD card. How often do you see mis-match in file content?
>
> i just want to say that i'm affected by this too, and i can reproduce it
> 100%.
>

Is it with SD or MMC card
Can you provide Beagle board rev info?

> do you want me to run that patch or you already have enough data?

Can you enable MMC debug and apply the debug patch I provided.
The debug patch did not print any AUTOCMD errors with Ming Lei setup.

> --
> bye,
> p.

2012-06-22 11:51:48

by Paolo Pisati

[permalink] [raw]
Subject: Re: MMC: commit dba3c29 ruins mmc card data on beagle-xm revB

On 06/20/2012 09:23 AM, T Krishnamoorthy, Balaji wrote:
>>
>> i just want to say that i'm affected by this too, and i can reproduce it
>> 100%.
>>
>
> Is it with SD or MMC card
> Can you provide Beagle board rev info?

kingston 4g class 4 sdhc c04g taiwan

tested on a beagle xm rev a and rev c, both boards exhibit the same
problem with this card, while with a brand new sandisk 16gb sdhc class 4
card, everything is ok.

i tried reverting dba3c29 "Enable Auto CMD12", and both cards are
behaving fine.

>> do you want me to run that patch or you already have enough data?
>
> Can you enable MMC debug and apply the debug patch I provided.
> The debug patch did not print any AUTOCMD errors with Ming Lei setup.

http://people.canonical.com/~ppisati/mmc-testing/

test-mmc.sh: script used for testing

test-mmc.log: md5sum of file copied around (as you can see after the
umount the md5 changes)

test-mmc.syslog: mmc-debug output (plus your patch)

after the test, my sd card was so badly wounded that it wouldn't even boot.
--
bye,
p.

2012-06-22 15:33:34

by Balaji T K

[permalink] [raw]
Subject: Re: MMC: commit dba3c29 ruins mmc card data on beagle-xm revB

On Fri, Jun 22, 2012 at 5:21 PM, Paolo Pisati <[email protected]> wrote:
> On 06/20/2012 09:23 AM, T Krishnamoorthy, Balaji wrote:
>>>
>>> i just want to say that i'm affected by this too, and i can reproduce it
>>> 100%.
>>>
>>
>> Is it with SD or MMC card
>> Can you provide Beagle board rev info?
>
> kingston 4g class 4 sdhc c04g taiwan
>
> tested on a beagle xm rev a and rev c, both boards exhibit the same
> problem with this card, while with a brand new sandisk 16gb sdhc class 4
> card, everything is ok.
>
> i tried reverting dba3c29 "Enable Auto CMD12", and both cards are
> behaving fine.
>
>>> do you want me to run that patch or you already have enough data?
>>
>> Can you enable MMC debug and apply the debug patch I provided.
>> The debug patch did not print any AUTOCMD errors with Ming Lei setup.
>
> http://people.canonical.com/~ppisati/mmc-testing/
>
> test-mmc.sh: script used for testing
>
> test-mmc.log: md5sum of file copied around (as you can see after the
> umount the md5 changes)
>
> test-mmc.syslog: mmc-debug output (plus your patch)

Thanks for testing and sharing the log.
md5sum is giving 2 different values for 8 tries which indicates writes are not
entirely random.

>
> after the test, my sd card was so badly wounded that it wouldn't even boot.

I guess boot partition was not updated, so I think it should boot until kernel
and fail at mounting filesystem as filesystem would have got corrupted by
previous test.

> --
> bye,
> p.