diff options
author | sam <sam@FreeBSD.org> | 2003-10-10 23:14:21 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2003-10-10 23:14:21 +0000 |
commit | 98e4036e5b9788802df7a257f689e91e34ba113d (patch) | |
tree | 19eca30476b376783a2f5001bee71fcf95a9fd63 /sys/dev/em | |
parent | 592158f5ce62f282f2676d220c95a828787891d4 (diff) | |
download | FreeBSD-src-98e4036e5b9788802df7a257f689e91e34ba113d.zip FreeBSD-src-98e4036e5b9788802df7a257f689e91e34ba113d.tar.gz |
locking fixups:
o correct recursive locking when polling and in em_82547_move_tail
o destroy mutex on detach
o add EM_LOCK_ASSERT and similar macros for creating+deleteing the mtx
Submitted by: Daniel Eischen <eischen@vigrid.com>
Diffstat (limited to 'sys/dev/em')
-rw-r--r-- | sys/dev/em/if_em.c | 15 | ||||
-rw-r--r-- | sys/dev/em/if_em.h | 8 |
2 files changed, 14 insertions, 9 deletions
diff --git a/sys/dev/em/if_em.c b/sys/dev/em/if_em.c index 36c8afc..6b9d6a1 100644 --- a/sys/dev/em/if_em.c +++ b/sys/dev/em/if_em.c @@ -301,8 +301,7 @@ em_attach(device_t dev) adapter->dev = dev; adapter->osdep.dev = dev; adapter->unit = device_get_unit(dev); - mtx_init(&adapter->mtx, device_get_nameunit(dev), - MTX_NETWORK_LOCK, MTX_DEF); + EM_LOCK_INIT(adapter, device_get_nameunit(dev)); if (em_adapter_list != NULL) em_adapter_list->prev = adapter; @@ -562,6 +561,8 @@ em_detach(device_t dev) if (adapter->prev != NULL) adapter->prev->next = adapter->next; + EM_LOCK_DESTROY(adapter); + ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); ifp->if_timer = 0; @@ -933,7 +934,7 @@ em_intr(void *arg) if (ether_poll_register(em_poll, ifp)) { em_disable_intr(adapter); - em_poll(ifp, 0, 1); + em_poll_locked(ifp, 0, 1); EM_UNLOCK(adapter); return; } @@ -1299,7 +1300,7 @@ em_encap(struct adapter *adapter, struct mbuf *m_head) * 82547 workaround to avoid controller hang in half-duplex environment. * The workaround is to avoid queuing a large packet that would span * the internal Tx FIFO ring boundary. We need to reset the FIFO pointers - * in this case. We do that only when FIFO is queiced. + * in this case. We do that only when FIFO is quiescent. * **********************************************************************/ static void @@ -1312,7 +1313,8 @@ em_82547_move_tail(void *arg) uint16_t length = 0; boolean_t eop = 0; - EM_LOCK(adapter); + EM_LOCK_ASSERT(adapter); + hw_tdt = E1000_READ_REG(&adapter->hw, TDT); sw_tdt = adapter->next_avail_tx_desc; @@ -1335,7 +1337,6 @@ em_82547_move_tail(void *arg) length = 0; } } - EM_UNLOCK(adapter); return; } @@ -1702,7 +1703,7 @@ em_allocate_pci_resources(struct adapter * adapter) return(ENXIO); } if (bus_setup_intr(dev, adapter->res_interrupt, - INTR_TYPE_NET /*| INTR_MPSAFE*/, + INTR_TYPE_NET | INTR_MPSAFE, (void (*)(void *)) em_intr, adapter, &adapter->int_handler_tag)) { printf("em%d: Error registering interrupt handler!\n", diff --git a/sys/dev/em/if_em.h b/sys/dev/em/if_em.h index 167f74b..8818165 100644 --- a/sys/dev/em/if_em.h +++ b/sys/dev/em/if_em.h @@ -425,7 +425,11 @@ struct adapter { struct em_hw_stats stats; }; -#define EM_LOCK(_sc) mtx_lock(&(_sc)->mtx) -#define EM_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) +#define EM_LOCK_INIT(_sc, _name) \ + mtx_init(&(_sc)->mtx, _name, MTX_NETWORK_LOCK, MTX_DEF) +#define EM_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->mtx) +#define EM_LOCK(_sc) mtx_lock(&(_sc)->mtx) +#define EM_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx) +#define EM_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->mtx, MA_OWNED) #endif /* _EM_H_DEFINED_ */ |