summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/sparc64/dev/iommu.c24
-rw-r--r--sys/arch/sparc64/dev/iommureg.h8
-rw-r--r--sys/arch/sparc64/dev/psycho.c4
-rw-r--r--sys/arch/sparc64/dev/schizo.c6
4 files changed, 20 insertions, 22 deletions
diff --git a/sys/arch/sparc64/dev/iommu.c b/sys/arch/sparc64/dev/iommu.c
index 8e78f79b043..2fc6003883e 100644
--- a/sys/arch/sparc64/dev/iommu.c
+++ b/sys/arch/sparc64/dev/iommu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iommu.c,v 1.43 2006/09/01 20:07:57 miod Exp $ */
+/* $OpenBSD: iommu.c,v 1.44 2007/01/26 16:53:28 tsi Exp $ */
/* $NetBSD: iommu.c,v 1.47 2002/02/08 20:03:45 eeh Exp $ */
/*
@@ -150,12 +150,12 @@ iommu_init(char *name, struct iommu_state *is, int tsbsize, u_int32_t iovabase)
*/
is->is_cr = (tsbsize << 16) | IOMMUCR_EN;
is->is_tsbsize = tsbsize;
- if (iovabase == -1) {
+ if (iovabase == (u_int32_t)-1) {
is->is_dvmabase = IOTSB_VSTART(is->is_tsbsize);
is->is_dvmaend = IOTSB_VEND;
} else {
is->is_dvmabase = iovabase;
- is->is_dvmaend = iovabase + IOTSB_VSIZE(tsbsize);
+ is->is_dvmaend = iovabase + IOTSB_VSIZE(tsbsize) - 1;
}
/*
@@ -211,12 +211,12 @@ iommu_init(char *name, struct iommu_state *is, int tsbsize, u_int32_t iovabase)
/*
* Now all the hardware's working we need to allocate a dvma map.
*/
- printf("dvma map %x-%x, ", is->is_dvmabase, is->is_dvmaend - 1);
+ printf("dvma map %x-%x, ", is->is_dvmabase, is->is_dvmaend);
printf("iotdb %llx-%llx",
(unsigned long long)is->is_ptsb,
(unsigned long long)(is->is_ptsb + size));
is->is_dvmamap = extent_create(name,
- is->is_dvmabase, is->is_dvmaend - PAGE_SIZE,
+ is->is_dvmabase, (u_long)is->is_dvmaend + 1,
M_DEVBUF, 0, 0, EX_NOWAIT);
/*
@@ -297,8 +297,7 @@ iommu_enter(struct iommu_state *is, struct strbuf_ctl *sb, vaddr_t va,
volatile int64_t *tte_ptr = &is->is_tsb[IOTSBSLOT(va,is->is_tsbsize)];
#ifdef DIAGNOSTIC
- if (va < is->is_dvmabase || round_page(va + PAGE_SIZE) >
- is->is_dvmaend + 1)
+ if (va < is->is_dvmabase || (va + PAGE_MASK) > is->is_dvmaend)
panic("iommu_enter: va %#lx not in DVMA space", va);
tte = *tte_ptr;
@@ -356,8 +355,7 @@ iommu_remove(struct iommu_state *is, struct strbuf_ctl *sb, vaddr_t va)
int64_t tte;
#ifdef DIAGNOSTIC
- if (trunc_page(va) < is->is_dvmabase || round_page(va) >
- is->is_dvmaend + 1)
+ if (va < is->is_dvmabase || (va + PAGE_MASK) > is->is_dvmaend)
panic("iommu_remove: va 0x%lx not in DVMA space", (u_long)va);
if (va != trunc_page(va)) {
printf("iommu_remove: unaligned va: %lx\n", va);
@@ -445,7 +443,7 @@ iommu_tsb_entry(struct iommu_state *is, vaddr_t dva)
{
int64_t tte;
- if (dva < is->is_dvmabase && dva > is->is_dvmaend)
+ if (dva < is->is_dvmabase || dva > is->is_dvmaend)
panic("invalid dva: %llx", (long long)dva);
tte = is->is_tsb[IOTSBSLOT(dva,is->is_tsbsize)];
@@ -1338,8 +1336,8 @@ iommu_dvmamap_validate_map(bus_dma_tag_t t, struct iommu_state *is,
err = 1;
}
if (map->_dm_dvmastart < is->is_dvmabase ||
- round_page(map->_dm_dvmastart + map->_dm_dvmasize) >
- is->is_dvmaend + 1) {
+ (round_page(map->_dm_dvmastart + map->_dm_dvmasize) - 1) >
+ is->is_dvmaend) {
printf("dvmaddr %llx len %llx out of range %x - %x\n",
map->_dm_dvmastart, map->_dm_dvmasize,
is->is_dvmabase, is->is_dvmaend);
@@ -1558,7 +1556,7 @@ iommu_dvmamap_sync_range(struct strbuf_ctl *sb, vaddr_t va, bus_size_t len)
va &= ~PAGE_MASK;
#ifdef DIAGNOSTIC
- if (va < is->is_dvmabase || vaend > is->is_dvmaend)
+ if (va < is->is_dvmabase || (vaend - 1) > is->is_dvmaend)
panic("invalid va range: %llx to %llx (%x to %x)",
(long long)va, (long long)vaend,
is->is_dvmabase,
diff --git a/sys/arch/sparc64/dev/iommureg.h b/sys/arch/sparc64/dev/iommureg.h
index 219b9e766f4..e5c5ec86109 100644
--- a/sys/arch/sparc64/dev/iommureg.h
+++ b/sys/arch/sparc64/dev/iommureg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: iommureg.h,v 1.13 2006/08/27 18:55:57 kettenis Exp $ */
+/* $OpenBSD: iommureg.h,v 1.14 2007/01/26 16:53:28 tsi Exp $ */
/* $NetBSD: iommureg.h,v 1.6 2001/07/20 00:07:13 eeh Exp $ */
/*
@@ -128,9 +128,9 @@ struct iommu_strbuf {
*/
-#define IOTSB_VEND (u_int)(0xffffffffffffffffLL<<PGSHIFT)
-#define IOTSB_VSTART(sz) (u_int)(IOTSB_VEND << ((sz)+10))
-#define IOTSB_VSIZE(sz) (u_int)(1 << ((sz)+10+PGSHIFT))
+#define IOTSB_VEND 0xffffffffU
+#define IOTSB_VSTART(sz) (u_int)(IOTSB_VEND << ((sz)+10+PGSHIFT))
+#define IOTSB_VSIZE(sz) (u_int)(1 << ((sz)+10+PGSHIFT))
#define MAKEIOTTE(pa,w,c,s) (((pa)&IOTTE_PAMASK)|((w)?IOTTE_W:0)|((c)?IOTTE_C:0)|((s)?IOTTE_STREAM:0)|(IOTTE_V|IOTTE_8K))
#define IOTSBSLOT(va,sz) ((u_int)(((vaddr_t)(va))-(is->is_dvmabase))>>PGSHIFT)
diff --git a/sys/arch/sparc64/dev/psycho.c b/sys/arch/sparc64/dev/psycho.c
index 34539f093e3..ac0a2b42383 100644
--- a/sys/arch/sparc64/dev/psycho.c
+++ b/sys/arch/sparc64/dev/psycho.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: psycho.c,v 1.49 2006/12/24 01:25:01 deraadt Exp $ */
+/* $OpenBSD: psycho.c,v 1.50 2007/01/26 16:53:28 tsi Exp $ */
/* $NetBSD: psycho.c,v 1.39 2001/10/07 20:30:41 eeh Exp $ */
/*
@@ -835,7 +835,7 @@ psycho_iommu_init(struct psycho_softc *sc, int tsbsize)
free(vdma, M_DEVBUF);
} else {
DPRINTF(PDB_CONF, ("psycho_iommu_init: getprop failed, "
- "iobase=0x%x\n", iobase));
+ "iobase=0x%x, tsbsize=%d\n", iobase, tsbsize));
}
/* give us a nice name.. */
diff --git a/sys/arch/sparc64/dev/schizo.c b/sys/arch/sparc64/dev/schizo.c
index 10fc53ba859..9e3de1943fc 100644
--- a/sys/arch/sparc64/dev/schizo.c
+++ b/sys/arch/sparc64/dev/schizo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: schizo.c,v 1.44 2007/01/20 16:26:53 kettenis Exp $ */
+/* $OpenBSD: schizo.c,v 1.45 2007/01/26 16:53:29 tsi Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -351,7 +351,7 @@ void
schizo_init_iommu(struct schizo_softc *sc, struct schizo_pbm *pbm)
{
struct iommu_state *is = &pbm->sp_is;
- int *vdma = NULL, nitem, tsbsize = 128 * 1024;
+ int *vdma = NULL, nitem, tsbsize = 7;
u_int32_t iobase = -1;
vaddr_t va;
char *name;
@@ -412,7 +412,7 @@ schizo_init_iommu(struct schizo_softc *sc, struct schizo_pbm *pbm)
free(vdma, M_DEVBUF);
} else {
DPRINTF(SDB_BUSMAP, ("schizo_iommu_init: getprop failed, "
- "iobase=0x%x\n", iobase));
+ "using iobase=0x%x, tsbsize=%d\n", iobase, tsbsize));
}
iommu_init(name, is, tsbsize, iobase);