summaryrefslogtreecommitdiffstats
path: root/sys/mips
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2010-04-09 01:14:11 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2010-04-09 01:14:11 +0000
commit4f086c2604dc3f689c57c6e0619187d74ddb1ca2 (patch)
tree35d21fceab9604546f96b77dcdab2fb418546d05 /sys/mips
parent7631143fbce954e8f11c2618b26aac6af6883c07 (diff)
downloadFreeBSD-src-4f086c2604dc3f689c57c6e0619187d74ddb1ca2.zip
FreeBSD-src-4f086c2604dc3f689c57c6e0619187d74ddb1ca2.tar.gz
Fix a bug where bus_dma_load_xxx() would not bounce misaligned buffers
due to rounding the buffer's physical address to the beginning of its page. This fixes a panic in arge(4) when using PPPoE. Reported by: Jakob van Santen <vansanten at wisc dot edu> Reviewed by: gonzo Obtained from: amd64
Diffstat (limited to 'sys/mips')
-rw-r--r--sys/mips/mips/busdma_machdep.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/mips/mips/busdma_machdep.c b/sys/mips/mips/busdma_machdep.c
index f2d41df..a6a7419 100644
--- a/sys/mips/mips/busdma_machdep.c
+++ b/sys/mips/mips/busdma_machdep.c
@@ -687,16 +687,21 @@ _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, pmap_t pmap,
* 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) {
+ bus_size_t sg_len;
+
KASSERT(kernel_pmap == pmap, ("pmap is not kernel pmap"));
+ sg_len = PAGE_SIZE - ((vm_offset_t)vaddr & PAGE_MASK);
paddr = pmap_kextract(vaddr);
if (((dmat->flags & BUS_DMA_COULD_BOUNCE) != 0) &&
- run_filter(dmat, paddr) != 0)
+ run_filter(dmat, paddr) != 0) {
+ sg_len = roundup2(sg_len, dmat->alignment);
map->pagesneeded++;
- vaddr += PAGE_SIZE;
+ }
+ vaddr += sg_len;
}
CTR1(KTR_BUSDMA, "pagesneeded= %d\n", map->pagesneeded);
}
OpenPOWER on IntegriCloud