diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2009-05-03 13:44:06 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2009-05-03 13:44:06 +0000 |
commit | 4dc7c966673bd5e748c7f957ac73005007a94c74 (patch) | |
tree | 60701045fdc0d93c211e898023afef205a683551 | |
parent | 420507c143b3cf9f031eea6fe6e771801eb38ae9 (diff) |
Avoid clobbering error return values with the result from extent_free(), by
simply calling iommu_dvma_unload(). Solution suggested by oga@.
While there, also unwrap a line that isn't long enough to need wrapping.
-rw-r--r-- | sys/arch/sparc64/dev/iommu.c | 5 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/viommu.c | 34 |
2 files changed, 9 insertions, 30 deletions
diff --git a/sys/arch/sparc64/dev/iommu.c b/sys/arch/sparc64/dev/iommu.c index be92ad98c45..97243af304f 100644 --- a/sys/arch/sparc64/dev/iommu.c +++ b/sys/arch/sparc64/dev/iommu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iommu.c,v 1.58 2009/05/02 18:39:27 kettenis Exp $ */ +/* $OpenBSD: iommu.c,v 1.59 2009/05/03 13:44:05 kettenis Exp $ */ /* $NetBSD: iommu.c,v 1.47 2002/02/08 20:03:45 eeh Exp $ */ /* @@ -1315,8 +1315,7 @@ iommu_dvmamap_unload(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map) map->dm_nsegs = 0; mtx_enter(&is->is_mtx); - error = extent_free(is->is_dvmamap, dvmaddr, - sgsize, EX_NOWAIT); + error = extent_free(is->is_dvmamap, dvmaddr, sgsize, EX_NOWAIT); map->_dm_dvmastart = 0; map->_dm_dvmasize = 0; mtx_leave(&is->is_mtx); diff --git a/sys/arch/sparc64/dev/viommu.c b/sys/arch/sparc64/dev/viommu.c index 10d1b0ba3c7..ca63d2c8148 100644 --- a/sys/arch/sparc64/dev/viommu.c +++ b/sys/arch/sparc64/dev/viommu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: viommu.c,v 1.5 2009/04/05 21:57:41 oga Exp $ */ +/* $OpenBSD: viommu.c,v 1.6 2009/05/03 13:44:05 kettenis Exp $ */ /* $NetBSD: iommu.c,v 1.47 2002/02/08 20:03:45 eeh Exp $ */ /* @@ -424,18 +424,9 @@ viommu_dvmamap_load(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, } } } - if (err) { - /* XXX keep enough state and just call unload here? */ - viommu_iomap_unload_map(is, ims); - iommu_iomap_clear_pages(ims); - map->dm_mapsize = 0; - map->dm_nsegs = 0; - mtx_enter(&is->is_mtx); - err = extent_free(is->is_dvmamap, dvmaddr, sgsize, EX_NOWAIT); - map->_dm_dvmastart = 0; - map->_dm_dvmasize = 0; - mtx_leave(&is->is_mtx); - } + + if (err) + viommu_dvmamap_unload(t, t0, map); return (err); } @@ -587,18 +578,8 @@ viommu_dvmamap_load_raw(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map, err = viommu_dvmamap_load_seg(t, is, map, segs, nsegs, flags, size, boundary); - if (err) { - /* XXX keep enough state and just call unload here? */ - viommu_iomap_unload_map(is, ims); - iommu_iomap_clear_pages(ims); - map->dm_mapsize = 0; - map->dm_nsegs = 0; - mtx_enter(&is->is_mtx); - err = extent_free(is->is_dvmamap, dvmaddr, sgsize, EX_NOWAIT); - map->_dm_dvmastart = 0; - map->_dm_dvmasize = 0; - mtx_leave(&is->is_mtx); - } + if (err) + viommu_dvmamap_unload(t, t0, map); return (err); } @@ -853,8 +834,7 @@ viommu_dvmamap_unload(bus_dma_tag_t t, bus_dma_tag_t t0, bus_dmamap_t map) map->dm_nsegs = 0; mtx_enter(&is->is_mtx); - error = extent_free(is->is_dvmamap, dvmaddr, - sgsize, EX_NOWAIT); + error = extent_free(is->is_dvmamap, dvmaddr, sgsize, EX_NOWAIT); map->_dm_dvmastart = 0; map->_dm_dvmasize = 0; mtx_leave(&is->is_mtx); |