diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c --- a/sys/arm/arm/busdma_machdep.c +++ b/sys/arm/arm/busdma_machdep.c @@ -541,8 +541,8 @@ maxpages = MAX_BPAGES; else maxpages = 2 * bz->map_count; - if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0 || - (bz->map_count > 0 && bz->total_bpages < maxpages)) { + if (((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0 || + bz->map_count > 0) && bz->total_bpages < maxpages) { int pages; pages = atop(roundup2(dmat->maxsize, PAGE_SIZE)) + 1; @@ -550,9 +550,7 @@ pages = MAX(pages, 2); if (alloc_bounce_pages(dmat, pages) < pages) return (ENOMEM); - - if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0) - dmat->flags |= BUS_DMA_MIN_ALLOC_COMP; + dmat->flags |= BUS_DMA_MIN_ALLOC_COMP; } bz->map_count++; return (0); diff --git a/sys/arm64/arm64/busdma_bounce.c b/sys/arm64/arm64/busdma_bounce.c --- a/sys/arm64/arm64/busdma_bounce.c +++ b/sys/arm64/arm64/busdma_bounce.c @@ -432,19 +432,15 @@ else maxpages = MIN(MAX_BPAGES, Maxmem - atop(dmat->common.lowaddr)); - if ((dmat->bounce_flags & BF_MIN_ALLOC_COMP) == 0 || - (bz->map_count > 0 && bz->total_bpages < maxpages)) { + if (((dmat->bounce_flags & BF_MIN_ALLOC_COMP) == 0 || + bz->map_count > 0) && bz->total_bpages < maxpages) { pages = atop(roundup2(dmat->common.maxsize, PAGE_SIZE)) + 1; pages = MIN(maxpages - bz->total_bpages, pages); pages = MAX(pages, 2); if (alloc_bounce_pages(dmat, pages) < pages) error = ENOMEM; - if ((dmat->bounce_flags & BF_MIN_ALLOC_COMP) == 0) { - if (error == 0) { - dmat->bounce_flags |= BF_MIN_ALLOC_COMP; - } - } else - error = 0; + else + dmat->bounce_flags |= BF_MIN_ALLOC_COMP; } bz->map_count++; diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c --- a/sys/powerpc/powerpc/busdma_machdep.c +++ b/sys/powerpc/powerpc/busdma_machdep.c @@ -330,22 +330,16 @@ maxpages = MAX_BPAGES; else maxpages = MIN(MAX_BPAGES, Maxmem -atop(dmat->lowaddr)); - if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0 - || (bz->map_count > 0 && bz->total_bpages < maxpages)) { + if (((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0 || + bz->map_count > 0) && bz->total_bpages < maxpages) { int pages; pages = MAX(atop(dmat->maxsize), 1); pages = MIN(maxpages - bz->total_bpages, pages); - pages = MAX(pages, 1); if (alloc_bounce_pages(dmat, pages) < pages) error = ENOMEM; - - if ((dmat->flags & BUS_DMA_MIN_ALLOC_COMP) == 0) { - if (error == 0) - dmat->flags |= BUS_DMA_MIN_ALLOC_COMP; - } else { - error = 0; - } + else + dmat->flags |= BUS_DMA_MIN_ALLOC_COMP; } bz->map_count++; } diff --git a/sys/riscv/riscv/busdma_bounce.c b/sys/riscv/riscv/busdma_bounce.c --- a/sys/riscv/riscv/busdma_bounce.c +++ b/sys/riscv/riscv/busdma_bounce.c @@ -291,21 +291,14 @@ else maxpages = MIN(MAX_BPAGES, Maxmem - atop(dmat->common.lowaddr)); - if ((dmat->bounce_flags & BF_MIN_ALLOC_COMP) == 0 || - (bz->map_count > 0 && bz->total_bpages < maxpages)) { + if (((dmat->bounce_flags & BF_MIN_ALLOC_COMP) == 0 || + bz->map_count > 0) && bz->total_bpages < maxpages) { pages = MAX(atop(dmat->common.maxsize), 1); pages = MIN(maxpages - bz->total_bpages, pages); - pages = MAX(pages, 1); if (alloc_bounce_pages(dmat, pages) < pages) error = ENOMEM; - if ((dmat->bounce_flags & BF_MIN_ALLOC_COMP) - == 0) { - if (error == 0) { - dmat->bounce_flags |= - BF_MIN_ALLOC_COMP; - } - } else - error = 0; + else + dmat->bounce_flags |= BF_MIN_ALLOC_COMP; } bz->map_count++; } diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c --- a/sys/x86/x86/busdma_bounce.c +++ b/sys/x86/x86/busdma_bounce.c @@ -323,22 +323,15 @@ else maxpages = MIN(MAX_BPAGES, Maxmem - atop(dmat->common.lowaddr)); - if ((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP) == 0 || - (bz->map_count > 0 && bz->total_bpages < maxpages)) { + if (((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP) == 0 || + bz->map_count > 0) && bz->total_bpages < maxpages) { pages = MAX(atop(dmat->common.maxsize), 1); pages = MIN(dmat->common.nsegments, pages); pages = MIN(maxpages - bz->total_bpages, pages); - pages = MAX(pages, 1); if (alloc_bounce_pages(dmat, pages) < pages) error = ENOMEM; - if ((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP) - == 0) { - if (error == 0) { - dmat->bounce_flags |= - BUS_DMA_MIN_ALLOC_COMP; - } - } else - error = 0; + else + dmat->bounce_flags |= BUS_DMA_MIN_ALLOC_COMP; } bz->map_count++; }