Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/mips/mips Allow len == 0 in bus_dmamap_sync().



details:   https://anonhg.NetBSD.org/src/rev/1dfc8b20df29
branches:  trunk
changeset: 745806:1dfc8b20df29
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Mar 13 03:49:39 2020 +0000

description:
Allow len == 0 in bus_dmamap_sync().

XXX pullup-9

diffstat:

 sys/arch/mips/mips/bus_dma.c |  20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diffs (55 lines):

diff -r 788afa316544 -r 1dfc8b20df29 sys/arch/mips/mips/bus_dma.c
--- a/sys/arch/mips/mips/bus_dma.c      Fri Mar 13 03:45:58 2020 +0000
+++ b/sys/arch/mips/mips/bus_dma.c      Fri Mar 13 03:49:39 2020 +0000
@@ -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 @@
                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 @@
 #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 @@
 #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);



Home | Main Index | Thread Index | Old Index