Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/arch/powerpc Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/a61e6ad75ca7
branches:  netbsd-9
changeset: 963698:a61e6ad75ca7
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Mar 09 10:36:42 2020 +0000

description:
Pull up following revision(s) (requested by rin in ticket #773):

        sys/arch/powerpc/ibm4xx/pmap.c: revision 1.81
        sys/arch/powerpc/ibm4xx/pmap.c: revision 1.82
        sys/arch/powerpc/ibm4xx/pmap.c: revision 1.83
        sys/arch/powerpc/ibm4xx/pmap.c: revision 1.84
        sys/arch/powerpc/ibm4xx/pmap.c: revision 1.85
        sys/arch/powerpc/include/ibm4xx/tlb.h: revision 1.6
        sys/arch/powerpc/include/ibm4xx/pmap.h: revision 1.20

Misc non-critical fixes.
- __asm --> __asm volatile for sure
- turn DEBUG code in __asm into DIAGNOSTIC code in C
- style

ppc4xx_tlb_enter(): invalidate entry after clearing MSR for sure.

pmap_procwr(): use dcbst instead of dcbf as a tiny optimization.

Retire tlbpid_t (u_short):
- PID (ctx, ASID) is 8-bit length, not half word.
- For struct pmap, no need to use integer types smaller than word as
  pm_ctx because of alignment.
- For ppc4xx_tlb_enter(), we need word-length storage for pid (and msr).
XXX
Better to rewrite pmap module with more suggestive integer types rather
than char, int, long, and so on.

Fix pmap_procwr().
While we need to turn off IMMU, DMMU should be kept on. Otherwise,
dcbst (and also icbi probably, though not documented clearly both
for 405 and 403) should not work correctly.

diffstat:

 sys/arch/powerpc/ibm4xx/pmap.c         |  30 +++++++++++++-----------------
 sys/arch/powerpc/include/ibm4xx/pmap.h |   4 ++--
 sys/arch/powerpc/include/ibm4xx/tlb.h  |   3 +--
 3 files changed, 16 insertions(+), 21 deletions(-)

diffs (139 lines):

diff -r d8f27a7f1ad2 -r a61e6ad75ca7 sys/arch/powerpc/ibm4xx/pmap.c
--- a/sys/arch/powerpc/ibm4xx/pmap.c    Mon Mar 09 10:11:40 2020 +0000
+++ b/sys/arch/powerpc/ibm4xx/pmap.c    Mon Mar 09 10:36:42 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.76.20.1 2020/02/27 18:23:10 martin Exp $    */
+/*     $NetBSD: pmap.c,v 1.76.20.2 2020/03/09 10:36:42 martin Exp $    */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.76.20.1 2020/02/27 18:23:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.76.20.2 2020/03/09 10:36:42 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -1173,16 +1173,18 @@
                ctx_alloc(pm);
                ctx = pm->pm_ctx;
        }
-       __asm volatile("mfmsr %0;"
-               "li %1, %7;"
+       __asm volatile(
+               "mfmsr %0;"
+               "li %1,0x20;"           /* Turn off IMMU */
                "andc %1,%0,%1;"
+               "ori %1,%1,0x10;"       /* Turn on DMMU for sure */
                "mtmsr %1;"
                "sync;isync;"
                "mfpid %1;"
                "mtpid %2;"
                "sync; isync;"
                "1:"
-               "dcbf 0,%3;"
+               "dcbst 0,%3;"
                "icbi 0,%3;"
                "add %3,%3,%5;"
                "addc. %4,%4,%6;"
@@ -1191,8 +1193,7 @@
                "mtmsr %0;"
                "sync; isync"
                : "=&r" (msr), "=&r" (opid)
-               : "r" (ctx), "r" (va), "r" (len), "r" (step), "r" (-step),
-                 "K" (PSL_IR | PSL_DR));
+               : "r" (ctx), "r" (va), "r" (len), "r" (step), "r" (-step));
 }
 
 
@@ -1207,7 +1208,8 @@
        if (!pid)
                return;
 
-       __asm(  "mfpid %1;"             /* Save PID */
+       __asm volatile(
+               "mfpid %1;"             /* Save PID */
                "mfmsr %2;"             /* Save MSR */
                "li %0,0;"              /* Now clear MSR */
                "mtmsr %0;"
@@ -1225,7 +1227,6 @@
                : "=&r" (i), "=&r" (found), "=&r" (msr)
                : "r" (va), "r" (pid));
        if (found && !TLB_LOCKED(i)) {
-
                /* Now flush translation */
                __asm volatile(
                        "tlbwe %0,%1,0;"
@@ -1292,8 +1293,7 @@
 ppc4xx_tlb_enter(int ctx, vaddr_t va, u_int pte)
 {
        u_long th, tl, idx;
-       tlbpid_t pid;
-       u_short msr;
+       int msr, pid;
        paddr_t pa;
        int sz;
 
@@ -1308,7 +1308,7 @@
        idx = ppc4xx_tlb_find_victim();
 
 #ifdef DIAGNOSTIC
-       if ((idx < tlb_nreserved) || (idx >= NTLB)) {
+       if ((idx < tlb_nreserved) || (idx >= NTLB) || (idx & 63) == 0) {
                panic("ppc4xx_tlb_enter: replacing entry %ld", idx);
        }
 #endif
@@ -1320,15 +1320,11 @@
        __asm volatile(
                "mfmsr %0;"                     /* Save MSR */
                "li %1,0;"
+               "mtmsr %1;"                     /* Clear MSR */
                "tlbwe %1,%3,0;"                /* Invalidate old entry. */
-               "mtmsr %1;"                     /* Clear MSR */
                "mfpid %1;"                     /* Save old PID */
                "mtpid %2;"                     /* Load translation ctx */
                "sync; isync;"
-#ifdef DEBUG
-               "andi. %3,%3,63;"
-               "tweqi %3,0;"                   /* XXXXX DEBUG trap on index 0 */
-#endif
                "tlbwe %4,%3,1; tlbwe %5,%3,0;" /* Set TLB */
                "sync; isync;"
                "mtpid %1; mtmsr %0;"           /* Restore PID and MSR */
diff -r d8f27a7f1ad2 -r a61e6ad75ca7 sys/arch/powerpc/include/ibm4xx/pmap.h
--- a/sys/arch/powerpc/include/ibm4xx/pmap.h    Mon Mar 09 10:11:40 2020 +0000
+++ b/sys/arch/powerpc/include/ibm4xx/pmap.h    Mon Mar 09 10:36:42 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.h,v 1.19 2019/07/17 08:39:03 skrll Exp $  */
+/*     $NetBSD: pmap.h,v 1.19.2.1 2020/03/09 10:36:42 martin Exp $     */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -143,7 +143,7 @@
  * Pmap stuff
  */
 struct pmap {
-       volatile tlbpid_t pm_ctx;       /* PID to identify PMAP's entries in TLB */
+       volatile int pm_ctx;    /* PID to identify PMAP's entries in TLB */
        int pm_refs;                    /* ref count */
        struct pmap_statistics pm_stats; /* pmap statistics */
        volatile u_int *pm_ptbl[STSZ];  /* Array of 64 pointers to page tables. */
diff -r d8f27a7f1ad2 -r a61e6ad75ca7 sys/arch/powerpc/include/ibm4xx/tlb.h
--- a/sys/arch/powerpc/include/ibm4xx/tlb.h     Mon Mar 09 10:11:40 2020 +0000
+++ b/sys/arch/powerpc/include/ibm4xx/tlb.h     Mon Mar 09 10:36:42 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tlb.h,v 1.5 2018/04/19 21:50:07 christos Exp $ */
+/*     $NetBSD: tlb.h,v 1.5.6.1 2020/03/09 10:36:42 martin Exp $       */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -89,7 +89,6 @@
 
 #ifndef _LOCORE
 
-typedef u_short tlbpid_t;
 typedef struct tlb_s {
        u_int tlb_hi;
        u_int tlb_lo;



Home | Main Index | Thread Index | Old Index