From a37ac213156557c658b53c1130db212d2038ca6d Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Mon, 6 Sep 2010 19:05:49 +0000 Subject: Make sure bus_dmamap_sync() always involves a function call, to prevent the compiler from doing stupid things like reordering stores around it. There is some debate whether this will be enough for newer versions of GCC and LLVM. If this is indeed deemed necessary, this will be addressed in a future diff. ok miod@, oga@ --- sys/arch/amd64/amd64/bus_dma.c | 3 +-- sys/arch/amd64/include/bus.h | 5 ++--- sys/arch/amd64/pci/pci_machdep.c | 4 ++-- sys/arch/i386/eisa/eisa_machdep.c | 4 ++-- sys/arch/i386/i386/bus_dma.c | 13 ++++++++++++- sys/arch/i386/include/bus.h | 5 ++--- sys/arch/i386/pci/pci_machdep.c | 4 ++-- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/sys/arch/amd64/amd64/bus_dma.c b/sys/arch/amd64/amd64/bus_dma.c index c4fca4afe72..b5475d6a55e 100644 --- a/sys/arch/amd64/amd64/bus_dma.c +++ b/sys/arch/amd64/amd64/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.32 2010/05/20 05:46:53 oga Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.33 2010/09/06 19:05:48 kettenis Exp $ */ /* $NetBSD: bus_dma.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */ /*- @@ -404,7 +404,6 @@ void _bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t addr, bus_size_t size, int op) { - /* Nothing to do here. */ } diff --git a/sys/arch/amd64/include/bus.h b/sys/arch/amd64/include/bus.h index 296373711c4..cdb107a2022 100644 --- a/sys/arch/amd64/include/bus.h +++ b/sys/arch/amd64/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.23 2010/04/08 00:55:25 oga Exp $ */ +/* $OpenBSD: bus.h,v 1.24 2010/09/06 19:05:48 kettenis Exp $ */ /* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */ /*- @@ -543,8 +543,7 @@ struct bus_dma_tag { #define bus_dmamap_unload(t, p) \ (*(t)->_dmamap_unload)((t), (p)) #define bus_dmamap_sync(t, p, o, l, ops) \ - (void)((t)->_dmamap_sync ? \ - (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) : (void)0) + (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \ (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f)) diff --git a/sys/arch/amd64/pci/pci_machdep.c b/sys/arch/amd64/pci/pci_machdep.c index f4d4d603692..7c05d359182 100644 --- a/sys/arch/amd64/pci/pci_machdep.c +++ b/sys/arch/amd64/pci/pci_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.c,v 1.35 2010/07/08 20:56:31 jordan Exp $ */ +/* $OpenBSD: pci_machdep.c,v 1.36 2010/09/06 19:05:48 kettenis Exp $ */ /* $NetBSD: pci_machdep.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */ /*- @@ -125,7 +125,7 @@ struct bus_dma_tag pci_bus_dma_tag = { _bus_dmamap_load_uio, _bus_dmamap_load_raw, _bus_dmamap_unload, - NULL, + _bus_dmamap_sync, _bus_dmamem_alloc, _bus_dmamem_free, _bus_dmamem_map, diff --git a/sys/arch/i386/eisa/eisa_machdep.c b/sys/arch/i386/eisa/eisa_machdep.c index 8eabdf267a0..60fe079a710 100644 --- a/sys/arch/i386/eisa/eisa_machdep.c +++ b/sys/arch/i386/eisa/eisa_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eisa_machdep.c,v 1.13 2009/03/10 15:03:17 oga Exp $ */ +/* $OpenBSD: eisa_machdep.c,v 1.14 2010/09/06 19:05:48 kettenis Exp $ */ /* $NetBSD: eisa_machdep.c,v 1.10.22.2 2000/06/25 19:36:58 sommerfeld Exp $ */ /*- @@ -91,7 +91,7 @@ struct bus_dma_tag eisa_bus_dma_tag = { _bus_dmamap_load_uio, _bus_dmamap_load_raw, _bus_dmamap_unload, - NULL, /* _dmamap_sync */ + _bus_dmamap_sync, _bus_dmamem_alloc, _bus_dmamem_free, _bus_dmamem_map, diff --git a/sys/arch/i386/i386/bus_dma.c b/sys/arch/i386/i386/bus_dma.c index 27cf4d36317..605d67d8bd8 100644 --- a/sys/arch/i386/i386/bus_dma.c +++ b/sys/arch/i386/i386/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.21 2010/03/27 00:37:15 oga Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.22 2010/09/06 19:05:48 kettenis Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. * All rights reserved. @@ -366,6 +366,17 @@ _bus_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map) map->dm_nsegs = 0; } +/* + * Common function for DMA map synchronization. May be called + * by bus-specific DMA map synchronization functions. + */ +void +_bus_dmamap_sync(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t addr, + bus_size_t size, int op) +{ + /* Nothing to do here. */ +} + /* * Common function for DMA-safe memory allocation. May be called * by bus-specific DMA memory allocation functions. diff --git a/sys/arch/i386/include/bus.h b/sys/arch/i386/include/bus.h index 120b2b3de05..fc4ec2e0338 100644 --- a/sys/arch/i386/include/bus.h +++ b/sys/arch/i386/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.52 2010/04/08 00:55:25 oga Exp $ */ +/* $OpenBSD: bus.h,v 1.53 2010/09/06 19:05:48 kettenis Exp $ */ /* $NetBSD: bus.h,v 1.6 1996/11/10 03:19:25 thorpej Exp $ */ /*- @@ -556,8 +556,7 @@ struct bus_dma_tag { #define bus_dmamap_unload(t, p) \ (*(t)->_dmamap_unload)((t), (p)) #define bus_dmamap_sync(t, p, o, l, ops) \ - (void)((t)->_dmamap_sync ? \ - (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) : (void)0) + (*(t)->_dmamap_sync)((t), (p), (o), (l), (ops)) #define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \ (*(t)->_dmamem_alloc)((t), (s), (a), (b), (sg), (n), (r), (f)) diff --git a/sys/arch/i386/pci/pci_machdep.c b/sys/arch/i386/pci/pci_machdep.c index d4a0336a104..d47c18b6e53 100644 --- a/sys/arch/i386/pci/pci_machdep.c +++ b/sys/arch/i386/pci/pci_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.c,v 1.53 2010/07/08 20:56:31 jordan Exp $ */ +/* $OpenBSD: pci_machdep.c,v 1.54 2010/09/06 19:05:48 kettenis Exp $ */ /* $NetBSD: pci_machdep.c,v 1.28 1997/06/06 23:29:17 thorpej Exp $ */ /*- @@ -167,7 +167,7 @@ struct bus_dma_tag pci_bus_dma_tag = { _bus_dmamap_load_uio, _bus_dmamap_load_raw, _bus_dmamap_unload, - NULL, /* _dmamap_sync */ + _bus_dmamap_sync, _bus_dmamem_alloc, _bus_dmamem_free, _bus_dmamem_map, -- cgit v1.2.3