summaryrefslogtreecommitdiffstats
path: root/sys/sys/bus_dma.h
diff options
context:
space:
mode:
authorzbb <zbb@FreeBSD.org>2015-07-08 13:52:59 +0000
committerzbb <zbb@FreeBSD.org>2015-07-08 13:52:59 +0000
commitad70ced005b6c89457096f744618bb95ba71f003 (patch)
tree76cdd2360c3f68817bb3850563b05804387c2a80 /sys/sys/bus_dma.h
parent79ef161338c558af0dbe0928d4315be38a814695 (diff)
downloadFreeBSD-src-ad70ced005b6c89457096f744618bb95ba71f003.zip
FreeBSD-src-ad70ced005b6c89457096f744618bb95ba71f003.tar.gz
Add memory barrier to bus_dmamap_sync()
On platforms which are fully IO-coherent, the map might be null. We need to guarantee that all data is observable after the sync operation is called. Add a memory barrier to ensure that on ARM. Reviewed by: andrew, kib Obtained from: Semihalf Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3012
Diffstat (limited to 'sys/sys/bus_dma.h')
-rw-r--r--sys/sys/bus_dma.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/sys/bus_dma.h b/sys/sys/bus_dma.h
index 4ea5b08..2a9d2ed 100644
--- a/sys/sys/bus_dma.h
+++ b/sys/sys/bus_dma.h
@@ -282,13 +282,25 @@ int bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
void bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
/*
- * Perform a synchronization operation on the given map.
+ * Perform a synchronization operation on the given map. If the map
+ * is NULL we have a fully IO-coherent system. On every ARM architecture
+ * there must be a memory barrier placed to ensure that all data
+ * accesses are visible before going any further.
*/
void _bus_dmamap_sync(bus_dma_tag_t, bus_dmamap_t, bus_dmasync_op_t);
+#if defined(__arm__)
+ #define __BUS_DMAMAP_SYNC_DEFAULT mb();
+#elif defined(__aarch64__)
+ #define __BUS_DMAMAP_SYNC_DEFAULT dmb(sy);
+#else
+ #define __BUS_DMAMAP_SYNC_DEFAULT {}
+#endif
#define bus_dmamap_sync(dmat, dmamap, op) \
do { \
if ((dmamap) != NULL) \
_bus_dmamap_sync(dmat, dmamap, op); \
+ else \
+ __BUS_DMAMAP_SYNC_DEFAULT \
} while (0)
/*
OpenPOWER on IntegriCloud