Author: jah
Date: Tue Oct 13 02:17:56 2015
New Revision: 289202
URL: https://svnweb.freebsd.org/changeset/base/289202

Log:
  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.

Modified:
  head/sys/x86/x86/busdma_bounce.c

Modified: head/sys/x86/x86/busdma_bounce.c
==============================================================================
--- head/sys/x86/x86/busdma_bounce.c    Tue Oct 13 01:04:38 2015        
(r289201)
+++ head/sys/x86/x86/busdma_bounce.c    Tue Oct 13 02:17:56 2015        
(r289202)
@@ -476,7 +476,8 @@ _bus_dmamap_count_phys(bus_dma_tag_t dma
                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_
                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_ta
                 * 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)) {
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to