mmc: Fix retry logic in sd_get_capabilities
In sd_get_capabilities an ACMD is sent (SD_CMD_APP_SEND_SCR), which requires sending APP_CMD (MMC_CMD_APP_CMD) before. Currently, the ACMD is retried on error, however APP_CMD isn't. In this case, when the ACMD fails and it is tried again, the retry attempts will not be handled as ACMD, which is wrong. The fix performs the retry attempts on the sequence of APP_CMD and the ACMD together. Signed-off-by: Yanir Levin <yanir.levin@tandemg.com> Reviewed-by: Eran Moshe <emoshe@gsitechnology.com> Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
@@ -1382,6 +1382,7 @@ static int sd_get_capabilities(struct mmc *mmc)
|
|||||||
ALLOC_CACHE_ALIGN_BUFFER(__be32, switch_status, 16);
|
ALLOC_CACHE_ALIGN_BUFFER(__be32, switch_status, 16);
|
||||||
struct mmc_data data;
|
struct mmc_data data;
|
||||||
int timeout;
|
int timeout;
|
||||||
|
uint retries = 3;
|
||||||
|
|
||||||
mmc->card_caps = MMC_MODE_1BIT | MMC_CAP(MMC_LEGACY);
|
mmc->card_caps = MMC_MODE_1BIT | MMC_CAP(MMC_LEGACY);
|
||||||
|
|
||||||
@@ -1389,25 +1390,26 @@ static int sd_get_capabilities(struct mmc *mmc)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Read the SCR to find out if this card supports higher speeds */
|
/* Read the SCR to find out if this card supports higher speeds */
|
||||||
cmd.cmdidx = MMC_CMD_APP_CMD;
|
do {
|
||||||
cmd.resp_type = MMC_RSP_R1;
|
cmd.cmdidx = MMC_CMD_APP_CMD;
|
||||||
cmd.cmdarg = mmc->rca << 16;
|
cmd.resp_type = MMC_RSP_R1;
|
||||||
|
cmd.cmdarg = mmc->rca << 16;
|
||||||
|
|
||||||
err = mmc_send_cmd(mmc, &cmd, NULL);
|
err = mmc_send_cmd(mmc, &cmd, NULL);
|
||||||
|
if (err)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (err)
|
cmd.cmdidx = SD_CMD_APP_SEND_SCR;
|
||||||
return err;
|
cmd.resp_type = MMC_RSP_R1;
|
||||||
|
cmd.cmdarg = 0;
|
||||||
|
|
||||||
cmd.cmdidx = SD_CMD_APP_SEND_SCR;
|
data.dest = (char *)scr;
|
||||||
cmd.resp_type = MMC_RSP_R1;
|
data.blocksize = 8;
|
||||||
cmd.cmdarg = 0;
|
data.blocks = 1;
|
||||||
|
data.flags = MMC_DATA_READ;
|
||||||
|
|
||||||
data.dest = (char *)scr;
|
err = mmc_send_cmd(mmc, &cmd, &data);
|
||||||
data.blocksize = 8;
|
} while (err && retries--);
|
||||||
data.blocks = 1;
|
|
||||||
data.flags = MMC_DATA_READ;
|
|
||||||
|
|
||||||
err = mmc_send_cmd_retry(mmc, &cmd, &data, 3);
|
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
Reference in New Issue
Block a user