diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2005-11-25 22:18:19 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2005-11-25 22:18:19 +0000 |
commit | 072f7d0d58d3c1c5e14fc9f8aa794661c05ddfb4 (patch) | |
tree | 7d58bd9fdeb6cebbe39dfa278e124cfaf4882ae9 /sys/arch/mvme88k | |
parent | 2330c1154142c0b67a46142a4abdf206a7d4d17d (diff) |
Replace utterly wrong bus_dmamap_sync() with a much better version.
Diffstat (limited to 'sys/arch/mvme88k')
-rw-r--r-- | sys/arch/mvme88k/mvme88k/bus_dma.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/sys/arch/mvme88k/mvme88k/bus_dma.c b/sys/arch/mvme88k/mvme88k/bus_dma.c index e37d73dd6f3..e92cb8c0398 100644 --- a/sys/arch/mvme88k/mvme88k/bus_dma.c +++ b/sys/arch/mvme88k/mvme88k/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.3 2004/12/25 23:02:25 miod Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.4 2005/11/25 22:18:18 miod Exp $ */ /* $NetBSD: bus_dma.c,v 1.2 2001/06/10 02:31:25 briggs Exp $ */ /*- @@ -430,7 +430,8 @@ bus_dmamap_sync(t, map, offset, len, op) bus_size_t len; int op; { - int i; + u_int nsegs; + bus_dma_segment_t *seg; switch (op) { case BUS_DMASYNC_PREWRITE: @@ -444,8 +445,29 @@ bus_dmamap_sync(t, map, offset, len, op) return; } - for (i = map->dm_nsegs; i--; ) - dma_cachectl_pa(map->dm_segs[i].ds_addr, len, op); + nsegs = map->dm_nsegs; + seg = map->dm_segs; + while (nsegs != 0 && len != 0) { + if (offset >= seg->ds_len) { + offset -= seg->ds_len; + } else { + bus_addr_t addr; + bus_size_t sublen; + + addr = seg->ds_addr + offset; + sublen = seg->ds_len - offset; + if (sublen > len) + sublen = len; + + if (dma_cachectl_pa(addr, sublen, op) != 0) + break; + + offset = 0; + len -= sublen; + } + seg++; + nsegs--; + } } /* |