Skip to content

Commit f436171

Browse files
riscv: Add macro for multiple nop instructions
Some cases need multiple nop instructions and arm64 already has a nice helper for not needing to write all of them out but instead use a helper to add n nops. So add a similar thing to riscv and convert the T-Head PMA alternative to use it. * 'riscv-nops' of git://git.kernel.org/pub/scm/linux/kernel/git/palmer/linux.git: riscv: convert the t-head pbmt errata to use the __nops macro riscv: introduce nops and __nops macros for NOP sequences
2 parents 3f19011 + 9c2ea4a commit f436171

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

arch/riscv/include/asm/asm.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,19 @@
6767
#error "Unexpected __SIZEOF_SHORT__"
6868
#endif
6969

70+
#ifdef __ASSEMBLY__
71+
72+
/* Common assembly source macros */
73+
74+
/*
75+
* NOP sequence
76+
*/
77+
.macro nops, num
78+
.rept \num
79+
nop
80+
.endr
81+
.endm
82+
83+
#endif /* __ASSEMBLY__ */
84+
7085
#endif /* _ASM_RISCV_ASM_H */

arch/riscv/include/asm/barrier.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#ifndef __ASSEMBLY__
1414

1515
#define nop() __asm__ __volatile__ ("nop")
16+
#define __nops(n) ".rept " #n "\nnop\n.endr\n"
17+
#define nops(n) __asm__ __volatile__ (__nops(n))
1618

1719
#define RISCV_FENCE(p, s) \
1820
__asm__ __volatile__ ("fence " #p "," #s : : : "memory")

arch/riscv/include/asm/errata_list.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,7 @@ asm(ALTERNATIVE_2("li %0, 0\t\nnop", \
6868
*/
6969
#define ALT_THEAD_PMA(_val) \
7070
asm volatile(ALTERNATIVE( \
71-
"nop\n\t" \
72-
"nop\n\t" \
73-
"nop\n\t" \
74-
"nop\n\t" \
75-
"nop\n\t" \
76-
"nop\n\t" \
77-
"nop", \
71+
__nops(7), \
7872
"li t3, %2\n\t" \
7973
"slli t3, t3, %4\n\t" \
8074
"and t3, %0, t3\n\t" \

0 commit comments

Comments
 (0)