public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [Patch 02/17] U-Boot-V2:Common:Clock Handle case of	clockrollover for get_time_ns
Date: Tue, 3 Jun 2008 16:14:48 +0200	[thread overview]
Message-ID: <20080603141448.GB897@pengutronix.de> (raw)
In-Reply-To: <8E8BB316C604E94AA019A54D0A5A82A201BB5297@dlee13.ent.ti.com>

On Tue, Jun 03, 2008 at 07:47:25AM -0500, Menon, Nishanth wrote:
> Sascha,
> > -----Original Message-----
> > From: Sascha Hauer [mailto:s.hauer at pengutronix.de]
> > Sent: Tuesday, June 03, 2008 3:08 AM
> > To: Menon, Nishanth
> > Cc: u-boot-users at lists.sourceforge.net; Laurent Desnogues; dirk.behme at googlemail.com;
> > philip.balister at gmail.com; Gopinath, Thara; Kamat, Nishant; Syed Mohammed, Khasim
> > Subject: Re: [Patch 02/17] U-Boot-V2:Common:Clock Handle case of clockrollover for get_time_ns
> > > -        cycle_delta = (cycle_now - cs->cycle_last) & cs->mask;
> > 
> > Look closer, the rollover case is handled implicitly by the unsigned
> > arithmetics.
> Agreed for logic when mask is the max value attainable.
> IMHO, The concept of cs->mask is messy. We do need a min, max and a mask.
> When:
> 	cycle_now = cs->read();
> 	cs->cycle_last = cycle_now;

Now cycle_now == cs->cycle_last...

> (cycle_now - cs->cycle_last) & cs->mask is wrong. 

...so 0 & cs->mask = 0

This makes no sense, but this is not the order of execution in current
code.

> Assumptions made:
> A) The bits masked out by cs->mask will remain constant. This may not be true.

Eh? That's why they are masked out.

> B) Roll over assume the min is 0 and max is cs->mask. This need not be the case.
> It would be good to be explicit.

Do you know any counter that does not start counting from zero? If you
have, noone prevents you from substracting the value in your clocksource
read function.


> > 
> > You are right, we do not have a possibility to detect a double rollover
> > without interrupts. Normally this is not an issue as this code is used
> > in timeout polling loops where the current time is polled often enough.
> > Anyway, maybe some comment should mention that this function is not
> > useful to measure long periods of time where 'long' is highly
> > architecture specific.
> >
> Yes, there are indenting issue + no doxygen documentation.. It helps as clock_source is critical implementation required in the system.
> 
> Regards,
> Nishanth Menon
> 

-- 
Pengutronix e.K. - Linux Solutions for Science and Industry
-----------------------------------------------------------
Kontakt-Informationen finden Sie im Header dieser Mail oder
auf der Webseite -> http://www.pengutronix.de/impressum/ <-

  reply	other threads:[~2008-06-03 14:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-21 16:25 [U-Boot-Users] [Patch 02/17] U-Boot-V2:Common:Clock Handle case of clock rollover for get_time_ns Menon, Nishanth
2008-06-03  8:07 ` Sascha Hauer
2008-06-03 12:47   ` [U-Boot-Users] [Patch 02/17] U-Boot-V2:Common:Clock Handle case of clockrollover " Menon, Nishanth
2008-06-03 14:14     ` Sascha Hauer [this message]
2008-06-03 14:39       ` [U-Boot-Users] [Patch 02/17] U-Boot-V2:Common:Clock Handle case ofclockrollover " Menon, Nishanth
2008-06-03 15:14         ` Sascha Hauer
2008-06-03 16:27           ` [U-Boot-Users] [Patch 02/17 Try 2] U-Boot-V2:Common:Clock Handle caseofclockrollover " Menon, Nishanth

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=20080603141448.GB897@pengutronix.de \
    --to=s.hauer@pengutronix.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