mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-27 16:39:08 +00:00
- 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.
This commit is contained in:
parent
d92cebca6a
commit
11202ac9db
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=185008
@ -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
|
||||
|
||||
/*
|
||||
|
@ -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 */
|
||||
|
@ -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 iommu_state *is, int tsbsize,
|
||||
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);
|
||||
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) == 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 *is, bus_dmamap_t map)
|
||||
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;
|
||||
@ -1139,7 +1141,7 @@ iommu_dvmamap_sync(bus_dma_tag_t dt, bus_dmamap_t map, bus_dmasync_op_t op)
|
||||
/* XXX This is probably bogus. */
|
||||
if ((op & BUS_DMASYNC_PREREAD) != 0)
|
||||
membar(Sync);
|
||||
if (IOMMU_HAS_SB(is) &&
|
||||
if ((map->dm_flags & DMF_COHERENT) == 0 && IOMMU_HAS_SB(is) &&
|
||||
((op & BUS_DMASYNC_POSTREAD) != 0 ||
|
||||
(op & BUS_DMASYNC_PREWRITE) != 0)) {
|
||||
IS_LOCK(is);
|
||||
|
Loading…
Reference in New Issue
Block a user