[U-Boot] [PATCH 2/4] mmc: dw_mmc: Zap endless timeout

Pantelis Antoniou panto at antoniou-consulting.com
Wed Aug 12 09:26:44 CEST 2015


Hi Marek,

> On Jul 27, 2015, at 23:39 , Marek Vasut <marex at denx.de> wrote:
> 
> Endless timeouts are bad, since if we get stuck in one, we have no
> way out. Zap this one by implementing proper timeout.
> 
> Signed-off-by: Marek Vasut <marex at denx.de>
> Cc: Dinh Nguyen <dinguyen at opensource.altera.com>
> Cc: Pantelis Antoniou <panto at antoniou-consulting.com>
> Cc: Tom Rini <trini at konsulko.com>
> ---
> drivers/mmc/dw_mmc.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
> index 3fffa71..0f61f16 100644
> --- a/drivers/mmc/dw_mmc.c
> +++ b/drivers/mmc/dw_mmc.c
> @@ -211,14 +211,29 @@ static int dwmci_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
> 	}
> 
> 	if (data) {
> -		do {
> +		start = get_timer(0);
> +		timeout = 1000;
> +		for (;;) {
> 			mask = dwmci_readl(host, DWMCI_RINTSTS);
> +			/* Error during data transfer. */
> 			if (mask & (DWMCI_DATA_ERR | DWMCI_DATA_TOUT)) {
> 				printf("%s: DATA ERROR!\n", __func__);
> 				bounce_buffer_stop(&bbstate);
> 				return -1;
> 			}
> -		} while (!(mask & DWMCI_INTMSK_DTO));
> +
> +			/* Data arrived correctly. */
> +			if (mask & DWMCI_INTMSK_DTO)
> +				break;
> +
> +			/* Check for timeout. */
> +			if (get_timer(start) > timeout) {
> +				printf("%s: Timeout waiting for data!\n",
> +				       __func__);
> +				bounce_buffer_stop(&bbstate);
> +				return TIMEOUT;
> +			}
> +		}
> 
> 		dwmci_writel(host, DWMCI_RINTSTS, mask);
> 
> -- 
> 2.1.4

Applied, thanks

— Pantelis



More information about the U-Boot mailing list