svn commit: r190077 - in stable/7/sys: . contrib/pf dev/ath/ath_hal
dev/cxgb sparc64/include sparc64/sparc64
Marius Strobl
marius at FreeBSD.org
Thu Mar 19 09:03:22 PDT 2009
Author: marius
Date: Thu Mar 19 16:03:21 2009
New Revision: 190077
URL: http://svn.freebsd.org/changeset/base/190077
Log:
MFC: r185008, r188456
- Allow the front-end to specify that iommu(4) should disable
rerun of the streaming cache for silicon bug workarounds.
- Announce the presence of a streaming cache on attach for
informational purposes.
- For performance reasons don't do unnecessary flushes of the
streaming cache when coherent mappings are synced.
- Fix some minor style issues.
Modified:
stable/7/sys/ (props changed)
stable/7/sys/contrib/pf/ (props changed)
stable/7/sys/dev/ath/ath_hal/ (props changed)
stable/7/sys/dev/cxgb/ (props changed)
stable/7/sys/sparc64/include/bus_private.h
stable/7/sys/sparc64/include/iommureg.h
stable/7/sys/sparc64/include/iommuvar.h
stable/7/sys/sparc64/sparc64/iommu.c
Modified: stable/7/sys/sparc64/include/bus_private.h
==============================================================================
--- stable/7/sys/sparc64/include/bus_private.h Thu Mar 19 15:59:29 2009 (r190076)
+++ stable/7/sys/sparc64/include/bus_private.h Thu Mar 19 16:03:21 2009 (r190077)
@@ -66,9 +66,10 @@ struct bus_dmamap {
int dm_flags; /* (p) */
};
-/* Flag values. */
-#define DMF_LOADED 1 /* Map is loaded */
-#define DMF_COHERENT 2 /* Coherent mapping requested */
+/* Flag values */
+#define DMF_LOADED (1 << 0) /* Map is loaded. */
+#define DMF_COHERENT (1 << 1) /* Coherent mapping requested. */
+#define DMF_STREAMED (1 << 2) /* Streaming cache used. */
int sparc64_dma_alloc_map(bus_dma_tag_t dmat, bus_dmamap_t *mapp);
void sparc64_dma_free_map(bus_dma_tag_t dmat, bus_dmamap_t map);
Modified: stable/7/sys/sparc64/include/iommureg.h
==============================================================================
--- stable/7/sys/sparc64/include/iommureg.h Thu Mar 19 15:59:29 2009 (r190076)
+++ stable/7/sys/sparc64/include/iommureg.h Thu Mar 19 16:03:21 2009 (r190077)
@@ -54,7 +54,7 @@
#define ISR_PGFLUSH 0x0008 /* streaming buffer page flush */
#define ISR_FLUSHSYNC 0x0010 /* streaming buffer flush sync */
-/* streaming buffer diagnostics registers. */
+/* streaming buffer diagnostics registers */
#define ISD_DATA_DIAG 0x0000 /* streaming buffer data RAM diag 0..127 */
#define ISD_ERROR_DIAG 0x0400 /* streaming buffer error status diag 0..127 */
#define ISD_PG_TAG_DIAG 0x0800 /* streaming buffer page tag diag 0..15 */
@@ -63,6 +63,7 @@
/* streaming buffer control register */
#define STRBUF_EN 0x0000000000000001UL
#define STRBUF_D 0x0000000000000002UL
+#define STRBUF_RR_DIS 0x0000000000000004UL
#define IOMMU_MAXADDR(bits) ((1UL << (bits)) - 1)
@@ -91,7 +92,7 @@
#define IOMMUCR_EN 0x0000000000000001UL
/*
- * Diagnostic register definitions.
+ * Diagnostic register definitions
*/
#define IOMMU_DTAG_VPNBITS 19
#define IOMMU_DTAG_VPNMASK ((1 << IOMMU_DTAG_VPNBITS) - 1)
@@ -126,10 +127,10 @@
/* Writeable */
#define IOTTE_W 0x0000000000000002UL
-/* log2 of the IOMMU TTE size. */
+/* log2 of the IOMMU TTE size */
#define IOTTE_SHIFT 3
-/* Streaming buffer line size. */
+/* Streaming buffer line size */
#define STRBUF_LINESZ 64
/*
Modified: stable/7/sys/sparc64/include/iommuvar.h
==============================================================================
--- stable/7/sys/sparc64/include/iommuvar.h Thu Mar 19 15:59:29 2009 (r190076)
+++ stable/7/sys/sparc64/include/iommuvar.h Thu Mar 19 16:03:21 2009 (r190077)
@@ -45,12 +45,12 @@
TAILQ_HEAD(iommu_maplruq_head, bus_dmamap);
/*
- * Per-IOMMU state. The parenthesized comments indicate the locking strategy:
+ * Per-IOMMU state; the parenthesized comments indicate the locking strategy:
* i - protected by is_mtx.
* r - read-only after initialization.
* * - comment refers to pointer target / target hardware registers
* (for bus_addr_t).
- * is_maplruq is also locked by is_mtx. Elements of is_tsb may only be
+ * is_maplruq is also locked by is_mtx. Elements of is_tsb may only be
* accessed from functions operating on the map owning the corresponding
* resource, so the locking the user is required to do to protect the
* map is sufficient.
@@ -81,7 +81,7 @@ struct iommu_state {
*/
volatile char is_flush[STRBUF_FLUSHSYNC_NBYTES * 3 - 1];
- /* copies of our parents state, to allow us to be self contained */
+ /* copies of our parent's state, to allow us to be self contained */
bus_space_tag_t is_bustag; /* (r) Our bus tag */
bus_space_handle_t is_bushandle; /* (r) */
bus_addr_t is_iommu; /* (r, *i) IOMMU registers */
@@ -96,6 +96,9 @@ struct iommu_state {
bus_addr_t is_dva; /* (r, *r) */
/* Tag compare diagnostics access */
bus_addr_t is_dtcmp; /* (r, *r) */
+ /* behavior flags */
+ u_int is_flags; /* (r) */
+#define IOMMU_RERUN_DISABLE (1 << 0)
};
/* interfaces for PCI/SBus code */
Modified: stable/7/sys/sparc64/sparc64/iommu.c
==============================================================================
--- stable/7/sys/sparc64/sparc64/iommu.c Thu Mar 19 15:59:29 2009 (r190076)
+++ stable/7/sys/sparc64/sparc64/iommu.c Thu Mar 19 16:03:21 2009 (r190077)
@@ -119,8 +119,7 @@ __FBSDID("$FreeBSD$");
* - When running out of DVMA space, return EINPROGRESS in the non-
* BUS_DMA_NOWAIT case and delay the callback until sufficient space
* becomes available.
- * - Use the streaming cache unless BUS_DMA_COHERENT is specified; do not
- * flush the streaming cache when coherent mappings are synced.
+ * - Use the streaming cache unless BUS_DMA_COHERENT is specified.
*/
#include "opt_iommu.h"
@@ -150,12 +149,12 @@ __FBSDID("$FreeBSD$");
#include <machine/iommuvar.h>
/*
- * Tuning constants.
+ * Tuning constants
*/
#define IOMMU_MAX_PRE (32 * 1024)
#define IOMMU_MAX_PRE_SEG 3
-/* Threshold for using the streaming buffer. */
+/* Threshold for using the streaming buffer */
#define IOMMU_STREAM_THRESH 128
MALLOC_DEFINE(M_IOMMU, "dvmamem", "IOMMU DVMA Buffers");
@@ -309,9 +308,10 @@ iommu_init(const char *name, struct iomm
is->is_dvmabase = IOTSB_VSTART(is->is_tsbsize);
size = IOTSB_BASESZ << is->is_tsbsize;
- printf("%s: DVMA map: %#lx to %#lx\n", name,
+ printf("%s: DVMA map: %#lx to %#lx%s\n", name,
is->is_dvmabase, is->is_dvmabase +
- (size << (IO_PAGE_SHIFT - IOTTE_SHIFT)) - 1);
+ (size << (IO_PAGE_SHIFT - IOTTE_SHIFT)) - 1,
+ IOMMU_HAS_SB(is) ? ", streaming buffer" : "");
/*
* Set up resource mamangement.
@@ -376,11 +376,13 @@ iommu_reset(struct iommu_state *is)
for (i = 0; i < 2; i++) {
if (is->is_sb[i] != 0) {
- /* Enable diagnostics mode? */
- IOMMU_WRITE8(is, is_sb[i], ISR_CTL, STRBUF_EN);
-
- /* No streaming buffers? Disable them */
- if (IOMMU_READ8(is, is_sb[i], ISR_CTL) == 0)
+ IOMMU_WRITE8(is, is_sb[i], ISR_CTL, STRBUF_EN |
+ ((is->is_flags & IOMMU_RERUN_DISABLE) != 0 ?
+ STRBUF_RR_DIS : 0));
+
+ /* No streaming buffers? Disable them. */
+ if ((IOMMU_READ8(is, is_sb[i], ISR_CTL) &
+ STRBUF_EN) == 0)
is->is_sb[i] = 0;
}
}
@@ -585,7 +587,7 @@ iommu_dvmamap_vunload(struct iommu_state
struct bus_dmamap_res *r;
int streamed = 0;
- IS_LOCK_ASSERT(is); /* for iommu_strbuf_sync() below. */
+ IS_LOCK_ASSERT(is); /* for iommu_strbuf_sync() below */
SLIST_FOREACH(r, &map->dm_reslist, dr_link) {
streamed |= iommu_remove(is, BDR_START(r), r->dr_used);
r->dr_used = 0;
@@ -820,7 +822,7 @@ iommu_dvmamap_destroy(bus_dma_tag_t dt,
}
/*
- * IOMMU DVMA operations, common to PCI and SBus.
+ * IOMMU DVMA operations, common to PCI and SBus
*/
static int
iommu_dvmamap_load_buffer(bus_dma_tag_t dt, struct iommu_state *is,
@@ -831,8 +833,8 @@ iommu_dvmamap_load_buffer(bus_dma_tag_t
bus_size_t sgsize, esize;
vm_offset_t vaddr, voffs;
vm_paddr_t curaddr;
- int error, sgcnt, firstpg, stream;
pmap_t pmap = NULL;
+ int error, firstpg, sgcnt;
KASSERT(buflen != 0, ("%s: buflen == 0!", __func__));
if (buflen > dt->dt_maxsize)
@@ -853,7 +855,9 @@ iommu_dvmamap_load_buffer(bus_dma_tag_t
sgcnt = *segp;
firstpg = 1;
- stream = iommu_use_streaming(is, map, buflen);
+ map->dm_flags &= ~DMF_STREAMED;
+ map->dm_flags |= iommu_use_streaming(is, map, buflen) != 0 ?
+ DMF_STREAMED : 0;
for (; buflen > 0; ) {
/*
* Get the physical address for this page.
@@ -874,7 +878,7 @@ iommu_dvmamap_load_buffer(bus_dma_tag_t
vaddr += sgsize;
iommu_enter(is, trunc_io_page(dvmaddr), trunc_io_page(curaddr),
- stream, flags);
+ (map->dm_flags & DMF_STREAMED) != 0, flags);
/*
* Chop the chunk up into segments of at most maxsegsz, but try
@@ -1139,7 +1143,7 @@ iommu_dvmamap_sync(bus_dma_tag_t dt, bus
/* XXX This is probably bogus. */
if ((op & BUS_DMASYNC_PREREAD) != 0)
membar(Sync);
- if (IOMMU_HAS_SB(is) &&
+ if ((map->dm_flags & DMF_STREAMED) != 0 &&
((op & BUS_DMASYNC_POSTREAD) != 0 ||
(op & BUS_DMASYNC_PREWRITE) != 0)) {
IS_LOCK(is);
More information about the svn-src-stable
mailing list