Skip to contentSkip to conversation

mmc: retry CMD1 in mmc_send_op_cond() until the eMMC is ready

PATCH New haibo.chen at nxp.com 2 participants 2 messages Jun 15, 2020 – Jun 16, 2020 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mmc: retry CMD1 in mmc_send_op_cond() until the eMMC is ready

From: Haibo Chen <[email protected]>

According to eMMC specification v5.1 section 6.4.3, we should issue CMD1 repeatedly in the idle state until the eMMC is ready even if mmc_send_op_cond() send CMD1 with argument = 0. Otherwise some eMMC devices seems to enter the inactive mode after mmc_complete_op_cond() issued CMD0 when the eMMC device is busy.

---
 drivers/mmc/mmc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/mmc/mmc.c +8 -1
index 85762b82e0..475f75fc64 100644
@@ -662,12 +662,15 @@ static int mmc_send_op_cond_iter(struct mmc *mmc, int use_arg)
 static int mmc_send_op_cond(struct mmc *mmc)
 {
 	int err, i;
+	int timeout = 1000;
+	uint start;
 
 	/* Some cards seem to need this */
 	mmc_go_idle(mmc);
 
+	start = get_timer(0);
  	/* Asking to the card its capabilities */
-	for (i = 0; i < 2; i++) {
+	for (i = 0; ; i++) {
 		err = mmc_send_op_cond_iter(mmc, i != 0);
 		if (err)
 			return err;
@@ -675,6 +678,10 @@ static int mmc_send_op_cond(struct mmc *mmc)
 		/* exit if not busy (flag seems to be inverted) */
 		if (mmc->ocr & OCR_BUSY)
 			break;
+
+		if (get_timer(start) > timeout)
+			return -ETIMEDOUT;
+		udelay(100);
 	}
 	mmc->op_cond_pending = 1;
 	return 0;
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 1/1 mmc: retry CMD1 in mmc_send_op_cond() until the eMMC is ready

Quoted 37 lines

Subject: [PATCH v2] mmc: retry CMD1 in mmc_send_op_cond() until the eMMC is ready

From: Haibo Chen <[email protected]>

According to eMMC specification v5.1 section 6.4.3, we should issue CMD1 repeatedly in the idle state until the eMMC is ready even if mmc_send_op_cond() send CMD1 with argument = 0. Otherwise some eMMC devices seems to enter the inactive mode after mmc_complete_op_cond() issued CMD0 when the eMMC device is busy.

---
 drivers/mmc/mmc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/mmc/mmc.c index renamed from drivers/mmc/mmc.c +0 -0

85762b82e0..475f75fc64 100644

drivers/mmc/mmc.c +4 -1
@@ -662,12 +662,15 @@ static int mmc_send_op_cond_iter(struct mmc
 *mmc, int use_arg)  static int mmc_send_op_cond(struct mmc *mmc)  {
 	int err, i;
+	int timeout = 1000;
+	uint start;
 
 	/* Some cards seem to need this */
 	mmc_go_idle(mmc);
 
+	start = get_timer(0);
  	/* Asking to the card its capabilities */
-	for (i = 0; i < 2; i++) {
+	for (i = 0; ; i++) {
 		err = mmc_send_op_cond_iter(mmc, i != 0);
 		if (err)
 			return err;

drivers/mmc/mmc.c static int mmc_send_op_cond(struct mmc *mmc) · line 684

Quoted 7 lines
drivers/mmc/mmc.c +4 -0
@@ -675,6 +678,10 @@ static int mmc_send_op_cond(struct mmc *mmc)
 		/* exit if not busy (flag seems to be inverted) */
 		if (mmc->ocr & OCR_BUSY)
 			break;
+
+		if (get_timer(start) > timeout)
+			return -ETIMEDOUT;
+		udelay(100);

The Linux code use 10ms delay, but it should be fine here.

Quoted 5 lines
drivers/mmc/mmc.c +0 -1
 	}
 	mmc->op_cond_pending = 1;
 	return 0;
--

2.17.1