From 21adbdd7d014cbc0b1b43c8ac93ecf302ab0824b Mon Sep 17 00:00:00 2001 From: mrg Date: Wed, 5 Apr 2000 14:26:51 +0000 Subject: [PATCH] after enabling the streaming buffer, check to see that it is actually there and enabled. if it appears to be missing or not enabled, do not use it. --- sys/arch/sparc64/dev/iommu.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/sys/arch/sparc64/dev/iommu.c b/sys/arch/sparc64/dev/iommu.c index 867a63975a69..d9c3bddacd47 100644 --- a/sys/arch/sparc64/dev/iommu.c +++ b/sys/arch/sparc64/dev/iommu.c @@ -1,4 +1,4 @@ -/* $NetBSD: iommu.c,v 1.4 2000/04/05 05:59:03 mrg Exp $ */ +/* $NetBSD: iommu.c,v 1.5 2000/04/05 14:26:51 mrg Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -202,8 +202,13 @@ iommu_reset(is) /* Need to do 64-bit stores */ bus_space_write_8(is->is_bustag, &is->is_iommu->iommu_cr, 0, is->is_cr); bus_space_write_8(is->is_bustag, &is->is_iommu->iommu_tsb, 0, is->is_ptsb); + /* Enable diagnostics mode? */ bus_space_write_8(is->is_bustag, &is->is_sb->strbuf_ctl, 0, STRBUF_EN); + + /* No streaming buffers? Disable them */ + if (bus_space_read_8(is->is_bustag, &is->is_sb->strbuf_ctl, 0) == 0) + is->is_sb = 0; } /* @@ -227,9 +232,11 @@ iommu_enter(is, va, pa, flags) !(flags&BUS_DMA_COHERENT)); /* Is the streamcache flush really needed? */ - bus_space_write_8(is->is_bustag, &is->is_sb->strbuf_pgflush, - 0, va); - iommu_flush(is); + if (is->is_sb) { + bus_space_write_8(is->is_bustag, &is->is_sb->strbuf_pgflush, 0, + va); + iommu_flush(is); + } DPRINTF(IDB_DVMA, ("Clearing TSB slot %d for va %p\n", (int)IOTSBSLOT(va,is->is_tsbsize), va)); is->is_tsb[IOTSBSLOT(va,is->is_tsbsize)] = tte; @@ -277,21 +284,24 @@ iommu_remove(is, va, len) * * If it takes more than .5 sec, something went wrong. */ - DPRINTF(IDB_DVMA, ("iommu_remove: flushing va %p TSB[%lx]@%p=%lx, %lu bytes left\n", + if (is->is_sb) { + DPRINTF(IDB_DVMA, ("iommu_remove: flushing va %p TSB[%lx]@%p=%lx, %lu bytes left\n", (long)va, (long)IOTSBSLOT(va,is->is_tsbsize), (long)&is->is_tsb[IOTSBSLOT(va,is->is_tsbsize)], (long)(is->is_tsb[IOTSBSLOT(va,is->is_tsbsize)]), (u_long)len)); - bus_space_write_8(is->is_bustag, &is->is_sb->strbuf_pgflush, 0, va); - if (len <= NBPG) { - iommu_flush(is); - len = 0; - } else len -= NBPG; - DPRINTF(IDB_DVMA, ("iommu_remove: flushed va %p TSB[%lx]@%p=%lx, %lu bytes left\n", + bus_space_write_8(is->is_bustag, + &is->is_sb->strbuf_pgflush, 0, va); + if (len <= NBPG) { + iommu_flush(is); + len = 0; + } else len -= NBPG; + DPRINTF(IDB_DVMA, ("iommu_remove: flushed va %p TSB[%lx]@%p=%lx, %lu bytes left\n", (long)va, (long)IOTSBSLOT(va,is->is_tsbsize), (long)&is->is_tsb[IOTSBSLOT(va,is->is_tsbsize)], (long)(is->is_tsb[IOTSBSLOT(va,is->is_tsbsize)]), (u_long)len)); + } is->is_tsb[IOTSBSLOT(va,is->is_tsbsize)] = 0; bus_space_write_8(is->is_bustag, &is->is_iommu->iommu_flush, 0, va); va += NBPG; @@ -315,6 +325,9 @@ iommu_flush(is) } \ } + if (!is->is_sb) + return (0); + is->is_flush = 0; membar_sync(); bus_space_write_8(is->is_bustag, &is->is_sb->strbuf_flushsync, 0, is->is_flushpa);