All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] mmc: omap: timeout counter fix
Date: Mon, 25 Oct 2010 20:18:57 -0500	[thread overview]
Message-ID: <4CC62C81.8000202@ti.com> (raw)
In-Reply-To: <4CC62B6C.30601@emk-elektronik.de>

Reinhard Meyer had written, on 10/25/2010 08:14 PM, the following:
> Dear Nishanth Menon,
>> Having a loop with a counter is no timing guarentee for timing
>> accuracy or compiler optimizations. For e.g. the same loop counter
>> which runs when the MPU is running at 600MHz will timeout in around
>> half the time when running at 1GHz. or the example where GCC 4.5
>> compiles with different optimization compared to GCC 4.4.
>> use a udelay(10) to ensure we have a predictable delay.
>> use an emperical number - 100000 uSec ~= 1sec for a worst case timeout.
>> This should never happen, and is adequate imaginary condition for us
>> to fail with timeout.
> 
> In such cases I prefer to use:
> 
> 	uint64_t etime;
> ...
> 	etime = get_ticks() + get_tbclk(); /* 1 second */
> 	do {
> 		whatever;
> 		udelay (xx);
> 	} while (condition && get_ticks() <= etime);
> 
> That is far more accurate than calling udelay() 100000 times.
> (depending on implementation and granularity udelay of a few usecs
> might be rounded significantly)
> You can still call udelay inside the loop if you don't want
> to poll the condition too tightly...
hmmm.. almost like the jiffies in kernel ;).. timing wise, I see that 
the only benefit is that the approach gives a little more accuracy to 
the timeout delay - the other benefit is option to loop continuously 
instead of delaying with udelays - overall, at least the segments I saw 
had no reason to hit the registers so hard (alright we dont have much 
else to do.. but still).. I am very open to options from 
Sukumar(original author) as well..

-- 
Regards,
Nishanth Menon

  reply	other threads:[~2010-10-26  1:18 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-26  1:02 [U-Boot] [PATCH v2] mmc: omap: timeout counter fix Nishanth Menon
2010-10-26  1:14 ` Reinhard Meyer
2010-10-26  1:18   ` Nishanth Menon [this message]
2010-10-26  5:29     ` Wolfgang Denk
2010-10-26  5:28   ` Wolfgang Denk
2010-10-26  5:34     ` Ghorai, Sukumar
2010-10-26 13:58       ` Nishanth Menon
2010-10-26  5:43     ` Reinhard Meyer
2010-10-26  5:48       ` Wolfgang Denk
2010-10-26  6:01         ` Reinhard Meyer
2010-10-26  7:00           ` [U-Boot] Timer implementations (was: Re: [PATCH v2] mmc: omap: timeout counter fix) Reinhard Meyer
2010-10-26  7:41             ` Wolfgang Denk
2010-10-26  7:57               ` [U-Boot] Timer implementations Reinhard Meyer
2010-10-26  9:33                 ` Wolfgang Denk
2010-10-26 10:18                   ` Reinhard Meyer
2010-10-26 13:05                     ` Wolfgang Denk
2010-10-26 13:33                       ` Reinhard Meyer
2010-10-26 21:19                         ` J. William Campbell
2010-10-28  6:02                           ` Reinhard Meyer
2010-11-01 13:47                             ` J. William Campbell
2010-11-01 20:01                               ` Reinhard Meyer
2010-11-01 20:15                                 ` Wolfgang Denk
2010-10-26 15:11                 ` Nishanth Menon
2010-10-26 15:17                   ` Wolfgang Denk
2010-10-26 15:22                     ` Nishanth Menon
2010-10-26 16:26                       ` Wolfgang Denk
2010-10-26 18:36                         ` Reinhard Meyer
2010-10-26  7:03           ` [U-Boot] [PATCH v2] mmc: omap: timeout counter fix J. William Campbell
2010-10-26  7:36           ` Wolfgang Denk
2010-10-26  7:48             ` Reinhard Meyer
2010-10-26  4:36 ` Wolfgang Denk
2010-10-26  5:26   ` Ghorai, Sukumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CC62C81.8000202@ti.com \
    --to=nm@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.