lkml.org 
[lkml]   [2010]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2] MMC:mmc_spi: Recover from CRC error for SD read/write operation over SPI.
From
Any comments?


Sonic

On Mon, Jul 12, 2010 at 3:50 PM, sonic zhang <sonic.adi@gmail.com> wrote:
> >From 94d1ea57ac2fbe37133e25e99ccb265250f0027d Mon Sep 17 00:00:00 2001
> From: Sonic Zhang <sonic.zhang@analog.com>
> Date: Fri, 9 Jul 2010 15:36:20 +0800
> Subject: [PATCH v2] MMC:mmc_spi: Recover from crc error for SD read/write operation over SPI.
>
> SPI bus is not reliable on all platforms when doing large data transfer.
> Current mmc spi driver fails SD read/write command immediately, if
> occasional CRC error is reported by SD device. This patch makes the
> operation recover from the CRC error by doing last SD command again.
> The retry count is set to 5 to ensure the driver pass any stress test.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> ---
>  drivers/mmc/host/mmc_spi.c |   22 ++++++++++++++++++++++
>  1 files changed, 22 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
> index ad847a2..8192434 100644
> --- a/drivers/mmc/host/mmc_spi.c
> +++ b/drivers/mmc/host/mmc_spi.c
> @@ -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 */
> @@ -1084,10 +1086,30 @@ static void mmc_spi_request(struct mmc_host *mmc, struct mmc_request *mrq)
>        }
>  #endif
>
> +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);
> +
> +               /*
> +                * SPI bus is not reliable when doing large data transfer.
> +                * If occasional crc error is reported by SD device when do
> +                * data read/write over SPI, it can be recovered by doing
> +                * last SD command again. The retry count is set to 5 to
> +                * ensure the driver pass any stress test.
> +                */
> +               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
> --
> 1.6.0
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2010-07-16 12:53    [W:0.078 / U:10.928 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site