Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 1 Feb 2019 00:36:14 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r343637 - in stable/12/sys/x86: include x86
Message-ID:  <201902010036.x110aEpM047214@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Fri Feb  1 00:36:14 2019
New Revision: 343637
URL: https://svnweb.freebsd.org/changeset/base/343637

Log:
  MFC r343146:
  x86 busdma: fix mis-use of bus_addr_t where vm_paddr_t is assumed.

Modified:
  stable/12/sys/x86/include/busdma_impl.h
  stable/12/sys/x86/x86/busdma_bounce.c
  stable/12/sys/x86/x86/busdma_machdep.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/x86/include/busdma_impl.h
==============================================================================
--- stable/12/sys/x86/include/busdma_impl.h	Fri Feb  1 00:34:18 2019	(r343636)
+++ stable/12/sys/x86/include/busdma_impl.h	Fri Feb  1 00:36:14 2019	(r343637)
@@ -87,7 +87,7 @@ struct bus_dma_impl {
 };
 
 void bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op);
-int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr);
+int bus_dma_run_filter(struct bus_dma_tag_common *dmat, vm_paddr_t paddr);
 int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
     bus_size_t alignment,
     bus_addr_t boundary, bus_addr_t lowaddr, bus_addr_t highaddr,

Modified: stable/12/sys/x86/x86/busdma_bounce.c
==============================================================================
--- stable/12/sys/x86/x86/busdma_bounce.c	Fri Feb  1 00:34:18 2019	(r343636)
+++ stable/12/sys/x86/x86/busdma_bounce.c	Fri Feb  1 00:36:14 2019	(r343637)
@@ -139,7 +139,7 @@ static int alloc_bounce_pages(bus_dma_tag_t dmat, u_in
 static int reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
     int commit);
 static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map,
-    vm_offset_t vaddr, bus_addr_t addr1, bus_addr_t addr2, bus_size_t size);
+    vm_offset_t vaddr, vm_paddr_t addr1, vm_paddr_t addr2, bus_size_t size);
 static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage);
 static void _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
     pmap_t pmap, void *buf, bus_size_t buflen, int flags);
@@ -507,7 +507,7 @@ static void
 _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf,
     bus_size_t buflen, int flags)
 {
-	bus_addr_t curaddr;
+	vm_paddr_t curaddr;
 	bus_size_t sgsize;
 
 	if (map != &nobounce_dmamap && map->pagesneeded == 0) {
@@ -536,7 +536,7 @@ _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap
 {
 	vm_offset_t vaddr;
 	vm_offset_t vendaddr;
-	bus_addr_t paddr;
+	vm_paddr_t paddr;
 	bus_size_t sg_len;
 
 	if (map != &nobounce_dmamap && map->pagesneeded == 0) {
@@ -643,12 +643,19 @@ _bus_dmamap_reserve_pages(bus_dma_tag_t dmat, bus_dmam
  * Add a single contiguous physical range to the segment list.
  */
 static int
-_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t curaddr,
+_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t curaddr,
     bus_size_t sgsize, bus_dma_segment_t *segs, int *segp)
 {
 	bus_addr_t baddr, bmask;
 	int seg;
 
+	KASSERT(curaddr <= BUS_SPACE_MAXADDR,
+	    ("ds_addr %#jx > BUS_SPACE_MAXADDR %#jx; dmat %p fl %#x low %#jx "
+	    "hi %#jx",
+	    (uintmax_t)curaddr, (uintmax_t)BUS_SPACE_MAXADDR,
+	    dmat, dmat->bounce_flags, (uintmax_t)dmat->common.lowaddr,
+	    (uintmax_t)dmat->common.highaddr));
+
 	/*
 	 * Make sure we don't cross any boundaries.
 	 */
@@ -695,7 +702,7 @@ bounce_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dm
     int *segp)
 {
 	bus_size_t sgsize;
-	bus_addr_t curaddr;
+	vm_paddr_t curaddr;
 	int error;
 
 	if (map == NULL)
@@ -747,7 +754,7 @@ bounce_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_
     int *segp)
 {
 	bus_size_t sgsize, max_sgsize;
-	bus_addr_t curaddr;
+	vm_paddr_t curaddr;
 	vm_offset_t kvaddr, vaddr;
 	int error;
 
@@ -1194,7 +1201,7 @@ reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t 
 
 static bus_addr_t
 add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
-    bus_addr_t addr1, bus_addr_t addr2, bus_size_t size)
+    vm_paddr_t addr1, vm_paddr_t addr2, bus_size_t size)
 {
 	struct bounce_zone *bz;
 	struct bounce_page *bpage;

Modified: stable/12/sys/x86/x86/busdma_machdep.c
==============================================================================
--- stable/12/sys/x86/x86/busdma_machdep.c	Fri Feb  1 00:34:18 2019	(r343636)
+++ stable/12/sys/x86/x86/busdma_machdep.c	Fri Feb  1 00:36:14 2019	(r343637)
@@ -99,14 +99,15 @@ bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op)
  * to check for a match, if there is no filter callback then assume a match.
  */
 int
-bus_dma_run_filter(struct bus_dma_tag_common *tc, bus_addr_t paddr)
+bus_dma_run_filter(struct bus_dma_tag_common *tc, vm_paddr_t paddr)
 {
 	int retval;
 
 	retval = 0;
 	do {
-		if (((paddr > tc->lowaddr && paddr <= tc->highaddr) ||
-		    ((paddr & (tc->alignment - 1)) != 0)) &&
+		if ((paddr >= BUS_SPACE_MAXADDR ||
+		    (paddr > tc->lowaddr && paddr <= tc->highaddr) ||
+		    (paddr & (tc->alignment - 1)) != 0) &&
 		    (tc->filter == NULL ||
 		    (*tc->filter)(tc->filterarg, paddr) != 0))
 			retval = 1;



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