Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64 Make bus_space_barrier() an inline instead ...



details:   https://anonhg.NetBSD.org/src/rev/9a2cdfd9490a
branches:  trunk
changeset: 521884:9a2cdfd9490a
user:      eeh <eeh%NetBSD.org@localhost>
date:      Thu Feb 07 21:36:54 2002 +0000

description:
Make bus_space_barrier() an inline instead of a function vector.

diffstat:

 sys/arch/sparc64/include/bus.h     |  42 +++++++++++++--------
 sys/arch/sparc64/sparc64/machdep.c |  74 ++++++++++++++++++++++---------------
 2 files changed, 70 insertions(+), 46 deletions(-)

diffs (186 lines):

diff -r 658baa0114d3 -r 9a2cdfd9490a sys/arch/sparc64/include/bus.h
--- a/sys/arch/sparc64/include/bus.h    Thu Feb 07 21:35:26 2002 +0000
+++ b/sys/arch/sparc64/include/bus.h    Thu Feb 07 21:36:54 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.h,v 1.32 2001/09/24 23:49:33 eeh Exp $     */
+/*     $NetBSD: bus.h,v 1.33 2002/02/07 21:36:54 eeh Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -147,10 +147,6 @@
                bus_space_handle_t, bus_size_t,
                bus_size_t, bus_space_handle_t *));
 
-       void    (*sparc_bus_barrier) __P((bus_space_tag_t,
-               bus_space_handle_t, bus_size_t,
-               bus_size_t, int));
-
        paddr_t (*sparc_bus_mmap) __P((bus_space_tag_t,
                bus_addr_t, off_t, int, int));
 
@@ -337,17 +333,6 @@
        _BS_CALL(t, sparc_intr_establish)(t, p, l, f, h, a);
 }
 
-__inline__ void
-bus_space_barrier(t, h, o, s, f)
-       bus_space_tag_t t;
-       bus_space_handle_t h;
-       bus_size_t o;
-       bus_size_t s;
-       int f;
-{
-       _BS_CALL(t, sparc_bus_barrier)(t, h, o, s, f);
-}
-
 #if 1
 /* XXXX Things get complicated if we use unmapped register accesses. */
 #define        bus_space_vaddr(t, h)   (vaddr_t)(h)
@@ -374,6 +359,31 @@
 #define        BUS_SPACE_BARRIER_READ  0x01            /* force read barrier */
 #define        BUS_SPACE_BARRIER_WRITE 0x02            /* force write barrier */
 
+__inline__ void
+bus_space_barrier(t, h, o, s, f)
+       bus_space_tag_t t;
+       bus_space_handle_t h;
+       bus_size_t o;
+       bus_size_t s;
+       int f;
+{
+       /*
+        * We have a bit of a problem with the bus_space_barrier()
+        * interface.  It defines a read barrier and a write barrier
+        * which really don't map to the 7 different types of memory
+        * barriers in the SPARC v9 instruction set.
+        */
+       if (f == BUS_SPACE_BARRIER_READ)
+               /* A load followed by a load to the same location? */
+               __asm __volatile("membar #Lookaside");
+       else if (f == BUS_SPACE_BARRIER_WRITE)
+               /* A store followed by a store? */
+               __asm __volatile("membar #StoreStore");
+       else 
+               /* A store followed by a load? */
+               __asm __volatile("membar #StoreLoad|#MemIssue|#Lookaside");
+}
+
 /*
  * Device space probe assistant.
  * The optional callback function's arguments are:
diff -r 658baa0114d3 -r 9a2cdfd9490a sys/arch/sparc64/sparc64/machdep.c
--- a/sys/arch/sparc64/sparc64/machdep.c        Thu Feb 07 21:35:26 2002 +0000
+++ b/sys/arch/sparc64/sparc64/machdep.c        Thu Feb 07 21:36:54 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.112 2001/09/24 23:49:33 eeh Exp $ */
+/*     $NetBSD: machdep.c,v 1.113 2002/02/07 21:36:55 eeh Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -1261,7 +1261,9 @@
                        paddr_t pa;
                        long incr;
 
-                       incr = min(buflen, NBPG);
+                       incr = NBPG - (vaddr&PGOFSET);
+                       incr = min(buflen, incr);
+
                        (void) pmap_extract(pmap_kernel(), vaddr, &pa);
                        buflen -= incr;
                        vaddr += incr;
@@ -1288,6 +1290,46 @@
                }
        }
 
+#ifdef DEBUG
+       {
+               size_t mbuflen, sglen;
+               int j;
+               int retval;
+
+               mbuflen = 0;
+               for (m = (struct mbuf *)map->_dm_source; m; m = m->m_next)
+                       mbuflen += (long)m->m_len;
+               sglen = 0;
+               for (j = 0; j < i; j++)
+                       sglen += segs[j].ds_len;
+               if (sglen != mbuflen) {
+                       printf("load_mbuf: sglen %ld != mbuflen %lx\n",
+                               sglen, mbuflen);
+                       Debugger();
+               }
+               if (sglen != len) {
+                       printf("load_mbuf: sglen %ld != len %lx\n",
+                               sglen, len);
+                       Debugger();
+               }
+               retval = bus_dmamap_load_raw(t, map, segs, i,
+                       (bus_size_t)len, flags);
+               if (map->dm_mapsize != len) {
+                       printf("load_mbuf: mapsize %ld != len %lx\n",
+                               map->dm_mapsize, len);
+                       Debugger();
+               }
+               sglen = 0;
+               for (j = 0; j < map->dm_nsegs; j++)
+                       sglen += map->dm_segs[j].ds_len;
+               if (sglen != len) {
+                       printf("load_mbuf: dmamap sglen %ld != len %lx\n",
+                               sglen, len);
+                       Debugger();
+               }
+               return (retval);
+       }
+#endif
        return (bus_dmamap_load_raw(t, map, segs, i,
                            (bus_size_t)len, flags));
 #else
@@ -1721,8 +1763,6 @@
 static void    *sparc_mainbus_intr_establish __P((bus_space_tag_t, int, int,
                                                   int, int (*) __P((void *)),
                                                   void *));
-static void     sparc_bus_barrier __P((bus_space_tag_t, bus_space_handle_t,
-                                      bus_size_t, bus_size_t, int));
 static int     sparc_bus_alloc __P((bus_space_tag_t, bus_addr_t, bus_addr_t,
                                     bus_size_t, bus_size_t, bus_size_t, int,
                                     bus_addr_t *, bus_space_handle_t *));
@@ -1915,31 +1955,6 @@
        return (ih);
 }
 
-void
-sparc_bus_barrier(t, h, offset, size, flags)
-       bus_space_tag_t t;
-       bus_space_handle_t h;
-       bus_size_t      offset;
-       bus_size_t      size;
-       int             flags;
-{
-       /* 
-        * We have lots of alternatives depending on whether we're
-        * synchronizing loads with loads, loads with stores, stores
-        * with loads, or stores with stores.  The only ones that seem
-        * generic are #Sync and #MemIssue.  I'll use #Sync for safety.
-        */
-       if (flags == (BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE))
-               __asm("membar #Sync" : );
-       else if (flags == BUS_SPACE_BARRIER_READ)
-               __asm("membar #Sync" : );
-       else if (flags == BUS_SPACE_BARRIER_WRITE)
-               __asm("membar #Sync" : );
-       else
-               printf("sparc_bus_barrier: unknown flags\n");
-       return;
-}
-
 int
 sparc_bus_alloc(t, rs, re, s, a, b, f, ap, hp)
        bus_space_tag_t t;
@@ -1973,7 +1988,6 @@
        sparc_bus_map,                  /* bus_space_map */
        sparc_bus_unmap,                /* bus_space_unmap */
        sparc_bus_subregion,            /* bus_space_subregion */
-       sparc_bus_barrier,              /* bus_space_barrier */
        sparc_bus_mmap,                 /* bus_space_mmap */
        sparc_mainbus_intr_establish    /* bus_intr_establish */
 };



Home | Main Index | Thread Index | Old Index