Skip to content

Commit 8488cdc

Browse files
committed
powerpc/64s: Move dcbt/dcbtst sequence into a macro
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 <mpe@ellerman.id.au> Link: https://msgid.link/20240229122521.762431-1-mpe@ellerman.id.au
1 parent d9cf600 commit 8488cdc

File tree

5 files changed

+27
-31
lines changed

5 files changed

+27
-31
lines changed

arch/powerpc/include/asm/ppc_asm.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,18 @@ END_FTR_SECTION_NESTED(CPU_FTR_CELL_TB_BUG, CPU_FTR_CELL_TB_BUG, 96)
510510
lis scratch,0x60000000@h; \
511511
dcbt 0,scratch,0b01010
512512

513+
#define DCBT_SETUP_STREAMS(from, from_parms, to, to_parms, scratch) \
514+
lis scratch,0x8000; /* GO=1 */ \
515+
clrldi scratch,scratch,32; \
516+
/* setup read stream 0 */ \
517+
dcbt 0,from,0b01000; /* addr from */ \
518+
dcbt 0,from_parms,0b01010; /* length and depth from */ \
519+
/* setup write stream 1 */ \
520+
dcbtst 0,to,0b01000; /* addr to */ \
521+
dcbtst 0,to_parms,0b01010; /* length and depth to */ \
522+
eieio; \
523+
dcbt 0,scratch,0b01010; /* all streams GO */
524+
513525
/*
514526
* toreal/fromreal/tophys/tovirt macros. 32-bit BookE makes them
515527
* keep the address intact to be compatible with code shared with

arch/powerpc/lib/copypage_power7.S

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,7 @@ _GLOBAL(copypage_power7)
2727
#endif
2828
ori r10,r7,1 /* stream=1 */
2929

30-
lis r8,0x8000 /* GO=1 */
31-
clrldi r8,r8,32
32-
33-
/* setup read stream 0 */
34-
dcbt 0,r4,0b01000 /* addr from */
35-
dcbt 0,r7,0b01010 /* length and depth from */
36-
/* setup write stream 1 */
37-
dcbtst 0,r9,0b01000 /* addr to */
38-
dcbtst 0,r10,0b01010 /* length and depth to */
39-
eieio
40-
dcbt 0,r8,0b01010 /* all streams GO */
30+
DCBT_SETUP_STREAMS(r4, r7, r9, r10, r8)
4131

4232
#ifdef CONFIG_ALTIVEC
4333
mflr r0

arch/powerpc/lib/copyuser_power7.S

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,7 @@ err1; stb r0,0(r3)
298298
or r7,r7,r0
299299
ori r10,r7,1 /* stream=1 */
300300

301-
lis r8,0x8000 /* GO=1 */
302-
clrldi r8,r8,32
303-
304-
/* setup read stream 0 */
305-
dcbt 0,r6,0b01000 /* addr from */
306-
dcbt 0,r7,0b01010 /* length and depth from */
307-
/* setup write stream 1 */
308-
dcbtst 0,r9,0b01000 /* addr to */
309-
dcbtst 0,r10,0b01010 /* length and depth to */
310-
eieio
311-
dcbt 0,r8,0b01010 /* all streams GO */
301+
DCBT_SETUP_STREAMS(r6, r7, r9, r10, r8)
312302

313303
beq cr1,.Lunwind_stack_nonvmx_copy
314304

arch/powerpc/lib/memcpy_power7.S

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
244244
or r7,r7,r0
245245
ori r10,r7,1 /* stream=1 */
246246

247-
lis r8,0x8000 /* GO=1 */
248-
clrldi r8,r8,32
249-
250-
dcbt 0,r6,0b01000
251-
dcbt 0,r7,0b01010
252-
dcbtst 0,r9,0b01000
253-
dcbtst 0,r10,0b01010
254-
eieio
255-
dcbt 0,r8,0b01010 /* GO */
247+
DCBT_SETUP_STREAMS(r6, r7, r9, r10, r8)
256248

257249
beq cr1,.Lunwind_stack_nonvmx_copy
258250

tools/testing/selftests/powerpc/copyloops/asm/ppc_asm.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,16 @@
4747
/* Default to taking the first of any alternative feature sections */
4848
test_feature = 1
4949

50+
#define DCBT_SETUP_STREAMS(from, from_parms, to, to_parms, scratch) \
51+
lis scratch,0x8000; /* GO=1 */ \
52+
clrldi scratch,scratch,32; \
53+
/* setup read stream 0 */ \
54+
dcbt 0,from,0b01000; /* addr from */ \
55+
dcbt 0,from_parms,0b01010; /* length and depth from */ \
56+
/* setup write stream 1 */ \
57+
dcbtst 0,to,0b01000; /* addr to */ \
58+
dcbtst 0,to_parms,0b01010; /* length and depth to */ \
59+
eieio; \
60+
dcbt 0,scratch,0b01010; /* all streams GO */
61+
5062
#endif /* __SELFTESTS_POWERPC_PPC_ASM_H */

0 commit comments

Comments
 (0)