Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 219031
b: refs/heads/master
c: 061c6c8
h: refs/heads/master
i:
  219029: 5580ee3
  219027: cfdc7a4
  219023: c3589db
v: v3
  • Loading branch information
Sonic Zhang authored and Chris Ball committed Oct 23, 2010
1 parent 1494e81 commit 3332acd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 95f25efe0ce22e28d61722d655d2ef582f5f7520
refs/heads/master: 061c6c847eeb11743e489a16e907b41c6f9042b6
21 changes: 21 additions & 0 deletions trunk/drivers/mmc/host/mmc_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,8 @@ static void mmc_spi_request(struct mmc_host *mmc, struct mmc_request *mrq)
{
struct mmc_spi_host *host = mmc_priv(mmc);
int status = -EINVAL;
int crc_retry = 5;
struct mmc_command stop;

#ifdef DEBUG
/* MMC core and layered drivers *MUST* issue SPI-aware commands */
Expand Down Expand Up @@ -1087,10 +1089,29 @@ static void mmc_spi_request(struct mmc_host *mmc, struct mmc_request *mrq)
/* request exclusive bus access */
spi_bus_lock(host->spi->master);

crc_recover:
/* issue command; then optionally data and stop */
status = mmc_spi_command_send(host, mrq, mrq->cmd, mrq->data != NULL);
if (status == 0 && mrq->data) {
mmc_spi_data_do(host, mrq->cmd, mrq->data, mrq->data->blksz);

/*
* The SPI bus is not always reliable for large data transfers.
* If an occasional crc error is reported by the SD device with
* data read/write over SPI, it may be recovered by repeating
* the last SD command again. The retry count is set to 5 to
* ensure the driver passes stress tests.
*/
if (mrq->data->error == -EILSEQ && crc_retry) {
stop.opcode = MMC_STOP_TRANSMISSION;
stop.arg = 0;
stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
status = mmc_spi_command_send(host, mrq, &stop, 0);
crc_retry--;
mrq->data->error = 0;
goto crc_recover;
}

if (mrq->stop)
status = mmc_spi_command_send(host, mrq, mrq->stop, 0);
else
Expand Down

0 comments on commit 3332acd

Please sign in to comment.