diff options
| author | ad <ad@NetBSD.org> | 2008-04-21 12:56:30 +0000 |
|---|---|---|
| committer | ad <ad@NetBSD.org> | 2008-04-21 12:56:30 +0000 |
| commit | a2249ef75cbe2acbcf5e0d0a53dcbfc6ebe40783 (patch) | |
| tree | 6a5a7871a7ca8808cd6013a6b8082dffd5db0da2 /sys/dev | |
| parent | 45e89afb6fdd63c527033ba5c11249e873d549f1 (diff) | |
Make ntp, pmc, reboot, sysarch, time syscalls MPSAFE.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ic/com.c | 12 | ||||
| -rw-r--r-- | sys/dev/ic/z8530tty.c | 12 | ||||
| -rw-r--r-- | sys/dev/ppbus/pps_ppbus.c | 21 |
3 files changed, 34 insertions, 11 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index b3bbf8fca91..bdf4b69f6bb 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $NetBSD: com.c,v 1.278 2008/04/11 12:45:08 tsutsui Exp $ */ +/* $NetBSD: com.c,v 1.279 2008/04/21 12:56:31 ad Exp $ */ /*- * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.278 2008/04/11 12:45:08 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.279 2008/04/21 12:56:31 ad Exp $"); #include "opt_com.h" #include "opt_ddb.h" @@ -788,9 +788,11 @@ comopen(dev_t dev, int flag, int mode, struct lwp *l) sc->sc_msr = CSR_READ_1(&sc->sc_regs, COM_REG_MSR); /* Clear PPS capture state on first open. */ + mutex_spin_enter(&timecounter_lock); memset(&sc->sc_pps_state, 0, sizeof(sc->sc_pps_state)); sc->sc_pps_state.ppscap = PPS_CAPTUREASSERT | PPS_CAPTURECLEAR; pps_init(&sc->sc_pps_state); + mutex_spin_exit(&timecounter_lock); mutex_spin_exit(&sc->sc_lock); @@ -1032,10 +1034,13 @@ comioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) #ifdef PPS_SYNC case PPS_IOC_KCBIND: #endif + mutex_spin_enter(&timecounter_lock); error = pps_ioctl(cmd, data, &sc->sc_pps_state); + mutex_spin_exit(&timecounter_lock); break; case TIOCDCDTIMESTAMP: /* XXX old, overloaded API used by xntpd v3 */ + mutex_spin_enter(&timecounter_lock); #ifndef PPS_TRAILING_EDGE TIMESPEC_TO_TIMEVAL((struct timeval *)data, &sc->sc_pps_state.ppsinfo.assert_timestamp); @@ -1043,6 +1048,7 @@ comioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) TIMESPEC_TO_TIMEVAL((struct timeval *)data, &sc->sc_pps_state.ppsinfo.clear_timestamp); #endif + mutex_spin_exit(&timecounter_lock); break; default: @@ -1908,11 +1914,13 @@ again: do { sc->sc_msr = msr; if ((sc->sc_pps_state.ppsparam.mode & PPS_CAPTUREBOTH) && (delta & MSR_DCD)) { + mutex_spin_enter(&timecounter_lock); pps_capture(&sc->sc_pps_state); pps_event(&sc->sc_pps_state, (msr & MSR_DCD) ? PPS_CAPTUREASSERT : PPS_CAPTURECLEAR); + mutex_spin_exit(&timecounter_lock); } /* diff --git a/sys/dev/ic/z8530tty.c b/sys/dev/ic/z8530tty.c index a5e8457dbe9..eb97c987624 100644 --- a/sys/dev/ic/z8530tty.c +++ b/sys/dev/ic/z8530tty.c @@ -1,4 +1,4 @@ -/* $NetBSD: z8530tty.c,v 1.122 2008/03/29 19:15:36 tsutsui Exp $ */ +/* $NetBSD: z8530tty.c,v 1.123 2008/04/21 12:56:31 ad Exp $ */ /*- * Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999 @@ -137,7 +137,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.122 2008/03/29 19:15:36 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: z8530tty.c,v 1.123 2008/04/21 12:56:31 ad Exp $"); #include "opt_kgdb.h" #include "opt_ntp.h" @@ -600,11 +600,13 @@ zsopen(dev_t dev, int flags, int mode, struct lwp *l) SET(cs->cs_preg[1], ZSWR1_RIE | ZSWR1_SIE); /* Clear PPS capture state on first open. */ + mutex_spin_enter(&timecounter_lock); zst->zst_ppsmask = 0; memset(&zst->zst_pps_state, 0, sizeof(zst->zst_pps_state)); zst->zst_pps_state.ppscap = PPS_CAPTUREASSERT | PPS_CAPTURECLEAR; pps_init(&zst->zst_pps_state); + mutex_spin_exit(&timecounter_lock); mutex_spin_exit(&cs->cs_lock); @@ -821,11 +823,13 @@ zsioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) #ifdef PPS_SYNC case PPS_IOC_KCBIND: #endif + mutex_spin_enter(&timecounter_lock); error = pps_ioctl(cmd, data, &zst->zst_pps_state); if (zst->zst_pps_state.ppsparam.mode & PPS_CAPTUREBOTH) zst->zst_ppsmask = ZSRR0_DCD; else zst->zst_ppsmask = 0; + mutex_spin_exit(&timecounter_lock); break; case TIOCDCDTIMESTAMP: /* XXX old, overloaded API used by xntpd v3 */ @@ -833,6 +837,7 @@ zsioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) error = EINVAL; break; } + mutex_spin_enter(&timecounter_lock); #ifndef PPS_TRAILING_EDGE TIMESPEC_TO_TIMEVAL((struct timeval *)data, &zst->zst_pps_state.ppsinfo.assert_timestamp); @@ -840,6 +845,7 @@ zsioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) TIMESPEC_TO_TIMEVAL((struct timeval *)data, &zst->zst_pps_state.ppsinfo.clear_timestamp); #endif + mutex_spin_exit(&timecounter_lock); /* * Now update interrupts. */ @@ -1484,11 +1490,13 @@ zstty_stint(struct zs_chanstate *cs, int force) if (ISSET(delta, zst->zst_ppsmask)) { if (zst->zst_pps_state.ppsparam.mode & PPS_CAPTUREBOTH) { + mutex_spin_enter(&timecounter_lock); pps_capture(&zst->zst_pps_state); pps_event(&zst->zst_pps_state, (ISSET(cs->cs_rr0, zst->zst_ppsmask)) ? PPS_CAPTUREASSERT : PPS_CAPTURECLEAR); + mutex_spin_exit(&timecounter_lock); } } diff --git a/sys/dev/ppbus/pps_ppbus.c b/sys/dev/ppbus/pps_ppbus.c index 7a45f03e0dd..26b28cbfce0 100644 --- a/sys/dev/ppbus/pps_ppbus.c +++ b/sys/dev/ppbus/pps_ppbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: pps_ppbus.c,v 1.12 2008/04/16 09:39:01 cegger Exp $ */ +/* $NetBSD: pps_ppbus.c,v 1.13 2008/04/21 12:56:31 ad Exp $ */ /* * ported to timecounters by Frank Kardel 2006 @@ -29,7 +29,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pps_ppbus.c,v 1.12 2008/04/16 09:39:01 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pps_ppbus.c,v 1.13 2008/04/21 12:56:31 ad Exp $"); #include "opt_ntp.h" @@ -122,11 +122,14 @@ ppsopen(dev_t dev, int flags, int fmt, struct lwp *l) ppbus_set_mode(sc->ppbus, PPBUS_PS2, 0); ppbus_wctr(sc->ppbus, IRQENABLE | PCD | nINIT | SELECTIN); + mutex_spin_enter(&timecounter_lock); memset((void *)&sc->pps_state, 0, sizeof(sc->pps_state)); sc->pps_state.ppscap = PPS_CAPTUREASSERT; pps_init(&sc->pps_state); + mutex_spin_exit(&timecounter_lock); sc->busy = 1; + return (0); } @@ -137,7 +140,9 @@ ppsclose(dev_t dev, int flags, int fmt, struct lwp *l) device_t ppbus = sc->ppbus; sc->busy = 0; + mutex_spin_enter(&timecounter_lock); sc->pps_state.ppsparam.mode = 0; + mutex_spin_exit(&timecounter_lock); ppbus_wdtr(ppbus, 0); ppbus_wctr(ppbus, 0); @@ -154,18 +159,18 @@ ppsintr(void *arg) struct pps_softc *sc = arg; device_t ppbus = sc->ppbus; + mutex_spin_enter(&timecounter_lock); pps_capture(&sc->pps_state); - - if (!(ppbus_rstr(ppbus) & nACK)) + if (!(ppbus_rstr(ppbus) & nACK)) { + mutex_spin_exit(&timecounter_lock); return; - + } if (sc->pps_state.ppsparam.mode & PPS_ECHOASSERT) ppbus_wctr(ppbus, IRQENABLE | AUTOFEED); - pps_event(&sc->pps_state, PPS_CAPTUREASSERT); - if (sc->pps_state.ppsparam.mode & PPS_ECHOASSERT) ppbus_wctr(ppbus, IRQENABLE); + mutex_spin_exit(&timecounter_lock); } static int @@ -184,7 +189,9 @@ ppsioctl(dev_t dev, u_long cmd, void *data, int flags, struct lwp *l) #ifdef PPS_SYNC case PPS_IOC_KCBIND: #endif + mutex_spin_enter(&timecounter_lock); error = pps_ioctl(cmd, data, &sc->pps_state); + mutex_spin_exit(&timecounter_lock); break; default: |
