Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sparc64/dev revert the iommu changes for now. my U...



details:   https://anonhg.NetBSD.org/src/rev/da6591699e7e
branches:  trunk
changeset: 763282:da6591699e7e
user:      mrg <mrg%NetBSD.org@localhost>
date:      Wed Mar 16 05:49:43 2011 +0000

description:
revert the iommu changes for now.  my U60 doesn't like them.

diffstat:

 sys/arch/sparc64/dev/iommu.c     |  89 +++++++++------------------------------
 sys/arch/sparc64/dev/iommureg.h  |  20 +-------
 sys/arch/sparc64/dev/iommuvar.h  |  15 +------
 sys/arch/sparc64/dev/psycho.c    |   6 +-
 sys/arch/sparc64/dev/psychoreg.h |   4 +-
 sys/arch/sparc64/dev/sbus.c      |   6 +-
 sys/arch/sparc64/dev/sbusreg.h   |   4 +-
 7 files changed, 36 insertions(+), 108 deletions(-)

diffs (truncated from 383 to 300 lines):

diff -r 4a92fe8c5edf -r da6591699e7e sys/arch/sparc64/dev/iommu.c
--- a/sys/arch/sparc64/dev/iommu.c      Wed Mar 16 05:31:03 2011 +0000
+++ b/sys/arch/sparc64/dev/iommu.c      Wed Mar 16 05:49:43 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iommu.c,v 1.101 2011/03/16 02:41:19 mrg Exp $  */
+/*     $NetBSD: iommu.c,v 1.102 2011/03/16 05:49:43 mrg Exp $  */
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.101 2011/03/16 02:41:19 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: iommu.c,v 1.102 2011/03/16 05:49:43 mrg Exp $");
 
 #include "opt_ddb.h"
 
@@ -134,7 +134,7 @@
         * be hard-wired, so we read the start and size from the PROM and
         * just use those values.
         */
-       is->is_cr = IOMMUCR_EN;
+       is->is_cr = (tsbsize << 16) | IOMMUCR_EN;
        is->is_tsbsize = tsbsize;
        if (iovabase == -1) {
                is->is_dvmabase = IOTSB_VSTART(is->is_tsbsize);
@@ -172,7 +172,7 @@
        memset(is->is_tsb, 0, size);
 
 #ifdef DEBUG
-       if ((iommudebug & IDB_INFO) && 0)
+       if (iommudebug & IDB_INFO)
        {
                /* Probe the iommu */
 
@@ -197,6 +197,11 @@
 #endif
 
        /*
+        * now actually start up the IOMMU
+        */
+       iommu_reset(is);
+
+       /*
         * Now all the hardware's working we need to allocate a dvma map.
         */
        aprint_debug("DVMA map: %x to %x\n",
@@ -209,20 +214,6 @@
            is->is_dvmabase, is->is_dvmaend,
            M_DEVBUF, 0, 0, EX_NOWAIT);
        /* XXXMRG Check is_dvmamap is valid. */
-
-       /*
-        * Set the TSB size.  The relevant bits were moved to the TSB
-        * base register in the PCIe host bridges.
-        */
-       if (strncmp(name, "pyro", 4) == 0)
-               is->is_ptsb |= is->is_tsbsize;
-       else
-               is->is_cr |= (is->is_tsbsize << 16);
-
-       /*
-        * now actually start up the IOMMU
-        */
-       iommu_reset(is);
 }
 
 /*
@@ -236,10 +227,13 @@
        int i;
        struct strbuf_ctl *sb;
 
-       IOMMUREG_WRITE(is, iommu_tsb, is->is_ptsb);
+       /* Need to do 64-bit stores */
+       bus_space_write_8(is->is_bustag, is->is_iommu, IOMMUREG(iommu_tsb),
+               is->is_ptsb);
 
        /* Enable IOMMU in diagnostic mode */
-       IOMMUREG_WRITE(is, iommu_cr, is->is_cr|IOMMUCR_DE);
+       bus_space_write_8(is->is_bustag, is->is_iommu, IOMMUREG(iommu_cr),
+               is->is_cr|IOMMUCR_DE);
 
        for (i = 0; i < 2; i++) {
                if ((sb = is->is_sb[i])) {
@@ -248,8 +242,6 @@
                        bus_space_write_8(is->is_bustag, is->is_sb[i]->sb_sb,
                                STRBUFREG(strbuf_ctl), STRBUF_EN);
 
-                       membar_lookaside();
-
                        /* No streaming buffers? Disable them */
                        if (bus_space_read_8(is->is_bustag,
                                is->is_sb[i]->sb_sb,
@@ -260,16 +252,12 @@
                                /*
                                 * locate the pa of the flush buffer.
                                 */
-                               if (pmap_extract(pmap_kernel(),
-                                    (vaddr_t)is->is_sb[i]->sb_flush,
-                                    &is->is_sb[i]->sb_flushpa) == FALSE)
-                                       is->is_sb[i]->sb_flush = NULL;
+                               (void)pmap_extract(pmap_kernel(),
+                                       (vaddr_t)is->is_sb[i]->sb_flush,
+                                       &is->is_sb[i]->sb_flushpa);
                        }
                }
        }
-
-       if (is->is_flags & IOMMU_FLUSH_CACHE)
-               IOMMUREG_WRITE(is, iommu_cache_invalidate, -1ULL);
 }
 
 /*
@@ -337,7 +325,6 @@
 void
 iommu_remove(struct iommu_state *is, vaddr_t va, size_t len)
 {
-       int slot;
 
 #ifdef DIAGNOSTIC
        if (va < is->is_dvmabase || va > is->is_dvmaend)
@@ -376,15 +363,8 @@
                is->is_tsb[IOTSBSLOT(va,is->is_tsbsize)] &= ~IOTTE_V;
                membar_storestore();
 #endif
-               IOMMUREG_WRITE(is, iommu_flush, va);
-
-               /* Flush cache if necessary. */
-               slot = IOTSBSLOT(trunc_page(va), is->is_tsbsize);
-               if ((is->is_flags & IOMMU_FLUSH_CACHE) &&
-                   (len == 0 || (slot % 8) == 7))
-                       IOMMUREG_WRITE(is, iommu_cache_flush,
-                           is->is_ptsb + slot * 8);
-
+               bus_space_write_8(is->is_bustag, is->is_iommu,
+                       IOMMUREG(iommu_flush), va);
                va += PAGE_SIZE;
        }
 }
@@ -473,7 +453,6 @@
        vaddr_t vaddr = (vaddr_t)buf;
        int seg;
        struct pmap *pmap;
-       int slot;
 
        if (map->dm_nsegs) {
                /* Already in use?? */
@@ -510,7 +489,6 @@
         * If our segment size is larger than the boundary we need to
         * split the transfer up int little pieces ourselves.
         */
-       KASSERT(is->is_dvmamap);
        s = splhigh();
        err = extent_alloc(is->is_dvmamap, sgsize, align,
            (sgsize > boundary) ? 0 : boundary,
@@ -619,17 +597,9 @@
                    flags | IOTTE_DEBUG(0x4000));
                needsflush = 1;
 
+               dvmaddr += PAGE_SIZE;
                vaddr += sgsize;
                buflen -= sgsize;
-
-               /* Flush cache if necessary. */
-               slot = IOTSBSLOT(trunc_page(dvmaddr), is->is_tsbsize);
-               if ((is->is_flags & IOMMU_FLUSH_CACHE) &&
-                   (buflen <= 0 || (slot % 8) == 7))
-                       IOMMUREG_WRITE(is, iommu_cache_flush,
-                           is->is_ptsb + slot * 8);
-
-               dvmaddr += PAGE_SIZE;
        }
        if (needsflush)
                iommu_strbuf_flush_done(sb);
@@ -702,7 +672,6 @@
        u_long dvmaddr, sgstart, sgend, bmask;
        struct pglist *pglist;
        const int pagesz = PAGE_SIZE;
-       int slot;
 #ifdef DEBUG
        int npg = 0;
 #endif
@@ -872,15 +841,7 @@
                                            prev_pa = pa,
                                            flags | IOTTE_DEBUG(++npg << 12));
                                        needsflush = 1;
-
-                                       /* Flush cache if necessary. */
-                                       slot = IOTSBSLOT(trunc_page(dvmaddr), is->is_tsbsize);
-                                       if ((is->is_flags & IOMMU_FLUSH_CACHE) &&
-                                           ((dvmaddr + pagesz) > sgend || (slot % 8) == 7))
-                                               IOMMUREG_WRITE(is, iommu_cache_flush,
-                                                   is->is_ptsb + slot * 8);
                                }
-
                                dvmaddr += pagesz;
                                pa += pagesz;
                                last_va = dvmaddr;
@@ -951,16 +912,8 @@
                iommu_enter(sb, dvmaddr, pa, flags | IOTTE_DEBUG(0x8000));
                needsflush = 1;
 
+               dvmaddr += pagesz;
                sgsize -= pagesz;
-
-               /* Flush cache if necessary. */
-               slot = IOTSBSLOT(trunc_page(dvmaddr), is->is_tsbsize);
-               if ((is->is_flags & IOMMU_FLUSH_CACHE) &&
-                   (sgsize == 0 || (slot % 8) == 7))
-                       IOMMUREG_WRITE(is, iommu_cache_flush,
-                           is->is_ptsb + slot * 8);
-
-               dvmaddr += pagesz;
        }
        if (needsflush)
                iommu_strbuf_flush_done(sb);
diff -r 4a92fe8c5edf -r da6591699e7e sys/arch/sparc64/dev/iommureg.h
--- a/sys/arch/sparc64/dev/iommureg.h   Wed Mar 16 05:31:03 2011 +0000
+++ b/sys/arch/sparc64/dev/iommureg.h   Wed Mar 16 05:49:43 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iommureg.h,v 1.17 2011/03/16 03:49:53 mrg Exp $        */
+/*     $NetBSD: iommureg.h,v 1.18 2011/03/16 05:49:43 mrg Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -49,21 +49,10 @@
  */
 
 /* iommmu registers */
-struct iommureg_old {
-       volatile uint64_t       iommu_cr;       /* IOMMU control register */
-       volatile uint64_t       iommu_tsb;      /* IOMMU TSB base register */
-       volatile uint64_t       iommu_flush;    /* IOMMU flush register */
-};
-
 struct iommureg {
-       volatile uint64_t       iommu_cr;       /* IOMMU control register */
-       volatile uint64_t       iommu_tsb;      /* IOMMU TSB base register */
-       volatile uint64_t       iommu_flush;    /* IOMMU flush register */
-       volatile u_int64_t      iommu_ctxflush;
-       volatile u_int64_t      iommu_reserved[28];
-       volatile u_int64_t      iommu_cache_flush;
-       volatile u_int64_t      iommu_cache_invalidate;
-       volatile u_int64_t      iommu_reserved2[30];
+       uint64_t        iommu_cr;       /* IOMMU control register */
+       uint64_t        iommu_tsb;      /* IOMMU TSB base register */
+       uint64_t        iommu_flush;    /* IOMMU flush register */
 };
 
 /* streaming buffer registers */
@@ -75,7 +64,6 @@
 
 #define        IOMMUREG(x)     (offsetof(struct iommureg, x))
 #define        STRBUFREG(x)    (offsetof(struct iommu_strbuf, x))
-
 /* streaming buffer control register */
 #define STRBUF_EN      0x000000000000000001LL
 #define STRBUF_D       0x000000000000000002LL
diff -r 4a92fe8c5edf -r da6591699e7e sys/arch/sparc64/dev/iommuvar.h
--- a/sys/arch/sparc64/dev/iommuvar.h   Wed Mar 16 05:31:03 2011 +0000
+++ b/sys/arch/sparc64/dev/iommuvar.h   Wed Mar 16 05:49:43 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iommuvar.h,v 1.18 2011/03/16 02:41:19 mrg Exp $        */
+/*     $NetBSD: iommuvar.h,v 1.19 2011/03/16 05:49:43 mrg Exp $        */
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -55,8 +55,6 @@
        u_int                   is_dvmaend;
        int64_t                 is_cr;          /* IOMMU control regiter value */
        struct extent           *is_dvmamap;    /* DVMA map for this instance */
-       int                     is_flags;
-#define IOMMU_FLUSH_CACHE      0x00000001
 
        struct strbuf_ctl       *is_sb[2];      /* Streaming buffers if any */
 
@@ -86,15 +84,4 @@
                void **, int);
 void   iommu_dvmamem_unmap(bus_dma_tag_t, void *, size_t);
 
-#define IOMMUREG_READ(is, reg)                         \
-       bus_space_read_8((is)->is_bustag,               \
-               (is)->is_iommu,                         \
-               IOMMUREG(reg))  
-
-#define IOMMUREG_WRITE(is, reg, v)                     \
-       bus_space_write_8((is)->is_bustag,              \
-               (is)->is_iommu,                         \
-               IOMMUREG(reg),                          \
-               (v))
-
 #endif /* _SPARC64_DEV_IOMMUVAR_H_ */
diff -r 4a92fe8c5edf -r da6591699e7e sys/arch/sparc64/dev/psycho.c
--- a/sys/arch/sparc64/dev/psycho.c     Wed Mar 16 05:31:03 2011 +0000
+++ b/sys/arch/sparc64/dev/psycho.c     Wed Mar 16 05:49:43 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: psycho.c,v 1.103 2011/03/16 03:51:29 mrg Exp $ */
+/*     $NetBSD: psycho.c,v 1.104 2011/03/16 05:49:43 mrg Exp $ */
 



Home | Main Index | Thread Index | Old Index