Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Oct 2015 02:17:56 +0000 (UTC)
From:      "Jason A. Harmening" <jah@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r289202 - head/sys/x86/x86
Message-ID:  <201510130217.t9D2HuHT028699@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510130217.t9D2HuHT028699>