From owner-svn-src-head@FreeBSD.ORG Fri Jul 27 05:48:42 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BD5B61065670; Fri, 27 Jul 2012 05:48:42 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A838E8FC0A; Fri, 27 Jul 2012 05:48:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6R5mg8d070139; Fri, 27 Jul 2012 05:48:42 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6R5mgiS070136; Fri, 27 Jul 2012 05:48:42 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201207270548.q6R5mgiS070136@svn.freebsd.org> From: Adrian Chadd Date: Fri, 27 Jul 2012 05:48:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238824 - head/sys/dev/ath X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Fri, 27 Jul 2012 05:48:43 -0000 Author: adrian Date: Fri Jul 27 05:48:42 2012 New Revision: 238824 URL: http://svn.freebsd.org/changeset/base/238824 Log: Migrate the descriptor allocation function to not care about the number of buffers, only the number of descriptors. This involves: * Change the allocation function to not use nbuf at all; * When calling it, pass in "nbuf * ndesc" to correctly update how many descriptors are being allocated. Whilst here, fix the descriptor allocation code to correctly allocate a larger buffer size if the Merlin 4KB WAR is required. It overallocates descriptors when allocating a block that doesn't ever have a 4KB boundary being crossed, but that can be fixed at a later stage. Modified: head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_ath_misc.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Fri Jul 27 05:37:01 2012 (r238823) +++ head/sys/dev/ath/if_ath.c Fri Jul 27 05:48:42 2012 (r238824) @@ -2773,7 +2773,7 @@ ath_load_cb(void *arg, bus_dma_segment_t int ath_descdma_alloc_desc(struct ath_softc *sc, struct ath_descdma *dd, ath_bufhead *head, - const char *name, int ds_size, int nbuf, int ndesc) + const char *name, int ds_size, int ndesc) { #define DS2PHYS(_dd, _ds) \ ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc)) @@ -2785,11 +2785,11 @@ ath_descdma_alloc_desc(struct ath_softc dd->dd_descsize = ds_size; DPRINTF(sc, ATH_DEBUG_RESET, - "%s: %s DMA: %u buffers %u desc/buf, %d bytes per descriptor\n", - __func__, name, nbuf, ndesc, dd->dd_descsize); + "%s: %s DMA: %u desc, %d bytes per descriptor\n", + __func__, name, ndesc, dd->dd_descsize); dd->dd_name = name; - dd->dd_desc_len = dd->dd_descsize * nbuf * ndesc; + dd->dd_desc_len = dd->dd_descsize * ndesc; /* * Merlin work-around: @@ -2797,8 +2797,8 @@ ath_descdma_alloc_desc(struct ath_softc * Assume one skipped descriptor per 4KB page. */ if (! ath_hal_split4ktrans(sc->sc_ah)) { - int numdescpage = 4096 / (dd->dd_descsize * ndesc); - dd->dd_desc_len = (nbuf / numdescpage + 1) * 4096; + int numpages = dd->dd_desc_len / 4096; + dd->dd_desc_len += ds_size * numpages; } /* @@ -2834,7 +2834,7 @@ ath_descdma_alloc_desc(struct ath_softc &dd->dd_dmamap); if (error != 0) { if_printf(ifp, "unable to alloc memory for %u %s descriptors, " - "error %u\n", nbuf * ndesc, dd->dd_name, error); + "error %u\n", ndesc, dd->dd_name, error); goto fail1; } @@ -2883,7 +2883,7 @@ ath_descdma_setup(struct ath_softc *sc, /* Allocate descriptors */ error = ath_descdma_alloc_desc(sc, dd, head, name, ds_size, - nbuf, ndesc); + nbuf * ndesc); /* Assume any errors during allocation were dealt with */ if (error != 0) { Modified: head/sys/dev/ath/if_ath_misc.h ============================================================================== --- head/sys/dev/ath/if_ath_misc.h Fri Jul 27 05:37:01 2012 (r238823) +++ head/sys/dev/ath/if_ath_misc.h Fri Jul 27 05:48:42 2012 (r238824) @@ -86,7 +86,7 @@ extern void ath_setslottime(struct ath_s extern int ath_descdma_alloc_desc(struct ath_softc *sc, struct ath_descdma *dd, ath_bufhead *head, const char *name, - int ds_size, int nbuf, int ndesc); + int ds_size, int ndesc); extern int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, ath_bufhead *head, const char *name, int ds_size, int nbuf, int ndesc);