diff options
author | scottl <scottl@FreeBSD.org> | 2008-02-12 16:24:30 +0000 |
---|---|---|
committer | scottl <scottl@FreeBSD.org> | 2008-02-12 16:24:30 +0000 |
commit | db8258708bf8a571518d133c84f7d5e0bbea8368 (patch) | |
tree | f8c7bedfa0ddc2b0964999befbe86256947ea937 | |
parent | 266bdb9965ed5920c58213cfd9527588f65f47a9 (diff) | |
download | FreeBSD-src-db8258708bf8a571518d133c84f7d5e0bbea8368.zip FreeBSD-src-db8258708bf8a571518d133c84f7d5e0bbea8368.tar.gz |
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
-rw-r--r-- | sys/amd64/amd64/busdma_machdep.c | 4 | ||||
-rw-r--r-- | sys/i386/i386/busdma_machdep.c | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/sys/amd64/amd64/busdma_machdep.c b/sys/amd64/amd64/busdma_machdep.c index 321c49e..c9475d5 100644 --- a/sys/amd64/amd64/busdma_machdep.c +++ b/sys/amd64/amd64/busdma_machdep.c @@ -598,14 +598,14 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat, * Count the number of bounce pages * 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; while (vaddr < vendaddr) { paddr = pmap_kextract(vaddr); if (run_filter(dmat, paddr) != 0) map->pagesneeded++; - vaddr += PAGE_SIZE; + vaddr += (PAGE_SIZE - ((vm_offset_t)vaddr & PAGE_MASK)); } CTR1(KTR_BUSDMA, "pagesneeded= %d\n", map->pagesneeded); } diff --git a/sys/i386/i386/busdma_machdep.c b/sys/i386/i386/busdma_machdep.c index 383061b..0c76c7a 100644 --- a/sys/i386/i386/busdma_machdep.c +++ b/sys/i386/i386/busdma_machdep.c @@ -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 * 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; 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) { map->pagesneeded++; } - vaddr += PAGE_SIZE; + vaddr += (PAGE_SIZE - ((vm_offset_t)vaddr & PAGE_MASK)); } CTR1(KTR_BUSDMA, "pagesneeded= %d\n", map->pagesneeded); } |