> -----Original Message----- > From: Richard Cochran [mailto:richardcoch...@gmail.com] > Sent: Saturday, April 04, 2015 1:27 PM > To: Keller, Jacob E > Cc: linuxptp-devel@lists.sourceforge.net > Subject: Re: [Linuxptp-devel] timecounter mask for non-bitwise > overflowing? > > On Sat, Apr 04, 2015 at 12:47:15AM +0000, Keller, Jacob E wrote: > > Hey Richard, and others, > > > > I am currently implementing a timecounter setup for a device which > > (nominally) represents time as > > > > Field1: 32bits, Seconds > > Field2: 32bits, Nanoseconds (never > 999,999,999) > > > > I do the math to convert this to u64 nanoseconds, and provide this to a > > cycle counter. > > So, I guess you want to do this because your HW has this split > representation, but you cannot adjust the frequency?
Several reasons: 1) consistency with the rest of the hardware in the driver 2) atomic time increments (I have a patch I want to propose that will enable atomic time increment for timecounters by just adding or subtracting from the offset) 3) hardware may have to change the frequency of the clock driving the system timer, so even though it was supposed to represent nominal seconds and nanoseconds, it won't actually, since the underlying clock won't be running at the right frequency). 4) support the gettime64/settime64 routines via the timecounter. > > > I think the timecounter code is actually incorrect, because it doesn't > > allow for arbitrary overflow points.... > > I think the timecounter is okay. Your problem is that the timecounter > uses base-2 counting, but your clock counts 10^9 nanoseconds (base-10). > > > Any suggestions or thoughts on the timecounter stuff? > > 32 bits of seconds gives you 136 years of uptime (assuming the counter > starts at zero). You can just use a 64 bit mask and forget about the > overflow, since it can never happen in practice. > Ok. That's what I was thinking. I would prefer that it not happen at all, but it really is a non-issue as you said. > > HTH, > Richard ------------------------------------------------------------------------------ BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT Develop your own process in accordance with the BPMN 2 standard Learn Process modeling best practices with Bonita BPM through live exercises http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_ source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel