All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: dw_mmc: avoid long timeout if register invalid
@ 2021-09-17  7:50 ` Christian Löhle
  2021-09-17 13:41   ` Jesper Nilsson
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Christian Löhle @ 2021-09-17  7:50 UTC (permalink / raw)
  To: linux-kernel, linux-mmc; +Cc: marten.lindahl, jh80.chung, ulf.hansson


Set the limit to 1s if the register is at reset value.

Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
---
 drivers/mmc/host/dw_mmc.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 6578cc64ae9e..cd9a6e0a7449 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1983,6 +1983,14 @@ static void dw_mci_set_drto(struct dw_mci *host)
 	/* add a bit spare time */
 	drto_ms += 10;
 
+	/*
+	 * If TMOUT register still holds the reset value the above calculation
+	 * would yield a timeout of over 167 seconds, limit it to 1000ms.
+	 * Normal reads/writes should not take anywhere close to 120s.
+	 */
+	if (drto_ms > 120000)
+		drto_ms = 1000;
+
 	spin_lock_irqsave(&host->irq_lock, irqflags);
 	if (!test_bit(EVENT_DATA_COMPLETE, &host->pending_events))
 		mod_timer(&host->dto_timer,
-- 
2.32.0
Hyperstone GmbH | Line-Eid-Strasse 3 | 78467 Konstanz
Managing Directors: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mmc: dw_mmc: avoid long timeout if register invalid
  2021-09-17  7:50 ` [PATCH] mmc: dw_mmc: avoid long timeout if register invalid Christian Löhle
@ 2021-09-17 13:41   ` Jesper Nilsson
  2021-09-20  9:34     ` Christian Löhle
  2021-09-24  9:49   ` Jaehoon Chung
  2021-09-30  6:53   ` [PATCHv2] " Christian Löhle
  2 siblings, 1 reply; 7+ messages in thread
From: Jesper Nilsson @ 2021-09-17 13:41 UTC (permalink / raw)
  To: Christian Löhle
  Cc: linux-kernel, linux-mmc, marten.lindahl, jh80.chung, ulf.hansson

On Fri, Sep 17, 2021 at 07:50:44AM +0000, Christian Löhle wrote:
> Set the limit to 1s if the register is at reset value.

One second could be to short, we have seen some cards take up
to 10s on write operations. Although that was quite a few years ago.

TMOUT is only used for reads if I understand correctly,
so it should be ok anyways.

/Jesper

> Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
> ---
>  drivers/mmc/host/dw_mmc.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 6578cc64ae9e..cd9a6e0a7449 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -1983,6 +1983,14 @@ static void dw_mci_set_drto(struct dw_mci *host)
>  	/* add a bit spare time */
>  	drto_ms += 10;
>  
> +	/*
> +	 * If TMOUT register still holds the reset value the above calculation
> +	 * would yield a timeout of over 167 seconds, limit it to 1000ms.
> +	 * Normal reads/writes should not take anywhere close to 120s.
> +	 */
> +	if (drto_ms > 120000)
> +		drto_ms = 1000;
> +
>  	spin_lock_irqsave(&host->irq_lock, irqflags);
>  	if (!test_bit(EVENT_DATA_COMPLETE, &host->pending_events))
>  		mod_timer(&host->dto_timer,
> -- 
> 2.32.0
> Hyperstone GmbH | Line-Eid-Strasse 3 | 78467 Konstanz
> Managing Directors: Dr. Jan Peter Berns.
> Commercial register of local courts: Freiburg HRB381782

/^JN - Jesper Nilsson
-- 
               Jesper Nilsson -- jesper.nilsson@axis.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mmc: dw_mmc: avoid long timeout if register invalid
  2021-09-17 13:41   ` Jesper Nilsson
@ 2021-09-20  9:34     ` Christian Löhle
  0 siblings, 0 replies; 7+ messages in thread
From: Christian Löhle @ 2021-09-20  9:34 UTC (permalink / raw)
  To: Jesper Nilsson
  Cc: linux-kernel, linux-mmc, marten.lindahl, jh80.chung, ulf.hansson

From: Jesper Nilsson <jesper.nilsson@axis.com>
Sent: Friday, September 17, 2021 3:41 PM
To: Christian Löhle
Cc: linux-kernel@vger.kernel.org; linux-mmc@vger.kernel.org; marten.lindahl@axis.com; jh80.chung@samsung.com; ulf.hansson@linaro.org
Subject: Re: [PATCH] mmc: dw_mmc: avoid long timeout if register invalid

>One second could be to short, we have seen some cards take up
>to 10s on write operations. Although that was quite a few years ago.
>
>TMOUT is only used for reads if I understand correctly,
>so it should be ok anyways.
>
>/Jesper

Yes, apart from it only affecting reads, the calculated timeout is only that high if the register still holds the reset value.
I've only seen and would expect this for initialization 'read' commands, like ACMD13, or ACMD51.
I have chosen 1s to hit an expectation that I would consider normal, that a card is initialized in a couple of seconds after plugging in, or never.

Regards,
Christian=
Hyperstone GmbH | Line-Eid-Strasse 3 | 78467 Konstanz
Managing Directors: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mmc: dw_mmc: avoid long timeout if register invalid
  2021-09-17  7:50 ` [PATCH] mmc: dw_mmc: avoid long timeout if register invalid Christian Löhle
  2021-09-17 13:41   ` Jesper Nilsson
@ 2021-09-24  9:49   ` Jaehoon Chung
  2021-09-29  6:53     ` Christian Löhle
  2021-09-30  6:53   ` [PATCHv2] " Christian Löhle
  2 siblings, 1 reply; 7+ messages in thread
From: Jaehoon Chung @ 2021-09-24  9:49 UTC (permalink / raw)
  To: Christian Löhle, linux-kernel, linux-mmc; +Cc: marten.lindahl, ulf.hansson

Hi,

On 9/17/21 4:50 PM, Christian Löhle wrote:
> 
> Set the limit to 1s if the register is at reset value.
> 
> Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
> ---
>  drivers/mmc/host/dw_mmc.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 6578cc64ae9e..cd9a6e0a7449 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -1983,6 +1983,14 @@ static void dw_mci_set_drto(struct dw_mci *host)
>  	/* add a bit spare time */
>  	drto_ms += 10;
>  
> +	/*
> +	 * If TMOUT register still holds the reset value the above calculation
> +	 * would yield a timeout of over 167 seconds, limit it to 1000ms.
> +	 * Normal reads/writes should not take anywhere close to 120s.
> +	 */
> +	if (drto_ms > 120000)
> +		drto_ms = 1000;
> +

If dtrt_ms is 167sec, it means that bus_hz should be 0 or 1.
What value is your host->bus_hz?

Best Regards,
Jaehoon Chung

>  	spin_lock_irqsave(&host->irq_lock, irqflags);
>  	if (!test_bit(EVENT_DATA_COMPLETE, &host->pending_events))
>  		mod_timer(&host->dto_timer,
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mmc: dw_mmc: avoid long timeout if register invalid
  2021-09-24  9:49   ` Jaehoon Chung
@ 2021-09-29  6:53     ` Christian Löhle
  2021-10-01  0:15       ` Jaehoon Chung
  0 siblings, 1 reply; 7+ messages in thread
From: Christian Löhle @ 2021-09-29  6:53 UTC (permalink / raw)
  To: Jaehoon Chung, linux-kernel, linux-mmc; +Cc: marten.lindahl, ulf.hansson

Hey,
so more generally the timeout here can be 41954 up to 167783 ms.
Is 42s too low to view it as invalid here?
Would you prefer the patch exluding the specific timeout values instead of anything above
41954?

Regards,
Christian




From: Jaehoon Chung <jh80.chung@samsung.com>
Sent: Friday, September 24, 2021 11:49 AM
To: Christian Löhle; linux-kernel@vger.kernel.org; linux-mmc@vger.kernel.org
Cc: marten.lindahl@axis.com; ulf.hansson@linaro.org
Subject: Re: [PATCH] mmc: dw_mmc: avoid long timeout if register invalid
    
Hi,

On 9/17/21 4:50 PM, Christian Löhle wrote:
> 
> Set the limit to 1s if the register is at reset value.
> 
> Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
> ---
>  drivers/mmc/host/dw_mmc.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 6578cc64ae9e..cd9a6e0a7449 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -1983,6 +1983,14 @@ static void dw_mci_set_drto(struct dw_mci *host)
>        /* add a bit spare time */
>        drto_ms += 10;
>  
> +     /*
> +      * If TMOUT register still holds the reset value the above calculation
> +      * would yield a timeout of over 167 seconds, limit it to 1000ms.
> +      * Normal reads/writes should not take anywhere close to 120s.
> +      */
> +     if (drto_ms > 120000)
> +             drto_ms = 1000;
> +

If dtrt_ms is 167sec, it means that bus_hz should be 0 or 1.
What value is your host->bus_hz?

Best Regards,
Jaehoon Chung

>        spin_lock_irqsave(&host->irq_lock, irqflags);
>        if (!test_bit(EVENT_DATA_COMPLETE, &host->pending_events))
>                mod_timer(&host->dto_timer,
> 

    =
Hyperstone GmbH | Line-Eid-Strasse 3 | 78467 Konstanz
Managing Directors: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCHv2] mmc: dw_mmc: avoid long timeout if register invalid
  2021-09-17  7:50 ` [PATCH] mmc: dw_mmc: avoid long timeout if register invalid Christian Löhle
  2021-09-17 13:41   ` Jesper Nilsson
  2021-09-24  9:49   ` Jaehoon Chung
@ 2021-09-30  6:53   ` Christian Löhle
  2 siblings, 0 replies; 7+ messages in thread
From: Christian Löhle @ 2021-09-30  6:53 UTC (permalink / raw)
  To: linux-kernel, linux-mmc; +Cc: marten.lindahl, jh80.chung, ulf.hansson

Set the limit to 1s if the register is at reset value.

Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
---
 drivers/mmc/host/dw_mmc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 6578cc64ae9e..96b620a9fd52 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1983,6 +1983,13 @@ static void dw_mci_set_drto(struct dw_mci *host)
 	/* add a bit spare time */
 	drto_ms += 10;
 
+	/*
+	 * If TMOUT register still holds the reset value the above calculation
+	 * would yield a timeout of over 167 seconds, limit it to 1000ms.
+	 */
+	if (drto_clks == 0xFFFFFF)
+		drto_ms = 1000;
+
 	spin_lock_irqsave(&host->irq_lock, irqflags);
 	if (!test_bit(EVENT_DATA_COMPLETE, &host->pending_events))
 		mod_timer(&host->dto_timer,
-- 
2.32.0
Hyperstone GmbH | Line-Eid-Strasse 3 | 78467 Konstanz
Managing Directors: Dr. Jan Peter Berns.
Commercial register of local courts: Freiburg HRB381782


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mmc: dw_mmc: avoid long timeout if register invalid
  2021-09-29  6:53     ` Christian Löhle
@ 2021-10-01  0:15       ` Jaehoon Chung
  0 siblings, 0 replies; 7+ messages in thread
From: Jaehoon Chung @ 2021-10-01  0:15 UTC (permalink / raw)
  To: Christian Löhle, linux-kernel, linux-mmc; +Cc: marten.lindahl, ulf.hansson

Hi

On 9/29/21 3:53 PM, Christian Löhle wrote:
> Hey,
> so more generally the timeout here can be 41954 up to 167783 ms.
> Is 42s too low to view it as invalid here?
> Would you prefer the patch exluding the specific timeout values instead of anything above
> 41954?
It's dependent with bus_hz value and div value.
So it's always not 167 or 42 seconds. Your comment is "TMOUT register is invalid".
But it's not invalid value. 
We can set to proper value at TMOUT register during probing or somewhere, according to each boards.

I understood what you want to avoid the long time timeout.
- I think your commit-msg, subject and comment need to describe in more detail. (Not register invalid)
- Not always 42 or 167secs when TMOUT is 0xFFFFFF. In some cases, it's under 100ms even though TMOUT is 0xFFFFFF.

If I misunderstood something, let me know, plz.

Anyway, Thanks for reporting this. 

Best Regards,
Jaehoon Chung

> 
> Regards,
> Christian
> 
> 
> 
> 
> From: Jaehoon Chung <jh80.chung@samsung.com>
> Sent: Friday, September 24, 2021 11:49 AM
> To: Christian Löhle; linux-kernel@vger.kernel.org; linux-mmc@vger.kernel.org
> Cc: marten.lindahl@axis.com; ulf.hansson@linaro.org
> Subject: Re: [PATCH] mmc: dw_mmc: avoid long timeout if register invalid
>     
> Hi,
> 
> On 9/17/21 4:50 PM, Christian Löhle wrote:
>>
>> Set the limit to 1s if the register is at reset value.
>>
>> Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
>> ---
>>   drivers/mmc/host/dw_mmc.c | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
>> index 6578cc64ae9e..cd9a6e0a7449 100644
>> --- a/drivers/mmc/host/dw_mmc.c
>> +++ b/drivers/mmc/host/dw_mmc.c
>> @@ -1983,6 +1983,14 @@ static void dw_mci_set_drto(struct dw_mci *host)
>>         /* add a bit spare time */
>>         drto_ms += 10;
>>   
>> +     /*
>> +      * If TMOUT register still holds the reset value the above calculation
>> +      * would yield a timeout of over 167 seconds, limit it to 1000ms.
>> +      * Normal reads/writes should not take anywhere close to 120s.
>> +      */
>> +     if (drto_ms > 120000)
>> +             drto_ms = 1000;
>> +
> 
> If dtrt_ms is 167sec, it means that bus_hz should be 0 or 1.
> What value is your host->bus_hz?
> 
> Best Regards,
> Jaehoon Chung
> 
>>         spin_lock_irqsave(&host->irq_lock, irqflags);
>>         if (!test_bit(EVENT_DATA_COMPLETE, &host->pending_events))
>>                 mod_timer(&host->dto_timer,
>>
> 
>     =
> Hyperstone GmbH | Line-Eid-Strasse 3 | 78467 Konstanz
> Managing Directors: Dr. Jan Peter Berns.
> Commercial register of local courts: Freiburg HRB381782
> 
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-10-01  0:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20210917075050epcas1p1962cd1c7c388b20ad17cb841461dae1b@epcas1p1.samsung.com>
2021-09-17  7:50 ` [PATCH] mmc: dw_mmc: avoid long timeout if register invalid Christian Löhle
2021-09-17 13:41   ` Jesper Nilsson
2021-09-20  9:34     ` Christian Löhle
2021-09-24  9:49   ` Jaehoon Chung
2021-09-29  6:53     ` Christian Löhle
2021-10-01  0:15       ` Jaehoon Chung
2021-09-30  6:53   ` [PATCHv2] " Christian Löhle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.