[Bug 264729] RTC clock is set incorrectly upon resume if NTP is in use

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 06 Aug 2022 10:18:50 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264729

--- Comment #1 from crahman@gmail.com ---
Created attachment 235719
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=235719&action=edit
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(). 
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 read,
the callout can be started again.

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