Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 06 Aug 2022 10:18:50 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 264729] RTC clock is set incorrectly upon resume if NTP is in use
Message-ID:  <bug-264729-227-iwX5l7Y0Qb@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-264729-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-264729-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D264729

--- Comment #1 from crahman@gmail.com ---
Created attachment 235719
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D235719&action=
=3Dedit
Patch to correct problem

To provide a more precise description of the problem:

After ntp is synced and ntp_is_time_error() returns true, when
periodic_resettodr() is run every 1800 or so seconds as a callout, it saves=
 the
current system time to the RTC clocks.

During a resume, after a suspend, it runs immediately, before inittodr().=20
inittodr() sets the system time based upon the RTC clocks.  But because
periodic_resettodr() runs first, it puts the uninitialized system time into=
 the
RTC, which is then used to initialize the system time.

As a result, if a suspend/resume is done while ntp is synced, the time will=
 be
incorrect.

The problem may be solved by writing the system time to the RTC before the
suspend, and cancelling the callout.  Upon wakeup, after the RTC clock is r=
ead,
the callout can be started again.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-264729-227-iwX5l7Y0Qb>