From f53d796ad2c3cc060cbbd4764c6284ecc37d2efd Mon Sep 17 00:00:00 2001 From: cheloha Date: Fri, 2 Sep 2022 21:33:51 +0000 Subject: [PATCH] vmd(8): compute i8254 read-back command latch from singular timestamp The intent of the i8254 read-back command is (most likely) to permit simultaneously latching two or three counters at once along with their statuses. To simulate this, we should compute olatch from one timestamp per read-back command, not one timestamp per counter. Improved with a tweak by dv@. Link: https://marc.info/?l=openbsd-tech&m=166213670605453&w=2 ok dv@ mlarkin@ --- usr.sbin/vmd/i8253.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/vmd/i8253.c b/usr.sbin/vmd/i8253.c index a745adf6ea0..20762c26378 100644 --- a/usr.sbin/vmd/i8253.c +++ b/usr.sbin/vmd/i8253.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i8253.c,v 1.34 2021/06/16 16:55:02 dv Exp $ */ +/* $OpenBSD: i8253.c,v 1.35 2022/09/02 21:33:51 cheloha Exp $ */ /* * Copyright (c) 2016 Mike Larkin * @@ -137,9 +137,9 @@ i8253_do_readback(uint32_t data) /* !TIMER_RB_COUNT == enable counter readback */ if (data & ~TIMER_RB_COUNT) { + clock_gettime(CLOCK_MONOTONIC, &now); for (i = 0; i < 3; i++) { if (data & readback_channel[i]) { - clock_gettime(CLOCK_MONOTONIC, &now); timespecsub(&now, &i8253_channel[i].ts, &delta); ns = delta.tv_sec * 1000000000 + delta.tv_nsec; ticks = ns / NS_PER_TICK; -- 2.20.1