summaryrefslogtreecommitdiff
path: root/sys/dev/pci/if_bnx.c
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2011-04-13 07:28:36 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2011-04-13 07:28:36 +0000
commit4bf4717f9dcf45b07bb04cd8ddd7c86d02ce38bd (patch)
treef61ac4bd533c1d04700816b1f99d553bb3aa8792 /sys/dev/pci/if_bnx.c
parenteb6291101974d5d37395fe84b4ff3c57cd6567bd (diff)
to quote from the gospel of bus_dma.9:
Synchronization operations are expressed from the perspective of the host RAM, e.g., a device -> memory operation is a READ and a memory -> device operation is a WRITE. the status block that the isr reads is written to by the device. the chip writes to memory, it is therefore a READ. this also adds the preread sync when the map is set up and the postread sync when the map is torn down for better symmetry. there are probably more issues like this in the code, but this is a start. discovered while discussing another diff with claudio@
Diffstat (limited to 'sys/dev/pci/if_bnx.c')
-rw-r--r--sys/dev/pci/if_bnx.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sys/dev/pci/if_bnx.c b/sys/dev/pci/if_bnx.c
index 5388e3fffee..bd17cadb39d 100644
--- a/sys/dev/pci/if_bnx.c
+++ b/sys/dev/pci/if_bnx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bnx.c,v 1.92 2011/04/05 18:01:21 henning Exp $ */
+/* $OpenBSD: if_bnx.c,v 1.93 2011/04/13 07:28:35 dlg Exp $ */
/*-
* Copyright (c) 2006 Broadcom Corporation
@@ -2286,6 +2286,8 @@ bnx_dma_free(struct bnx_softc *sc)
/* Destroy the status block. */
if (sc->status_block != NULL && sc->status_map != NULL) {
+ bus_dmamap_sync(sc->bnx_dmatag, sc->status_map, 0,
+ sc->status_map->dm_mapsize, BUS_DMASYNC_POSTREAD);
bus_dmamap_unload(sc->bnx_dmatag, sc->status_map);
bus_dmamem_unmap(sc->bnx_dmatag, (caddr_t)sc->status_block,
BNX_STATUS_BLK_SZ);
@@ -2424,6 +2426,9 @@ bnx_dma_alloc(struct bnx_softc *sc)
goto bnx_dma_alloc_exit;
}
+ bus_dmamap_sync(sc->bnx_dmatag, sc->status_map, 0,
+ sc->status_map->dm_mapsize, BUS_DMASYNC_PREREAD);
+
sc->status_block_paddr = sc->status_map->dm_segs[0].ds_addr;
/* DRC - Fix for 64 bit addresses. */
@@ -5152,7 +5157,7 @@ bnx_intr(void *xsc)
DBRUNIF(1, sc->interrupts_generated++);
bus_dmamap_sync(sc->bnx_dmatag, sc->status_map, 0,
- sc->status_map->dm_mapsize, BUS_DMASYNC_POSTWRITE);
+ sc->status_map->dm_mapsize, BUS_DMASYNC_POSTREAD);
/*
* If the hardware status block index
@@ -5232,7 +5237,7 @@ bnx_intr(void *xsc)
}
bus_dmamap_sync(sc->bnx_dmatag, sc->status_map, 0,
- sc->status_map->dm_mapsize, BUS_DMASYNC_PREWRITE);
+ sc->status_map->dm_mapsize, BUS_DMASYNC_PREREAD);
/* Re-enable interrupts. */
REG_WR(sc, BNX_PCICFG_INT_ACK_CMD,