summaryrefslogtreecommitdiff
path: root/sys/dev/pci/mfii.c
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2020-06-24 22:03:46 +0000
committercheloha <cheloha@cvs.openbsd.org>2020-06-24 22:03:46 +0000
commitca98724d303a2d2852e5afc6ca4f8df91ce7c4f1 (patch)
tree78c03b913ca4a13ca82e30fea2eea3633977a5a0 /sys/dev/pci/mfii.c
parentd5d00fdfec2707a72d8f409ed3069c27bc916b04 (diff)
kernel: use gettime(9)/getuptime(9) in lieu of time_second(9)/time_uptime(9)
time_second(9) and time_uptime(9) are widely used in the kernel to quickly get the system UTC or system uptime as a time_t. However, time_t is 64-bit everywhere, so it is not generally safe to use them on 32-bit platforms: you have a split-read problem if your hardware cannot perform atomic 64-bit reads. This patch replaces time_second(9) with gettime(9), a safer successor interface, throughout the kernel. Similarly, time_uptime(9) is replaced with getuptime(9). There is a performance cost on 32-bit platforms in exchange for eliminating the split-read problem: instead of two register reads you now have a lockless read loop to pull the values from the timehands. This is really not *too* bad in the grand scheme of things, but compared to what we were doing before it is several times slower. There is no performance cost on 64-bit (__LP64__) platforms. With input from visa@, dlg@, and tedu@. Several bugs squashed by visa@. ok kettenis@
Diffstat (limited to 'sys/dev/pci/mfii.c')
-rw-r--r--sys/dev/pci/mfii.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/dev/pci/mfii.c b/sys/dev/pci/mfii.c
index 6c399712763..3eadcdf81db 100644
--- a/sys/dev/pci/mfii.c
+++ b/sys/dev/pci/mfii.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfii.c,v 1.70 2020/06/24 18:59:30 krw Exp $ */
+/* $OpenBSD: mfii.c,v 1.71 2020/06/24 22:03:41 cheloha Exp $ */
/*
* Copyright (c) 2012 David Gwynne <dlg@openbsd.org>
@@ -1966,7 +1966,7 @@ mfii_initialise_firmware(struct mfii_softc *sc)
htolem32(&iiq->system_request_frame_base_address_hi,
MFII_DMA_DVA(sc->sc_requests) >> 32);
- iiq->timestamp = htole64(time_uptime);
+ iiq->timestamp = htole64(getuptime());
ccb = scsi_io_get(&sc->sc_iopool, SCSI_NOSLEEP);
if (ccb == NULL) {