Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Update the dmamp argument only when the allocation ...



details:   https://anonhg.NetBSD.org/src/rev/349c06238dbc
branches:  trunk
changeset: 820265:349c06238dbc
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Jan 05 09:08:44 2017 +0000

description:
Update the dmamp argument only when the allocation succeeded.

diffstat:

 sys/arch/arm/arm32/bus_dma.c |  11 ++++++-----
 sys/arch/x86/x86/bus_dma.c   |  12 +++++++-----
 2 files changed, 13 insertions(+), 10 deletions(-)

diffs (97 lines):

diff -r 7e77adec1d4a -r 349c06238dbc sys/arch/arm/arm32/bus_dma.c
--- a/sys/arch/arm/arm32/bus_dma.c      Thu Jan 05 07:53:20 2017 +0000
+++ b/sys/arch/arm/arm32/bus_dma.c      Thu Jan 05 09:08:44 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_dma.c,v 1.97 2016/12/23 07:15:27 cherry Exp $      */
+/*     $NetBSD: bus_dma.c,v 1.98 2017/01/05 09:08:45 msaitoh Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_arm_bus_space.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.97 2016/12/23 07:15:27 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.98 2017/01/05 09:08:45 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -361,8 +361,6 @@
        map->dm_mapsize = 0;            /* no valid mappings */
        map->dm_nsegs = 0;
 
-       *dmamp = map;
-
 #ifdef _ARM32_NEED_BUS_DMA_BOUNCE
        struct arm32_bus_dma_cookie *cookie;
        int cookieflags;
@@ -382,6 +380,7 @@
 
        if ((cookieflags & _BUS_DMA_MIGHT_NEED_BOUNCE) == 0) {
                STAT_INCR(creates);
+               *dmamp = map;
                return 0;
        }
 
@@ -404,10 +403,12 @@
  out:
        if (error)
                _bus_dmamap_destroy(t, map);
+       else
+               *dmamp = map;
 #else
+       *dmamp = map;
        STAT_INCR(creates);
 #endif /* _ARM32_NEED_BUS_DMA_BOUNCE */
-
 #ifdef DEBUG_DMA
        printf("dmamap_create:map=%p\n", map);
 #endif /* DEBUG_DMA */
diff -r 7e77adec1d4a -r 349c06238dbc sys/arch/x86/x86/bus_dma.c
--- a/sys/arch/x86/x86/bus_dma.c        Thu Jan 05 07:53:20 2017 +0000
+++ b/sys/arch/x86/x86/bus_dma.c        Thu Jan 05 09:08:44 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_dma.c,v 1.74 2015/10/27 18:49:26 christos Exp $    */
+/*     $NetBSD: bus_dma.c,v 1.75 2017/01/05 09:08:44 msaitoh Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2007 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.74 2015/10/27 18:49:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.75 2017/01/05 09:08:44 msaitoh Exp $");
 
 /*
  * The following is included because _bus_dma_uiomove is derived from
@@ -306,8 +306,6 @@
        map->dm_mapsize = 0;            /* no valid mappings */
        map->dm_nsegs = 0;
 
-       *dmamp = map;
-
        if (t->_bounce_thresh == 0 || _BUS_AVAIL_END <= t->_bounce_thresh)
                map->_dm_bounce_thresh = 0;
        cookieflags = 0;
@@ -321,8 +319,10 @@
        if (map->_dm_bounce_thresh != 0)
                cookieflags |= X86_DMA_MIGHT_NEED_BOUNCE;
 
-       if ((cookieflags & X86_DMA_MIGHT_NEED_BOUNCE) == 0)
+       if ((cookieflags & X86_DMA_MIGHT_NEED_BOUNCE) == 0) {
+               *dmamp = map;
                return 0;
+       }
 
        cookiesize = sizeof(struct x86_bus_dma_cookie) +
            (sizeof(bus_dma_segment_t) * map->_dm_segcnt);
@@ -343,6 +343,8 @@
  out:
        if (error)
                _bus_dmamap_destroy(t, map);
+       else
+               *dmamp = map;
 
        return (error);
 }



Home | Main Index | Thread Index | Old Index