Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/powerpc/ibm4xx Tiny improvements to copyin() and co...



details:   https://anonhg.NetBSD.org/src/rev/b2df36b27625
branches:  trunk
changeset: 745025:b2df36b27625
user:      rin <rin%NetBSD.org@localhost>
date:      Fri Feb 21 14:49:57 2020 +0000

description:
Tiny improvements to copyin() and copyout():

- Use lwz/stw instead of 4-byte lswi/stswi for 405 and later, which
  support unaligned word load/store by hardware. In many cases, both
  source and destination are aligned on word boundaries.

- Use dcbst instead of dcbf to flush cache. The former does not
  invalidate the cache line. Copied data should be used soon after.

diffstat:

 sys/arch/powerpc/ibm4xx/trap.c |  28 ++++++++++++++++++++++------
 1 files changed, 22 insertions(+), 6 deletions(-)

diffs (80 lines):

diff -r 340cb3621186 -r b2df36b27625 sys/arch/powerpc/ibm4xx/trap.c
--- a/sys/arch/powerpc/ibm4xx/trap.c    Fri Feb 21 14:27:20 2020 +0000
+++ b/sys/arch/powerpc/ibm4xx/trap.c    Fri Feb 21 14:49:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.76 2020/02/21 14:27:20 rin Exp $    */
+/*     $NetBSD: trap.c,v 1.77 2020/02/21 14:49:57 rin Exp $    */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.76 2020/02/21 14:27:20 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.77 2020/02/21 14:49:57 rin Exp $");
 
 #include "opt_altivec.h"
 #include "opt_ddb.h"
@@ -428,12 +428,20 @@
                "   beq- 2f;"                   /* No words. Go do bytes */
                "   mtctr %[count];"
                "1: mtpid %[ctx]; sync;"
+#ifdef PPC_IBM403
                "   lswi %[tmp],%[udaddr],4;"   /* Load user word */
+#else
+               "   lwz %[tmp],0(%[udaddr]);"
+#endif
                "   addi %[udaddr],%[udaddr],0x4;" /* next udaddr word */
                "   sync; isync;"
                "   mtpid %[pid]; sync;"
+#ifdef PPC_IBM403
                "   stswi %[tmp],%[kaddr],4;"   /* Store kernel word */
-               "   dcbf 0,%[kaddr];"           /* flush cache */
+#else
+               "   stw %[tmp],0(%[kaddr]);"
+#endif
+               "   dcbst 0,%[kaddr];"          /* flush cache */
                "   addi %[kaddr],%[kaddr],0x4;" /* next udaddr word */
                "   sync; isync;"
                "   bdnz 1b;"                   /* repeat */
@@ -448,7 +456,7 @@
                "   sync; isync;"
                "   mtpid %[pid]; sync;"
                "   stb %[tmp],0(%[kaddr]);"    /* Store kernel byte */
-               "   dcbf 0,%[kaddr];"           /* flush cache */
+               "   dcbst 0,%[kaddr];"          /* flush cache */
                "   addi %[kaddr],%[kaddr],0x1;"
                "   sync; isync;"
                "   b 3b;"
@@ -527,12 +535,20 @@
                "   beq- 2f;"                   /* No words. Go do bytes */
                "   mtctr %[count];"
                "1: mtpid %[pid]; sync;"
+#ifdef PPC_IBM403
                "   lswi %[tmp],%[kaddr],4;"    /* Load kernel word */
+#else
+               "   lwz %[tmp],0(%[kaddr]);"
+#endif
                "   addi %[kaddr],%[kaddr],0x4;" /* next kaddr word */
                "   sync; isync;"
                "   mtpid %[ctx]; sync;"
+#ifdef PPC_IBM403
                "   stswi %[tmp],%[udaddr],4;"  /* Store user word */
-               "   dcbf 0,%[udaddr];"          /* flush cache */
+#else
+               "   stw %[tmp],0(%[udaddr]);"
+#endif
+               "   dcbst 0,%[udaddr];"         /* flush cache */
                "   addi %[udaddr],%[udaddr],0x4;" /* next udaddr word */
                "   sync; isync;"
                "   bdnz 1b;"                   /* repeat */
@@ -547,7 +563,7 @@
                "   sync; isync;"
                "   mtpid %[ctx]; sync;"
                "   stb %[tmp],0(%[udaddr]);"   /* Store user byte */
-               "   dcbf 0,%[udaddr];"          /* flush cache */
+               "   dcbst 0,%[udaddr];"         /* flush cache */
                "   addi %[udaddr],%[udaddr],0x1;"
                "   sync; isync;"
                "   b 3b;"



Home | Main Index | Thread Index | Old Index