diff --git a/sys/kern/subr_bus_dma.c b/sys/kern/subr_bus_dma.c --- a/sys/kern/subr_bus_dma.c +++ b/sys/kern/subr_bus_dma.c @@ -400,23 +400,23 @@ CTR5(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d nsegs %d", __func__, dmat, flags, error, nsegs); - if (error == EINPROGRESS) + /* + * Previously we were limited to EINPROGRESS here. I guess we should + * return errors as soon as they appear. */ + if (__predict_false(error != 0)) return (error); segs = _bus_dmamap_complete(dmat, map, NULL, nsegs, error); - if (error) + if (__predict_false(error != 0)) (*callback)(callback_arg, segs, 0, error); else (*callback)(callback_arg, segs, nsegs, 0); /* - * 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. + * Previously we returned only ENOMEM. Now we should also return EBIG + * as some architectures (arm64) may also return this error. */ - if (error == ENOMEM) - return (error); - - return (0); + return (error); } int @@ -434,7 +434,7 @@ ++nsegs; segs = _bus_dmamap_complete(dmat, map, NULL, nsegs, error); - if (error) + if (__predict_false(error)) (*callback)(callback_arg, segs, 0, 0, error); else (*callback)(callback_arg, segs, nsegs, m0->m_pkthdr.len, error);