Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64 - in _bus_dmamap_unload(), pmap_page_protec...



details:   https://anonhg.NetBSD.org/src/rev/ed81727f4076
branches:  trunk
changeset: 752692:ed81727f4076
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu Mar 04 08:01:35 2010 +0000

description:
- in _bus_dmamap_unload(), pmap_page_protect() and pmap_clear_reference()
  switch the dcache_flush_page() into a dcache_flush_page_all()
- in both pmap_kremove()/pmap_remove(), remove the blast_dcache() call
  and replace it with dcache_flush_page_all()
- in pmap_get_page() [used to allocate PTP's], always call pmap_zero_page(pa)
- flush the dcache of the dst page in pmap_{copy,zero}_page() by redirecting
  throught a C function that calls the (renamed) asm.  the old asm code had a
  comment about needing to do this...
- add a couple of membar #Sync's that the USIII manual recommends


based on discussions with chuq@, skrll@ and martin@.


these help my SB2000 / SB2500 with both disk / nfs builds and other tasks,
sometimes lasting for several hours before failing or asserting.

diffstat:

 sys/arch/sparc64/include/pmap.h    |   6 +++-
 sys/arch/sparc64/sparc64/locore.s  |  40 +++++++++++++++--------------
 sys/arch/sparc64/sparc64/machdep.c |   6 ++--
 sys/arch/sparc64/sparc64/pmap.c    |  50 ++++++++++++++++++++++++++-----------
 4 files changed, 64 insertions(+), 38 deletions(-)

diffs (263 lines):

diff -r e423631ad059 -r ed81727f4076 sys/arch/sparc64/include/pmap.h
--- a/sys/arch/sparc64/include/pmap.h   Thu Mar 04 03:10:18 2010 +0000
+++ b/sys/arch/sparc64/include/pmap.h   Thu Mar 04 08:01:35 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.50 2010/02/24 04:48:28 mrg Exp $    */
+/*     $NetBSD: pmap.h,v 1.51 2010/03/04 08:01:35 mrg Exp $    */
 
 /*-
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -204,6 +204,10 @@
 void           switchexit(struct lwp *, int);
 void           pmap_kprotect(vaddr_t, vm_prot_t);
 
+/* SPARC64 specific */
+void           pmap_copy_page_phys(paddr_t, paddr_t);
+void           pmap_zero_page_phys(paddr_t);
+
 /* Installed physical memory, as discovered during bootstrap. */
 extern int phys_installed_size;
 extern struct mem_region *phys_installed;
diff -r e423631ad059 -r ed81727f4076 sys/arch/sparc64/sparc64/locore.s
--- a/sys/arch/sparc64/sparc64/locore.s Thu Mar 04 03:10:18 2010 +0000
+++ b/sys/arch/sparc64/sparc64/locore.s Thu Mar 04 08:01:35 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.321 2010/02/24 09:49:36 mrg Exp $ */
+/*     $NetBSD: locore.s,v 1.322 2010/03/04 08:01:35 mrg Exp $ */
 
 /*
  * Copyright (c) 1996-2002 Eduardo Horvath
@@ -203,10 +203,10 @@
  */
 #ifdef DCACHE_BUG
 #define DLFLUSH(a,t) \
-       andn    a, 0x1f, t; \
+       andn    a, 0x3f, t; \
        stxa    %g0, [ t ] ASI_DCACHE_TAG; \
        membar  #Sync
-/* The following can be used if the pointer is 16-byte aligned */
+/* The following can be used if the pointer is 32-byte aligned */
 #define DLFLUSH2(t) \
        stxa    %g0, [ t ] ASI_DCACHE_TAG; \
        membar  #Sync
@@ -775,7 +775,6 @@
        TA32
 ufast_DMMU_miss:                       ! 068 = fast data access MMU miss
        ldxa    [%g0] ASI_DMMU_8KPTR, %g2! Load DMMU 8K TSB pointer
-
 #ifdef NO_TSB
        ba,a    %icc, data_miss
 #endif
@@ -4947,11 +4946,15 @@
        membar  #Sync
        or      %o0, DEMAP_PAGE_PRIMARY, %o0
        stxa    %o0, [%o0] ASI_DMMU_DEMAP               ! Do the demap
+       membar  #Sync
        stxa    %o0, [%o0] ASI_IMMU_DEMAP               ! to both TLBs
+       membar  #Sync
 #ifdef TLB_FLUSH_LOWVA
        srl     %o0, 0, %o0                             ! and make sure it's both 32- and 64-bit entries
        stxa    %o0, [%o0] ASI_DMMU_DEMAP               ! Do the demap
+       membar  #Sync
        stxa    %o0, [%o0] ASI_IMMU_DEMAP               ! Do the demap
+       membar  #Sync
 #endif
        flush   %o1
        stxa    %o5, [%o2] ASI_DMMU                     ! Restore primary context
@@ -5050,6 +5053,7 @@
        wrpr    %o4, 0, %pstate
 
        stxa    %o2, [%o2] ASI_IMMU_DEMAP
+       membar  #Sync
        stxa    %o2, [%o2] ASI_DMMU_DEMAP
 
        sethi   %hi(KERNBASE), %o4
@@ -6566,22 +6570,19 @@
         membar #StoreStore|#StoreLoad
 
 /*
- * pmap_zero_page(pa)
+ * pmap_zero_page_phys(pa)
  *
  * Zero one page physically addressed
  *
  * Block load/store ASIs do not exist for physical addresses,
  * so we won't use them.
  *
- * While we do the zero operation, we also need to blast away
- * the contents of the D$.  We will execute a flush at the end
- * to sync the I$.
- */
-       .data
-paginuse:
-       .word   0
-       .text
-ENTRY(pmap_zero_page)
+ * We will execute a flush at the end to sync the I$.
+ *
+ * This version expects to have the dcache_flush_page_all(pa)
+ * to have been called before calling into here.
+ */
+ENTRY(pmap_zero_page_phys)
 #ifndef _LP64
        COMBINE(%o0, %o1, %o0)
 #endif
@@ -6625,7 +6626,7 @@
         wr     %g0, ASI_PRIMARY_NOFAULT, %asi  ! Make C code happy
 
 /*
- * pmap_copy_page(paddr_t src, paddr_t dst)
+ * pmap_copy_page_phys(paddr_t src, paddr_t dst)
  *
  * Copy one page physically addressed
  * We need to use a global reg for ldxa/stxa
@@ -6634,10 +6635,11 @@
  * 32-bit stack.  We will unroll the loop by 4 to
  * improve performance.
  *
- * XXX We also need to blast the D$ and flush like
- * XXX pmap_zero_page.
- */
-ENTRY(pmap_copy_page)
+ * This version expects to have the dcache_flush_page_all(pa)
+ * to have been called before calling into here.
+ *
+ */
+ENTRY(pmap_copy_page_phys)
 #ifndef _LP64
        COMBINE(%o0, %o1, %o0)
        COMBINE(%o2, %o3, %o1)
diff -r e423631ad059 -r ed81727f4076 sys/arch/sparc64/sparc64/machdep.c
--- a/sys/arch/sparc64/sparc64/machdep.c        Thu Mar 04 03:10:18 2010 +0000
+++ b/sys/arch/sparc64/sparc64/machdep.c        Thu Mar 04 08:01:35 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.251 2010/02/08 19:02:32 joerg Exp $ */
+/*     $NetBSD: machdep.c,v 1.252 2010/03/04 08:01:35 mrg Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.251 2010/02/08 19:02:32 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.252 2010/03/04 08:01:35 mrg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1299,7 +1299,7 @@
                         * We should be flushing a subrange, but we
                         * don't know where the segments starts.
                         */
-                       dcache_flush_page(pa);
+                       dcache_flush_page_all(pa);
                }
        }
 
diff -r e423631ad059 -r ed81727f4076 sys/arch/sparc64/sparc64/pmap.c
--- a/sys/arch/sparc64/sparc64/pmap.c   Thu Mar 04 03:10:18 2010 +0000
+++ b/sys/arch/sparc64/sparc64/pmap.c   Thu Mar 04 08:01:35 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.254 2010/02/24 10:11:53 mrg Exp $   */
+/*     $NetBSD: pmap.c,v 1.255 2010/03/04 08:01:35 mrg Exp $   */
 /*
  *
  * Copyright (C) 1996-1999 Eduardo Horvath.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.254 2010/02/24 10:11:53 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.255 2010/03/04 08:01:35 mrg Exp $");
 
 #undef NO_VCACHE /* Don't forget the locked TLB in dostart */
 #define        HWREF
@@ -1608,11 +1608,10 @@
                 */
 
                tlb_flush_pte(va, pm);
+               dcache_flush_page_all(pa);
        }
-       if (flush) {
+       if (flush)
                REMOVE_STAT(flushes);
-               blast_dcache();
-       }
 }
 
 /*
@@ -1998,11 +1997,10 @@
                tsb_invalidate(va, pm);
                REMOVE_STAT(tflushes);
                tlb_flush_pte(va, pm);
+               dcache_flush_page_all(pa);
        }
-       if (flush && pm->pm_refs) {
+       if (flush && pm->pm_refs)
                REMOVE_STAT(flushes);
-               blast_dcache();
-       }
        DPRINTF(PDB_REMOVE, ("\n"));
        pv_check();
        mutex_exit(&pmap_lock);
@@ -2418,9 +2416,7 @@
        int modified = 0;
 
        DPRINTF(PDB_CHANGEPROT|PDB_REF, ("pmap_clear_modify(%p)\n", pg));
-#endif
-
-#if defined(DEBUG)
+
        modified = pmap_is_modified(pg);
 #endif
        mutex_enter(&pmap_lock);
@@ -2556,7 +2552,7 @@
                        }
                }
        }
-       dcache_flush_page(VM_PAGE_TO_PHYS(pg));
+       dcache_flush_page_all(VM_PAGE_TO_PHYS(pg));
        pv_check();
 #ifdef DEBUG
        if (pmap_is_referenced_locked(pg)) {
@@ -2924,9 +2920,8 @@
                                pv->pv_next = NULL;
                        }
                }
-               if (needflush) {
-                       dcache_flush_page(VM_PAGE_TO_PHYS(pg));
-               }
+               if (needflush)
+                       dcache_flush_page_all(VM_PAGE_TO_PHYS(pg));
        }
        /* We should really only flush the pages we demapped. */
        pv_check();
@@ -3624,3 +3619,28 @@
        pmap->pm_refs = 1;
        pmap_activate_pmap(pmap);
 }
+
+/*
+ * pmap_copy_page()/pmap_zero_page()
+ *
+ * we make sure that the destination page is flushed from all D$'s
+ * before we perform the copy/zero.
+ */
+extern int cold;
+void
+pmap_copy_page(paddr_t src, paddr_t dst)
+{
+
+       if (!cold)
+               dcache_flush_page_all(dst);
+       pmap_copy_page_phys(src, dst);
+}
+
+void
+pmap_zero_page(paddr_t pa)
+{
+
+       if (!cold)
+               dcache_flush_page_all(pa);
+       pmap_zero_page_phys(pa);
+}



Home | Main Index | Thread Index | Old Index