summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorVignesh R <vigneshr@ti.com>2017-05-12 20:16:40 +0200
committerPeng Fan <peng.fan@nxp.com>2017-08-17 07:57:19 +0800
commit571f23225ca29c53bc4cfe643a758506f1e62d51 (patch)
tree91cc060290cef3db5e14a263acb94794900e9e1d /drivers
parent961230e1adda83eb88b26b9b7ee3f7ab994f18ef (diff)
mmc: Retry some MMC cmds on failure
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> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/mmc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index c7dda64114..49edf5208e 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;