I have a diff to add DMA support to dwmmc(4). The hardware is a bit dumb and can only transfer up to 4K in a single DMA "segment". Currently sdmmc(4) allocates a bus DMA mapping structure that allows for segments up to MAXPHYS. Subdividing such segments in my driver seems a bit dumb.
So here is a diff that allows a driver to allocate its own DMA mapping structure, specifying whatever hardware constraints it needs, and pass it on to sdmmc(4). If no such structure is passed, sdmcc(4) continues to allocate one for us with the default constraints. ok? Index: dev/sdmmc/sdmmc.c =================================================================== RCS file: /cvs/src/sys/dev/sdmmc/sdmmc.c,v retrieving revision 1.47 diff -u -p -r1.47 sdmmc.c --- dev/sdmmc/sdmmc.c 6 Apr 2017 07:07:28 -0000 1.47 +++ dev/sdmmc/sdmmc.c 24 Dec 2017 00:53:32 -0000 @@ -115,11 +115,12 @@ sdmmc_attach(struct device *parent, stru sc->sct = saa->sct; sc->sch = saa->sch; sc->sc_dmat = saa->dmat; + sc->sc_dmap = saa->dmap; sc->sc_flags = saa->flags; sc->sc_caps = saa->caps; sc->sc_max_xfer = saa->max_xfer; - if (ISSET(sc->sc_caps, SMC_CAPS_DMA)) { + if (ISSET(sc->sc_caps, SMC_CAPS_DMA) && sc->sc_dmap == NULL) { error = bus_dmamap_create(sc->sc_dmat, MAXPHYS, SDMMC_MAXNSEGS, MAXPHYS, 0, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW, &sc->sc_dmap); if (error) { Index: dev/sdmmc/sdmmcchip.h =================================================================== RCS file: /cvs/src/sys/dev/sdmmc/sdmmcchip.h,v retrieving revision 1.9 diff -u -p -r1.9 sdmmcchip.h --- dev/sdmmc/sdmmcchip.h 5 May 2016 20:40:48 -0000 1.9 +++ dev/sdmmc/sdmmcchip.h 24 Dec 2017 00:53:32 -0000 @@ -97,6 +97,7 @@ struct sdmmcbus_attach_args { sdmmc_chipset_tag_t sct; sdmmc_chipset_handle_t sch; bus_dma_tag_t dmat; + bus_dmamap_t dmap; int flags; int caps; long max_xfer;