Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Sprinkle bus_dmamap_sync to make this work on my...
details: https://anonhg.NetBSD.org/src/rev/d03293e5e10a
branches: trunk
changeset: 331214:d03293e5e10a
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Tue Aug 05 17:25:16 2014 +0000
description:
Sprinkle bus_dmamap_sync to make this work on my Thinkpad T61 (amd64)
with 4GB RAM.
diffstat:
sys/dev/pci/if_wpi.c | 41 ++++++++++++++++++++++++++++++++++++++---
1 files changed, 38 insertions(+), 3 deletions(-)
diffs (142 lines):
diff -r a161a07da20b -r d03293e5e10a sys/dev/pci/if_wpi.c
--- a/sys/dev/pci/if_wpi.c Tue Aug 05 16:28:39 2014 +0000
+++ b/sys/dev/pci/if_wpi.c Tue Aug 05 17:25:16 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wpi.c,v 1.62 2014/07/05 17:39:21 jakllsch Exp $ */
+/* $NetBSD: if_wpi.c,v 1.63 2014/08/05 17:25:16 jmcneill Exp $ */
/*-
* Copyright (c) 2006, 2007
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.62 2014/07/05 17:39:21 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.63 2014/08/05 17:25:16 jmcneill Exp $");
/*
* Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters.
@@ -450,6 +450,7 @@
goto fail;
memset(dma->vaddr, 0, size);
+ bus_dmamap_sync(dma->tag, dma->map, 0, size, BUS_DMASYNC_PREWRITE);
dma->paddr = dma->map->dm_segs[0].ds_addr;
if (kvap != NULL)
@@ -605,12 +606,14 @@
static int
wpi_alloc_rx_ring(struct wpi_softc *sc, struct wpi_rx_ring *ring)
{
+ bus_size_t size;
int i, error;
ring->cur = 0;
+ size = WPI_RX_RING_COUNT * sizeof (uint32_t);
error = wpi_dma_contig_alloc(sc->sc_dmat, &ring->desc_dma,
- (void **)&ring->desc, WPI_RX_RING_COUNT * sizeof (uint32_t),
+ (void **)&ring->desc, size,
WPI_RING_DMA_ALIGN, BUS_DMA_NOWAIT);
if (error != 0) {
aprint_error_dev(sc->sc_dev,
@@ -648,6 +651,9 @@
ring->desc[i] = htole32(rbuf->paddr);
}
+ bus_dmamap_sync(sc->sc_dmat, ring->desc_dma.map, 0, size,
+ BUS_DMASYNC_PREWRITE);
+
return 0;
fail: wpi_free_rx_ring(sc, ring);
@@ -711,6 +717,8 @@
/* update shared page with ring's base address */
sc->shared->txbase[qid] = htole32(ring->desc_dma.paddr);
+ bus_dmamap_sync(sc->sc_dmat, sc->shared_dma.map, 0,
+ sizeof(struct wpi_shared), BUS_DMASYNC_PREWRITE);
error = wpi_dma_contig_alloc(sc->sc_dmat, &ring->cmd_dma,
(void **)&ring->cmd, count * sizeof (struct wpi_tx_cmd), 4,
@@ -1303,6 +1311,8 @@
memcpy((char *)dma->vaddr + WPI_FW_INIT_DATA_MAXSZ, init_text,
init_textsz);
+ bus_dmamap_sync(dma->tag, dma->map, 0, dma->size, BUS_DMASYNC_PREWRITE);
+
/* tell adapter where to find initialization images */
wpi_mem_lock(sc);
wpi_mem_write(sc, WPI_MEM_DATA_BASE, dma->paddr);
@@ -1333,6 +1343,8 @@
memcpy((char *)dma->vaddr + WPI_FW_MAIN_DATA_MAXSZ, main_text,
main_textsz);
+ bus_dmamap_sync(dma->tag, dma->map, 0, dma->size, BUS_DMASYNC_PREWRITE);
+
/* tell adapter where to find runtime images */
wpi_mem_lock(sc);
wpi_mem_write(sc, WPI_MEM_DATA_BASE, dma->paddr);
@@ -1995,6 +2007,16 @@
ring->queued++;
+ bus_dmamap_sync(sc->sc_dmat, data->map, 0,
+ data->map->dm_mapsize,
+ BUS_DMASYNC_PREWRITE);
+ bus_dmamap_sync(sc->sc_dmat, ring->cmd_dma.map, 0,
+ ring->cmd_dma.size,
+ BUS_DMASYNC_PREWRITE);
+ bus_dmamap_sync(sc->sc_dmat, ring->desc_dma.map, 0,
+ ring->desc_dma.size,
+ BUS_DMASYNC_PREWRITE);
+
/* kick ring */
ring->cur = (ring->cur + 1) % WPI_TX_RING_COUNT;
WPI_WRITE(sc, WPI_TX_WIDX, ring->qid << 8 | ring->cur);
@@ -2290,6 +2312,7 @@
struct wpi_tx_ring *ring = &sc->cmdq;
struct wpi_tx_desc *desc;
struct wpi_tx_cmd *cmd;
+ struct wpi_dma_info *dma;
KASSERT(size <= sizeof cmd->data);
@@ -2302,11 +2325,17 @@
cmd->idx = ring->cur;
memcpy(cmd->data, buf, size);
+ dma = &ring->cmd_dma;
+ bus_dmamap_sync(dma->tag, dma->map, 0, dma->size, BUS_DMASYNC_PREWRITE);
+
desc->flags = htole32(WPI_PAD32(size) << 28 | 1 << 24);
desc->segs[0].addr = htole32(ring->cmd_dma.paddr +
ring->cur * sizeof (struct wpi_tx_cmd));
desc->segs[0].len = htole32(4 + size);
+ dma = &ring->desc_dma;
+ bus_dmamap_sync(dma->tag, dma->map, 0, dma->size, BUS_DMASYNC_PREWRITE);
+
/* kick cmd ring */
ring->cur = (ring->cur + 1) % WPI_CMD_RING_COUNT;
WPI_WRITE(sc, WPI_TX_WIDX, ring->qid << 8 | ring->cur);
@@ -2627,6 +2656,9 @@
desc->segs[1].addr = htole32(data->map->dm_segs[0].ds_addr);
desc->segs[1].len = htole32(data->map->dm_segs[0].ds_len);
+ bus_dmamap_sync(sc->sc_dmat, data->map, 0, data->map->dm_mapsize,
+ BUS_DMASYNC_PREWRITE);
+
/* kick cmd ring */
ring->cur = (ring->cur + 1) % WPI_CMD_RING_COUNT;
WPI_WRITE(sc, WPI_TX_WIDX, ring->qid << 8 | ring->cur);
@@ -2857,6 +2889,9 @@
desc->segs[0].addr = htole32(data->map->dm_segs[0].ds_addr);
desc->segs[0].len = htole32(data->map->dm_segs[0].ds_len);
+ bus_dmamap_sync(sc->sc_dmat, data->map, 0, data->map->dm_mapsize,
+ BUS_DMASYNC_PREWRITE);
+
/* kick cmd ring */
ring->cur = (ring->cur + 1) % WPI_CMD_RING_COUNT;
WPI_WRITE(sc, WPI_TX_WIDX, ring->qid << 8 | ring->cur);
Home |
Main Index |
Thread Index |
Old Index