Re: [PATCH 1/5] powerpc/64s: Move dcbt/dcbtst sequence into a macro

2024-03-13 Thread Michael Ellerman
On Thu, 29 Feb 2024 23:25:17 +1100, Michael Ellerman wrote:
> There's an almost identical code sequence to specify load/store access
> hints in __copy_tofrom_user_power7(), copypage_power7() and
> memcpy_power7().
> 
> Move the sequence into a common macro, which is passed the registers to
> use as they differ slightly.
> 
> [...]

Applied to powerpc/next.

[1/5] powerpc/64s: Move dcbt/dcbtst sequence into a macro
  https://git.kernel.org/powerpc/c/8488cdcb00fd5f238754005a43a3a7445860d344
[2/5] powerpc/64s: Use .machine power4 around dcbt
  https://git.kernel.org/powerpc/c/4e284e38ed586edeb8bdb2b0c544273a7f72021c
[3/5] powerpc/fsl: Fix mfpmr build errors with newer binutils
  https://git.kernel.org/powerpc/c/5f491356b7149564ab22323ccce79c8d595bfd0c
[4/5] powerpc/fsl: Modernise mt/mfpmr
  https://git.kernel.org/powerpc/c/f01dbd73ccf122486ad4b52e74f5505985dd6af4
[5/5] powerpc: Remove cpu-as-y completely
  https://git.kernel.org/powerpc/c/ca3d3aa14e7673f1b15e862b71998a4664d50ebe

cheers


[PATCH 1/5] powerpc/64s: Move dcbt/dcbtst sequence into a macro

2024-02-29 Thread Michael Ellerman
There's an almost identical code sequence to specify load/store access
hints in __copy_tofrom_user_power7(), copypage_power7() and
memcpy_power7().

Move the sequence into a common macro, which is passed the registers to
use as they differ slightly.

There also needs to be a copy in the selftests, it could be shared in
future if the headers are cleaned up / refactored.

Signed-off-by: Michael Ellerman 
---
 arch/powerpc/include/asm/ppc_asm.h   | 12 
 arch/powerpc/lib/copypage_power7.S   | 12 +---
 arch/powerpc/lib/copyuser_power7.S   | 12 +---
 arch/powerpc/lib/memcpy_power7.S | 10 +-
 .../selftests/powerpc/copyloops/asm/ppc_asm.h| 12 
 5 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc_asm.h 
b/arch/powerpc/include/asm/ppc_asm.h
index 041ee2595520..78c7548eac1e 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -510,6 +510,18 @@ END_FTR_SECTION_NESTED(CPU_FTR_CELL_TB_BUG, 
CPU_FTR_CELL_TB_BUG, 96)
lis scratch,0x6000@h;   \
dcbt0,scratch,0b01010
 
+#define DCBT_SETUP_STREAMS(from, from_parms, to, to_parms, scratch)\
+   lis scratch,0x8000; /* GO=1 */  \
+   clrldi  scratch,scratch,32; \
+   /* setup read stream 0 */   \
+   dcbt0,from,0b01000; /* addr from */ \
+   dcbt0,from_parms,0b01010;   /* length and depth from */ \
+   /* setup write stream 1 */  \
+   dcbtst  0,to,0b01000;   /* addr to */   \
+   dcbtst  0,to_parms,0b01010; /* length and depth to */   \
+   eieio;  \
+   dcbt0,scratch,0b01010;  /* all streams GO */
+
 /*
  * toreal/fromreal/tophys/tovirt macros. 32-bit BookE makes them
  * keep the address intact to be compatible with code shared with
diff --git a/arch/powerpc/lib/copypage_power7.S 
b/arch/powerpc/lib/copypage_power7.S
index a783973f1215..07e7cec4d135 100644
--- a/arch/powerpc/lib/copypage_power7.S
+++ b/arch/powerpc/lib/copypage_power7.S
@@ -27,17 +27,7 @@ _GLOBAL(copypage_power7)
 #endif
ori r10,r7,1/* stream=1 */
 
-   lis r8,0x8000   /* GO=1 */
-   clrldi  r8,r8,32
-
-   /* setup read stream 0  */
-   dcbt0,r4,0b01000/* addr from */
-   dcbt0,r7,0b01010   /* length and depth from */
-   /* setup write stream 1 */
-   dcbtst  0,r9,0b01000   /* addr to */
-   dcbtst  0,r10,0b01010  /* length and depth to */
-   eieio
-   dcbt0,r8,0b01010/* all streams GO */
+   DCBT_SETUP_STREAMS(r4, r7, r9, r10, r8)
 
 #ifdef CONFIG_ALTIVEC
mflrr0
diff --git a/arch/powerpc/lib/copyuser_power7.S 
b/arch/powerpc/lib/copyuser_power7.S
index ac41053c3a5a..8474c682a178 100644
--- a/arch/powerpc/lib/copyuser_power7.S
+++ b/arch/powerpc/lib/copyuser_power7.S
@@ -298,17 +298,7 @@ err1;  stb r0,0(r3)
or  r7,r7,r0
ori r10,r7,1/* stream=1 */
 
-   lis r8,0x8000   /* GO=1 */
-   clrldi  r8,r8,32
-
-   /* setup read stream 0 */
-   dcbt0,r6,0b01000   /* addr from */
-   dcbt0,r7,0b01010   /* length and depth from */
-   /* setup write stream 1 */
-   dcbtst  0,r9,0b01000   /* addr to */
-   dcbtst  0,r10,0b01010  /* length and depth to */
-   eieio
-   dcbt0,r8,0b01010/* all streams GO */
+   DCBT_SETUP_STREAMS(r6, r7, r9, r10, r8)
 
beq cr1,.Lunwind_stack_nonvmx_copy
 
diff --git a/arch/powerpc/lib/memcpy_power7.S b/arch/powerpc/lib/memcpy_power7.S
index 9398b2b746c4..b7c5e7fca8b9 100644
--- a/arch/powerpc/lib/memcpy_power7.S
+++ b/arch/powerpc/lib/memcpy_power7.S
@@ -244,15 +244,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
or  r7,r7,r0
ori r10,r7,1/* stream=1 */
 
-   lis r8,0x8000   /* GO=1 */
-   clrldi  r8,r8,32
-
-   dcbt0,r6,0b01000
-   dcbt0,r7,0b01010
-   dcbtst  0,r9,0b01000
-   dcbtst  0,r10,0b01010
-   eieio
-   dcbt0,r8,0b01010/* GO */
+   DCBT_SETUP_STREAMS(r6, r7, r9, r10, r8)
 
beq cr1,.Lunwind_stack_nonvmx_copy
 
diff --git a/tools/testing/selftests/powerpc/copyloops/asm/ppc_asm.h 
b/tools/testing/selftests/powerpc/copyloops/asm/ppc_asm.h
index a89f1fbf86ec..1d293ab77185 100644
--- a/tools/testing/selftests/powerpc/copyloops/asm/ppc_asm.h
+++ b/tools/testing/selftests/powerpc/copyloops/asm/ppc_asm.h
@@ -47,4 +47,16 @@
 /* Default to taking the first of any alternative feature sections */
 test_feature = 1
 
+#define DCBT_SETUP_STREAMS(from, from_parms, to, to_parms, scratch)\
+   lis scratch,0x8000;