All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean-Jacques Hiblot <jjhiblot@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 22/22] mmc: Retry some MMC cmds on failure
Date: Fri, 12 May 2017 20:16:40 +0200	[thread overview]
Message-ID: <1494613000-8156-23-git-send-email-jjhiblot@ti.com> (raw)
In-Reply-To: <1494613000-8156-1-git-send-email-jjhiblot@ti.com>

From: Vignesh R <vigneshr@ti.com>

With certain SD cards like Kingston 8GB/16GB UHS card, it is seen that
MMC_CMD_ALL_SEND_CID cmd fails on first attempt, but succeeds
subsequently. Therefore, retry MMC_CMD_ALL_SEND_CID cmd at least thrice
as done in Linux kernel.
Similarly, it is seen that MMC_CMD_SET_BLOCKLEN may fail on first
attempt, therefore retry this cmd five times as done in kernel.

Signed-off-by: Vignesh R <vigneshr@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 drivers/mmc/mmc.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index c7dda64..49edf52 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -275,6 +275,8 @@ int mmc_send_status(struct mmc *mmc, int timeout)
 int mmc_set_blocklen(struct mmc *mmc, int len)
 {
 	struct mmc_cmd cmd;
+	int retries = 5;
+	int err;
 
 	if (mmc->ddr_mode)
 		return 0;
@@ -282,8 +284,13 @@ int mmc_set_blocklen(struct mmc *mmc, int len)
 	cmd.cmdidx = MMC_CMD_SET_BLOCKLEN;
 	cmd.resp_type = MMC_RSP_R1;
 	cmd.cmdarg = len;
+	do {
+		err = mmc_send_cmd(mmc, &cmd, NULL);
+		if (!err)
+			break;
+	} while (retries--);
 
-	return mmc_send_cmd(mmc, &cmd, NULL);
+	return err;
 }
 
 static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
@@ -1867,6 +1874,7 @@ static int mmc_startup(struct mmc *mmc)
 	u64 cmult, csize;
 	struct mmc_cmd cmd;
 	struct blk_desc *bdesc;
+	int retries = 3;
 
 #ifdef CONFIG_MMC_SPI_CRC_ON
 	if (mmc_host_is_spi(mmc)) { /* enable CRC check for spi */
@@ -1874,7 +1882,6 @@ static int mmc_startup(struct mmc *mmc)
 		cmd.resp_type = MMC_RSP_R1;
 		cmd.cmdarg = 1;
 		err = mmc_send_cmd(mmc, &cmd, NULL);
-
 		if (err)
 			return err;
 	}
@@ -1886,7 +1893,9 @@ static int mmc_startup(struct mmc *mmc)
 	cmd.resp_type = MMC_RSP_R2;
 	cmd.cmdarg = 0;
 
-	err = mmc_send_cmd(mmc, &cmd, NULL);
+	do {
+		err = mmc_send_cmd(mmc, &cmd, NULL);
+	} while (err && retries-- > 0);
 
 	if (err)
 		return err;
-- 
1.9.1

  parent reply	other threads:[~2017-05-12 18:16 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170512181724epcas5p36ff2843856a4d329a0b106cd063f7286@epcas5p3.samsung.com>
2017-05-12 18:16 ` [U-Boot] [PATCH 00/22] mmc: Add support for HS200 and UHS modes Jean-Jacques Hiblot
2017-05-12 18:16   ` [U-Boot] [PATCH 01/22] mmc: split mmc_startup() Jean-Jacques Hiblot
2017-05-15  3:27     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 02/22] mmc: move the MMC startup for version above v4.0 in a separate function Jean-Jacques Hiblot
2017-05-15  3:27     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 03/22] mmc: make ext_csd part of struct mmc Jean-Jacques Hiblot
2017-05-15  3:27     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 04/22] mmc: add a function to read and test the ext csd (mmc >= 4) Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 05/22] mmc: introduces mmc modes Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-15 10:34       ` Jean-Jacques Hiblot
2017-05-12 18:16   ` [U-Boot] [PATCH 06/22] mmc: Add a fonction to dump the mmc capabilities Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 07/22] mmc: use mmc modes to select the correct bus speed Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 08/22] cmd: mmc: display the mode name and current bus speed in the mmc info Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 09/22] mmc: refactor SD startup to make it easier to support new modes Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-15 10:49       ` Jean-Jacques Hiblot
2017-05-12 18:16   ` [U-Boot] [PATCH 10/22] mmc: refactor MMC " Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-25 12:25     ` Jaehoon Chung
2017-05-25 14:40       ` Jean-Jacques Hiblot
2017-05-26  1:12         ` Jaehoon Chung
2017-05-12 18:16   ` [U-Boot] [PATCH 11/22] mmc: make mmc_set_ios() return status Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 12/22] mmc: Enable signal voltage to be selected from mmc core Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-15 14:18       ` Jean-Jacques Hiblot
2017-05-17  1:38         ` Simon Glass
2017-05-17 10:35       ` Kishon Vijay Abraham I
2017-05-12 18:16   ` [U-Boot] [PATCH 13/22] mmc: Add a new callback function to enable/disable vdd Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 14/22] mmc: add power cyle support in mmc core Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-15 15:50       ` Jean-Jacques Hiblot
2017-05-25 12:35     ` Jaehoon Chung
2017-05-25 14:50       ` Jean-Jacques Hiblot
2017-06-15 16:13       ` Jean-Jacques Hiblot
2017-05-12 18:16   ` [U-Boot] [PATCH 15/22] mmc: add a new mmc parameter to disable mmc clock Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 16/22] mmc: disable the mmc clock during power off Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 17/22] mmc: Add a execute_tuning() callback to the mmc operations Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-25 12:37     ` Jaehoon Chung
2017-05-25 14:51       ` Jean-Jacques Hiblot
2017-05-12 18:16   ` [U-Boot] [PATCH 18/22] mmc: add HS200 support in MMC core Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-25 12:42     ` Jaehoon Chung
2017-05-12 18:16   ` [U-Boot] [PATCH 19/22] mmc: Add a new callback function to check if the card is busy Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 20/22] mmc: Add support for UHS modes Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-16 14:20     ` Jean-Jacques Hiblot
2017-05-17  1:59       ` Jaehoon Chung
2017-05-25 12:50     ` Jaehoon Chung
2017-05-12 18:16   ` [U-Boot] [PATCH 21/22] mmc: Change mode when switching to a boot partition Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-25 12:53     ` Jaehoon Chung
2017-05-12 18:16   ` Jean-Jacques Hiblot [this message]
2017-05-15  3:28     ` [U-Boot] [PATCH 22/22] mmc: Retry some MMC cmds on failure Simon Glass
2017-05-15 15:49       ` Jean-Jacques Hiblot
2017-05-17  1:38         ` Simon Glass
2017-05-17 14:47           ` Jean-Jacques Hiblot
2017-05-15  2:33   ` [U-Boot] [PATCH 00/22] mmc: Add support for HS200 and UHS modes Jaehoon Chung
2017-05-18  4:27   ` Jaehoon Chung
2017-05-23 15:24     ` Jean-Jacques Hiblot
2017-05-25  7:41       ` Jaehoon Chung
2017-05-25 14:42         ` Jean-Jacques Hiblot
2017-06-02 16:46         ` Jean-Jacques Hiblot
2017-06-16 10:00         ` Jean-Jacques Hiblot
2017-06-29  9:59           ` Jaehoon Chung
2017-07-26 11:33             ` Kever Yang
2017-07-28 13:05               ` Jaehoon Chung
2017-08-25  8:16                 ` Ziyuan
2017-08-27 20:10                   ` Simon Glass
2017-08-27 20:17                     ` Tom Rini
2017-08-28  5:53                       ` Jaehoon Chung
2017-09-12 21:31                         ` Marek Vasut
2017-08-28  5:45                     ` Ziyuan
2017-09-15 13:20                 ` Jean-Jacques Hiblot
2017-09-16 17:12                   ` Marek Vasut

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=1494613000-8156-23-git-send-email-jjhiblot@ti.com \
    --to=jjhiblot@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.