Date: Fri, 29 Mar 2013 16:26:25 +0000 (UTC) From: Jim Harris <jimharris@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r248896 - in head/sys: kern sys Message-ID: <201303291626.r2TGQPsp051920@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jimharris Date: Fri Mar 29 16:26:25 2013 New Revision: 248896 URL: http://svnweb.freebsd.org/changeset/base/248896 Log: Add bus_dmamap_load_bio for non-CAM disk drivers that wish to enable unmapped I/O. Sponsored by: Intel Reviewed by: kib Modified: head/sys/kern/subr_bus_dma.c head/sys/sys/bus_dma.h Modified: head/sys/kern/subr_bus_dma.c ============================================================================== --- head/sys/kern/subr_bus_dma.c Fri Mar 29 16:24:20 2013 (r248895) +++ head/sys/kern/subr_bus_dma.c Fri Mar 29 16:26:25 2013 (r248896) @@ -409,6 +409,45 @@ bus_dmamap_load_ccb(bus_dma_tag_t dmat, } int +bus_dmamap_load_bio(bus_dma_tag_t dmat, bus_dmamap_t map, struct bio *bio, + bus_dmamap_callback_t *callback, void *callback_arg, + int flags) +{ + bus_dma_segment_t *segs; + struct memdesc mem; + int error; + int nsegs; + + if ((flags & BUS_DMA_NOWAIT) == 0) { + mem = memdesc_bio(bio); + _bus_dmamap_waitok(dmat, map, &mem, callback, callback_arg); + } + nsegs = -1; + error = _bus_dmamap_load_bio(dmat, map, bio, &nsegs, flags); + nsegs++; + + CTR5(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d nsegs %d", + __func__, dmat, flags, error, nsegs); + + if (error == EINPROGRESS) + return (error); + + segs = _bus_dmamap_complete(dmat, map, NULL, nsegs, error); + if (error) + (*callback)(callback_arg, segs, 0, error); + else + (*callback)(callback_arg, segs, nsegs, error); + /* + * Return ENOMEM to the caller so that it can pass it up the stack. + * This error only happens when NOWAIT is set, so deferral is disabled. + */ + if (error == ENOMEM) + return (error); + + return (0); +} + +int bus_dmamap_load_mem(bus_dma_tag_t dmat, bus_dmamap_t map, struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg, int flags) Modified: head/sys/sys/bus_dma.h ============================================================================== --- head/sys/sys/bus_dma.h Fri Mar 29 16:24:20 2013 (r248895) +++ head/sys/sys/bus_dma.h Fri Mar 29 16:26:25 2013 (r248896) @@ -233,6 +233,13 @@ int bus_dmamap_load_ccb(bus_dma_tag_t dm int flags); /* + * Like bus_dmamap_load but for bios. + */ +int bus_dmamap_load_bio(bus_dma_tag_t dmat, bus_dmamap_t map, struct bio *bio, + bus_dmamap_callback_t *callback, void *callback_arg, + int flags); + +/* * Loads any memory descriptor. */ int bus_dmamap_load_mem(bus_dma_tag_t dmat, bus_dmamap_t map,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303291626.r2TGQPsp051920>