--- //depot/vendor/freebsd/src/sys/dev/nve/if_nve.c 2005/11/21 22:15:44 +++ //depot/user/jhb/acpipci/dev/nve/if_nve.c 2005/11/22 20:06:59 @@ -315,8 +315,7 @@ /* Allocate mutex */ mtx_init(&sc->mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, - MTX_DEF | MTX_RECURSE); - mtx_init(&sc->osmtx, device_get_nameunit(dev), NULL, MTX_SPIN); + MTX_DEF); callout_init_mtx(&sc->stat_callout, &sc->mtx, 0); sc->dev = dev; @@ -563,6 +571,7 @@ NVE_UNLOCK(sc); callout_drain(&sc->stat_callout); ether_ifdetach(ifp); + sc->dead = 1; } if (sc->miibus) @@ -603,7 +612,6 @@ if (ifp) if_free(ifp); mtx_destroy(&sc->mtx); - mtx_destroy(&sc->osmtx); DEBUGOUT(NVE_DEBUG_DEINIT, "nve: nve_detach - exit\n"); @@ -665,6 +673,14 @@ ifp->if_drv_flags |= IFF_DRV_RUNNING; ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + /* + * Dragonfly resets these to 0 here, but I think they should already + * always be 0. + */ + if (ifp->if_timer != 0 || sc->pending_txs != 0) + if_printf(ifp, "reinit: timer %d, pending_txs %d", + ifp->if_timer, sc->pending_txs); + callout_reset(&sc->stat_callout, hz, nve_tick, sc); DEBUGOUT(NVE_DEBUG_INIT, "nve: nve_init - exit\n"); @@ -1471,6 +1490,9 @@ struct nve_rx_desc *desc; struct nve_map_buffer *buf; + if (device_is_attached(sc->dev) && !sc->dead) + NVE_LOCK_ASSERT(sc); + DEBUGOUT(NVE_DEBUG_API, "nve: nve_osfreerxbuf\n"); desc = (struct nve_rx_desc *) id; @@ -1589,16 +1611,21 @@ nve_oslinkchg(PNV_VOID ctx, NV_SINT32 enabled) { struct nve_softc *sc = (struct nve_softc *)ctx; +#if 0 struct ifnet *ifp; +#endif DEBUGOUT(NVE_DEBUG_API, "nve: nve_oslinkchg\n"); +#if 0 ifp = sc->ifp; + /* XXXX: This should _not_ change IFF_UP!!! */ if (enabled) ifp->if_flags |= IFF_UP; else ifp->if_flags &= ~IFF_UP; +#endif return (1); } @@ -1717,10 +1744,12 @@ static NV_SINT32 nve_oslockacquire(PNV_VOID ctx, NV_SINT32 type, PNV_VOID lock) { + struct nve_softc *sc = (struct nve_softc *)ctx; DEBUGOUT(NVE_DEBUG_LOCK, "nve: nve_oslockacquire\n"); - NVE_OSLOCK((struct nve_softc *)lock); + if (!mtx_owned(&sc->mtx) && device_is_attached(sc->dev) && !sc->dead) + device_printf(sc->dev, "%s: normal mutex not held\n", __func__); return (1); } @@ -1729,10 +1758,12 @@ static NV_SINT32 nve_oslockrelease(PNV_VOID ctx, NV_SINT32 type, PNV_VOID lock) { + struct nve_softc *sc = (struct nve_softc *)ctx; DEBUGOUT(NVE_DEBUG_LOCK, "nve: nve_oslockrelease\n"); - NVE_OSUNLOCK((struct nve_softc *)lock); + if (!mtx_owned(&sc->mtx) && device_is_attached(sc->dev) && !sc->dead) + device_printf(sc->dev, "%s: normal mutex not held\n", __func__); return (1); } --- //depot/vendor/freebsd/src/sys/dev/nve/if_nvereg.h 2005/11/21 22:15:44 +++ //depot/user/jhb/acpipci/dev/nve/if_nvereg.h 2005/11/22 20:06:59 @@ -139,8 +139,8 @@ u_int32_t pending_rxs; u_int32_t pending_txs; + int dead; struct mtx mtx; - struct mtx osmtx; /* Stuff for dealing with the NVIDIA OS API */ struct callout ostimer; @@ -165,8 +165,6 @@ #define NVE_LOCK(_sc) mtx_lock(&(_sc)->mtx) #define NVE_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) #define NVE_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->mtx, MA_OWNED) -#define NVE_OSLOCK(_sc) mtx_lock_spin(&(_sc)->osmtx) -#define NVE_OSUNLOCK(_sc) mtx_unlock_spin(&(_sc)->osmtx) #define IF_Kbps(x) ((x) * 1000) /* kilobits/sec. */ #define IF_Mbps(x) (IF_Kbps((x) * 1000)) /* megabits/sec. */