diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-07-31 14:30:05 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-07-31 14:30:05 +0000 |
commit | 339c66d4a0faeb891adbdecdcd53766094ff8717 (patch) | |
tree | 20e945b3e1d138a41630fcbeb09948cd6736e87f | |
parent | 1374f3ab2e843d3deb579088ee8d96258c94b011 (diff) |
on error, just call unload() instead of doing all the actions that it
would do manually.
sparc64 does a similar thing already.
ok kettenis@
-rw-r--r-- | sys/arch/amd64/amd64/sg_dma.c | 22 | ||||
-rw-r--r-- | sys/arch/i386/i386/sg_dma.c | 28 |
2 files changed, 8 insertions, 42 deletions
diff --git a/sys/arch/amd64/amd64/sg_dma.c b/sys/arch/amd64/amd64/sg_dma.c index 86488e306d8..e60c95dbe99 100644 --- a/sys/arch/amd64/amd64/sg_dma.c +++ b/sys/arch/amd64/amd64/sg_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sg_dma.c,v 1.5 2009/06/08 11:16:11 jsg Exp $ */ +/* $OpenBSD: sg_dma.c,v 1.6 2009/07/31 14:30:04 oga Exp $ */ /* * Copyright (c) 2009 Owain G. Ainsworth <oga@openbsd.org> * @@ -329,15 +329,7 @@ sg_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, } } if (err) { - sg_iomap_unload_map(is, spm); - sg_iomap_clear_pages(spm); - map->dm_mapsize = 0; - map->dm_nsegs = 0; - mtx_enter(&is->sg_mtx); - extent_free(is->sg_ex, dvmaddr, sgsize, EX_NOWAIT); - spm->spm_start = 0; - spm->spm_size = 0; - mtx_leave(&is->sg_mtx); + sg_dmamap_unload(t, map); } else { map->_dm_origbuf = buf; map->_dm_buftype = BUS_BUFTYPE_LINEAR; @@ -594,15 +586,7 @@ sg_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, size, boundary); if (err) { - sg_iomap_unload_map(is, spm); - sg_iomap_clear_pages(spm); - map->dm_mapsize = 0; - map->dm_nsegs = 0; - mtx_enter(&is->sg_mtx); - extent_free(is->sg_ex, dvmaddr, sgsize, EX_NOWAIT); - spm->spm_start = 0; - spm->spm_size = 0; - mtx_leave(&is->sg_mtx); + sg_dmamap_unload(t, map); } else { /* This will be overwritten if mbuf or uio called us */ map->_dm_origbuf = segs; diff --git a/sys/arch/i386/i386/sg_dma.c b/sys/arch/i386/i386/sg_dma.c index 361a248bd4a..615dcb46df8 100644 --- a/sys/arch/i386/i386/sg_dma.c +++ b/sys/arch/i386/i386/sg_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sg_dma.c,v 1.2 2009/06/08 11:08:51 jsg Exp $ */ +/* $OpenBSD: sg_dma.c,v 1.3 2009/07/31 14:30:04 oga Exp $ */ /* * Copyright (c) 2009 Owain G. Ainsworth <oga@openbsd.org> * @@ -328,17 +328,8 @@ sg_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, } } } - if (err) { - sg_iomap_unload_map(is, spm); - sg_iomap_clear_pages(spm); - map->dm_mapsize = 0; - map->dm_nsegs = 0; - mtx_enter(&is->sg_mtx); - extent_free(is->sg_ex, dvmaddr, sgsize, EX_NOWAIT); - spm->spm_start = 0; - spm->spm_size = 0; - mtx_leave(&is->sg_mtx); - } + if (err) + sg_dmamap_unload(t, map); return (err); } @@ -577,17 +568,8 @@ sg_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, err = sg_dmamap_load_seg(t, is, map, segs, nsegs, flags, size, boundary); - if (err) { - sg_iomap_unload_map(is, spm); - sg_iomap_clear_pages(spm); - map->dm_mapsize = 0; - map->dm_nsegs = 0; - mtx_enter(&is->sg_mtx); - extent_free(is->sg_ex, dvmaddr, sgsize, EX_NOWAIT); - spm->spm_start = 0; - spm->spm_size = 0; - mtx_leave(&is->sg_mtx); - } + if (err) + sg_dmamap_unload(t, map); return (err); } |