Re: [PATCH V14 07/24] mmc: block: Use data timeout in card_busy_detect()

From: Adrian Hunter
Date: Wed Nov 22 2017 - 02:40:52 EST

On 21/11/17 17:39, Ulf Hansson wrote:
> On 21 November 2017 at 14:42, Adrian Hunter <adrian.hunter@xxxxxxxxx> wrote:
>> card_busy_detect() has a 10 minute timeout. However the correct timeout is
>> the data timeout. Change card_busy_detect() to use the data timeout.
> Unfortunate I don't think there is "correct" timeout for this case.
> The data->timeout_ns is to indicate for the host to how long the
> maximum time it's allowed to take between blocks that are written to
> the data lines.
> I haven't found a definition of the busy timeout, after the data write
> has completed. The spec only mentions that the device moves to
> programming state and pulls DAT0 to indicate busy.

To me it reads more like the timeout is for each block, including the last
i.e. the same timeout for "busy". Note the card is also busy between blocks.

Equally it is the timeout we give the host controller. So either the host
controller does not have a timeout for "busy" - which begs the question why
it has a timeout at all - or it invents its own "busy" timeout - which begs
the question why it isn't in the spec.

> Sure, 10 min seems crazy, perhaps something along the lines of 10-20 s
> is more reasonable. What do you think?

We give SD cards a generous 3 seconds for writes. SDHCI has long had a 10
second software timer for the whole request, which strongly suggests that
requests have always completed within 10 seconds. So that puts the range of
an arbitrary timeout 3-10 s.