diff options
author | skra <skra@FreeBSD.org> | 2015-11-21 19:55:01 +0000 |
---|---|---|
committer | skra <skra@FreeBSD.org> | 2015-11-21 19:55:01 +0000 |
commit | 878d380e47836d558fe3ed644cf376159f9f63dd (patch) | |
tree | a2f950be9ed45eef9d36916983f76f162e19fe58 /sys/powerpc/powerpc | |
parent | 166f1788604aff8fa632cfd46c947fec8749ba6e (diff) | |
download | FreeBSD-src-878d380e47836d558fe3ed644cf376159f9f63dd.zip FreeBSD-src-878d380e47836d558fe3ed644cf376159f9f63dd.tar.gz |
Fix BUS_DMA_MIN_ALLOC_COMP flag logic. When bus_dmamap_t map is being
created for bus_dma_tag_t tag, bounce pages should be allocated
only if needed.
Before the fix, they were allocated always if BUS_DMA_COULD_BOUNCE flag
was set but BUS_DMA_MIN_ALLOC_COMP not. As bounce pages are never freed,
it could cause memory exhaustion when a lot of such tags together with
their maps were created.
Note that there could be more maps in one tag by current design.
However BUS_DMA_MIN_ALLOC_COMP flag is tag's flag. It's set after
bounce pages are allocated. Thus, they are allocated only for first
tag's map which needs them.
Approved by: kib (mentor)
Diffstat (limited to 'sys/powerpc/powerpc')
-rw-r--r-- | sys/powerpc/powerpc/busdma_machdep.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c index 1e57d92..122e507 100644 --- a/sys/powerpc/powerpc/busdma_machdep.c +++ b/sys/powerpc/powerpc/busdma_machdep.c @@ -423,8 +423,8 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) 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); |