Date: Thu, 9 Aug 2012 14:46:52 +0000 (UTC) From: Ed Maste <emaste@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r239149 - head/sys/dev/netmap Message-ID: <201208091446.q79EkqtH020523@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: emaste Date: Thu Aug 9 14:46:52 2012 New Revision: 239149 URL: http://svn.freebsd.org/changeset/base/239149 Log: Improve lock and unlock symmetry - Move destruction of per-ring locks to netmap_dtor_locked to mirror the initialization that happens in NIOCREGIF. Otherwise unloading a netmap- capable interface that was never put into netmap mode would try to mtx_destroy an uninitialized mutex, and panic. - Destroy core_lock in netmap_detach, mirroring init in netmap_attach. - Also comment out the knlist_destroy for now as there is currently no knlist_init. Sponsored by: ADARA Networks Reviewed by: luigi@ Modified: head/sys/dev/netmap/netmap.c Modified: head/sys/dev/netmap/netmap.c ============================================================================== --- head/sys/dev/netmap/netmap.c Wed Aug 8 20:21:33 2012 (r239148) +++ head/sys/dev/netmap/netmap.c Thu Aug 9 14:46:52 2012 (r239149) @@ -356,13 +356,20 @@ netmap_dtor_locked(void *data) lim = na->tx_rings[i].nkr_num_slots; for (j = 0; j < lim; j++) netmap_free_buf(nifp, ring->slot[j].buf_idx); + /* knlist_destroy(&na->tx_rings[i].si.si_note); */ + mtx_destroy(&na->tx_rings[i].q_lock); } for (i = 0; i < na->num_rx_rings + 1; i++) { struct netmap_ring *ring = na->rx_rings[i].ring; lim = na->rx_rings[i].nkr_num_slots; for (j = 0; j < lim; j++) netmap_free_buf(nifp, ring->slot[j].buf_idx); + /* knlist_destroy(&na->rx_rings[i].si.si_note); */ + mtx_destroy(&na->rx_rings[i].q_lock); } + /* XXX kqueue(9) needed; these will mirror knlist_init. */ + /* knlist_destroy(&na->tx_si.si_note); */ + /* knlist_destroy(&na->rx_si.si_note); */ NMA_UNLOCK(); netmap_free_rings(na); wakeup(na); @@ -1318,13 +1325,14 @@ netmap_attach(struct netmap_adapter *na, ifp->if_capabilities |= IFCAP_NETMAP; na = buf; + /* Core lock initialized here. Others are initialized after + * netmap_if_new. + */ + mtx_init(&na->core_lock, "netmap core lock", MTX_NETWORK_LOCK, + MTX_DEF); if (na->nm_lock == NULL) { ND("using default locks for %s", ifp->if_xname); na->nm_lock = netmap_lock_wrapper; - /* core lock initialized here. - * others initialized after netmap_if_new - */ - mtx_init(&na->core_lock, "netmap core lock", MTX_NETWORK_LOCK, MTX_DEF); } } #ifdef linux @@ -1348,22 +1356,13 @@ netmap_attach(struct netmap_adapter *na, void netmap_detach(struct ifnet *ifp) { - u_int i; struct netmap_adapter *na = NA(ifp); if (!na) return; - for (i = 0; i < na->num_tx_rings + 1; i++) { - knlist_destroy(&na->tx_rings[i].si.si_note); - mtx_destroy(&na->tx_rings[i].q_lock); - } - for (i = 0; i < na->num_rx_rings + 1; i++) { - knlist_destroy(&na->rx_rings[i].si.si_note); - mtx_destroy(&na->rx_rings[i].q_lock); - } - knlist_destroy(&na->tx_si.si_note); - knlist_destroy(&na->rx_si.si_note); + mtx_destroy(&na->core_lock); + bzero(na, sizeof(*na)); WNA(ifp) = NULL; free(na, M_DEVBUF);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201208091446.q79EkqtH020523>