Module Name:    src
Committed By:   thorpej
Date:           Fri Mar 13 03:49:39 UTC 2020

Modified Files:
        src/sys/arch/mips/mips: bus_dma.c

Log Message:
Allow len == 0 in bus_dmamap_sync().

XXX pullup-9


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/mips/mips/bus_dma.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/mips/mips/bus_dma.c
diff -u src/sys/arch/mips/mips/bus_dma.c:1.38 src/sys/arch/mips/mips/bus_dma.c:1.39
--- src/sys/arch/mips/mips/bus_dma.c:1.38	Wed Aug 17 22:02:19 2016
+++ src/sys/arch/mips/mips/bus_dma.c	Fri Mar 13 03:49:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: bus_dma.c,v 1.38 2016/08/17 22:02:19 skrll Exp $	*/
+/*	$NetBSD: bus_dma.c,v 1.39 2020/03/13 03:49:39 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.38 2016/08/17 22:02:19 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.39 2020/03/13 03:49:39 thorpej Exp $");
 
 #define _MIPS_BUS_DMA_PRIVATE
 
@@ -750,11 +750,12 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
 		panic("_bus_dmamap_sync: mix PRE and POST");
 
 	if (offset >= map->dm_mapsize)
-		panic("_bus_dmamap_sync: bad offset %"PRIxPADDR 
-			" (map size is %"PRIxPSIZE")",
-				offset, map->dm_mapsize);
-	if (len == 0 || (offset + len) > map->dm_mapsize)
-		panic("_bus_dmamap_sync: bad length");
+		panic("%s: bad offset 0x%jx >= 0x%jx", __func__,
+		    (intmax_t)offset, (intmax_t)map->dm_mapsize);
+	if ((offset + len) > map->dm_mapsize)
+		panic("%s: bad length 0x%jx + 0x%jx > 0x%jx", __func__,
+		    (intmax_t)offset, (intmax_t)len,
+		    (intmax_t)map->dm_mapsize);
 #endif
 
 	/*
@@ -777,7 +778,7 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
 #ifdef _MIPS_NEED_BUS_DMA_BOUNCE
 	struct mips_bus_dma_cookie * const cookie = map->_dm_cookie;
 	if (cookie != NULL && (cookie->id_flags & _BUS_DMA_IS_BOUNCING)
-	    && (ops & BUS_DMASYNC_PREWRITE)) {
+	    && (ops & BUS_DMASYNC_PREWRITE) && len != 0) {
 		STAT_INCR(write_bounces);
 		/*
 		 * Copy the caller's buffer to the bounce buffer.
@@ -920,7 +921,8 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
 #ifdef _MIPS_NEED_BUS_DMA_BOUNCE
 	if ((ops & BUS_DMASYNC_POSTREAD) == 0
 	    || cookie == NULL
-	    || (cookie->id_flags & _BUS_DMA_IS_BOUNCING) == 0)
+	    || (cookie->id_flags & _BUS_DMA_IS_BOUNCING) == 0
+	    || len == 0)
 		return;
 
 	STAT_INCR(read_bounces);

Reply via email to