
On Tue, Jun 03, 2008 at 09:39:51AM -0500, Menon, Nishanth wrote:
Sascha,
-----Original Message----- From: Sascha Hauer [mailto:s.hauer@pengutronix.de] Sent: Tuesday, June 03, 2008 9:15 AM To: Menon, Nishanth Cc: u-boot-users@lists.sourceforge.net; Laurent Desnogues; dirk.behme@googlemail.com; philip.balister@gmail.com; Gopinath, Thara; Kamat, Nishant; Syed Mohammed, Khasim Subject: Re: [Patch 02/17] U-Boot-V2:Common:Clock Handle case ofclockrollover for get_time_ns
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.
For the sake of discussion: unsigned int now = 0x120; unsigned int last = 0x128; unsigned int mask = 0xFFF0; unsigned int delta1 = now - last; unsigned int delta2 = (now & mask) - (last & mask); printf ("delta1=0x%08X maskdelta1=0x%08X delta2=0x%08X\n",delta1, delta1 & mask, delta2);
Output will be: delta1=0xFFFFFFF8 maskdelta1=0x0000FFF0 delta2=0x00000000
What we will get now is maskdelta1, while delta2 is the right value.
It's not that I thought of the code by myself, I just looked into the kernel and it's exactly like this in the kernel code. So you either just found a kernel bug or we both understand something wrong.
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
I do not. I am just being a paranoid idiot ;)..
have, noone prevents you from substracting the value in your clocksource read function.
Max however is assumed to be cs->mask then. We could have timers which can be configured for ticking till a configured max. probably my paranoia kicking in again?
If that's the only possibility to program this timer then go out and kill the chip designer ;)
Sascha
Regards, Nishanth Menon