Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hp700 Made changes to how bus_dmamap_sync() and the...



details:   https://anonhg.NetBSD.org/src/rev/35b2bd8bd7d0
branches:  trunk
changeset: 535190:35b2bd8bd7d0
user:      fredette <fredette%NetBSD.org@localhost>
date:      Sun Aug 11 19:39:37 2002 +0000

description:
Made changes to how bus_dmamap_sync() and the if_ie_gsc driver work
when it comes to flushing the cache.  These changes should eliminate
the "ie0: receive descriptors out of sync" and "ie0: reset" messages.

diffstat:

 sys/arch/hp700/gsc/gscbus.c    |   6 +++---
 sys/arch/hp700/gsc/if_ie_gsc.c |  34 +++++++++++++++++++++++-----------
 sys/arch/hp700/hp700/mainbus.c |  35 +++++++++++++----------------------
 sys/arch/hp700/include/bus.h   |  14 ++++++--------
 4 files changed, 45 insertions(+), 44 deletions(-)

diffs (197 lines):

diff -r cf2619a45fec -r 35b2bd8bd7d0 sys/arch/hp700/gsc/gscbus.c
--- a/sys/arch/hp700/gsc/gscbus.c       Sun Aug 11 19:28:05 2002 +0000
+++ b/sys/arch/hp700/gsc/gscbus.c       Sun Aug 11 19:39:37 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: gscbus.c,v 1.1 2002/06/06 19:48:05 fredette Exp $      */
+/*     $NetBSD: gscbus.c,v 1.2 2002/08/11 19:39:37 fredette Exp $      */
 
 /*     $OpenBSD: gscbus.c,v 1.13 2001/08/01 20:32:04 miod Exp $        */
 
@@ -112,7 +112,7 @@
 int    gsc_dmamap_load_raw __P((void *, bus_dmamap_t,
                                 bus_dma_segment_t *, int, bus_size_t, int));
 void   gsc_dmamap_unload __P((void *, bus_dmamap_t));
-void   gsc_dmamap_sync __P((void *, bus_dmamap_t, bus_addr_t, bus_size_t, bus_dmasync_op_t));
+void   gsc_dmamap_sync __P((void *, bus_dmamap_t, bus_addr_t, bus_size_t, int));
 
 int    gsc_dmamem_alloc __P((void *, bus_size_t, bus_size_t,
                              bus_size_t, bus_dma_segment_t *, int, int *, int));
@@ -299,7 +299,7 @@
        bus_dmamap_t map;
        bus_addr_t addr;
        bus_size_t size;
-       bus_dmasync_op_t op;
+       int op;
 {
 
 }
diff -r cf2619a45fec -r 35b2bd8bd7d0 sys/arch/hp700/gsc/if_ie_gsc.c
--- a/sys/arch/hp700/gsc/if_ie_gsc.c    Sun Aug 11 19:28:05 2002 +0000
+++ b/sys/arch/hp700/gsc/if_ie_gsc.c    Sun Aug 11 19:39:37 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ie_gsc.c,v 1.1 2002/06/06 19:48:05 fredette Exp $   */
+/*     $NetBSD: if_ie_gsc.c,v 1.2 2002/08/11 19:39:37 fredette Exp $   */
 
 /*     $OpenBSD: if_ie_gsc.c,v 1.6 2001/01/12 22:57:04 mickey Exp $    */
 
@@ -271,9 +271,11 @@
        int offset;
 {
        u_int16_t val;
-       pdcache_small(0, (vaddr_t)sc->sc_maddr + offset, 2);
-       val = *(volatile u_int16_t *)((caddr_t)sc->sc_maddr + offset);
-       pdcache_small(0, (vaddr_t)sc->sc_maddr + offset, 2);
+       __asm __volatile(
+       "       ldh     0(%1), %0       \n"
+       "       fdc     %%r0(%1)        \n"
+       : "=&r" (val)
+       : "r" ((caddr_t)sc->sc_maddr + offset));
        return (val);
 }
 
@@ -283,8 +285,11 @@
        int offset;
        u_int16_t v;
 {
-       *(volatile u_int16_t *)((caddr_t)sc->sc_maddr + offset) = v;
-       fdcache_small(0, (vaddr_t)sc->sc_maddr + offset, 2);
+       __asm __volatile(
+       "       sth     %0, 0(%1)       \n"
+       "       fdc     %%r0(%1)        \n"
+       : /* no outputs */
+       : "r" (v), "r" ((caddr_t)sc->sc_maddr + offset));
 }
 
 void
@@ -299,9 +304,16 @@
         * zero, so we have to add in the appropriate offset here.
         */
        addr += sc->sc_dmamap->dm_segs[0].ds_addr;
-       *(volatile u_int16_t *)((caddr_t)sc->sc_maddr + offset + 0) = (addr      ) & 0xffff;
-       *(volatile u_int16_t *)((caddr_t)sc->sc_maddr + offset + 2) = (addr >> 16) & 0xffff;
-       fdcache_small(0, (vaddr_t)sc->sc_maddr + offset, 4);
+       __asm __volatile(
+       "       ldi     2, %%r21                \n"
+       "       extru   %0, 15, 16, %%r22       \n"
+       "       sth     %0, 0(%1)               \n"
+       "       sth     %%r22, 2(%1)            \n"
+       "       fdc     %%r0(%1)                \n"
+       "       fdc     %%r21(%1)               \n"
+       : /* No outputs */
+       : "r" (addr), "r" ((caddr_t)sc->sc_maddr + offset)
+       : "r21", "r22");
 }
 
 void
@@ -313,9 +325,9 @@
 {
        struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
 
+       memcpy (p, (void *)((caddr_t)sc->sc_maddr + offset), size);
        bus_dmamap_sync(gsc->iemt, sc->sc_dmamap, offset, size,
-                       BUS_DMASYNC_POSTREAD);
-       memcpy (p, (void *)((caddr_t)sc->sc_maddr + offset), size);
+                       BUS_DMASYNC_PREREAD);
 }
 
 void
diff -r cf2619a45fec -r 35b2bd8bd7d0 sys/arch/hp700/hp700/mainbus.c
--- a/sys/arch/hp700/hp700/mainbus.c    Sun Aug 11 19:28:05 2002 +0000
+++ b/sys/arch/hp700/hp700/mainbus.c    Sun Aug 11 19:39:37 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mainbus.c,v 1.1 2002/06/06 19:48:06 fredette Exp $     */
+/*     $NetBSD: mainbus.c,v 1.2 2002/08/11 19:39:38 fredette Exp $     */
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -161,7 +161,7 @@
 int mbus_dmamap_load_uio __P((void *, bus_dmamap_t, struct uio *, int));
 int mbus_dmamap_load_raw __P((void *, bus_dmamap_t, bus_dma_segment_t *, int, bus_size_t, int));
 void mbus_dmamap_unload __P((void *, bus_dmamap_t));
-void mbus_dmamap_sync __P((void *, bus_dmamap_t, bus_addr_t, bus_size_t, bus_dmasync_op_t));
+void mbus_dmamap_sync __P((void *, bus_dmamap_t, bus_addr_t, bus_size_t, int));
 int mbus_dmamem_alloc __P((void *, bus_size_t, bus_size_t, bus_size_t, bus_dma_segment_t *, int, int *, int));
 void mbus_dmamem_free __P((void *, bus_dma_segment_t *, int));
 int mbus_dmamem_map __P((void *, bus_dma_segment_t *, int, size_t, caddr_t *, int));
@@ -954,35 +954,26 @@
 }
 
 void
-mbus_dmamap_sync(void *v, bus_dmamap_t map, bus_addr_t addr, bus_size_t size, bus_dmasync_op_t ops)
+mbus_dmamap_sync(void *v, bus_dmamap_t map, bus_addr_t addr, bus_size_t size, int ops)
 {
        /*
         * XXX - for now, we flush the whole map.
         */
 
-       /* fdc for BUS_DMASYNC_PREWRITE. */
-       if (ops & BUS_DMASYNC_PREWRITE) {
+       /*
+        * For everything except BUS_DMASYNC_POSTWRITE, flush 
+        * the map from the cache.  For BUS_DMASYNC_PREREAD and 
+        * BUS_DMASYNC_POSTREAD we should only need to purge the 
+        * map, but this isn't good enough for the osiop driver, 
+        * at least.
+        */
+       if (ops & (BUS_DMASYNC_PREWRITE |
+                  BUS_DMASYNC_PREREAD |
+                  BUS_DMASYNC_POSTREAD)) {
                fdcache(HPPA_SID_KERNEL, map->dm_segs[0]._ds_va,
                    map->dm_mapsize);
                sync_caches();
        }
-
-       /*
-        * Purging on both BUS_DMASYNC_PREREAD and BUS_DMASYNC_POSTREAD
-        * is hopefully only wasteful, as opposed to necessary.  (It is
-        * necessary if, for some reason, between PREREAD and POSTREAD,
-        * some code makes a reference to the DMA region.)  Otherwise,
-        * ideally I think the purge should only happen on PREREAD.
-        */
-       if (ops & (BUS_DMASYNC_PREREAD | BUS_DMASYNC_POSTREAD)) {
-               pdcache(HPPA_SID_KERNEL, map->dm_segs[0]._ds_va,
-                   map->dm_mapsize);
-               sync_caches();
-       }
-
-       /* syncdma for a POSTREAD or a POSTWRITE. */
-       if (ops & (BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE))
-               __asm __volatile ("syncdma");
 }
 
 /*
diff -r cf2619a45fec -r 35b2bd8bd7d0 sys/arch/hp700/include/bus.h
--- a/sys/arch/hp700/include/bus.h      Sun Aug 11 19:28:05 2002 +0000
+++ b/sys/arch/hp700/include/bus.h      Sun Aug 11 19:39:37 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.h,v 1.1 2002/06/06 19:48:07 fredette Exp $ */
+/*     $NetBSD: bus.h,v 1.2 2002/08/11 19:39:39 fredette Exp $ */
 
 /*     $OpenBSD: bus.h,v 1.13 2001/07/30 14:15:59 art Exp $    */
 
@@ -321,12 +321,10 @@
 struct proc;
 struct uio;
 
-typedef enum {
-       BUS_DMASYNC_POSTREAD,
-       BUS_DMASYNC_POSTWRITE,
-       BUS_DMASYNC_PREREAD,
-       BUS_DMASYNC_PREWRITE
-} bus_dmasync_op_t;
+#define        BUS_DMASYNC_POSTREAD    0x01
+#define        BUS_DMASYNC_POSTWRITE   0x02
+#define        BUS_DMASYNC_PREREAD     0x04
+#define        BUS_DMASYNC_PREWRITE    0x08
 
 typedef const struct hppa_bus_dma_tag  *bus_dma_tag_t;
 typedef struct hppa_bus_dmamap *bus_dmamap_t;
@@ -370,7 +368,7 @@
        int     (*_dmamap_load_raw) __P((void *, bus_dmamap_t,
                    bus_dma_segment_t *, int, bus_size_t, int));
        void    (*_dmamap_unload) __P((void *, bus_dmamap_t));
-       void    (*_dmamap_sync) __P((void *, bus_dmamap_t, bus_addr_t, bus_size_t, bus_dmasync_op_t));
+       void    (*_dmamap_sync) __P((void *, bus_dmamap_t, bus_addr_t, bus_size_t, int));
 
        /*
         * DMA memory utility functions.



Home | Main Index | Thread Index | Old Index