svn commit: r206405 - head/sys/mips/mips
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Fri Apr 9 01:14:11 UTC 2010
Author: nwhitehorn
Date: Fri Apr 9 01:14:11 2010
New Revision: 206405
URL: http://svn.freebsd.org/changeset/base/206405
Log:
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
Modified:
head/sys/mips/mips/busdma_machdep.c
Modified: head/sys/mips/mips/busdma_machdep.c
==============================================================================
--- head/sys/mips/mips/busdma_machdep.c Thu Apr 8 19:34:55 2010 (r206404)
+++ head/sys/mips/mips/busdma_machdep.c Fri Apr 9 01:14:11 2010 (r206405)
@@ -687,16 +687,21 @@ _bus_dmamap_count_pages(bus_dma_tag_t dm
* 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);
}
More information about the svn-src-all
mailing list