Changeset View
Changeset View
Standalone View
Standalone View
sys/x86/x86/busdma_bounce.c
Show First 20 Lines • Show All 317 Lines • ▼ Show 20 Lines | if ((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) { | ||||
* basis up to a sane limit. | * basis up to a sane limit. | ||||
*/ | */ | ||||
if (dmat->common.alignment > 1) | if (dmat->common.alignment > 1) | ||||
maxpages = MAX_BPAGES; | maxpages = MAX_BPAGES; | ||||
else | else | ||||
maxpages = MIN(MAX_BPAGES, Maxmem - | maxpages = MIN(MAX_BPAGES, Maxmem - | ||||
atop(dmat->common.lowaddr)); | atop(dmat->common.lowaddr)); | ||||
if ((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP) == 0 || | if ((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP) == 0 || | ||||
(bz->map_count > 0 && bz->total_bpages < maxpages)) { | (bz->map_count > 0 && bz->total_bpages < maxpages)) { | ||||
jhb: The final check here (`bz->total_pages < maxpages`) does keep us from adding pages for future… | |||||
Done Inline ActionsNot if BUS_DMA_MIN_ALLOC_COMP isn't set. Which I think means we add one extra page per tag (not per dmamap as I said earlier). As before, I really can't say I understand why the code was designed this way... cperciva: Not if BUS_DMA_MIN_ALLOC_COMP isn't set. Which I think means we add one extra page per tag… | |||||
pages = MAX(atop(dmat->common.maxsize), 1); | pages = MAX(atop(dmat->common.maxsize), 1); | ||||
pages = MIN(dmat->common.nsegments, pages); | |||||
pages = MIN(maxpages - bz->total_bpages, pages); | pages = MIN(maxpages - bz->total_bpages, pages); | ||||
pages = MAX(pages, 1); | pages = MAX(pages, 1); | ||||
if (alloc_bounce_pages(dmat, pages) < pages) | if (alloc_bounce_pages(dmat, pages) < pages) | ||||
error = ENOMEM; | error = ENOMEM; | ||||
if ((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP) | if ((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP) | ||||
== 0) { | == 0) { | ||||
if (error == 0) { | if (error == 0) { | ||||
dmat->bounce_flags |= | dmat->bounce_flags |= | ||||
▲ Show 20 Lines • Show All 716 Lines • Show Last 20 Lines |
The final check here (bz->total_pages < maxpages) does keep us from adding pages for future maps once we do hit MAX_BPAGES. But I still find it rather convoluted.