[1/3] mmc: dw_mmc: Increase cmd11 timeout to 500ms
diff mbox

Message ID 1428084787-8710-1-git-send-email-dianders@chromium.org
State New, archived
Headers show

Commit Message

Douglas Anderson April 3, 2015, 6:13 p.m. UTC
The Designware databook claims that cmd11 should be finished in 2ms,
but my testing showed that not to be the case in some situations.
I've seen cmd11 timeouts of up to 130ms (!) during reboot tests.
Let's bump the timeout way up so that we're absolutely sure.  CMD11 is
only sent during card insertion, so this extra timeout shouldn't be
terrible.

Fixes: 5c935165da79 ("mmc: dw_mmc: Add a timeout for sending CMD11")
Signed-off-by: Doug Anderson <dianders@chromium.org>
---
 drivers/mmc/host/dw_mmc.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Jaehoon Chung April 6, 2015, 10:46 a.m. UTC | #1
Hi, Doug.

On 04/04/2015 03:13 AM, Doug Anderson wrote:
> The Designware databook claims that cmd11 should be finished in 2ms,
> but my testing showed that not to be the case in some situations.
> I've seen cmd11 timeouts of up to 130ms (!) during reboot tests.
> Let's bump the timeout way up so that we're absolutely sure.  CMD11 is
> only sent during card insertion, so this extra timeout shouldn't be
> terrible.

Is it h/w problem? Could you explain to me about "some situations"?
As you said, this timeout only used during card inserting. So, it's not critical..
But there is much different between 2ms and 500ms(or 130ms).

Best Regards,
Jaehoon Chung

> 
> Fixes: 5c935165da79 ("mmc: dw_mmc: Add a timeout for sending CMD11")
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> ---
>  drivers/mmc/host/dw_mmc.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 3883fe6..339a929 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -1023,11 +1023,13 @@ static void __dw_mci_start_request(struct dw_mci *host,
>  
>  	if (cmd->opcode == SD_SWITCH_VOLTAGE) {
>  		/*
> -		 * Databook says to fail after 2ms w/ no response; give an
> -		 * extra jiffy just in case we're about to roll over.
> +		 * Databook says to fail after 2ms w/ no response, but evidence
> +		 * shows that sometimes the cmd11 interrupt takes over 130ms.
> +		 * We'll set to 500ms, plus an extra jiffy just in case jiffies
> +		 * is just about to roll over.
>  		 */
>  		mod_timer(&host->cmd11_timer,
> -			  jiffies + msecs_to_jiffies(2) + 1);
> +			  jiffies + msecs_to_jiffies(500) + 1);
>  	}
>  
>  	if (mrq->stop)
>
Douglas Anderson April 6, 2015, 7:32 p.m. UTC | #2
Jaehoon,

On Mon, Apr 6, 2015 at 3:46 AM, Jaehoon Chung <jh80.chung@samsung.com> wrote:
> Hi, Doug.
>
> On 04/04/2015 03:13 AM, Doug Anderson wrote:
>> The Designware databook claims that cmd11 should be finished in 2ms,
>> but my testing showed that not to be the case in some situations.
>> I've seen cmd11 timeouts of up to 130ms (!) during reboot tests.
>> Let's bump the timeout way up so that we're absolutely sure.  CMD11 is
>> only sent during card insertion, so this extra timeout shouldn't be
>> terrible.
>
> Is it h/w problem? Could you explain to me about "some situations"?
> As you said, this timeout only used during card inserting. So, it's not critical..
> But there is much different between 2ms and 500ms(or 130ms).

Very good question, and it makes sense to dig into this...

OK, I think I've got it.  Dang printk bites me again.  I have serial
console enabled and my printouts were actually causing these delays.
With serial console turned off I reliably get ~280us for the interrupt
to fire (tested across SD and WiFi across 137 + 128 + 111 + 127 = 503
reboots)

I think it makes sense to land this patch anyway, but with an updated
description.  I'm happy to repost this or happy if you just want to
update the description when applying.

---

Although the cmd11 interrupt should come within 2ms, that's a very
short time.  Let's increase the timeout to be really sure that we
don't get an accidnetal timeout.  One case in particular this is
useful is if you've got a serial console and printk in just the right
places.  Under that scenario I've seen delays of up to 130ms before
the interrupt fired.

CMD11 is only sent during card insertion, so this extra timeout
shouldn't be terrible.

---

-Doug
Jaehoon Chung April 7, 2015, 2 a.m. UTC | #3
Hi, Doug.

On 04/07/2015 04:32 AM, Doug Anderson wrote:
> Jaehoon,
> 
> On Mon, Apr 6, 2015 at 3:46 AM, Jaehoon Chung <jh80.chung@samsung.com> wrote:
>> Hi, Doug.
>>
>> On 04/04/2015 03:13 AM, Doug Anderson wrote:
>>> The Designware databook claims that cmd11 should be finished in 2ms,
>>> but my testing showed that not to be the case in some situations.
>>> I've seen cmd11 timeouts of up to 130ms (!) during reboot tests.
>>> Let's bump the timeout way up so that we're absolutely sure.  CMD11 is
>>> only sent during card insertion, so this extra timeout shouldn't be
>>> terrible.
>>
>> Is it h/w problem? Could you explain to me about "some situations"?
>> As you said, this timeout only used during card inserting. So, it's not critical..
>> But there is much different between 2ms and 500ms(or 130ms).
> 
> Very good question, and it makes sense to dig into this...
> 
> OK, I think I've got it.  Dang printk bites me again.  I have serial
> console enabled and my printouts were actually causing these delays.
> With serial console turned off I reliably get ~280us for the interrupt
> to fire (tested across SD and WiFi across 137 + 128 + 111 + 127 = 503
> reboots)

Oh..agreed. I also think printouts can be caused the delay.
Thanks for your explanation.

> 
> I think it makes sense to land this patch anyway, but with an updated
> description.  I'm happy to repost this or happy if you just want to
> update the description when applying.

To save your time, when applying, i will do the updating description.

Best Regards,
Jaehoon Chung

> 
> ---
> 
> Although the cmd11 interrupt should come within 2ms, that's a very
> short time.  Let's increase the timeout to be really sure that we
> don't get an accidnetal timeout.  One case in particular this is
> useful is if you've got a serial console and printk in just the right
> places.  Under that scenario I've seen delays of up to 130ms before
> the interrupt fired.
> 
> CMD11 is only sent during card insertion, so this extra timeout
> shouldn't be terrible.
> 
> ---
> 
> -Doug
> --
> 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/
>

Patch
diff mbox

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 3883fe6..339a929 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1023,11 +1023,13 @@  static void __dw_mci_start_request(struct dw_mci *host,
 
 	if (cmd->opcode == SD_SWITCH_VOLTAGE) {
 		/*
-		 * Databook says to fail after 2ms w/ no response; give an
-		 * extra jiffy just in case we're about to roll over.
+		 * Databook says to fail after 2ms w/ no response, but evidence
+		 * shows that sometimes the cmd11 interrupt takes over 130ms.
+		 * We'll set to 500ms, plus an extra jiffy just in case jiffies
+		 * is just about to roll over.
 		 */
 		mod_timer(&host->cmd11_timer,
-			  jiffies + msecs_to_jiffies(2) + 1);
+			  jiffies + msecs_to_jiffies(500) + 1);
 	}
 
 	if (mrq->stop)