A busdma tag maintains a "bounce zone", an allocator of pages that can
be used to transfer data when a DMA mapping requires bouncing. These
pages are generally reserved at DMA map creation time, or at tag
creation time (if BUS_DMA_ALLOCNOW is specified).
busdma tags may share a single bounce zone. If BUS_DMA_ALLOCNOW is not
specified when creating a tag, then the first mapping created for that
tag will reserve a page in the bounce zone, even though it may not be
needed. This can result in overallocation and leaks of memory if many
busdma tags and mappings are created, or if tags and mappings are
destroyed and re-created over time.
Commit 6fa7734d6fbbe attempted to fix this, but made the bounce page
reservation logic too restrictive, causing some drivers to fail to
reserve bounce pages entirely; it was reverted in commit eae22c44301.
Try again to fix the same problem: try to reserve pages if the zone does
not already exceed its maximum. While here, simplify logic used to set
the BUS_DMA_MI_ALLOC_COMP flag on a tag after bounce pages are
successfully reserved.
PR: 278569