All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Timeout for SDHCI commands
@ 2014-06-12  9:41 Eli Billauer
  2014-06-12  9:41 ` [U-Boot] [PATCH] mmc: sdhci: Fixed timeout for sdhci_send_command() Eli Billauer
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Billauer @ 2014-06-12  9:41 UTC (permalink / raw)
  To: u-boot

The patch in the following mail is a result of a problem I had using an eMMC
device on a Xilinx Zynq ARM processor. It turned out that the waiting for a
certain response from the SDIO interface was made with a plain loop, with
no absolute time measurement. Since I'm using a relatively fast processor,
the timeout expired before the eMMC chip managed to acknowledge an
mmc_switch() with EXT_CSD_HS_TIMING.

This patch fixes the problem on my board, and eMMC works properly with it.
However I can't say that I really understand what I did, and the 100 ms
timeout was chosen with a finger in the wind. If there's a reason why the
timeout should be longer or shorter, this is a good time to come forward.

Thanks,
  Eli

Eli Billauer (1):
  mmc: sdhci: Fixed timeout for sdhci_send_command()

 drivers/mmc/sdhci.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

-- 
1.7.2.3

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

* [U-Boot] [PATCH] mmc: sdhci: Fixed timeout for sdhci_send_command()
  2014-06-12  9:41 [U-Boot] [PATCH] Timeout for SDHCI commands Eli Billauer
@ 2014-06-12  9:41 ` Eli Billauer
  2014-06-19 16:43   ` Andy Fleming
  2014-06-27  9:37   ` Pantelis Antoniou
  0 siblings, 2 replies; 7+ messages in thread
From: Eli Billauer @ 2014-06-12  9:41 UTC (permalink / raw)
  To: u-boot

The current wait loop just reads the status 10000 times, which makes the
actual timeout period platform-dependent. The udelay() call within the loop
makes the new timeout ~100 ms.

Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
---
 drivers/mmc/sdhci.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 3125d13..80f3a91 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -226,6 +226,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
 			break;
 		if (--retry == 0)
 			break;
+		udelay(10);
 	} while ((stat & mask) != mask);
 
 	if (retry == 0) {
-- 
1.7.2.3

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

* [U-Boot] [PATCH] mmc: sdhci: Fixed timeout for sdhci_send_command()
  2014-06-12  9:41 ` [U-Boot] [PATCH] mmc: sdhci: Fixed timeout for sdhci_send_command() Eli Billauer
@ 2014-06-19 16:43   ` Andy Fleming
  2014-06-19 16:50     ` Eli Billauer
  2014-06-27  9:37   ` Pantelis Antoniou
  1 sibling, 1 reply; 7+ messages in thread
From: Andy Fleming @ 2014-06-19 16:43 UTC (permalink / raw)
  To: u-boot

On Thu, Jun 12, 2014 at 4:41 AM, Eli Billauer <eli.billauer@gmail.com> wrote:
> The current wait loop just reads the status 10000 times, which makes the
> actual timeout period platform-dependent. The udelay() call within the loop
> makes the new timeout ~100 ms.
>
> Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
> ---
>  drivers/mmc/sdhci.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
> index 3125d13..80f3a91 100644
> --- a/drivers/mmc/sdhci.c
> +++ b/drivers/mmc/sdhci.c
> @@ -226,6 +226,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
>                         break;
>                 if (--retry == 0)
>                         break;
> +               udelay(10);
>         } while ((stat & mask) != mask);


Hmmm...

Is 100ms part of the spec? I like the idea of making the timeout more
time-based, but it seems to me that this changes the timeout quite
significantly. If it took N ms before, it now takes N + 100 ms.

I think, if we want the timeout to be ~100ms, we should use a udelay
of 100 or 1000, and then reduce "retry" accordingly.

Andy

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

* [U-Boot] [PATCH] mmc: sdhci: Fixed timeout for sdhci_send_command()
  2014-06-19 16:43   ` Andy Fleming
@ 2014-06-19 16:50     ` Eli Billauer
  0 siblings, 0 replies; 7+ messages in thread
From: Eli Billauer @ 2014-06-19 16:50 UTC (permalink / raw)
  To: u-boot

On 19/06/14 19:43, Andy Fleming wrote:
> On Thu, Jun 12, 2014 at 4:41 AM, Eli Billauer<eli.billauer@gmail.com>  wrote:
>    
>> The current wait loop just reads the status 10000 times, which makes the
>> actual timeout period platform-dependent. The udelay() call within the loop
>> makes the new timeout ~100 ms.
>>
>> [ snipped patch ]
>>      
>
> Hmmm...
>
> Is 100ms part of the spec? I like the idea of making the timeout more
> time-based, but it seems to me that this changes the timeout quite
> significantly. If it took N ms before, it now takes N + 100 ms.
>
> I think, if we want the timeout to be ~100ms, we should use a udelay
> of 100 or 1000, and then reduce "retry" accordingly.
>    
Hi,

As I said in the mail preceding this patch, I don't know what the 
timeout should be. Maybe someone with a better knowledge on MMC could 
come forward.

Regards,
    Eli
> Andy
>
>    

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

* [U-Boot] [PATCH] mmc: sdhci: Fixed timeout for sdhci_send_command()
  2014-06-12  9:41 ` [U-Boot] [PATCH] mmc: sdhci: Fixed timeout for sdhci_send_command() Eli Billauer
  2014-06-19 16:43   ` Andy Fleming
@ 2014-06-27  9:37   ` Pantelis Antoniou
  2014-07-01 18:11     ` Andy Fleming
  2014-07-04 21:02     ` Steve Rae
  1 sibling, 2 replies; 7+ messages in thread
From: Pantelis Antoniou @ 2014-06-27  9:37 UTC (permalink / raw)
  To: u-boot

Hi Eli,

On Jun 12, 2014, at 12:41 PM, Eli Billauer wrote:

> The current wait loop just reads the status 10000 times, which makes the
> actual timeout period platform-dependent. The udelay() call within the loop
> makes the new timeout ~100 ms.
> 
> Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
> ---
> drivers/mmc/sdhci.c |    1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
> index 3125d13..80f3a91 100644
> --- a/drivers/mmc/sdhci.c
> +++ b/drivers/mmc/sdhci.c
> @@ -226,6 +226,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
> 			break;
> 		if (--retry == 0)
> 			break;
> +		udelay(10);
> 	} while ((stat & mask) != mask);
> 
> 	if (retry == 0) {
> -- 
> 1.7.2.3

Looking at the linux sources is no good, cause linux is interrupt driven.
This delay is used because the driver is not interrupt driven, so you have
to wait until the interrupt indication is delivered.

The only reference to interrupt latency I found is related to tuning and is
set to 50ms which I supposed is very pessimistic.
I think a timeout of 100ms would be fine.

Regards

-- Pantelis

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

* [U-Boot] [PATCH] mmc: sdhci: Fixed timeout for sdhci_send_command()
  2014-06-27  9:37   ` Pantelis Antoniou
@ 2014-07-01 18:11     ` Andy Fleming
  2014-07-04 21:02     ` Steve Rae
  1 sibling, 0 replies; 7+ messages in thread
From: Andy Fleming @ 2014-07-01 18:11 UTC (permalink / raw)
  To: u-boot

On Fri, Jun 27, 2014 at 4:37 AM, Pantelis Antoniou <
pantelis.antoniou@gmail.com> wrote:

> Hi Eli,
>
> On Jun 12, 2014, at 12:41 PM, Eli Billauer wrote:
>
> > The current wait loop just reads the status 10000 times, which makes the
> > actual timeout period platform-dependent. The udelay() call within the
> loop
> > makes the new timeout ~100 ms.
> >
> > Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
> > ---
> > drivers/mmc/sdhci.c |    1 +
> > 1 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
> > index 3125d13..80f3a91 100644
> > --- a/drivers/mmc/sdhci.c
> > +++ b/drivers/mmc/sdhci.c
> > @@ -226,6 +226,7 @@ int sdhci_send_command(struct mmc *mmc, struct
> mmc_cmd *cmd,
> >                       break;
> >               if (--retry == 0)
> >                       break;
> > +             udelay(10);
> >       } while ((stat & mask) != mask);
> >
> >       if (retry == 0) {
> > --
> > 1.7.2.3
>
> Looking at the linux sources is no good, cause linux is interrupt driven.
> This delay is used because the driver is not interrupt driven, so you have
> to wait until the interrupt indication is delivered.
>
> The only reference to interrupt latency I found is related to tuning and is
> set to 50ms which I supposed is very pessimistic.
> I think a timeout of 100ms would be fine.
>
>
I suspect the timeout of 100ms is fine (though it's always nice when we tie
such numbers to something more concrete than: "it works if I make it wait
longer"). My main point was that this actually *adds* 100ms to the
preexisting timeout, instead of making the timeout ~100ms. If we reduced
the number of checks and increased the delay, the delay would completely
dominate the timeout loop, and total time would become closer to ~100ms.

Andy

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

* [U-Boot] [PATCH] mmc: sdhci: Fixed timeout for sdhci_send_command()
  2014-06-27  9:37   ` Pantelis Antoniou
  2014-07-01 18:11     ` Andy Fleming
@ 2014-07-04 21:02     ` Steve Rae
  1 sibling, 0 replies; 7+ messages in thread
From: Steve Rae @ 2014-07-04 21:02 UTC (permalink / raw)
  To: u-boot

Tested-by: Steve Rae <srae@broadcom.com>

(does resolve the issue on our board!)

On 14-06-27 02:37 AM, Pantelis Antoniou wrote:
> Hi Eli,
>
> On Jun 12, 2014, at 12:41 PM, Eli Billauer wrote:
>
>> The current wait loop just reads the status 10000 times, which makes the
>> actual timeout period platform-dependent. The udelay() call within the loop
>> makes the new timeout ~100 ms.
>>
>> Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
>> ---
>> drivers/mmc/sdhci.c |    1 +
>> 1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
>> index 3125d13..80f3a91 100644
>> --- a/drivers/mmc/sdhci.c
>> +++ b/drivers/mmc/sdhci.c
>> @@ -226,6 +226,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
>> 			break;
>> 		if (--retry == 0)
>> 			break;
>> +		udelay(10);
>> 	} while ((stat & mask) != mask);
>>
>> 	if (retry == 0) {
>> --
>> 1.7.2.3
>
> Looking at the linux sources is no good, cause linux is interrupt driven.
> This delay is used because the driver is not interrupt driven, so you have
> to wait until the interrupt indication is delivered.
>
> The only reference to interrupt latency I found is related to tuning and is
> set to 50ms which I supposed is very pessimistic.
> I think a timeout of 100ms would be fine.
>
> Regards
>
> -- Pantelis
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>

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

end of thread, other threads:[~2014-07-04 21:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-12  9:41 [U-Boot] [PATCH] Timeout for SDHCI commands Eli Billauer
2014-06-12  9:41 ` [U-Boot] [PATCH] mmc: sdhci: Fixed timeout for sdhci_send_command() Eli Billauer
2014-06-19 16:43   ` Andy Fleming
2014-06-19 16:50     ` Eli Billauer
2014-06-27  9:37   ` Pantelis Antoniou
2014-07-01 18:11     ` Andy Fleming
2014-07-04 21:02     ` Steve Rae

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.