On Thu, Dec 03, 2020 at 10:31:02PM +0100, Thomas Gleixner wrote: > On Thu, Dec 03 2020 at 22:05, Thomas Gleixner wrote: > > On Thu, Dec 03 2020 at 12:16, Jason Gunthorpe wrote: > > So now we have two options to fix this: > > > > 1) Use a negative sync_offset for devices which need #1 above > > (rtc_cmos & similar) > > > > That requires setting tsched to t2 - abs(sync_offset) > > > > 2) Use always a positive sync_offset and a flag which tells > > rtc_tv_nsec_ok() whether it needs to add or subtract. > > > > #1 is good enough. All it takes is a comment at the timer start code why > > abs() is required. > > > > Let me hack that up along with the hrtimer muck. > > That comment in rtc.h makes me cry: > > /* Number of nsec it takes to set the RTC clock. This influences when > * the set ops are called. An offset: > * - of 0.5 s will call RTC set for wall clock time 10.0 s at 9.5 s > * - of 1.5 s will call RTC set for wall clock time 10.0 s at 8.5 s > * - of -0.5 s will call RTC set for wall clock time 10.0 s at 10.5 s > */ > > Setting the wall clock time 10.0 at 10.5 is only possible for time > traveling RTCs. It magically works, but come on ... No tardis required. You can think of storing to a RTC as including a millisecond component, so the three examples are: 10.0 stores 9.5, 10.0 stores 8.5, 10.0 stores 10.5. It was probably included due to cmos, either as a misunderstanding what it does, or it does actually store 10.5 when you store 10.0.. Jason