Skip to content

Commit 6da1115

Browse files
jones-drewpalmer-dabbelt
authored andcommitted
riscv: Provide a definition for 'pause'
If we're going to provide the encoding for 'pause' in cpu_relax() anyway, then we can drop the toolchain checks and just always use it. The advantage of doing this is that other code that need pause don't need to also define it (yes, another use is coming). Add the definition to insn-def.h since it's an instruction definition and also because insn-def.h doesn't include much, so it's safe to include from asm/vdso/processor.h without concern for circular dependencies. Signed-off-by: Andrew Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 4cece76 commit 6da1115

File tree

4 files changed

+4
-16
lines changed

4 files changed

+4
-16
lines changed

arch/riscv/Kconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,6 @@ config RISCV_ISA_ZICBOZ
639639

640640
If you don't know what to do here, say Y.
641641

642-
config TOOLCHAIN_HAS_ZIHINTPAUSE
643-
bool
644-
default y
645-
depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zihintpause)
646-
depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zihintpause)
647-
depends on LLD_VERSION >= 150000 || LD_VERSION >= 23600
648-
649642
config TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI
650643
def_bool y
651644
# https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aed44286efa8ae8717a77d94b51ac3614e2ca6dc

arch/riscv/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ else
7575
riscv-march-$(CONFIG_TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI) := $(riscv-march-y)_zicsr_zifencei
7676
endif
7777

78-
# Check if the toolchain supports Zihintpause extension
79-
riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE) := $(riscv-march-y)_zihintpause
80-
8178
# Remove F,D,V from isa string for all. Keep extensions between "fd" and "v" by
8279
# matching non-v and non-multi-letter extensions out with the filter ([^v_]*)
8380
KBUILD_CFLAGS += -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64ima)fd([^v_]*)v?/\1\2/')

arch/riscv/include/asm/insn-def.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,6 @@
196196
INSN_I(OPCODE_MISC_MEM, FUNC3(2), __RD(0), \
197197
RS1(base), SIMM12(4))
198198

199+
#define RISCV_PAUSE ".4byte 0x100000f"
200+
199201
#endif /* __ASM_INSN_DEF_H */

arch/riscv/include/asm/vdso/processor.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#ifndef __ASSEMBLY__
66

77
#include <asm/barrier.h>
8+
#include <asm/insn-def.h>
89

910
static inline void cpu_relax(void)
1011
{
@@ -14,16 +15,11 @@ static inline void cpu_relax(void)
1415
__asm__ __volatile__ ("div %0, %0, zero" : "=r" (dummy));
1516
#endif
1617

17-
#ifdef CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE
1818
/*
1919
* Reduce instruction retirement.
2020
* This assumes the PC changes.
2121
*/
22-
__asm__ __volatile__ ("pause");
23-
#else
24-
/* Encoding of the pause instruction */
25-
__asm__ __volatile__ (".4byte 0x100000F");
26-
#endif
22+
__asm__ __volatile__ (RISCV_PAUSE);
2723
barrier();
2824
}
2925

0 commit comments

Comments
 (0)