Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Sync with other *BSDs:



details:   https://anonhg.NetBSD.org/src/rev/305350447e06
branches:  trunk
changeset: 449867:305350447e06
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Mar 27 03:10:39 2019 +0000

description:
Sync with other *BSDs:

>From OpenBSD's rev. 1.93:
 > 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:

 sys/dev/pci/if_bnx.c |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (55 lines):

diff -r 5d6694c3f2c2 -r 305350447e06 sys/dev/pci/if_bnx.c
--- a/sys/dev/pci/if_bnx.c      Wed Mar 27 02:51:41 2019 +0000
+++ b/sys/dev/pci/if_bnx.c      Wed Mar 27 03:10:39 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bnx.c,v 1.68 2019/01/22 03:42:27 msaitoh Exp $      */
+/*     $NetBSD: if_bnx.c,v 1.69 2019/03/27 03:10:39 msaitoh Exp $      */
 /*     $OpenBSD: if_bnx.c,v 1.85 2009/11/09 14:32:41 dlg Exp $ */
 
 /*-
@@ -35,7 +35,7 @@
 #if 0
 __FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.3 2006/04/13 14:12:26 ru Exp $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.68 2019/01/22 03:42:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.69 2019/03/27 03:10:39 msaitoh Exp $");
 
 /*
  * The following controllers are supported by this driver:
@@ -2213,6 +2213,8 @@
 
        /* 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, (void *)sc->status_block,
                    BNX_STATUS_BLK_SZ);
@@ -2355,6 +2357,9 @@
                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;
        memset(sc->status_block, 0, BNX_STATUS_BLK_SZ);
 
@@ -5275,7 +5280,7 @@
        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
@@ -5354,7 +5359,7 @@
        }
 
        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,



Home | Main Index | Thread Index | Old Index