From b39722d6dd22d6749aa4497019abae8fb8145c97 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Fri, 27 Jul 2012 05:48:42 +0000 Subject: [PATCH] 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. --- sys/dev/ath/if_ath.c | 16 ++++++++-------- sys/dev/ath/if_ath_misc.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index b2c3e87bec6..6ac0e971101 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -2773,7 +2773,7 @@ ath_load_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error) 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 *sc, 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 *sc, * 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 *sc, &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) { diff --git a/sys/dev/ath/if_ath_misc.h b/sys/dev/ath/if_ath_misc.h index edbda8b2777..a629cbaec36 100644 --- a/sys/dev/ath/if_ath_misc.h +++ b/sys/dev/ath/if_ath_misc.h @@ -86,7 +86,7 @@ extern void ath_setslottime(struct ath_softc *sc); 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);