Skip to contentSkip to conversation

u-boot 2011.12rc1: OMAP MMC: Add delay before waiting for status

PATCH Superseded Peter A. Bigot 3 participants 3 messages Dec 27, 2011 – Jan 2, 2012 MMC, SD and SDIO

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 u-boot 2011.12rc1: OMAP MMC: Add delay before waiting for status

From: "Peter A. Bigot" <[email protected]>

Pending upstream patch from http://patchwork.ozlabs.org/patch/132795/ is required to successfully boot on xM.

---
 ...P-MMC-Add-delay-before-waiting-for-status.patch |   45 ++++++++++++++++++++
 recipes-bsp/u-boot/u-boot_2011.12.bb               |    3 +-
 2 files changed, 47 insertions(+), 1 deletions(-)
 create mode 100644 recipes-bsp/u-boot/u-boot/2011.12/U-Boot-OMAP-MMC-Add-delay-before-waiting-for-status.patch
recipes-bsp/u-boot/u-boot/2011.12/U-Boot-OMAP-MMC-Add-delay-before-waiting-for-status.patch new file +45 -0
new file mode 100644
index 0000000..b334639
@@ -0,0 +1,45 @@
+From patchwork Thu Dec 22 09:56:35 2011
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 8bit
+Subject: [U-Boot] OMAP MMC: Add delay before waiting for status
+Date: Wed, 21 Dec 2011 23:56:35 -0000
+From: =?utf-8?q?Andreas_M=C3=BCller_=3Cschnitzeltony=40gmx=2Ede=3E?=
+X-Patchwork-Id: 132795
+Message-Id: <[email protected]>
+To: [email protected]
+
+Loading kernel from MMC created the following error message reproducable:
+
+| reading uImage
+| mmc_send_cmd: timedout waiting for stat!
+|
+| 2860468 bytes read
+
+Tested on overo with OMAP3530:
+* OMAP3530-GP ES3.1, CPU-OPP2, L3-165MHz, Max CPU Clock 720 mHz
+  Die ID #470e000400000000040398d31402100c
+* OMAP3530-GP ES3.1, CPU-OPP2, L3-165MHz, Max CPU Clock 600 mHz
+  Die ID #112000040000000004035c140101b011
+
+Signed-off-by: Andreas Müller <[email protected]>
+
+---
+drivers/mmc/omap_hsmmc.c |    4 ++++
+ 1 files changed, 4 insertions(+), 0 deletions(-)
+
+diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
+index c38b9e6..ac91e5d 100644
+--- a/drivers/mmc/omap_hsmmc.c
++++ b/drivers/mmc/omap_hsmmc.c
+@@ -197,6 +197,10 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
+ 	unsigned int flags, mmc_stat;
+ 	ulong start;
+ 
++	/* Delay added before checking the status */
++	if (cmd->cmdidx == MMC_CMD_SEND_STATUS)
++		udelay(1); /* wait 1 us */
++
+ 	start = get_timer(0);
+ 	while ((readl(&mmc_base->pstate) & DATI_MASK) == DATI_CMDDIS) {
+ 		if (get_timer(0) - start > MAX_RETRY_MS) {
recipes-bsp/u-boot/u-boot_2011.12.bb +2 -1
index b735702..ed6e9be 100644
@@ -6,7 +6,7 @@ UBOOT_IMAGE = "u-boot-${MACHINE}-${PV}-${PR}.img"
 UBOOT_SYMLINK = "u-boot-${MACHINE}.img"
 
 PV = "2011.09+2011.12rc1"
-PR = "r1"
+PR = "r2"
 
 # No patches for other machines yet
 COMPATIBLE_MACHINE = "(beagleboard|pandaboard|hawkboard|am3517-evm|am37x-evm|omap3evm)"
@@ -17,6 +17,7 @@ SRC_URI = "git://www.denx.de/git/u-boot.git;protocol=git \
            file://2011.12/0003-beagleboard-add-support-for-scanning-loop-through-ex.patch \
            file://2011.12/0004-omap4-common-mount-root-RO.patch \
            file://2011.12/0005-omap4-common-use-ext4-by-default.patch \
+           file://2011.12/U-Boot-OMAP-MMC-Add-delay-before-waiting-for-status.patch \
           "
 
 SRCREV = "d82a27bc5c404da907f71960a3ed2e148ac73fd0"
Signature · 1 line
1.7.6.4
#2 lore raw
Quoted 6 lines · Tom Rini
Quoted 5 lines · Peter A. Bigot

From: "Peter A. Bigot" <[email protected]>

Pending upstream patch from http://patchwork.ozlabs.org/patch/132795/ is required to successfully boot on xM.

Quoted 8 lines
Quoted 1 line

I don't see the harm here so:

But I need to talk with Andreas a bit and see what's going on here as I hadn't seen that problem here before.

Some more background on this patch:

For my two overos board revision 2 I got

| reading uImage
| mmc_send_cmd: timedout waiting for stat!
|
| 2860468 bytes read

but the loaded kernel worked without issues. To invesigate, I added a message in drivers/mmc/omap_hsmmc.c / mmc_send_cmd():

	while (readl(&mmc_base->stat)) {
		if (get_timer(0) - start > MAX_RETRY_MS) {
			printf("%s: timedout waiting for stat!\n", __func__);
-->			printf("cmd->cmdidx: %u\n", cmd->cmdidx);
			return TIMEOUT;
		}
	}

This lead to

| cmd->cmdidx: 13

which is found in include/mmc.h:

| #define MMC_CMD_SEND_STATUS 13.

This cmdidx is only set once in drivers/mmc/mmc.c / mmc_send_status(). On all calls of mmc_send_status I added (see attachment)

printf("mmc_send_status called from %s\n", __func__);

and got:

| reading uImage
| mmc_send_status called from mmc_read_blocks
| mmc_send_status called from mmc_read_blocks
| mmc_send_status called from mmc_read_blocks
| mmc_send_status called from mmc_read_blocks
| mmc_send_status called from mmc_read_blocks
| mmc_send_status called from mmc_read_blocks
| mmc_send_status called from mmc_read_blocks
| mmc_send_status called from mmc_read_blocks
| mmc_send_status called from mmc_read_blocks
| 
| 3018844 bytes read

This showed me (I recreated this here with a different kernel):
1. In my case mmc_send_status is called only from mmc_read_blocks and < 10 times
2. The error message disappeared!!

So I added the delay as you see in the patch. I started with a delay of 10ms and reduced it to minimum of 1us and the error did not occure anymore.

Maybe the problem is depending on the SDcard type? At the moment I cannot tell which card type I used because it is at the office. It seems Peter had same
issues: Which card type do you use?

Happy new year

Andreas

From a439a42b8e2e30d1db0dc85cc6c673b5e9c6f561 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <[email protected]>
Date: Mon, 2 Jan 2012 01:04:13 +0100
Subject: [PATCH] test printf
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 drivers/mmc/mmc.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/mmc/mmc.c +4 -0
index 21665ec..eee32a4 100644
@@ -307,6 +307,7 @@ mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t blkcnt, const void*src)
 		}
 
 		/* Waiting for the ready status */
+		printf("mmc_send_status called from %s\n", __func__);
 		mmc_send_status(mmc, timeout);
 	}
 
@@ -375,6 +376,7 @@ int mmc_read_blocks(struct mmc *mmc, void *dst, ulong start, lbaint_t blkcnt)
 		}
 
 		/* Waiting for the ready status */
+		printf("mmc_send_status called from %s\n", __func__);
 		mmc_send_status(mmc, timeout);
 	}
 
@@ -610,6 +612,7 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)
 	ret = mmc_send_cmd(mmc, &cmd, NULL);
 
 	/* Waiting for the ready status */
+	printf("mmc_send_status called from %s\n", __func__);
 	mmc_send_status(mmc, timeout);
 
 	return ret;
@@ -918,6 +921,7 @@ int mmc_startup(struct mmc *mmc)
 	err = mmc_send_cmd(mmc, &cmd, NULL);
 
 	/* Waiting for the ready status */
+	printf("mmc_send_status called from %s\n", __func__);
 	mmc_send_status(mmc, timeout);
 
 	if (err)
Signature · 1 line
1.7.4.4