From owner-svn-src-head@FreeBSD.ORG Tue Apr 2 06:24:23 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 544CD5DE; Tue, 2 Apr 2013 06:24:23 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 2E667A88; Tue, 2 Apr 2013 06:24:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r326ONhi077468; Tue, 2 Apr 2013 06:24:23 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r326ONGW077467; Tue, 2 Apr 2013 06:24:23 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201304020624.r326ONGW077467@svn.freebsd.org> From: Adrian Chadd Date: Tue, 2 Apr 2013 06:24:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248999 - head/sys/dev/ath X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Apr 2013 06:24:23 -0000 Author: adrian Date: Tue Apr 2 06:24:22 2013 New Revision: 248999 URL: http://svnweb.freebsd.org/changeset/base/248999 Log: Some TX dmamap cleanups. * Don't use BUS_DMA_ALLOCNOW for descriptor DMA maps; we never use bounce buffers for the descriptors themselves. * Add some XXX's to mark where the ath_buf has its mbuf ripped from underneath it without actually cleaning up the dmamap. I haven't audited those particular code paths to see if the DMA map is guaranteed to be setup there; I'll do that later. * Print out a warning if the descdma tidyup code is given some descriptors w/ maps to free. Ideally the owner will free the mbufs and unmap the descriptors before freeing the descriptor/ath_buf pairs, but right now that's not guaranteed to be done. Reviewed by: scottl (BUS_DMA_ALLOCNOW tag) Modified: head/sys/dev/ath/if_ath.c Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Tue Apr 2 06:21:37 2013 (r248998) +++ head/sys/dev/ath/if_ath.c Tue Apr 2 06:24:22 2013 (r248999) @@ -2742,6 +2742,7 @@ ath_start(struct ifnet *ifp) "%s: flush fragmented packet, state %s\n", __func__, ieee80211_state_name[ni->ni_vap->iv_state]); + /* XXX dmamap */ ath_freetx(next); goto reclaim; } @@ -3031,6 +3032,9 @@ ath_descdma_alloc_desc(struct ath_softc /* * Setup DMA descriptor area. + * + * BUS_DMA_ALLOCNOW is not used; we never use bounce + * buffers for the descriptors themselves. */ error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), /* parent */ PAGE_SIZE, 0, /* alignment, bounds */ @@ -3040,7 +3044,7 @@ ath_descdma_alloc_desc(struct ath_softc dd->dd_desc_len, /* maxsize */ 1, /* nsegments */ dd->dd_desc_len, /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ + 0, /* flags */ NULL, /* lockfunc */ NULL, /* lockarg */ &dd->dd_dmat); @@ -3237,6 +3241,7 @@ ath_descdma_cleanup(struct ath_softc *sc { struct ath_buf *bf; struct ieee80211_node *ni; + int do_warning = 0; if (dd->dd_dmamap != 0) { bus_dmamap_unload(dd->dd_dmat, dd->dd_dmamap); @@ -3247,6 +3252,23 @@ ath_descdma_cleanup(struct ath_softc *sc if (head != NULL) { TAILQ_FOREACH(bf, head, bf_list) { if (bf->bf_m) { + /* + * XXX warn if there's buffers here. + * XXX it should have been freed by the + * owner! + */ + + if (do_warning == 0) { + do_warning = 1; + device_printf(sc->sc_dev, + "%s: %s: mbuf should've been" + " unmapped/freed!\n", + __func__, + dd->dd_name); + } + bus_dmamap_sync(sc->sc_dmat, bf->bf_dmamap, + BUS_DMASYNC_POSTREAD); + bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); m_freem(bf->bf_m); bf->bf_m = NULL; }