[U-Boot] [PATCH] mmc: sdhci: Avoid commands errors by simple timeout adaptation.

Przemyslaw Marczak p.marczak at samsung.com
Fri Oct 4 15:17:19 CEST 2013


Hi Jaehoon,

On 10/04/2013 06:39 AM, Jaehoon Chung wrote:
> Hi Przemyslaw,
>
> On 10/01/2013 09:16 PM, Przemyslaw Marczak wrote:
>> Old command timeout value was too small and it caused I/O errors which
>> led to uncompleted read/write/erase operations and filesystem errors.
>> Timeout adaptation fixes this issue.
>>
>> Changes in sdhci_send_command() function:
>> - change timeout variable to static
>> - increase default command timeout to 100 ms
>> - add definition of max command timeout value,
>>    which can be redefined in each board config file
>> - wait for card ready state for max defined time
>>    if it doesn't exceed defined maximum or return COMM_ERR
>>
>> Once successfully increased timeout value will be used in next function
>> call. This fix was tested on Goni, Trats, Trats2 boards by testing UMS
>> on MMC storage.
>>
>> Signed-off-by: Przemyslaw Marczak <p.marczak at samsung.com>
>> ---
>>   drivers/mmc/sdhci.c |   34 +++++++++++++++++++++++++++-------
>>   1 file changed, 27 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
>> index 4261991..af11fc5 100644
>> --- a/drivers/mmc/sdhci.c
>> +++ b/drivers/mmc/sdhci.c
>> @@ -110,6 +110,22 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,
>>   	return 0;
>>   }
>>
>> +/*
>> + * No command will be sent by driver if card is busy, so driver must wait
>> + * for card ready state.
>> + * Every time when card is busy after timeout then (last) timeout value will be
>> + * increased twice but only if it doesn't exceed global defined maximum.
>> + * Each function call will use last timeout value. Max timeout can be redefined
>> + * in board config file.
>> + */
>> +#ifndef CONFIG_SDHCI_CMD_MAX_TIMEOUT
>> +#define CONFIG_SDHCI_CMD_MAX_TIMEOUT		3200
> How do you get "3200"? Is it too long time?
>

After testing mmc read/write operations on Trats emmc card I observed 
that in most cases the timeout value was incremented to 800ms.
You can add reset timeout at every function call and than you will see 
how often and what time values are needed by commands, in most cases it 
is small time value but after transfer ends - send status command is 
send, which needs more time. I suppose that there are a lot of card 
types which need some more time - so I put there this value to be sure 
that in most cases this MAX is good enough.


>> +#endif
>> +#define CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT	100
>> +
>> +/* Timeout unit - ms */
>> +static unsigned int cmd_timeout = CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT;
> Global variable?

Ok, maybe I should put this inside function...

Regards,

-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com


More information about the U-Boot mailing list