From 7ef1f80fdd3ab40ec0c9ba6a13e39b0552eea059 Mon Sep 17 00:00:00 2001 From: scottl Date: Wed, 3 May 2006 04:14:17 +0000 Subject: Allow bus_dmamap_load() to pass ENOMEM back to the caller. This puts it into conformance with the mbuf and uio load routines. ENOMEM can only happen with BUS_DMA_NOWAIT is passed in, thus the deferals are disabled. I don't like doing this, but fixing this fixes assumptions in other important drivers, which is a net benefit for now. --- sys/amd64/amd64/busdma_machdep.c | 14 ++++++++++---- sys/i386/i386/busdma_machdep.c | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/sys/amd64/amd64/busdma_machdep.c b/sys/amd64/amd64/busdma_machdep.c index 1d70417..348ab78 100644 --- a/sys/amd64/amd64/busdma_machdep.c +++ b/sys/amd64/amd64/busdma_machdep.c @@ -703,9 +703,10 @@ bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, error = _bus_dmamap_load_buffer(dmat, map, buf, buflen, NULL, flags, &lastaddr, dmat->segments, &nsegs, 1); + CTR5(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d nsegs %d", + __func__, dmat, dmat->flags, error, nsegs + 1); + if (error == EINPROGRESS) { - CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d", - __func__, dmat, dmat->flags, error); return (error); } @@ -714,8 +715,13 @@ bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, else (*callback)(callback_arg, dmat->segments, nsegs + 1, 0); - CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error 0 nsegs %d", - __func__, dmat, dmat->flags, nsegs + 1); + /* + * Return ENOMEM to the caller so that it can pass it up the stack. + * This error only happens when NOWAIT is set, so deferal is disabled. + */ + if (error == ENOMEM) + return (error); + return (0); } diff --git a/sys/i386/i386/busdma_machdep.c b/sys/i386/i386/busdma_machdep.c index 08db5e0..0904bfb 100644 --- a/sys/i386/i386/busdma_machdep.c +++ b/sys/i386/i386/busdma_machdep.c @@ -706,9 +706,10 @@ bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, error = _bus_dmamap_load_buffer(dmat, map, buf, buflen, NULL, flags, &lastaddr, dmat->segments, &nsegs, 1); + CTR5(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d nsegs %d", + __func__, dmat, dmat->flags, error, nsegs + 1); + if (error == EINPROGRESS) { - CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d", - __func__, dmat, dmat->flags, error); return (error); } @@ -717,8 +718,13 @@ bus_dmamap_load(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, else (*callback)(callback_arg, dmat->segments, nsegs + 1, 0); - CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error 0 nsegs %d", - __func__, dmat, dmat->flags, nsegs + 1); + /* + * Return ENOMEM to the caller so that it can pass it up the stack. + * This error only happens when NOWAIT is set, so deferal is disabled. + */ + if (error == ENOMEM) + return (error); + return (0); } -- cgit v1.1