Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Apply OpenBSD if_bwfm_pci.c:1.25 by patrick:



details:   https://anonhg.NetBSD.org/src/rev/c841b4505823
branches:  trunk
changeset: 994019:c841b4505823
user:      maya <maya%NetBSD.org@localhost>
date:      Mon Oct 15 16:29:10 2018 +0000

description:
Apply OpenBSD if_bwfm_pci.c:1.25 by patrick:

Add bus_dmamap_sync(9) calls to bwfm(4) so that we make sure the data
is synced properly before the CPU or the WiFi chip access the supplied
memory.  Makes PCIe-connected bwfm(4) work on ARM-based machines.

diffstat:

 sys/dev/pci/if_bwfm_pci.c |  27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diffs (90 lines):

diff -r 25b280f29e45 -r c841b4505823 sys/dev/pci/if_bwfm_pci.c
--- a/sys/dev/pci/if_bwfm_pci.c Mon Oct 15 12:46:43 2018 +0000
+++ b/sys/dev/pci/if_bwfm_pci.c Mon Oct 15 16:29:10 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bwfm_pci.c,v 1.3 2018/09/03 16:29:32 riastradh Exp $        */
+/*     $NetBSD: if_bwfm_pci.c,v 1.4 2018/10/15 16:29:10 maya Exp $     */
 /*     $OpenBSD: if_bwfm_pci.c,v 1.18 2018/02/08 05:00:38 patrick Exp $        */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -956,6 +956,9 @@
                                    pkts->pkts[idx].bb_map, *mp, BUS_DMA_NOWAIT) != 0)
                                        return EFBIG;
                        }
+                       bus_dmamap_sync(sc->sc_dmat, pkts->pkts[idx].bb_map,
+                           0, pkts->pkts[idx].bb_map->dm_mapsize,
+                           BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
                        pkts->last = idx;
                        pkts->pkts[idx].bb_m = *mp;
                        *pktid = idx;
@@ -975,6 +978,9 @@
 
        if (pktid >= pkts->npkt || pkts->pkts[pktid].bb_m == NULL)
                return NULL;
+       bus_dmamap_sync(sc->sc_dmat, pkts->pkts[pktid].bb_map, 0,
+           pkts->pkts[pktid].bb_map->dm_mapsize,
+           BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
        bus_dmamap_unload(sc->sc_dmat, pkts->pkts[pktid].bb_map);
        m = pkts->pkts[pktid].bb_m;
        pkts->pkts[pktid].bb_m = NULL;
@@ -1134,6 +1140,9 @@
                ring->r_ptr = bus_space_read_2(sc->sc_tcm_iot,
                    sc->sc_tcm_ioh, ring->r_idx_addr);
        } else {
+               bus_dmamap_sync(sc->sc_dmat,
+                   BWFM_PCI_DMA_MAP(sc->sc_dma_idx_buf), ring->r_idx_addr,
+                   sizeof(uint16_t), BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
                ring->r_ptr = *(uint16_t *)(BWFM_PCI_DMA_KVA(sc->sc_dma_idx_buf)
                    + ring->r_idx_addr);
        }
@@ -1185,6 +1194,9 @@
        } else {
                ring->w_ptr = *(uint16_t *)(BWFM_PCI_DMA_KVA(sc->sc_dma_idx_buf)
                    + ring->w_idx_addr);
+               bus_dmamap_sync(sc->sc_dmat,
+                   BWFM_PCI_DMA_MAP(sc->sc_dma_idx_buf), ring->w_idx_addr,
+                   sizeof(uint16_t), BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
        }
 }
 
@@ -1198,6 +1210,9 @@
        } else {
                *(uint16_t *)(BWFM_PCI_DMA_KVA(sc->sc_dma_idx_buf)
                    + ring->r_idx_addr) = ring->r_ptr;
+               bus_dmamap_sync(sc->sc_dmat,
+                   BWFM_PCI_DMA_MAP(sc->sc_dma_idx_buf), ring->r_idx_addr,
+                   sizeof(uint16_t), BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
        }
 }
 
@@ -1211,6 +1226,9 @@
        } else {
                *(uint16_t *)(BWFM_PCI_DMA_KVA(sc->sc_dma_idx_buf)
                    + ring->w_idx_addr) = ring->w_ptr;
+               bus_dmamap_sync(sc->sc_dmat,
+                   BWFM_PCI_DMA_MAP(sc->sc_dma_idx_buf), ring->w_idx_addr,
+                   sizeof(uint16_t), BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
        }
 }
 
@@ -1286,7 +1304,9 @@
 
        if (*avail == 0)
                return NULL;
-
+       bus_dmamap_sync(sc->sc_dmat, BWFM_PCI_DMA_MAP(ring->ring),
+           ring->r_ptr * ring->itemsz, *avail * ring->itemsz,
+           BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
        return BWFM_PCI_DMA_KVA(ring->ring) + (ring->r_ptr * ring->itemsz);
 }
 
@@ -1310,6 +1330,9 @@
 bwfm_pci_ring_write_commit(struct bwfm_pci_softc *sc,
     struct bwfm_pci_msgring *ring)
 {
+       bus_dmamap_sync(sc->sc_dmat, BWFM_PCI_DMA_MAP(ring->ring),
+           0, BWFM_PCI_DMA_LEN(ring->ring), BUS_DMASYNC_PREREAD |
+           BUS_DMASYNC_PREWRITE);
        bwfm_pci_ring_write_wptr(sc, ring);
        bwfm_pci_ring_bell(sc, ring);
 }



Home | Main Index | Thread Index | Old Index