public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Reinhard Meyer <u-boot@emk-elektronik.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] Timer implementations
Date: Tue, 26 Oct 2010 12:18:04 +0200	[thread overview]
Message-ID: <4CC6AADC.8050608@emk-elektronik.de> (raw)
In-Reply-To: <20101026093355.A73D1152451@gemini.denx.de>

Dear Wolfgang Denk,

>> Actually CONFIG_SYS_HZ (whatever that is).
> 
> It is defined to be 1000.

Ok, game with that.

Then the define CONFIG_SYS_HZ should not be in every <board>.h since that
suggests that a board developer has some freedom there...

>> I think it is necessary to summarize all implicit or explicit documented
>> "defined to have's" regarding the timer and then to verify that all
>> implementations adhere to them.
> 
> Indeed - documentation is an are where U-Boot has a serious lack.

OK, to summarize:

1. reset_timer(), get_timer(base) operate with 1ms granularity.
An implementation MUST make that close to 1ms.
On second thought, it might be valueable to be able to set
CONFIG_SYS_HZ to the exact value of the actual granularity.
(for example 1024, if a 32kHz based timer is used).

It should be pointed out, that the pair reset_timer()/get_timer()
cannot be used nested,

and MOST IMPORTANT that some implementations of udelay() might
call reset_timer() and therefore break an outer timeout loop !!!

It is also open if reset_timer() does actually reset the hardware timer
(e.g. tbu/tbl at PPC) - which would be messing up any time difference
calculation using get_ticks() - or does emulate that by remembering
the hardware value and subtracting it later in every subsequent
get_timer() call?

2. get_ticks() and friends operate at a higher rate (tbu/tbl for PPC).
Since they are defined as having 64 bits they MUST not wrap at 32 bits,
i.e. if the hardware provides only 32 bits, the upper 32 bits must be
emulated by software.
Otherwise we have to document that get_ticks() cannot be used to get
64 bit time differences.

OR fall back to a 32 bit get_ticks() that should perhaps increment at
a microsecond rate (see Bill Campbell's post).

If you really closely look at the various implementations of those
timers, you will easyly see the wide variations implemented there.

Best Regards,
Reinhard

  reply	other threads:[~2010-10-26 10: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
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 [this message]
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=4CC6AADC.8050608@emk-elektronik.de \
    --to=u-boot@emk-elektronik.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox