summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2010-09-03 18:14:54 +0000
committerkettenis <kettenis@openbsd.org>2010-09-03 18:14:54 +0000
commit488e64d3e68b9b29c773000e1929271f5e53e27c (patch)
treef35ceedeb3fb183d86e95ca94acccf03b00a2909
parentfix initialization value of analog register AR_AN_TOP2 on some high (diff)
downloadwireguard-openbsd-488e64d3e68b9b29c773000e1929271f5e53e27c.tar.xz
wireguard-openbsd-488e64d3e68b9b29c773000e1929271f5e53e27c.zip
bus_dmamap_sync() freshly initialized Rx descriptors before flipping the bit
that hands them over to the hardware. This prevents the hardware from seeing stale contents if the compiler decides to re-order stores or if the hardware does store-reordering. There are sme doubts whether the i386/amd64 bus_dmamap_sync() implementation will be able to convince future compilers that do even more insanely stupid optimizations from re-ordering stores. That will be addressed in a seperate patch. ok matthew@, sthen@, oga@
-rw-r--r--sys/dev/pci/if_vr.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c
index fb2b03220be..6023d33a07c 100644
--- a/sys/dev/pci/if_vr.c
+++ b/sys/dev/pci/if_vr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vr.c,v 1.105 2010/05/19 15:27:35 oga Exp $ */
+/* $OpenBSD: if_vr.c,v 1.106 2010/09/03 18:14:54 kettenis Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -1562,6 +1562,10 @@ vr_alloc_mbuf(struct vr_softc *sc, struct vr_chain_onefrag *r)
d = r->vr_ptr;
d->vr_data = htole32(r->vr_map->dm_segs[0].ds_addr);
d->vr_ctl = htole32(VR_RXCTL | VR_RXLEN);
+
+ bus_dmamap_sync(sc->sc_dmat, sc->sc_listmap, 0,
+ sc->sc_listmap->dm_mapsize, BUS_DMASYNC_PREWRITE);
+
d->vr_status = htole32(VR_RXSTAT);
bus_dmamap_sync(sc->sc_dmat, sc->sc_listmap, 0,