From f7c701d528f76021ddae78abb6492d20bbe88f5f Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Mon, 23 Mar 2009 19:27:23 +0000 Subject: [PATCH] Reenable 64-bit DMA for twa(4) controllers, but use a 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. Reviewed by: scottl MFC after: 1 week --- sys/dev/twa/tw_cl_init.c | 2 +- sys/dev/twa/tw_osl.h | 6 ++++++ sys/dev/twa/tw_osl_freebsd.c | 12 ++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/sys/dev/twa/tw_cl_init.c b/sys/dev/twa/tw_cl_init.c index 52864b2c6de5..ca282faa237c 100644 --- a/sys/dev/twa/tw_cl_init.c +++ b/sys/dev/twa/tw_cl_init.c @@ -692,7 +692,7 @@ tw_cli_init_connection(struct tw_cli_ctlr_context *ctlr, 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 diff --git a/sys/dev/twa/tw_osl.h b/sys/dev/twa/tw_osl.h index d68cc5ec600f..6082253b6ffa 100644 --- a/sys/dev/twa/tw_osl.h +++ b/sys/dev/twa/tw_osl.h @@ -57,6 +57,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 */ diff --git a/sys/dev/twa/tw_osl_freebsd.c b/sys/dev/twa/tw_osl_freebsd.c index d18fd0a746b0..85b3af1c5962 100644 --- a/sys/dev/twa/tw_osl_freebsd.c +++ b/sys/dev/twa/tw_osl_freebsd.c @@ -491,8 +491,8 @@ 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 */ - BUS_SPACE_MAXADDR_32BIT,/* lowaddr */ + TW_OSLI_DMA_BOUNDARY, /* boundary */ + BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ TW_CL_MAX_IO_SIZE, /* maxsize */ @@ -515,7 +515,7 @@ tw_osli_alloc_mem(struct twa_softc *sc) if (bus_dma_tag_create(sc->parent_tag, /* parent */ sc->alignment, /* alignment */ 0, /* boundary */ - BUS_SPACE_MAXADDR_32BIT,/* lowaddr */ + BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ dma_mem_size, /* maxsize */ @@ -562,7 +562,7 @@ tw_osli_alloc_mem(struct twa_softc *sc) if (bus_dma_tag_create(sc->parent_tag, /* parent */ sc->alignment, /* alignment */ 0, /* boundary */ - BUS_SPACE_MAXADDR_32BIT,/* lowaddr */ + BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ TW_CL_MAX_IO_SIZE, /* maxsize */ @@ -588,7 +588,7 @@ tw_osli_alloc_mem(struct twa_softc *sc) if (bus_dma_tag_create(sc->parent_tag, /* parent */ sc->alignment, /* alignment */ 0, /* boundary */ - BUS_SPACE_MAXADDR_32BIT,/* lowaddr */ + BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ TW_CL_MAX_IO_SIZE, /* maxsize */ @@ -1347,7 +1347,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; }