diff options
author | jah <jah@FreeBSD.org> | 2015-10-13 02:17:56 +0000 |
---|---|---|
committer | jah <jah@FreeBSD.org> | 2015-10-13 02:17:56 +0000 |
commit | 12fd50f244eb30a8abe71c32de3cd15e43950cc8 (patch) | |
tree | dde1bfb07724bd8d312583f9661a4b1cfb92da01 /sys/x86 | |
parent | f5fe95c16689039f41ebcbc6d142094a85abbd67 (diff) | |
download | FreeBSD-src-12fd50f244eb30a8abe71c32de3cd15e43950cc8.zip FreeBSD-src-12fd50f244eb30a8abe71c32de3cd15e43950cc8.tar.gz |
Ensure the client regions for unmapped bounce buffers created through bus_dmamap_load_phys() do not span multiple pages.
This is already done for mapped buffers.
While here, stop casting bus_addr_t to vm_offset_t.
Diffstat (limited to 'sys/x86')
-rw-r--r-- | sys/x86/x86/busdma_bounce.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c index 48c500f..48f9bb3 100644 --- a/sys/x86/x86/busdma_bounce.c +++ b/sys/x86/x86/busdma_bounce.c @@ -476,7 +476,8 @@ _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf, while (buflen != 0) { sgsize = MIN(buflen, dmat->common.maxsegsz); if (bus_dma_run_filter(&dmat->common, curaddr)) { - sgsize = MIN(sgsize, PAGE_SIZE); + sgsize = MIN(sgsize, + PAGE_SIZE - (curaddr & PAGE_MASK)); map->pagesneeded++; } curaddr += sgsize; @@ -630,7 +631,7 @@ bounce_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) && map->pagesneeded != 0 && bus_dma_run_filter(&dmat->common, curaddr)) { - sgsize = MIN(sgsize, PAGE_SIZE); + sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK)); curaddr = add_bounce_page(dmat, map, 0, curaddr, sgsize); } @@ -694,7 +695,7 @@ bounce_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf, * Compute the segment size, and adjust counts. */ max_sgsize = MIN(buflen, dmat->common.maxsegsz); - sgsize = PAGE_SIZE - ((vm_offset_t)curaddr & PAGE_MASK); + sgsize = PAGE_SIZE - (curaddr & PAGE_MASK); if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) && map->pagesneeded != 0 && bus_dma_run_filter(&dmat->common, curaddr)) { |