[U-Boot] [PATCH v1] mmc: dwmmc: Enable small delay before returning error

Marek Vasut marex at denx.de
Mon Feb 18 11:57:50 UTC 2019


On 2/18/19 5:16 AM, chee.hong.ang at intel.com wrote:
> From: "Ang, Chee Hong" <chee.hong.ang at intel.com>
> 
> 'SET_BLOCKLEN' may occasionally fail on first attempt.

Why ?

> This patch enable a small delay in dwmci_send_cmd() on
> busy, I/O or CRC error to allow the MMC controller recovers
> from the failure/error on subsequent retries.

Why 100 uS ?

Can we rather detect whether the controller recovered by polling some bit?

> Signed-off-by: Ang, Chee Hong <chee.hong.ang at intel.com>
> ---
>  drivers/mmc/dw_mmc.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
> index 7544b84..8dcc518 100644
> --- a/drivers/mmc/dw_mmc.c
> +++ b/drivers/mmc/dw_mmc.c
> @@ -266,8 +266,11 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
>  	if (data)
>  		flags = dwmci_set_transfer_mode(host, data);
>  
> -	if ((cmd->resp_type & MMC_RSP_136) && (cmd->resp_type & MMC_RSP_BUSY))
> -		return -1;
> +	if ((cmd->resp_type & MMC_RSP_136) &&
> +	    (cmd->resp_type & MMC_RSP_BUSY)) {
> +		ret = -1;
> +		goto delay_ret;
> +	}
>  
>  	if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
>  		flags |= DWMCI_CMD_ABORT_STOP;
> @@ -316,11 +319,13 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
>  		return -ETIMEDOUT;
>  	} else if (mask & DWMCI_INTMSK_RE) {
>  		debug("%s: Response Error.\n", __func__);
> -		return -EIO;
> +		ret = -EIO;
> +		goto delay_ret;
>  	} else if ((cmd->resp_type & MMC_RSP_CRC) &&
>  		   (mask & DWMCI_INTMSK_RCRC)) {
>  		debug("%s: Response CRC Error.\n", __func__);
> -		return -EIO;
> +		ret = -EIO;
> +		goto delay_ret;
>  	}
>  
>  
> @@ -347,6 +352,7 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
>  		}
>  	}
>  
> +delay_ret:
>  	udelay(100);
>  
>  	return ret;
> 


-- 
Best regards,
Marek Vasut


More information about the U-Boot mailing list