From a6f2bb0d28c6cb4b05c7b736b521b6547becaaa9 Mon Sep 17 00:00:00 2001 From: kettenis Date: Sun, 13 Jul 2014 21:51:12 +0000 Subject: [PATCH] The correct place to call _bus_dmamap_sync() is after we copy data *to* the bounce buffer and before we copy data *from* the bounce buffer. Currently _bus_dmamap_sync() is a no-op, but keeping it #ifdef'ed out in the wrong place makes no sense. ok deraadt@, miod@ --- sys/arch/amd64/isa/isa_machdep.c | 13 ++++++------- sys/arch/i386/isa/isa_machdep.c | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/sys/arch/amd64/isa/isa_machdep.c b/sys/arch/amd64/isa/isa_machdep.c index eb5f22629f4..52bd2b2bc9e 100644 --- a/sys/arch/amd64/isa/isa_machdep.c +++ b/sys/arch/amd64/isa/isa_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isa_machdep.c,v 1.23 2014/07/12 18:44:41 tedu Exp $ */ +/* $OpenBSD: isa_machdep.c,v 1.24 2014/07/13 21:51:12 kettenis Exp $ */ /* $NetBSD: isa_machdep.c,v 1.22 1997/06/12 23:57:32 thorpej Exp $ */ #define ISA_DMA_STATS @@ -634,7 +634,11 @@ _isa_bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset, bcopy(cookie->id_origbuf + offset, cookie->id_bouncebuf + offset, len); - } else if (op & BUS_DMASYNC_POSTREAD) { + } + + _bus_dmamap_sync(t, map, offset, len, op); + + if (op & BUS_DMASYNC_POSTREAD) { /* * If we're bouncing this transfer, copy the * bounce buffer to the caller's buffer. @@ -644,11 +648,6 @@ _isa_bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset, cookie->id_origbuf + offset, len); } - -#if 0 - /* This is a noop anyhow, so why bother calling it? */ - _bus_dmamap_sync(t, map, op); -#endif } /* diff --git a/sys/arch/i386/isa/isa_machdep.c b/sys/arch/i386/isa/isa_machdep.c index debed933940..dd859f5b64e 100644 --- a/sys/arch/i386/isa/isa_machdep.c +++ b/sys/arch/i386/isa/isa_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isa_machdep.c,v 1.76 2014/07/12 18:44:42 tedu Exp $ */ +/* $OpenBSD: isa_machdep.c,v 1.77 2014/07/13 21:51:12 kettenis Exp $ */ /* $NetBSD: isa_machdep.c,v 1.22 1997/06/12 23:57:32 thorpej Exp $ */ /*- @@ -907,7 +907,11 @@ _isa_bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset, bcopy((char *)cookie->id_origbuf + offset, cookie->id_bouncebuf + offset, len); - } else if (op & BUS_DMASYNC_POSTREAD) { + } + + _bus_dmamap_sync(t, map, offset, len, op); + + if (op & BUS_DMASYNC_POSTREAD) { /* * If we're bouncing this transfer, copy the * bounce buffer to the caller's buffer. @@ -917,11 +921,6 @@ _isa_bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset, cookie->id_origbuf + offset, len); } - -#if 0 - /* This is a noop anyhow, so why bother calling it? */ - _bus_dmamap_sync(t, map, op); -#endif } /* -- 2.20.1