diff options
author | Thorsten Lockert <tholo@cvs.openbsd.org> | 2004-06-24 19:35:28 +0000 |
---|---|---|
committer | Thorsten Lockert <tholo@cvs.openbsd.org> | 2004-06-24 19:35:28 +0000 |
commit | c6cc17e855e1d9fe177fba41d00de6e89fdc852e (patch) | |
tree | bdc6bde04c820ca59fe49d60185cf6ac40b44e30 /sys/dev | |
parent | 128dd71ffeec48b94e085c757b3626553d619e7c (diff) |
This moves access to wall and uptime variables in MI code,
encapsulating all such access into wall-defined functions
that makes sure locking is done as needed.
It also cleans up some uses of wall time vs. uptime some
places, but there is sure to be more of these needed as
well, particularily in MD code. Also, many current calls
to microtime() should probably be changed to getmicrotime(),
or to the {,get}microuptime() versions.
ok art@ deraadt@ aaron@ matthieu@ beck@ sturm@ millert@ others
"Oh, that is not your problem!" from miod@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/isp_openbsd.h | 18 | ||||
-rw-r--r-- | sys/dev/ic/nslm7x.c | 18 | ||||
-rw-r--r-- | sys/dev/ic/smc90cx6.c | 12 | ||||
-rw-r--r-- | sys/dev/pci/ncr.c | 14 | ||||
-rw-r--r-- | sys/dev/raidframe/rf_etimer.h | 12 | ||||
-rw-r--r-- | sys/dev/usb/usb.c | 8 | ||||
-rw-r--r-- | sys/dev/wscons/wskbd.c | 6 | ||||
-rw-r--r-- | sys/dev/wscons/wsmouse.c | 7 | ||||
-rw-r--r-- | sys/dev/wscons/wsmux.c | 6 |
9 files changed, 41 insertions, 60 deletions
diff --git a/sys/dev/ic/isp_openbsd.h b/sys/dev/ic/isp_openbsd.h index 8969ca5cad8..af343770bea 100644 --- a/sys/dev/ic/isp_openbsd.h +++ b/sys/dev/ic/isp_openbsd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: isp_openbsd.h,v 1.24 2003/03/30 16:57:42 krw Exp $ */ +/* $OpenBSD: isp_openbsd.h,v 1.25 2004/06/24 19:35:23 tholo Exp $ */ /* * OpenBSD Specific definitions for the Qlogic ISP Host Adapter */ @@ -125,10 +125,10 @@ struct isposinfo { if (!MUST_POLL(isp)) \ ISP_LOCK(isp) -#define NANOTIME_T struct timeval -#define GET_NANOTIME microtime -#define GET_NANOSEC(x) (((x)->tv_sec * 1000000 + (x)->tv_usec) * 1000) -#define NANOTIME_SUB isp_microtime_sub +#define NANOTIME_T struct timespec +#define GET_NANOTIME nanotime +#define GET_NANOSEC(x) (((x)->tv_sec * 1000000000 + (x)->tv_nsec)) +#define NANOTIME_SUB isp_nanotime_sub #define MAXISPREQUEST(isp) 256 @@ -307,7 +307,7 @@ void isp_uninit(struct ispsoftc *); static INLINE void isp_lock(struct ispsoftc *); static INLINE void isp_unlock(struct ispsoftc *); static INLINE u_int64_t -isp_microtime_sub(struct timeval *, struct timeval *); +isp_nanotime_sub(struct timespec *, struct timespec *); static void isp_wait_complete(struct ispsoftc *); /* @@ -365,11 +365,11 @@ isp_unlock(struct ispsoftc *isp) } static INLINE u_int64_t -isp_microtime_sub(struct timeval *b, struct timeval *a) +isp_nanotime_sub(struct timespec *b, struct timespec *a) { - struct timeval x; + struct timespec x; u_int64_t elapsed; - timersub(b, a, &x); + timespecsub(b, a, &x); elapsed = GET_NANOSEC(&x); if (elapsed == 0) elapsed++; diff --git a/sys/dev/ic/nslm7x.c b/sys/dev/ic/nslm7x.c index 30866f69603..d6e8aa62cdd 100644 --- a/sys/dev/ic/nslm7x.c +++ b/sys/dev/ic/nslm7x.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nslm7x.c,v 1.7 2004/05/07 07:00:46 grange Exp $ */ +/* $OpenBSD: nslm7x.c,v 1.8 2004/06/24 19:35:23 tholo Exp $ */ /* $NetBSD: nslm7x.c,v 1.17 2002/11/15 14:55:41 ad Exp $ */ /*- @@ -376,22 +376,18 @@ lm_gtredata(sme, tred) struct envsys_tre_data *tred; { static const struct timeval onepointfive = { 1, 500000 }; - struct timeval t; + struct timeval t, mtv; struct lm_softc *sc = sme->sme_cookie; - int i, s; + int i; /* read new values at most once every 1.5 seconds */ timeradd(&sc->lastread, &onepointfive, &t); - s = splclock(); - i = timercmp(&mono_time, &t, >); + getmicrouptime(&mtv); + i = timercmp(&mtv, &t, >); if (i) { - sc->lastread.tv_sec = mono_time.tv_sec; - sc->lastread.tv_usec = mono_time.tv_usec; - } - splx(s); - - if (i) + sc->lastread = mtv; sc->refresh_sensor_data(sc); + } *tred = sc->sensors[tred->sensor]; diff --git a/sys/dev/ic/smc90cx6.c b/sys/dev/ic/smc90cx6.c index d011c1308c8..72f09855f94 100644 --- a/sys/dev/ic/smc90cx6.c +++ b/sys/dev/ic/smc90cx6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smc90cx6.c,v 1.9 2004/06/21 23:50:35 tholo Exp $ */ +/* $OpenBSD: smc90cx6.c,v 1.10 2004/06/24 19:35:23 tholo Exp $ */ /* $NetBSD: smc90cx6.c,v 1.17 1996/05/07 01:43:18 thorpej Exp $ */ /* @@ -667,10 +667,7 @@ bah_start(ifp) sc->sc_arccom.ac_if.if_timer = ARCTIMEOUT; #ifdef BAHTIMINGS - bcopy((caddr_t)&time, - (caddr_t)&(sc->sc_stats.lasttxstart_tv), - sizeof(struct timeval)); - + getmicrotime(&sc->sc_stats.lasttxstart_tv); sc->sc_stats.lasttxstart_mics = clkread(); #endif } @@ -979,10 +976,7 @@ bah_tint(sc, isr) ifp->if_timer = ARCTIMEOUT; #ifdef BAHTIMINGS - bcopy((caddr_t)&time, - (caddr_t)&(sc->sc_stats.lasttxstart_tv), - sizeof(struct timeval)); - + getmicrotime(&sc->sc_stats.lasttxstart_tv); sc->sc_stats.lasttxstart_mics = clkread(); #endif diff --git a/sys/dev/pci/ncr.c b/sys/dev/pci/ncr.c index ff356cdd827..029b5fab1c4 100644 --- a/sys/dev/pci/ncr.c +++ b/sys/dev/pci/ncr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncr.c,v 1.69 2004/06/21 23:50:35 tholo Exp $ */ +/* $OpenBSD: ncr.c,v 1.70 2004/06/24 19:35:23 tholo Exp $ */ /* $NetBSD: ncr.c,v 1.63 1997/09/23 02:39:15 perry Exp $ */ /************************************************************************** @@ -1466,7 +1466,7 @@ static void ncr_attach (pcici_t tag, int unit); #if 0 static char ident[] = - "\n$OpenBSD: ncr.c,v 1.69 2004/06/21 23:50:35 tholo Exp $\n"; + "\n$OpenBSD: ncr.c,v 1.70 2004/06/24 19:35:23 tholo Exp $\n"; #endif static const u_long ncr_version = NCR_VERSION * 11 @@ -1620,6 +1620,10 @@ static char *ncr_name (ncb_p np) * THESE MUST ALL BE ALIGNED TO A 4-BYTE BOUNDARY. */ #ifdef __OpenBSD__ +/* + * XXX - set up a timer that will update a local copy or microuptime once + * every tick. + */ static unsigned long script_kvars[] = { (unsigned long)&mono_time.tv_sec, (unsigned long)&mono_time, @@ -4473,7 +4477,7 @@ static int32_t ncr_start (struct scsi_xfer * xp) bzero (&cp->phys.header.stamp, sizeof (struct tstamp)); #ifdef __OpenBSD__ - cp->phys.header.stamp.start = mono_time; + microuptime(&cp->phys.header.stamp.start); #else gettime(&cp->phys.header.stamp.start); #endif @@ -6092,7 +6096,7 @@ void ncr_exception (ncb_p np) #ifdef __OpenBSD__ if (time_uptime - np->regtime.tv_sec>10) { int i; - np->regtime = mono_time; + microuptime(&np->regtime); #else if (time.tv_sec - np->regtime.tv_sec>10) { int i; @@ -7707,7 +7711,7 @@ static void ncb_profile (ncb_p np, ccb_p cp) u_long diff; #ifdef __OpenBSD__ - PROFILE.end = mono_time; + getmicrouptime(&PROFILE.end); #else gettime(&PROFILE.end); #endif diff --git a/sys/dev/raidframe/rf_etimer.h b/sys/dev/raidframe/rf_etimer.h index 197433740a1..5b632f74ea4 100644 --- a/sys/dev/raidframe/rf_etimer.h +++ b/sys/dev/raidframe/rf_etimer.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rf_etimer.h,v 1.6 2002/12/16 07:01:03 tdeval Exp $ */ +/* $OpenBSD: rf_etimer.h,v 1.7 2004/06/24 19:35:24 tholo Exp $ */ /* $NetBSD: rf_etimer.h,v 1.4 1999/08/13 03:26:55 oster Exp $ */ /* @@ -48,19 +48,13 @@ struct RF_Etimer_s { #define RF_ETIMER_START(_t_) \ do { \ - int s; \ bzero(&(_t_), sizeof (_t_)); \ - s = splclock(); \ - (_t_).st = mono_time; \ - splx(s); \ + getmicrouptime(&(_t_).st); \ } while (0) #define RF_ETIMER_STOP(_t_) \ do { \ - int s; \ - s = splclock(); \ - (_t_).et = mono_time; \ - splx(s); \ + getmicrouptime(&(_t_).et); \ } while (0) #define RF_ETIMER_EVAL(_t_) \ diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index 64be39aaacc..60e918b2865 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb.c,v 1.27 2004/05/04 16:59:32 grange Exp $ */ +/* $OpenBSD: usb.c,v 1.28 2004/06/24 19:35:24 tholo Exp $ */ /* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */ /* @@ -720,15 +720,15 @@ usb_add_event(int type, struct usb_event *uep) { struct usb_event_q *ueq; struct usb_event ue; - struct timeval thetime; + struct timespec thetime; int s; - microtime(&thetime); + nanotime(&thetime); /* Don't want to wait here inside splusb() */ ueq = malloc(sizeof *ueq, M_USBDEV, M_WAITOK); ueq->ue = *uep; ueq->ue.ue_type = type; - TIMEVAL_TO_TIMESPEC(&thetime, &ueq->ue.ue_time); + ueq->ue.ue_time = thetime; s = splusb(); if (++usb_nevents >= USB_MAX_EVENTS) { diff --git a/sys/dev/wscons/wskbd.c b/sys/dev/wscons/wskbd.c index 22b97eb5988..21894d8077c 100644 --- a/sys/dev/wscons/wskbd.c +++ b/sys/dev/wscons/wskbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wskbd.c,v 1.40 2004/04/05 06:22:07 miod Exp $ */ +/* $OpenBSD: wskbd.c,v 1.41 2004/06/24 19:35:24 tholo Exp $ */ /* $NetBSD: wskbd.c,v 1.38 2000/03/23 07:01:47 thorpej Exp $ */ /* @@ -586,7 +586,6 @@ wskbd_input(dev, type, value) struct wskbd_softc *sc = (struct wskbd_softc *)dev; struct wscons_event *ev; struct wseventvar *evar; - struct timeval xxxtime; #if NWSDISPLAY > 0 int num, i; #endif @@ -649,8 +648,7 @@ wskbd_input(dev, type, value) } ev->type = type; ev->value = value; - microtime(&xxxtime); - TIMEVAL_TO_TIMESPEC(&xxxtime, &ev->time); + nanotime(&ev->time); evar->put = put; WSEVENT_WAKEUP(evar); } diff --git a/sys/dev/wscons/wsmouse.c b/sys/dev/wscons/wsmouse.c index 668eb55a39d..ebbef486705 100644 --- a/sys/dev/wscons/wsmouse.c +++ b/sys/dev/wscons/wsmouse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmouse.c,v 1.12 2003/09/23 16:51:12 millert Exp $ */ +/* $OpenBSD: wsmouse.c,v 1.13 2004/06/24 19:35:24 tholo Exp $ */ /* $NetBSD: wsmouse.c,v 1.12 2000/05/01 07:36:58 takemura Exp $ */ /* @@ -347,10 +347,7 @@ wsmouse_input(wsmousedev, btns, x, y, z, flags) /* TIMESTAMP sets `time' field of the event to the current time */ #define TIMESTAMP \ do { \ - int s; \ - s = splhigh(); \ - TIMEVAL_TO_TIMESPEC(&time, &ev->time); \ - splx(s); \ + getnanotime(&ev->time); \ } while (0) if (flags & WSMOUSE_INPUT_ABSOLUTE_X) { diff --git a/sys/dev/wscons/wsmux.c b/sys/dev/wscons/wsmux.c index a6af8aff3f6..56118d9907f 100644 --- a/sys/dev/wscons/wsmux.c +++ b/sys/dev/wscons/wsmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsmux.c,v 1.11 2003/09/23 16:51:12 millert Exp $ */ +/* $OpenBSD: wsmux.c,v 1.12 2004/06/24 19:35:24 tholo Exp $ */ /* $NetBSD: wsmux.c,v 1.9 2000/05/28 10:33:14 takemura Exp $ */ /* @@ -526,7 +526,6 @@ wsmuxdoioctl(dv, cmd, data, flag, p) int s, put, get, n; struct wseventvar *evar; struct wscons_event *ev; - struct timeval xxxtime; struct wsmux_device_list *l; DPRINTF(("wsmuxdoioctl: %s: sc=%p, cmd=%08lx\n", @@ -551,8 +550,7 @@ wsmuxdoioctl(dv, cmd, data, flag, p) put = 0; ev = &evar->q[put]; *ev = *(struct wscons_event *)data; - microtime(&xxxtime); - TIMEVAL_TO_TIMESPEC(&xxxtime, &ev->time); + nanotime(&ev->time); evar->put = put; WSEVENT_WAKEUP(evar); splx(s); |