Module Name: src Committed By: msaitoh Date: Thu Jan 5 09:08:45 UTC 2017
Modified Files: src/sys/arch/arm/arm32: bus_dma.c src/sys/arch/x86/x86: bus_dma.c Log Message: Update the dmamp argument only when the allocation succeeded. To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/sys/arch/arm/arm32/bus_dma.c cvs rdiff -u -r1.74 -r1.75 src/sys/arch/x86/x86/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/arm/arm32/bus_dma.c diff -u src/sys/arch/arm/arm32/bus_dma.c:1.97 src/sys/arch/arm/arm32/bus_dma.c:1.98 --- src/sys/arch/arm/arm32/bus_dma.c:1.97 Fri Dec 23 07:15:27 2016 +++ src/sys/arch/arm/arm32/bus_dma.c Thu Jan 5 09:08:45 2017 @@ -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 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_ 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 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_ if ((cookieflags & _BUS_DMA_MIGHT_NEED_BOUNCE) == 0) { STAT_INCR(creates); + *dmamp = map; return 0; } @@ -404,10 +403,12 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_ 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 */ Index: src/sys/arch/x86/x86/bus_dma.c diff -u src/sys/arch/x86/x86/bus_dma.c:1.74 src/sys/arch/x86/x86/bus_dma.c:1.75 --- src/sys/arch/x86/x86/bus_dma.c:1.74 Tue Oct 27 18:49:26 2015 +++ src/sys/arch/x86/x86/bus_dma.c Thu Jan 5 09:08:44 2017 @@ -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 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_ 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 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_ 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 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_ out: if (error) _bus_dmamap_destroy(t, map); + else + *dmamp = map; return (error); }