Skip to content

rtc-cmos,rtc-mc146818-lib: fixes

Mateusz Jończyk linux-alpha linux-rtc lkml stable 7 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest9 patches 3 repliesIn review
  2. v49 patches 0 repliesSuperseded
  3. v3 posting 2/27 patches 12 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v3 posting 1/27 patches0 repliesSuperseded
v26 patches1 replySuperseded
v1 posting 2/26 of 7 patches2 repliesSuperseded
v1 posting 1/21 patch1 replySuperseded

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9rtc-cmos: take rtc_lock while reading from CMOSdrivers/rtc/rtc-cmos.c+3 -00 replies
2/9rtc: change return values of mc146818_get_time()drivers/rtc/rtc-mc146818-lib.c+2 -20 replies
3/9Check return value from mc146818_get_time()arch/alpha/kernel/rtc.c arch/x86/kernel/hpet.c drivers/base/power/trace.c +2 more+26 -60 replies
4/9rtc-mc146818-lib: fix RTC presence checkdrivers/rtc/rtc-cmos.c drivers/rtc/rtc-mc146818-lib.c include/linux/mc146818rtc.h+35 -100 replies
5/9rtc-mc146818-lib: extract mc146818_avoid_UIPdrivers/rtc/rtc-mc146818-lib.c include/linux/mc146818rtc.h+73 -00 replies
6/9rtc-mc146818-lib: refactor mc146818_get_timedrivers/rtc/rtc-mc146818-lib.c+42 -670 replies
7/9rtc-mc146818-lib: refactor mc146818_does_rtc_workdrivers/rtc/rtc-mc146818-lib.c+1 -160 replies
8/9rtc-cmos: avoid UIP when reading alarm timedrivers/rtc/rtc-cmos.c+49 -232 replies
9/9rtc-cmos: avoid UIP when writing alarm timedrivers/rtc/rtc-cmos.c+66 -410 replies

Reviews trailers per patch

1 of 9 patches has a Reviewed-by or Acked-by.

PatchNobuhiro Iwamatsu
1/9R-b
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [PATCH v5 0/9] rtc-cmos,rtc-mc146818-lib: fixes

Hello,

This patch series fixes some issues in the RTC CMOS handling code:

1. A missing spin_lock_irq() / spin_unlock_irq() pair in cmos_set_alarm().
2. A failing presence check of the RTC: the clock was misdetected as broken since Linux 5.11 on one of our home systems.
3. Do not touch the RTC alarm registers when the RTC update is in progress. (On some Intel chipsets, this causes bogus values being read or writes to fail silently.)

This is my first patch series, so please review carefully.

v2: Drop the last patch:
Revert "rtc: cmos: Replace spin_lock_irqsave with spin_lock in hard IRQ"
which was made obsolete by mainlining of
commit 13be2efc390a ("rtc: cmos: Disable irq around direct invocation of cmos_interrupt()")

v3: Rework solution to problem 3 (I'd like to thank Greg KH for comment), drop x86 refactoring patches (I'll send them later).

v4: Fixed some issues pointed out by Mr Alexandre Belloni:
- do not add strings to rtc-mc146818-lib.c - I moved the error printing code to callers of mc146818_get_time(). This resulted in two new patches in the series,
- other small issues.

v5: Increase maximum accepted duration of the UIP high pulse from 10 to 20ms,
in case there are some very slow chips out there.

Note: this may cause problems with hpet_rtc_interrupt() if the CMOS RTC stops working while the system is running and RTC update interrupt / RTC alarm interrupt is enabled (which should be rare). In this case, hpet_rtc_interrupt() is executed 64 times per second and takes up to 20ms to complete - which may constantly occupy one CPU. I am not sure if this is likely enough to implement special handling of this case in hpet_rtc_interrupt().

I have noticed that mach_get_cmos_time() in arch/x86/kernel/rtc.c performs a similar function to mc146818_get_time() in drivers/rtc/rtc-cmos.c . In the future, I'm going to post a new series that removes this duplicated code and makes mach_get_cmos_time() use mc146818_get_time(). This will likely include reducing polling interval in mc146818_avoid_UIP() from 1ms to 100us to make it more similar to mach_get_cmos_time()'s current behaviour.

Greetings,
Mateusz

Cc Alessandro Zummo <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc Greg KH <[email protected]>