All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] sys_rtc01: TCONF on system time mismatch when STA_UNSYNC is unset
@ 2026-11-18 10:17 Cyril Hrubis
  2026-11-18 13:32 ` [LTP] " linuxtestproject.agent
  2026-11-19  3:25 ` [LTP] [PATCH] " Wei Gao via ltp
  0 siblings, 2 replies; 3+ messages in thread
From: Cyril Hrubis @ 2026-11-18 10:17 UTC (permalink / raw)
  To: ltp

It turns out that the STA_UNSYNC flag is set at boot and cleared by ntp,
so we should skip the TFAIL when the flag is cleared, since that means
that NTP have adjusted the system time and it's possibly out of sync
with RTC.

Fixes: 3d11e5dd622e "sys_rtc01: Report TCONF on system time mismatch when STA_UNSYNC is set"
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/sysfs/class/rtc/sys_rtc01.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/testcases/kernel/sysfs/class/rtc/sys_rtc01.c b/testcases/kernel/sysfs/class/rtc/sys_rtc01.c
index 0e1c69f95..4857d4a8b 100644
--- a/testcases/kernel/sysfs/class/rtc/sys_rtc01.c
+++ b/testcases/kernel/sysfs/class/rtc/sys_rtc01.c
@@ -43,12 +43,9 @@
  * test performs, so on a long-running system a purely fixed slack would
  * eventually produce false failures even on perfectly healthy hardware.
  *
- * If the system was booted with an RTC that was off the current time and the
- * system clock was later stepped in userspace via :manpage:`clock_settime(2)`
- * or :manpage:`settimeofday(2)` without updating the RTC, the kernel sets
- * STA_UNSYNC and CONFIG_RTC_SYSTOHC does not write the system clock back to
- * the RTC while hctosys remains 1. Report TCONF instead of TFAIL when
- * since_epoch diverges from system time while STA_UNSYNC is set.
+ * If system time was corrected by NTP the kernel clears STA_UNSYNC flag.
+ * Report TCONF instead of TFAIL when since_epoch diverges from system time
+ * when STA_UNSYNC is not set.
  *
  * Under virtualization the slack is additionally multiplied, since a VM's
  * clock (and thus its emulated RTC) commonly lags real time by tens of
@@ -112,14 +109,14 @@ static long read_hctosys(const char *name)
 	return TST_SYSFS_READ_LI(PATH_CLASS_RTC "/%s/hctosys", name);
 }
 
-static int is_clock_unsynced(void)
+static int clock_is_synced(void)
 {
 	struct timex tx = { .modes = 0 };
 
 	if (adjtimex(&tx) == -1)
 		tst_brk(TBROK | TERRNO, "adjtimex() failed");
 
-	return !!(tx.status & STA_UNSYNC);
+	return !(tx.status & STA_UNSYNC);
 }
 
 static void read_rtc_snapshot(const char *name, char *date, size_t date_size,
@@ -217,9 +214,9 @@ static void check_rtc(const char *name, int any_hctosys)
 			"%s: since_epoch (%lld), system time (%lld), diff %llds <= slack %lds",
 			name, (long long)since_epoch, (long long)sys_epoch,
 			diff, slack);
-	} else if (is_clock_unsynced()) {
+	} else if (clock_is_synced()) {
 		tst_res(TCONF,
-			"%s: since_epoch (%lld), system time (%lld), diff %llds > slack %lds (STA_UNSYNC is set)",
+			"%s: since_epoch (%lld), system time (%lld), diff %llds > slack %lds (STA_UNSYNC is not set)",
 			name, (long long)since_epoch, (long long)sys_epoch,
 			diff, slack);
 	} else {
-- 
2.55.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] sys_rtc01: TCONF on system time mismatch when STA_UNSYNC is unset
  2026-11-18 10:17 [LTP] [PATCH] sys_rtc01: TCONF on system time mismatch when STA_UNSYNC is unset Cyril Hrubis
@ 2026-11-18 13:32 ` linuxtestproject.agent
  2026-11-19  3:25 ` [LTP] [PATCH] " Wei Gao via ltp
  1 sibling, 0 replies; 3+ messages in thread
From: linuxtestproject.agent @ 2026-11-18 13:32 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril,

On Wed Nov 18 11:17:20 2026 +0100, Cyril Hrubis <chrubis@suse.cz> wrote:
> sys_rtc01: TCONF on system time mismatch when STA_UNSYNC is unset

Verdict - Reviewed

---
Note:

The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.

Regards,
LTP AI Reviewer

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] sys_rtc01: TCONF on system time mismatch when STA_UNSYNC is unset
  2026-11-18 10:17 [LTP] [PATCH] sys_rtc01: TCONF on system time mismatch when STA_UNSYNC is unset Cyril Hrubis
  2026-11-18 13:32 ` [LTP] " linuxtestproject.agent
@ 2026-11-19  3:25 ` Wei Gao via ltp
  1 sibling, 0 replies; 3+ messages in thread
From: Wei Gao via ltp @ 2026-11-19  3:25 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

On Wed, Nov 18, 2026 at 11:17:20AM +0100, Cyril Hrubis wrote:
> It turns out that the STA_UNSYNC flag is set at boot and cleared by ntp,
> so we should skip the TFAIL when the flag is cleared, since that means
> that NTP have adjusted the system time and it's possibly out of sync
> with RTC.
> 
> Fixes: 3d11e5dd622e "sys_rtc01: Report TCONF on system time mismatch when STA_UNSYNC is set"

Very nit comments:
  Standard Fixes tag syntax encloses the commit title in parentheses:
  Fixes: 3d11e5dd622e ("sys_rtc01: Report TCONF on system time mismatch when STA_UNSYNC is set")

Reviewed-by: Wei Gao <wegao@suse.com>

> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>  testcases/kernel/sysfs/class/rtc/sys_rtc01.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/testcases/kernel/sysfs/class/rtc/sys_rtc01.c b/testcases/kernel/sysfs/class/rtc/sys_rtc01.c
> index 0e1c69f95..4857d4a8b 100644
> --- a/testcases/kernel/sysfs/class/rtc/sys_rtc01.c
> +++ b/testcases/kernel/sysfs/class/rtc/sys_rtc01.c
> @@ -43,12 +43,9 @@
>   * test performs, so on a long-running system a purely fixed slack would
>   * eventually produce false failures even on perfectly healthy hardware.
>   *
> - * If the system was booted with an RTC that was off the current time and the
> - * system clock was later stepped in userspace via :manpage:`clock_settime(2)`
> - * or :manpage:`settimeofday(2)` without updating the RTC, the kernel sets
> - * STA_UNSYNC and CONFIG_RTC_SYSTOHC does not write the system clock back to
> - * the RTC while hctosys remains 1. Report TCONF instead of TFAIL when
> - * since_epoch diverges from system time while STA_UNSYNC is set.
> + * If system time was corrected by NTP the kernel clears STA_UNSYNC flag.
> + * Report TCONF instead of TFAIL when since_epoch diverges from system time
> + * when STA_UNSYNC is not set.
>   *
>   * Under virtualization the slack is additionally multiplied, since a VM's
>   * clock (and thus its emulated RTC) commonly lags real time by tens of
> @@ -112,14 +109,14 @@ static long read_hctosys(const char *name)
>  	return TST_SYSFS_READ_LI(PATH_CLASS_RTC "/%s/hctosys", name);
>  }
>  
> -static int is_clock_unsynced(void)
> +static int clock_is_synced(void)
>  {
>  	struct timex tx = { .modes = 0 };
>  
>  	if (adjtimex(&tx) == -1)
>  		tst_brk(TBROK | TERRNO, "adjtimex() failed");
>  
> -	return !!(tx.status & STA_UNSYNC);
> +	return !(tx.status & STA_UNSYNC);
>  }
>  
>  static void read_rtc_snapshot(const char *name, char *date, size_t date_size,
> @@ -217,9 +214,9 @@ static void check_rtc(const char *name, int any_hctosys)
>  			"%s: since_epoch (%lld), system time (%lld), diff %llds <= slack %lds",
>  			name, (long long)since_epoch, (long long)sys_epoch,
>  			diff, slack);
> -	} else if (is_clock_unsynced()) {
> +	} else if (clock_is_synced()) {
>  		tst_res(TCONF,
> -			"%s: since_epoch (%lld), system time (%lld), diff %llds > slack %lds (STA_UNSYNC is set)",
> +			"%s: since_epoch (%lld), system time (%lld), diff %llds > slack %lds (STA_UNSYNC is not set)",
>  			name, (long long)since_epoch, (long long)sys_epoch,
>  			diff, slack);
>  	} else {
> -- 
> 2.55.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-19  3:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 10:17 [LTP] [PATCH] sys_rtc01: TCONF on system time mismatch when STA_UNSYNC is unset Cyril Hrubis
2026-11-18 13:32 ` [LTP] " linuxtestproject.agent
2026-11-19  3:25 ` [LTP] [PATCH] " Wei Gao via ltp

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.