diff --git a/sys/alpha/alpha/busdma_machdep.c b/sys/alpha/alpha/busdma_machdep.c index 28240ae0c27d..8b701041b521 100644 --- a/sys/alpha/alpha/busdma_machdep.c +++ b/sys/alpha/alpha/busdma_machdep.c @@ -674,11 +674,14 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m; for (m = m0; m != NULL && error == 0; m = m->m_next) { - error = _bus_dmamap_load_buffer(dmat, - dm_segments, - m->m_data, m->m_len, - NULL, flags, &lastaddr, &nsegs, first); - first = 0; + if (m->m_len > 0) { + error = _bus_dmamap_load_buffer(dmat, + dm_segments, + m->m_data, m->m_len, + NULL, flags, &lastaddr, + &nsegs, first); + first = 0; + } } } else { error = EINVAL; @@ -738,13 +741,15 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, resid < iov[i].iov_len ? resid : iov[i].iov_len; caddr_t addr = (caddr_t) iov[i].iov_base; - error = _bus_dmamap_load_buffer(dmat, - dm_segments, - addr, minlen, - td, flags, &lastaddr, &nsegs, first); - first = 0; + if (minlen > 0) { + error = _bus_dmamap_load_buffer(dmat, + dm_segments, + addr, minlen, + td, flags, &lastaddr, &nsegs, first); + first = 0; - resid -= minlen; + resid -= minlen; + } } if (error) { diff --git a/sys/amd64/amd64/busdma_machdep.c b/sys/amd64/amd64/busdma_machdep.c index 21e602544130..a5a20fcbab03 100644 --- a/sys/amd64/amd64/busdma_machdep.c +++ b/sys/amd64/amd64/busdma_machdep.c @@ -632,11 +632,14 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m; for (m = m0; m != NULL && error == 0; m = m->m_next) { - error = _bus_dmamap_load_buffer(dmat, - dm_segments, - m->m_data, m->m_len, - NULL, flags, &lastaddr, &nsegs, first); - first = 0; + if (m->m_len > 0) { + error = _bus_dmamap_load_buffer(dmat, + dm_segments, + m->m_data, m->m_len, + NULL, flags, &lastaddr, + &nsegs, first); + first = 0; + } } } else { error = EINVAL; @@ -696,13 +699,15 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, resid < iov[i].iov_len ? resid : iov[i].iov_len; caddr_t addr = (caddr_t) iov[i].iov_base; - error = _bus_dmamap_load_buffer(dmat, - dm_segments, - addr, minlen, - td, flags, &lastaddr, &nsegs, first); - first = 0; + if (minlen > 0) { + error = _bus_dmamap_load_buffer(dmat, + dm_segments, + addr, minlen, + td, flags, &lastaddr, &nsegs, first); + first = 0; - resid -= minlen; + resid -= minlen; + } } if (error) { diff --git a/sys/i386/i386/busdma_machdep.c b/sys/i386/i386/busdma_machdep.c index 21e602544130..a5a20fcbab03 100644 --- a/sys/i386/i386/busdma_machdep.c +++ b/sys/i386/i386/busdma_machdep.c @@ -632,11 +632,14 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m; for (m = m0; m != NULL && error == 0; m = m->m_next) { - error = _bus_dmamap_load_buffer(dmat, - dm_segments, - m->m_data, m->m_len, - NULL, flags, &lastaddr, &nsegs, first); - first = 0; + if (m->m_len > 0) { + error = _bus_dmamap_load_buffer(dmat, + dm_segments, + m->m_data, m->m_len, + NULL, flags, &lastaddr, + &nsegs, first); + first = 0; + } } } else { error = EINVAL; @@ -696,13 +699,15 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, resid < iov[i].iov_len ? resid : iov[i].iov_len; caddr_t addr = (caddr_t) iov[i].iov_base; - error = _bus_dmamap_load_buffer(dmat, - dm_segments, - addr, minlen, - td, flags, &lastaddr, &nsegs, first); - first = 0; + if (minlen > 0) { + error = _bus_dmamap_load_buffer(dmat, + dm_segments, + addr, minlen, + td, flags, &lastaddr, &nsegs, first); + first = 0; - resid -= minlen; + resid -= minlen; + } } if (error) { diff --git a/sys/ia64/ia64/busdma_machdep.c b/sys/ia64/ia64/busdma_machdep.c index e10f0843d855..d12ea4f7ab13 100644 --- a/sys/ia64/ia64/busdma_machdep.c +++ b/sys/ia64/ia64/busdma_machdep.c @@ -644,11 +644,14 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m; for (m = m0; m != NULL && error == 0; m = m->m_next) { - error = _bus_dmamap_load_buffer(dmat, - dm_segments, - m->m_data, m->m_len, - NULL, flags, &lastaddr, &nsegs, first); - first = 0; + if (m->m_len > 0) { + error = _bus_dmamap_load_buffer(dmat, + dm_segments, + m->m_data, m->m_len, + NULL, flags, &lastaddr, + &nsegs, first); + first = 0; + } } } else { error = EINVAL; @@ -708,13 +711,15 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, resid < iov[i].iov_len ? resid : iov[i].iov_len; caddr_t addr = (caddr_t) iov[i].iov_base; - error = _bus_dmamap_load_buffer(dmat, - dm_segments, - addr, minlen, - td, flags, &lastaddr, &nsegs, first); - first = 0; + if (minlen > 0) { + error = _bus_dmamap_load_buffer(dmat, + dm_segments, + addr, minlen, + td, flags, &lastaddr, &nsegs, first); + first = 0; - resid -= minlen; + resid -= minlen; + } } if (error) { diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c index 4bb5f0cf3ae2..6ab1667af103 100644 --- a/sys/powerpc/powerpc/busdma_machdep.c +++ b/sys/powerpc/powerpc/busdma_machdep.c @@ -423,10 +423,12 @@ bus_dmamap_load_mbuf(bus_dma_tag_t dmat, bus_dmamap_t map, struct mbuf *m0, struct mbuf *m; for (m = m0; m != NULL && error == 0; m = m->m_next) { - error = bus_dmamap_load_buffer(dmat, dm_segments, - m->m_data, m->m_len, NULL, flags, - &lastaddr, &nsegs, first); - first = 0; + if (m->m_len > 0) { + error = bus_dmamap_load_buffer(dmat, + dm_segments, m->m_data, m->m_len, NULL, + flags, &lastaddr, &nsegs, first); + first = 0; + } } } else { error = EINVAL; @@ -483,12 +485,14 @@ bus_dmamap_load_uio(bus_dma_tag_t dmat, bus_dmamap_t map, struct uio *uio, resid < iov[i].iov_len ? resid : iov[i].iov_len; caddr_t addr = (caddr_t) iov[i].iov_base; - error = bus_dmamap_load_buffer(dmat, dm_segments, addr, - minlen, td, flags, &lastaddr, &nsegs, first); + if (minlen > 0) { + error = bus_dmamap_load_buffer(dmat, dm_segments, addr, + minlen, td, flags, &lastaddr, &nsegs, first); - first = 0; + first = 0; - resid -= minlen; + resid -= minlen; + } } if (error) { diff --git a/sys/sparc64/sparc64/bus_machdep.c b/sys/sparc64/sparc64/bus_machdep.c index f11e9a01cca2..0c26023a22d0 100644 --- a/sys/sparc64/sparc64/bus_machdep.c +++ b/sys/sparc64/sparc64/bus_machdep.c @@ -454,10 +454,12 @@ nexus_dmamap_load_mbuf(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, struct mbuf *m; for (m = m0; m != NULL && error == 0; m = m->m_next) { - error = _nexus_dmamap_load_buffer(ddmat, - dm_segments, m->m_data, m->m_len, NULL, flags, - &lastaddr, &nsegs, first); - first = 0; + if (m->m_len > 0) { + error = _nexus_dmamap_load_buffer(ddmat, + dm_segments, m->m_data, m->m_len, NULL, + flags, &lastaddr, &nsegs, first); + first = 0; + } } } else { error = EINVAL; @@ -514,11 +516,13 @@ nexus_dmamap_load_uio(bus_dma_tag_t pdmat, bus_dma_tag_t ddmat, resid < iov[i].iov_len ? resid : iov[i].iov_len; caddr_t addr = (caddr_t) iov[i].iov_base; - error = _nexus_dmamap_load_buffer(ddmat, dm_segments, addr, - minlen, td, flags, &lastaddr, &nsegs, first); - first = 0; + if (minlen > 0) { + error = _nexus_dmamap_load_buffer(ddmat, dm_segments, + addr, minlen, td, flags, &lastaddr, &nsegs, first); + first = 0; - resid -= minlen; + resid -= minlen; + } } if (error) {