All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC] ARM timing code refactoring
Date: Sun, 23 Jan 2011 23:57:58 +0100	[thread overview]
Message-ID: <20110123225758.222691365DB@gemini.denx.de> (raw)
In-Reply-To: <4D3C9BFC.1010907@emk-elektronik.de>

Dear Reinhard Meyer,

In message <4D3C9BFC.1010907@emk-elektronik.de> you wrote:
>
> >> get_timer() returns a monotonous upward counting time stamp with a
> >> resolution of milliseconds. After reaching ULONG_MAX the timer wraps
> >> around to 0.
> 
> Exactly that wrap makes the situation so complicated, since the simple code
> u32 get_timer(void)
> {
>   return (ticks * 1000ULL) / tickspersec;
> }
> won't do that wrap.

Do you have a better suggestion?

> >> The get_timer() implementation may be interrupt based and is only
> >> available after relocation.
> 
> Currently it is used before relocation in some places, I think I have
> seen it in NAND drivers... That would have to be changed then.

Indeed.  It is unreliable or even broken now.

> This is already implemented functionally very closely (apart from factoring and the
> get_timer(void) change) to this in AT91, the only (academic) hitch is that it will
> burp a few billion years after each reset :)

> What bothers me is the need for 64 bit mul/div in each loop iteration, for CPUs without
> hardware for that this might slow down data transfer loops of the style
> 
> u32 start_time = get_timer();
> do {
> 	if ("data_ready")
> 		/* transfer a byte */
> 	if (get_timer() - start_time > timeout)
> 		/* fail and exit loop */
> } while (--"bytestodo" > 0);
> 
> since get_timer() will be somewhat like:
> 
> 	return (tick * 1000ULL) / tickspersec;
> 
> As I stated before, tickspersec is a variable in, for example, AT91. So the
> expression cannot be optimized by the compiler.

I don't think this is the only way to implement this. How does Linux
derive time info from jiffies?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You get a wonderful view from the point of no return.
                                    - Terry Pratchett, _Making_Money_

  parent reply	other threads:[~2011-01-23 22:57 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-22 10:20 [U-Boot] [RFC] ARM timing code refactoring Albert ARIBAUD
2011-01-22 10:42 ` Reinhard Meyer
2011-01-22 11:32   ` Albert ARIBAUD
2011-01-22 11:00 ` [U-Boot] [RFC] U-boot (was: ARM) " Reinhard Meyer
2011-01-22 12:22   ` [U-Boot] [RFC] U-boot Albert ARIBAUD
2011-01-22 19:19 ` [U-Boot] [RFC] ARM timing code refactoring Wolfgang Denk
2011-01-22 20:17   ` Albert ARIBAUD
2011-01-22 21:26     ` Wolfgang Denk
2011-01-22 21:51       ` Reinhard Meyer
2011-01-23 10:12         ` Wolfgang Denk
2011-01-23 10:26           ` Reinhard Meyer
2011-01-23 16:23             ` Wolfgang Denk
2011-01-23 18:47               ` Reinhard Meyer
2011-01-23 19:35                 ` Wolfgang Denk
2011-01-23 20:59                   ` Albert ARIBAUD
2011-01-23 21:22                     ` Reinhard Meyer
2011-01-23 22:01                       ` Reinhard Meyer
2011-01-23 22:57                       ` Wolfgang Denk [this message]
2011-01-24  1:42                         ` J. William Campbell
2011-01-24  7:24                           ` Albert ARIBAUD
2011-01-24  7:50                             ` Reinhard Meyer
2011-01-24 12:59                               ` Wolfgang Denk
2011-01-24  8:25                             ` Andreas Bießmann
2011-01-24 11:58                               ` Albert ARIBAUD
2011-01-24 12:06                                 ` Albert ARIBAUD
2011-01-24 12:58                                 ` Andreas Bießmann
2011-01-24 12:54                             ` Wolfgang Denk
2011-01-24 13:02                             ` Wolfgang Denk
2011-01-24 16:23                               ` J. William Campbell
2011-01-22 22:13       ` Albert ARIBAUD
2011-01-23 16:15         ` Wolfgang Denk

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=20110123225758.222691365DB@gemini.denx.de \
    --to=wd@denx.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 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.