From 56e9b8d55f31a168aaffa05ac859e79e1536159f Mon Sep 17 00:00:00 2001 From: gonzo Date: Sat, 10 Dec 2016 17:59:34 +0000 Subject: [PATCH] [iwn] Perform BUS_DMASYNC_PREREAD when initializing RX buffer BUS_DMASYNC_PREREAD is required when setting up RX buffer, otherwise data provided by card can be overwritten by data evicted from cache Also use proper tag when setting up RX descriptor Reviewed by: adrian, avos, ivadasz Differential Revision: https://reviews.freebsd.org/D8717 --- sys/dev/iwn/if_iwn.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index b2107ae9fc5f..f5d298bd8640 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -1910,6 +1910,9 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, struct iwn_rx_ring *ring) goto fail; } + bus_dmamap_sync(ring->data_dmat, data->map, + BUS_DMASYNC_PREREAD); + /* Set physical address of RX buffer (256-byte aligned). */ ring->desc[i] = htole32(paddr >> 8); } @@ -3040,14 +3043,19 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, if (error != 0 && error != EFBIG) { panic("%s: could not load old RX mbuf", __func__); } + bus_dmamap_sync(ring->data_dmat, data->map, + BUS_DMASYNC_PREREAD); /* Physical address may have changed. */ ring->desc[ring->cur] = htole32(paddr >> 8); - bus_dmamap_sync(ring->data_dmat, ring->desc_dma.map, + bus_dmamap_sync(ring->desc_dma.tag, ring->desc_dma.map, BUS_DMASYNC_PREWRITE); counter_u64_add(ic->ic_ierrors, 1); return; } + bus_dmamap_sync(ring->data_dmat, data->map, + BUS_DMASYNC_PREREAD); + m = data->m; data->m = m1; /* Update RX descriptor. */