From: Wake Liu via ltp <ltp@lists.linux.it>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: Wake Liu <wakel@google.com>,
ltp@lists.linux.it, linuxtestproject.agent@gmail.com
Subject: Re: [LTP] sys_rtc01: Report TCONF on system time mismatch when STA_UNSYNC is set
Date: Wed, 18 Nov 2026 13:18:08 +0000 [thread overview]
Message-ID: <20261118131808.682117-1-wakel@google.com> (raw)
In-Reply-To: <av16AqIo5sj10FEv@yuki.lan>
Hi Cyril,
> Hmm, I guess that the logic should be the other way, if STA_UNSYNC is
> not set the clock was modified by NTP and the test should be skipped:
I think the logic in 3d11e5dd622e as applied is the right way around;
inverting it would bring back the failure this patch fixes.
In kernel/time/ntp.c, the kernel writes the system time back to the RTC
only while STA_UNSYNC is clear: sync_hw_clock() returns early if
!ntp_synced(), and do_adjtimex() queues sync_work via
ntp_notify_cmos_timer() once an NTP daemon clears STA_UNSYNC. With
CONFIG_RTC_SYSTOHC=y on a writable RTC, the NTP-corrected time is
written to the RTC within a few seconds and then every 11 minutes, so
since_epoch is expected to match system time. (That is also how
leapsec01 ended up writing its fake 23:59:58 into rtc0 when it cleared
STA_UNSYNC [1].)
Conversely, STA_UNSYNC set is the state where nothing keeps the RTC in
sync: it is set at boot, and every clock_settime(), settimeofday(), or
ADJ_SETOFFSET sets it again via ntp_clear(). On Android test devices,
for example, the harness sets the clock with date(1) after boot and no
NTP daemon clears STA_UNSYNC, so rtc0 stays at its boot-time offset
("diff 24441s > slack 10s"). chronyd without rtcsync behaves the same
way: it disciplines the system clock while leaving STA_UNSYNC set. With
the inverted check, all of these would hit TFAIL again, while systems
actively syncing the RTC via SYSTOHC would report TCONF.
The reviewer is right on two limitations:
1. When STA_UNSYNC is set, userspace cannot tell a broken RTC apart
from a system clock stepped after boot, though the since_epoch vs
date/time check still runs on all systems.
2. When STA_UNSYNC is clear, the RTC can still diverge if
CONFIG_RTC_SYSTOHC is disabled (or points to a different RTC), or if
the RTC driver is read-only / does not support set_time.
Do you think it is worth sending a follow-up to also check
CONFIG_RTC_SYSTOHC / CONFIG_RTC_SYSTOHC_DEVICE (when kernel config is
available), or would you prefer to keep 3d11e5dd622e as-is and just
note the read-only / non-SYSTOHC case in the comment?
[1] https://lore.kernel.org/ltp/20261116064205.2360040-1-wakel@google.com/
Best regards,
Wake
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-11-18 13:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 23:58 [LTP] [PATCH] sys_rtc01: Report TCONF on system time mismatch when STA_UNSYNC is set Wake Liu via ltp
2026-11-18 4:49 ` [LTP] " linuxtestproject.agent
2026-11-18 10:12 ` Cyril Hrubis
2026-11-18 13:18 ` Wake Liu via ltp [this message]
2026-11-19 7:55 ` Cyril Hrubis
2026-11-18 9:23 ` [LTP] [PATCH] " Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118131808.682117-1-wakel@google.com \
--to=ltp@lists.linux.it \
--cc=chrubis@suse.cz \
--cc=linuxtestproject.agent@gmail.com \
--cc=wakel@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox