Skip to content

ntp/rtc: Fixes and cleanups

Thomas Gleixner linux-renesas-soc linux-rtc lkml 1 version Applied

Status from this message: The following commit has been merged into the timers/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 21 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/8rtc: mc146818: Prevent reading garbagedrivers/rtc/rtc-mc146818-lib.c+39 -2518 replies
2/8rtc: mc146818: Reduce spinlock section in mc146818_set_time()drivers/rtc/rtc-mc146818-lib.c+2 -40 replies
3/8rtc: cmos: Make rtc_cmos sync offset correctdrivers/rtc/rtc-cmos.c+3 -01 reply
4/8rtc: core: Make the sync offset default more realisticdrivers/rtc/class.c+1 -14 replies
5/8ntp: Make the RTC synchronization more reliableinclude/linux/timex.h kernel/time/ntp.c kernel/time/ntp_internal.h+55 -435 replies
6/8ntp, rtc: Move rtc_set_ntp_time() to ntp codedrivers/rtc/Makefile drivers/rtc/systohc.c include/linux/rtc.h +1 more+85 -992 replies
7/8ntp: Make the RTC sync offset less obscuredrivers/rtc/class.c drivers/rtc/rtc-cmos.c include/linux/rtc.h +1 more+62 -330 replies
8/8ntp: Consolidate the RTC update implementationkernel/time/ntp.c+47 -922 replies

Reviews trailers per patch

6 of 8 patches have a Reviewed-by or Acked-by.

PatchAlexandre BelloniMiroslav LichvarJason GunthorpeMickaël SalaünBorislav PetkovLen Brown
1/8A-b A-b T-b T-b T-b T-b T-b
2/8
3/8R-b
4/8A-b R-b
5/8T-b R-b
6/8Requested-by R-b
7/8
8/8R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 6 reviewers.

Read the v1 thread

Cover letter [patch 0/8] ntp/rtc: Fixes and cleanups

Miroslav ran into a situation where the periodic RTC synchronization almost never was able to hit the time window for the update. That happens due the usage of delayed_work and the properties of the timer wheel.

While that particular problem is halfways simple to fix this started to unearth other problems with that code particularly with rtc_set_npt_time() but expanded into other things as well.

1) The update offset for rtc-cmos is off by a full second

2) The readout of MC146818 (rtc-cmos and arch code) is broken and can return garbage.

2) Alexandre questioned the approach in general and wants to get rid of it. Of course there are better methods to do that and it can be completely done in user space.

Unfortunately it's not that simple as this would be a user visible change, so making it at least halfways correct.

3) Alexandre requested to move that code into the NTP code as this is not really RTC functionality and just usage of the RTC API.

4) The update offset itself was questioned, but the time between the write and the next seconds increment in the RTC is fundamentaly a hardware property. The transport time, which is pretty irrelevant for direct accessible RTCs (rtc-cmos), but relevant for RTC behind i2c/SPI needs to be added on top.

It's undebated that this transport time cannot be correctly estimated, but right now it's 500ms which is far off. The correct transport time can be calibrated, a halfways correct value supplied via DT, but that's an orthogonal problem.

The following series addresses the above:

1) Fix the readout function of MC146818
2) Fix the rtc-cmos offset
3) Reduce the default transport time

4) Switch the NTP periodic sync code to a hrtimer/work combo

5) Move rtc_set_npt_time() to the ntp code
6) Make the update offset more intuitive
7) Simplify the whole machinery

Thanks,

tglx

---
 a/drivers/rtc/systohc.c        |   61 ----------
 drivers/rtc/Makefile           |    1 
 drivers/rtc/class.c            |    9 +
 drivers/rtc/rtc-cmos.c         |    3 
 drivers/rtc/rtc-mc146818-lib.c |   70 +++++++-----
 include/linux/rtc.h            |   69 +++++-------
 include/linux/timex.h          |    1 
 kernel/time/ntp.c              |  232 ++++++++++++++++++++++++-----------------
 kernel/time/ntp_internal.h     |    7 +
 9 files changed, 225 insertions(+), 228 deletions(-)