diff options
author | jhb <jhb@FreeBSD.org> | 2005-10-31 21:37:27 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2005-10-31 21:37:27 +0000 |
commit | 6ce4d2f51a51d0b643cef2918b92238bdeb9a572 (patch) | |
tree | 04bfc657d80ffde3438ef970a4ba058a5ec5e189 /sys/dev | |
parent | 086563b4955f4b19bd7df9737a138ac62fbaa99a (diff) | |
download | FreeBSD-src-6ce4d2f51a51d0b643cef2918b92238bdeb9a572.zip FreeBSD-src-6ce4d2f51a51d0b643cef2918b92238bdeb9a572.tar.gz |
- Use callout_*() to manage the callout and make it MPSAFE.
- Fix locking in detach(), we only need to lock across vr_stop().
Tested by: Mike Tancsa mike at sentex dot net
MFC after: 1 week
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/vr/if_vr.c | 25 | ||||
-rw-r--r-- | sys/dev/vr/if_vrreg.h | 2 |
2 files changed, 11 insertions, 16 deletions
diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c index d4f5932..27ae364 100644 --- a/sys/dev/vr/if_vr.c +++ b/sys/dev/vr/if_vr.c @@ -655,6 +655,8 @@ vr_attach(dev) mtx_init(&sc->vr_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, MTX_DEF); + callout_init_mtx(&sc->vr_stat_callout, &sc->vr_mtx, 0); + /* * Map control/status registers. */ @@ -755,8 +757,6 @@ vr_attach(dev) goto fail; } - callout_handle_init(&sc->vr_stat_ch); - /* Call MI attach routine. */ ether_ifattach(ifp, eaddr); @@ -799,16 +799,14 @@ vr_detach(device_t dev) ether_poll_deregister(ifp); #endif - VR_LOCK(sc); - - sc->suspended = 1; - /* These should only be active if attach succeeded */ if (device_is_attached(dev)) { + VR_LOCK(sc); + sc->suspended = 1; vr_stop(sc); - VR_UNLOCK(sc); /* XXX: Avoid recursive acquire. */ + VR_UNLOCK(sc); + callout_drain(&sc->vr_stat_callout); ether_ifdetach(ifp); - VR_LOCK(sc); } if (sc->vr_miibus) device_delete_child(dev, sc->vr_miibus); @@ -827,7 +825,6 @@ vr_detach(device_t dev) if (sc->vr_ldata) contigfree(sc->vr_ldata, sizeof(struct vr_list_data), M_DEVBUF); - VR_UNLOCK(sc); mtx_destroy(&sc->vr_mtx); return (0); @@ -1128,7 +1125,7 @@ vr_tick(void *xsc) struct vr_softc *sc = xsc; struct mii_data *mii; - VR_LOCK(sc); + VR_LOCK_ASSERT(sc); if (sc->vr_flags & VR_F_RESTART) { if_printf(sc->vr_ifp, "restarting\n"); @@ -1140,9 +1137,7 @@ vr_tick(void *xsc) mii = device_get_softc(sc->vr_miibus); mii_tick(mii); - sc->vr_stat_ch = timeout(vr_tick, sc, hz); - - VR_UNLOCK(sc); + callout_reset(&sc->vr_stat_callout, hz, vr_tick, sc); } #ifdef DEVICE_POLLING @@ -1532,7 +1527,7 @@ vr_init_locked(struct vr_softc *sc) ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - sc->vr_stat_ch = timeout(vr_tick, sc, hz); + callout_reset(&sc->vr_stat_callout, hz, vr_tick, sc); } /* @@ -1668,7 +1663,7 @@ vr_stop(struct vr_softc *sc) ifp = sc->vr_ifp; ifp->if_timer = 0; - untimeout(vr_tick, sc, sc->vr_stat_ch); + callout_stop(&sc->vr_stat_callout); ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); VR_SETBIT16(sc, VR_COMMAND, VR_CMD_STOP); diff --git a/sys/dev/vr/if_vrreg.h b/sys/dev/vr/if_vrreg.h index 7b43c0b..1ef3756 100644 --- a/sys/dev/vr/if_vrreg.h +++ b/sys/dev/vr/if_vrreg.h @@ -465,7 +465,7 @@ struct vr_softc { u_int8_t vr_flags; /* See VR_F_* below */ struct vr_list_data *vr_ldata; struct vr_chain_data vr_cdata; - struct callout_handle vr_stat_ch; + struct callout vr_stat_callout; struct mtx vr_mtx; int suspended; /* if 1, sleeping/detaching */ #ifdef DEVICE_POLLING |