If busdma is being used to realign dynamic buffers and the alignment is set to

PAGE_SIZE or less, the bounce page counting logic was flawed and wouldn't
reserve any pages.  Adjust to be correct.  Review of other architectures is
forthcoming.

Submitted by: Joseph Golio
This commit is contained in:
scottl 2008-02-12 16:24:30 +00:00
parent 266bdb9965
commit db8258708b
2 changed files with 4 additions and 4 deletions

View File

@ -598,14 +598,14 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat,
* Count the number of bounce pages * Count the number of bounce pages
* needed in order to complete this transfer * needed in order to complete this transfer
*/ */
vaddr = trunc_page((vm_offset_t)buf); vaddr = (vm_offset_t)buf;
vendaddr = (vm_offset_t)buf + buflen; vendaddr = (vm_offset_t)buf + buflen;
while (vaddr < vendaddr) { while (vaddr < vendaddr) {
paddr = pmap_kextract(vaddr); paddr = pmap_kextract(vaddr);
if (run_filter(dmat, paddr) != 0) if (run_filter(dmat, paddr) != 0)
map->pagesneeded++; map->pagesneeded++;
vaddr += PAGE_SIZE; vaddr += (PAGE_SIZE - ((vm_offset_t)vaddr & PAGE_MASK));
} }
CTR1(KTR_BUSDMA, "pagesneeded= %d\n", map->pagesneeded); CTR1(KTR_BUSDMA, "pagesneeded= %d\n", map->pagesneeded);
} }

View File

@ -585,7 +585,7 @@ _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
* Count the number of bounce pages * Count the number of bounce pages
* needed in order to complete this transfer * needed in order to complete this transfer
*/ */
vaddr = trunc_page((vm_offset_t)buf); vaddr = (vm_offset_t)buf;
vendaddr = (vm_offset_t)buf + buflen; vendaddr = (vm_offset_t)buf + buflen;
while (vaddr < vendaddr) { while (vaddr < vendaddr) {
@ -594,7 +594,7 @@ _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
run_filter(dmat, paddr) != 0) { run_filter(dmat, paddr) != 0) {
map->pagesneeded++; map->pagesneeded++;
} }
vaddr += PAGE_SIZE; vaddr += (PAGE_SIZE - ((vm_offset_t)vaddr & PAGE_MASK));
} }
CTR1(KTR_BUSDMA, "pagesneeded= %d\n", map->pagesneeded); CTR1(KTR_BUSDMA, "pagesneeded= %d\n", map->pagesneeded);
} }