git: 762dcf106412 - main - goldfish_rtc: Fix handling a local time RTC
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 14 Aug 2022 18:50:29 UTC
The branch main has been updated by jrtc27:
URL: https://cgit.FreeBSD.org/src/commit/?id=762dcf10641251c55dda2e6950fef8bb698027ad
commit 762dcf10641251c55dda2e6950fef8bb698027ad
Author: Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2022-08-14 18:50:22 +0000
Commit: Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2022-08-14 18:50:22 +0000
goldfish_rtc: Fix handling a local time RTC
The default QEMU config is to have the RTC in UTC. However, if run with
-rtc base=localtime (and wall_cmos_clock is set to match), the driver
fails to account for adjkerntz due to the use of CLOCKF_SETTIME_NO_ADJ.
Copy the same code used by other CLOCKF_SETTIME_NO_ADJ-using drivers
to fix this, namely manually subtracting utc_offset().
Fixes: d63a631e7244 ("Add Goldfish RTC device driver for RISC-V")
MFC after: 1 week
---
sys/dev/goldfish/goldfish_rtc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sys/dev/goldfish/goldfish_rtc.c b/sys/dev/goldfish/goldfish_rtc.c
index 6cd209ff5872..31b671cd4b3e 100644
--- a/sys/dev/goldfish/goldfish_rtc.c
+++ b/sys/dev/goldfish/goldfish_rtc.c
@@ -151,6 +151,11 @@ goldfish_rtc_settime(device_t dev, struct timespec *ts)
sc = device_get_softc(dev);
+ /*
+ * We request a timespec with no resolution-adjustment. That also
+ * disables utc adjustment, so apply that ourselves.
+ */
+ ts->tv_sec -= utc_offset();
nsec = (uint64_t)ts->tv_sec * 1000000000 + ts->tv_nsec;
mtx_lock(&sc->mtx);