--- //depot/yahoo/ybsd_6/src/sys/dev/em/if_em.c 2006/09/26 14:59:47 +++ //depot/jhb/bsd6/src/sys/dev/em/if_em.c 2006/10/27 11:55:29 @@ -245,7 +245,6 @@ static void em_82547_update_fifo_head(struct adapter *, int); static int em_82547_tx_fifo_reset(struct adapter *); static void em_82547_move_tail(void *arg); -static void em_82547_move_tail_locked(struct adapter *); static int em_dma_malloc(struct adapter *, bus_size_t, struct em_dma_alloc *, int); static void em_dma_free(struct adapter *, struct em_dma_alloc *); @@ -416,8 +415,8 @@ OID_AUTO, "stats", CTLTYPE_INT|CTLFLAG_RW, adapter, 0, em_sysctl_stats, "I", "Statistics"); - callout_init(&adapter->timer, CALLOUT_MPSAFE); - callout_init(&adapter->tx_fifo_timer, CALLOUT_MPSAFE); + callout_init_mtx(&adapter->timer, &adapter->mtx, 0); + callout_init_mtx(&adapter->tx_fifo_timer, &adapter->mtx, 0); /* Determine hardware revision */ em_identify_hardware(adapter); @@ -623,10 +639,13 @@ EM_UNLOCK(adapter); ether_ifdetach(adapter->ifp); + callout_drain(&adapter->timer); + callout_drain(&adapter->tx_fifo_timer); + em_free_pci_resources(adapter); bus_generic_detach(dev); if_free(ifp); /* Free Transmit Descriptor ring */ if (adapter->tx_desc_base) { em_dma_free(adapter, &adapter->txdma); @@ -1213,6 +1231,10 @@ ifp = adapter->ifp; EM_LOCK(adapter); + if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { + EM_UNLOCK(adapter); + return; + } callout_stop(&adapter->timer); adapter->hw.get_link_status = 1; @@ -1625,7 +1653,7 @@ bus_dmamap_sync(adapter->txdma.dma_tag, adapter->txdma.dma_map, BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); if (adapter->hw.mac_type == em_82547 && adapter->link_duplex == HALF_DUPLEX) - em_82547_move_tail_locked(adapter); + em_82547_move_tail(adapter); else { E1000_WRITE_REG(&adapter->hw, TDT, i); if (adapter->hw.mac_type == em_82547) @@ -1644,8 +1672,9 @@ * **********************************************************************/ static void -em_82547_move_tail_locked(struct adapter *adapter) +em_82547_move_tail(void *arg) { + struct adapter *adapter = arg; uint16_t hw_tdt; uint16_t sw_tdt; struct em_tx_desc *tx_desc; @@ -1678,16 +1707,6 @@ } } -static void -em_82547_move_tail(void *arg) -{ - struct adapter *adapter = arg; - - EM_LOCK(adapter); - em_82547_move_tail_locked(adapter); - EM_UNLOCK(adapter); -} - static int em_82547_fifo_workaround(struct adapter *adapter, int len) { @@ -1873,7 +1892,7 @@ struct adapter *adapter = arg; struct ifnet *ifp = adapter->ifp; - EM_LOCK(adapter); + EM_LOCK_ASSERT(adapter); em_check_for_link(&adapter->hw); em_update_link_status(adapter); @@ -1883,8 +1902,6 @@ em_smartspeed(adapter); callout_reset(&adapter->timer, hz, em_local_timer, adapter); - - EM_UNLOCK(adapter); } static void