Author: jhb
Date: Mon Mar 30 18:47:13 2009
New Revision: 190569
URL: http://svn.freebsd.org/changeset/base/190569

Log:
  MFC: Use a DMA boundary of 4GB to prevent individual transactions from
  crossing a 4GB address boundary.  Due to bus_size_t type limitations, the
  driver uses a 2GB boundary in PAE kernels.  This fixes a data corruption
  issue when using twa(4) in machines with >= 8 GB of RAM.

Modified:
  stable/6/sys/   (props changed)
  stable/6/sys/contrib/pf/   (props changed)
  stable/6/sys/dev/cxgb/   (props changed)
  stable/6/sys/dev/twa/tw_cl_init.c
  stable/6/sys/dev/twa/tw_osl.h
  stable/6/sys/dev/twa/tw_osl_freebsd.c

Modified: stable/6/sys/dev/twa/tw_cl_init.c
==============================================================================
--- stable/6/sys/dev/twa/tw_cl_init.c   Mon Mar 30 18:43:41 2009        
(r190568)
+++ stable/6/sys/dev/twa/tw_cl_init.c   Mon Mar 30 18:47:13 2009        
(r190569)
@@ -691,7 +691,7 @@ tw_cli_init_connection(struct tw_cli_ctl
        init_connect->message_credits = TW_CL_SWAP16(message_credits);
        init_connect->features = TW_CL_SWAP32(set_features);
        if (ctlr->flags & TW_CL_64BIT_ADDRESSES)
-               init_connect->features |= TWA_64BIT_SG_ADDRESSES;
+               init_connect->features |= TW_CL_SWAP32(TWA_64BIT_SG_ADDRESSES);
        if (set_features & TWA_EXTENDED_INIT_CONNECT) {
                /*
                 * Fill in the extra fields needed for an extended

Modified: stable/6/sys/dev/twa/tw_osl.h
==============================================================================
--- stable/6/sys/dev/twa/tw_osl.h       Mon Mar 30 18:43:41 2009        
(r190568)
+++ stable/6/sys/dev/twa/tw_osl.h       Mon Mar 30 18:47:13 2009        
(r190569)
@@ -55,6 +55,12 @@
 
 //#define TW_OSLI_DEFERRED_INTR_USED
 
+#ifdef PAE
+#define        TW_OSLI_DMA_BOUNDARY            (1u << 31)
+#else
+#define        TW_OSLI_DMA_BOUNDARY            ((bus_size_t)((uint64_t)1 << 
32))
+#endif
+
 /* Possible values of req->state. */
 #define TW_OSLI_REQ_STATE_INIT         0x0     /* being initialized */
 #define TW_OSLI_REQ_STATE_BUSY         0x1     /* submitted to CL */

Modified: stable/6/sys/dev/twa/tw_osl_freebsd.c
==============================================================================
--- stable/6/sys/dev/twa/tw_osl_freebsd.c       Mon Mar 30 18:43:41 2009        
(r190568)
+++ stable/6/sys/dev/twa/tw_osl_freebsd.c       Mon Mar 30 18:47:13 2009        
(r190569)
@@ -484,7 +484,7 @@ tw_osli_alloc_mem(struct twa_softc *sc)
        /* Create the parent dma tag. */
        if (bus_dma_tag_create(NULL,                    /* parent */
                                sc->alignment,          /* alignment */
-                               0,                      /* boundary */
+                               TW_OSLI_DMA_BOUNDARY,   /* boundary */
                                BUS_SPACE_MAXADDR,      /* lowaddr */
                                BUS_SPACE_MAXADDR,      /* highaddr */
                                NULL, NULL,             /* filter, filterarg */
@@ -1324,7 +1324,7 @@ static TW_VOID
 twa_map_load_callback(TW_VOID *arg, bus_dma_segment_t *segs,
        TW_INT32 nsegments, TW_INT32 error)
 {
-       *((bus_addr_t *)arg) = segs[0].ds_addr;
+       *((TW_UINT64 *)arg) = segs[0].ds_addr;
 }
 
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to