All of lore.kernel.org
 help / color / mirror / Atom feed
From: J. William Campbell <jwilliamcampbell@comcast.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC][Timer API] Revised Specification -	Implementation details
Date: Fri, 27 May 2011 10:11:22 -0700	[thread overview]
Message-ID: <4DDFDB3A.3060100@comcast.net> (raw)
In-Reply-To: <BANLkTimJAGouiZ-1RAxRCJeyg7srBOR7KA@mail.gmail.com>

On 5/27/2011 8:13 AM, Simon Glass wrote:
> On Fri, May 27, 2011 at 8:00 AM, J. William Campbell
> <jwilliamcampbell@comcast.net>  wrote:
> [snip]
>> Hi All,
>>      A more precise statement of the problem is that all timer delays
>> may be shortened by the timer resolution. So this means that if you have
>> a timeout of 1 ms in your get_time(0) {   } while ( ...<  1), then your
>> actual delay may be anywhere between 0 and 1 ms. The problem arises when
>> some piece of common code uses a delay of say 8 millisec, expecting the
>> actual delay to be between 7 and 8. If the resolution is 10 ms, the
>> delay will be between 0 and 10 ms, 0 being particularly bad. This can be
>> fixed in get_timer, making the 8 ms delay  become a minimum of 10 ms at
>> the expense of it becoming up to 20 ms sometimes. Since these delays are
>> used mostly for error conditions, making them longer will probably be
>> ok, and doesn't require changing any of the common code. It probably
>> will not make things slower either, because the error timeouts should
>> not be reached. The reset of the hardware timer would cause all "short"
>> delays to become 10 ms. This reset approach is bad in that it prevents
>> proper nesting of timing loops. However, in this case it isn't so bad,
>> in that the nested loops are just extended, not shortened. Note that if
>> the reset is only resetting the HARDWARE interrupt generator, not the
>> actual timestamp itself, we are just extending all existing timeouts by
>> 0 to 10 ms.. So this just lengthens all pending timeouts. The other fix
>> is in my opinion nicer, because it affects the nest loops less. If the
>> inner loop is executed 100 times, with the reset, the outer loop timeout
>> is extended by up to 1000 ms.
>>
>> Best Regards,
>> Bill Campbell
> Hi Bill,
>
> Yes I agree that this is ugly - I didn't realize that this is what
> reset_timer() does, but I think these 10ms platforms should have to
> live with the fact that timeouts will be 0-10ms longer than hoped.
> Perhaps reset_timer() should become a non-standard board thing that is
> deprecated. Really if you have a 10ms timer and are asking for a 10ms
> timeout you are being a bit hopeful.
Hi All,
     Yes, but the person writing the driver was writing "common" code. 
He probably didn't even know there was a timer whose resolution was not 
1 ms.
> But perhaps this argues for a function to check timeouts - at the
> moment get_timer() returns the time since an event and it is used at
> the start of the loop and the end. Perhaps we should have:
>
> #define TIMEOUTMS 2000
>
> stop_time = get_future_time(TIMEOUT_MS);  // Returns current time +
> TIMEOUT_MS + (resolution of timer)
> while (get_timer(stop_time)<  0)     // (I would much prefer while
> (!timed_out(stop_time))
>     wait for something
> }
>
> Regards,
> Simon
In the existing system, you can get the same result by running the while 
loop  with a condition of (get_timer(base) < TIMEOUTMS + TIMER_RESOLUTION).
We could just make TIMER_RESOLUTION a mandatory define for all u-boots. 
Then common code would be wrong if the TIMER_RESOLUTION were omitted. 
For all I know, there may be such a define already. Anybody know of one?

Best Regards,
Bill Campbell

  reply	other threads:[~2011-05-27 17:11 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-26 13:27 [U-Boot] [RFC][Timer API] Revised Specification - Implementation details Graeme Russ
2011-05-26 15:57 ` Simon Glass
2011-05-26 17:28   ` Wolfgang Denk
2011-05-26 22:44     ` Graeme Russ
2011-05-27  5:23       ` Simon Glass
2011-05-27  7:40         ` Wolfgang Denk
2011-05-27 14:46           ` Simon Glass
2011-05-26 16:56 ` J. William Campbell
2011-05-26 17:53   ` Wolfgang Denk
2011-05-26 18:52     ` J. William Campbell
2011-05-26 19:16       ` Wolfgang Denk
2011-05-26 19:54         ` J. William Campbell
2011-05-26 20:27           ` Wolfgang Denk
2011-05-26 20:39             ` J. William Campbell
2011-05-26 22:59       ` Graeme Russ
2011-05-26 23:28   ` Graeme Russ
2011-05-27  1:26     ` J. William Campbell
2011-05-27  1:51       ` Graeme Russ
2011-05-27  3:54         ` J. William Campbell
2011-05-27  4:33           ` Graeme Russ
2011-05-27  6:33             ` J. William Campbell
2011-05-27  6:54               ` Graeme Russ
2011-05-27 15:49                 ` J. William Campbell
2011-05-28  0:32                   ` Graeme Russ
2011-05-27  7:33           ` Wolfgang Denk
2011-05-27 14:16             ` J. William Campbell
2011-05-27  7:28       ` Wolfgang Denk
2011-05-27 14:04         ` J. William Campbell
2011-05-27  7:13     ` Wolfgang Denk
2011-05-27  7:35       ` Graeme Russ
2011-05-27  7:48         ` Wolfgang Denk
2011-05-27  7:57           ` Graeme Russ
2011-05-27  8:01             ` Graeme Russ
2011-05-27 11:27               ` Wolfgang Denk
2011-05-27 12:43                 ` Graeme Russ
2011-05-27 13:07                   ` Scott McNutt
2011-05-27 15:00                     ` J. William Campbell
2011-05-27 15:13                       ` Simon Glass
2011-05-27 17:11                         ` J. William Campbell [this message]
2011-05-27 15:44                       ` Scott McNutt
2011-05-27 15:59                         ` J. William Campbell
2011-05-29 15:55                     ` Wolfgang Denk
2011-05-29 19:12                       ` Simon Glass
2011-05-30 10:57                         ` Wolfgang Denk
2011-05-30 11:47                           ` Graeme Russ
2011-05-30 12:31                             ` Wolfgang Denk
2011-05-30 12:46                               ` Graeme Russ
2011-05-30 18:57                           ` Reinhard Meyer
2011-05-31  0:24                             ` Graeme Russ
2011-05-31  4:07                               ` Reinhard Meyer
2011-05-31  4:24                                 ` Graeme Russ
2011-05-31  4:36                                   ` Reinhard Meyer
2011-05-31  4:53                                     ` Graeme Russ
2011-05-31  5:56                                     ` Wolfgang Denk
2011-05-31  4:45                               ` Simon Glass
2011-05-31  4:53                                 ` Reinhard Meyer
2011-05-31  5:03                                   ` Graeme Russ
2011-05-31  5:16                                     ` Reinhard Meyer
2011-05-31  6:03                                     ` Wolfgang Denk
2011-05-31  6:23                                       ` Graeme Russ
2011-05-31  5:18                                   ` Wolfgang Denk
2011-05-31  5:37                                     ` Reinhard Meyer
2011-05-31  6:10                                       ` Wolfgang Denk
2011-05-31  4:56                           ` Simon Glass
2011-05-31  5:49                             ` Wolfgang Denk
2011-05-31  6:28                               ` Graeme Russ
2011-05-31  6:29                                 ` Graeme Russ
2011-06-15 13:17                           ` Graeme Russ
2011-06-15 16:03                             ` Simon Glass
2011-06-15 20:38                               ` Graeme Russ
2011-06-15 21:58                                 ` Simon Glass
2011-06-15 23:09                                   ` Graeme Russ
2011-06-16  5:53                                     ` Simon Glass
2011-06-16  6:27                                       ` Graeme Russ
2011-06-16 13:58                                         ` Simon Glass
2011-05-27 11:26             ` Wolfgang Denk
2011-05-27 14:23         ` J. William Campbell
2011-05-28  5:53           ` Graeme Russ
2011-05-28  6:18             ` Reinhard Meyer
2011-05-28  8:59               ` Graeme Russ
2011-05-29  1:41             ` J. William Campbell
2011-05-26 17:49 ` Wolfgang Denk
2011-05-26 22:51   ` Graeme Russ
2011-05-27  7:17     ` Wolfgang Denk
2011-05-27  7:33       ` Graeme Russ
2011-05-27  7:45         ` Wolfgang Denk
2011-05-27 14:58           ` Simon Glass

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=4DDFDB3A.3060100@comcast.net \
    --to=jwilliamcampbell@comcast.net \
    --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.