* [PATCH v1 1/3] RISC-V: insn-def: Add I-type insn-def
2023-01-08 16:33 [PATCH v1 0/3] Remove toolchain dependencies for Zicbom Conor Dooley
@ 2023-01-08 16:33 ` Conor Dooley
2023-01-08 16:33 ` [PATCH v1 2/3] RISC-V: replace cbom instructions with an insn-def Conor Dooley
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Conor Dooley @ 2023-01-08 16:33 UTC (permalink / raw)
To: palmer
Cc: conor, Conor Dooley, Arnd Bergmann, Geert Uytterhoeven,
Heiko Stuebner, Guo Ren, Andrew Jones, Lad Prabhakar, linux-riscv
From: Andrew Jones <ajones@ventanamicro.com>
CBO instructions use the I-type of instruction format where
the immediate is used to identify the CBO instruction type.
Add I-type instruction encoding support to insn-def.
Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
---
arch/riscv/include/asm/insn-def.h | 46 +++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/arch/riscv/include/asm/insn-def.h b/arch/riscv/include/asm/insn-def.h
index 16044affa57c..39f9e0893564 100644
--- a/arch/riscv/include/asm/insn-def.h
+++ b/arch/riscv/include/asm/insn-def.h
@@ -12,6 +12,12 @@
#define INSN_R_RD_SHIFT 7
#define INSN_R_OPCODE_SHIFT 0
+#define INSN_I_SIMM12_SHIFT 20
+#define INSN_I_RS1_SHIFT 15
+#define INSN_I_FUNC3_SHIFT 12
+#define INSN_I_RD_SHIFT 7
+#define INSN_I_OPCODE_SHIFT 0
+
#ifdef __ASSEMBLY__
#ifdef CONFIG_AS_HAS_INSN
@@ -20,6 +26,10 @@
.insn r \opcode, \func3, \func7, \rd, \rs1, \rs2
.endm
+ .macro insn_i, opcode, func3, rd, rs1, simm12
+ .insn i \opcode, \func3, \rd, \rs1, \simm12
+ .endm
+
#else
#include <asm/gpr-num.h>
@@ -33,9 +43,18 @@
(.L__gpr_num_\rs2 << INSN_R_RS2_SHIFT))
.endm
+ .macro insn_i, opcode, func3, rd, rs1, simm12
+ .4byte ((\opcode << INSN_I_OPCODE_SHIFT) | \
+ (\func3 << INSN_I_FUNC3_SHIFT) | \
+ (.L__gpr_num_\rd << INSN_I_RD_SHIFT) | \
+ (.L__gpr_num_\rs1 << INSN_I_RS1_SHIFT) | \
+ (\simm12 << INSN_I_SIMM12_SHIFT))
+ .endm
+
#endif
#define __INSN_R(...) insn_r __VA_ARGS__
+#define __INSN_I(...) insn_i __VA_ARGS__
#else /* ! __ASSEMBLY__ */
@@ -44,6 +63,9 @@
#define __INSN_R(opcode, func3, func7, rd, rs1, rs2) \
".insn r " opcode ", " func3 ", " func7 ", " rd ", " rs1 ", " rs2 "\n"
+#define __INSN_I(opcode, func3, rd, rs1, simm12) \
+ ".insn i " opcode ", " func3 ", " rd ", " rs1 ", " simm12 "\n"
+
#else
#include <linux/stringify.h>
@@ -60,14 +82,32 @@
" (.L__gpr_num_\\rs2 << " __stringify(INSN_R_RS2_SHIFT) "))\n" \
" .endm\n"
+#define DEFINE_INSN_I \
+ __DEFINE_ASM_GPR_NUMS \
+" .macro insn_i, opcode, func3, rd, rs1, simm12\n" \
+" .4byte ((\\opcode << " __stringify(INSN_I_OPCODE_SHIFT) ") |" \
+" (\\func3 << " __stringify(INSN_I_FUNC3_SHIFT) ") |" \
+" (.L__gpr_num_\\rd << " __stringify(INSN_I_RD_SHIFT) ") |" \
+" (.L__gpr_num_\\rs1 << " __stringify(INSN_I_RS1_SHIFT) ") |" \
+" (\\simm12 << " __stringify(INSN_I_SIMM12_SHIFT) "))\n" \
+" .endm\n"
+
#define UNDEFINE_INSN_R \
" .purgem insn_r\n"
+#define UNDEFINE_INSN_I \
+" .purgem insn_i\n"
+
#define __INSN_R(opcode, func3, func7, rd, rs1, rs2) \
DEFINE_INSN_R \
"insn_r " opcode ", " func3 ", " func7 ", " rd ", " rs1 ", " rs2 "\n" \
UNDEFINE_INSN_R
+#define __INSN_I(opcode, func3, rd, rs1, simm12) \
+ DEFINE_INSN_I \
+ "insn_i " opcode ", " func3 ", " rd ", " rs1 ", " simm12 "\n" \
+ UNDEFINE_INSN_I
+
#endif
#endif /* ! __ASSEMBLY__ */
@@ -76,9 +116,14 @@
__INSN_R(RV_##opcode, RV_##func3, RV_##func7, \
RV_##rd, RV_##rs1, RV_##rs2)
+#define INSN_I(opcode, func3, rd, rs1, simm12) \
+ __INSN_I(RV_##opcode, RV_##func3, RV_##rd, \
+ RV_##rs1, RV_##simm12)
+
#define RV_OPCODE(v) __ASM_STR(v)
#define RV_FUNC3(v) __ASM_STR(v)
#define RV_FUNC7(v) __ASM_STR(v)
+#define RV_SIMM12(v) __ASM_STR(v)
#define RV_RD(v) __ASM_STR(v)
#define RV_RS1(v) __ASM_STR(v)
#define RV_RS2(v) __ASM_STR(v)
@@ -87,6 +132,7 @@
#define RV___RS1(v) __RV_REG(v)
#define RV___RS2(v) __RV_REG(v)
+#define RV_OPCODE_MISC_MEM RV_OPCODE(15)
#define RV_OPCODE_SYSTEM RV_OPCODE(115)
#define HFENCE_VVMA(vaddr, asid) \
--
2.39.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v1 2/3] RISC-V: replace cbom instructions with an insn-def
2023-01-08 16:33 [PATCH v1 0/3] Remove toolchain dependencies for Zicbom Conor Dooley
2023-01-08 16:33 ` [PATCH v1 1/3] RISC-V: insn-def: Add I-type insn-def Conor Dooley
@ 2023-01-08 16:33 ` Conor Dooley
2023-01-08 16:33 ` [PATCH v1 3/3] RISC-V: remove toolchain version checks for Zicbom Conor Dooley
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Conor Dooley @ 2023-01-08 16:33 UTC (permalink / raw)
To: palmer
Cc: conor, Conor Dooley, Arnd Bergmann, Geert Uytterhoeven,
Heiko Stuebner, Guo Ren, Andrew Jones, Lad Prabhakar, linux-riscv
From: Conor Dooley <conor.dooley@microchip.com>
Using the cbom instructions directly in ALT_CMO_OP, requires toolchain
support for the instructions. Using an insn-def will allow for removal
of toolchain version checks in the build system & simplification of the
proposed [1] function-based CMO scheme.
Link: https://lore.kernel.org/linux-riscv/fb3b34ae-e35e-4dc2-a8f4-19984a2f58a8@app.fastmail.com/ [1]
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
---
arch/riscv/include/asm/errata_list.h | 3 ++-
arch/riscv/include/asm/insn-def.h | 12 ++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/include/asm/errata_list.h b/arch/riscv/include/asm/errata_list.h
index 4180312d2a70..b71e3ccd3110 100644
--- a/arch/riscv/include/asm/errata_list.h
+++ b/arch/riscv/include/asm/errata_list.h
@@ -7,6 +7,7 @@
#include <asm/alternative.h>
#include <asm/csr.h>
+#include <asm/insn-def.h>
#include <asm/vendorid_list.h>
#ifdef CONFIG_ERRATA_SIFIVE
@@ -125,7 +126,7 @@ asm volatile(ALTERNATIVE_2( \
"mv a0, %1\n\t" \
"j 2f\n\t" \
"3:\n\t" \
- "cbo." __stringify(_op) " (a0)\n\t" \
+ CBO_##_op(a0) \
"add a0, a0, %0\n\t" \
"2:\n\t" \
"bltu a0, %2, 3b\n\t" \
diff --git a/arch/riscv/include/asm/insn-def.h b/arch/riscv/include/asm/insn-def.h
index 39f9e0893564..e01ab51f50d2 100644
--- a/arch/riscv/include/asm/insn-def.h
+++ b/arch/riscv/include/asm/insn-def.h
@@ -180,4 +180,16 @@
INSN_R(OPCODE_SYSTEM, FUNC3(0), FUNC7(51), \
__RD(0), RS1(gaddr), RS2(vmid))
+#define CBO_inval(base) \
+ INSN_I(OPCODE_MISC_MEM, FUNC3(2), __RD(0), \
+ RS1(base), SIMM12(0))
+
+#define CBO_clean(base) \
+ INSN_I(OPCODE_MISC_MEM, FUNC3(2), __RD(0), \
+ RS1(base), SIMM12(1))
+
+#define CBO_flush(base) \
+ INSN_I(OPCODE_MISC_MEM, FUNC3(2), __RD(0), \
+ RS1(base), SIMM12(2))
+
#endif /* __ASM_INSN_DEF_H */
--
2.39.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH v1 3/3] RISC-V: remove toolchain version checks for Zicbom
2023-01-08 16:33 [PATCH v1 0/3] Remove toolchain dependencies for Zicbom Conor Dooley
2023-01-08 16:33 ` [PATCH v1 1/3] RISC-V: insn-def: Add I-type insn-def Conor Dooley
2023-01-08 16:33 ` [PATCH v1 2/3] RISC-V: replace cbom instructions with an insn-def Conor Dooley
@ 2023-01-08 16:33 ` Conor Dooley
2023-01-09 10:33 ` [PATCH v1 0/3] Remove toolchain dependencies " Andrew Jones
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Conor Dooley @ 2023-01-08 16:33 UTC (permalink / raw)
To: palmer
Cc: conor, Conor Dooley, Arnd Bergmann, Geert Uytterhoeven,
Heiko Stuebner, Guo Ren, Andrew Jones, Lad Prabhakar, linux-riscv
From: Conor Dooley <conor.dooley@microchip.com>
Commit b8c86872d1dc ("riscv: fix detection of toolchain Zicbom
support") fixed building on systems where Zicbom was supported by the
compiler/assembler but not by the linker in an easily backportable
manner.
Now that the we have insn-defs for the 3 instructions, toolchain support
is no longer required for Zicbom.
Stop emitting "_zicbom" in -march when Zicbom is enabled & drop the
version checks entirely.
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
---
arch/riscv/Kconfig | 8 --------
arch/riscv/Makefile | 3 ---
2 files changed, 11 deletions(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index e2b656043abf..33bbdc33cef8 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -416,16 +416,8 @@ config RISCV_ISA_SVPBMT
If you don't know what to do here, say Y.
-config TOOLCHAIN_HAS_ZICBOM
- bool
- default y
- depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zicbom)
- depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zicbom)
- depends on LLD_VERSION >= 150000 || LD_VERSION >= 23800
-
config RISCV_ISA_ZICBOM
bool "Zicbom extension support for non-coherent DMA operation"
- depends on TOOLCHAIN_HAS_ZICBOM
depends on !XIP_KERNEL && MMU
select RISCV_DMA_NONCOHERENT
select RISCV_ALTERNATIVE
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 12d91b0a73d8..f9ba78ddb5c6 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -58,9 +58,6 @@ riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c
toolchain-need-zicsr-zifencei := $(call cc-option-yn, -march=$(riscv-march-y)_zicsr_zifencei)
riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei
-# Check if the toolchain supports Zicbom extension
-riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZICBOM) := $(riscv-march-y)_zicbom
-
# Check if the toolchain supports Zihintpause extension
riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE) := $(riscv-march-y)_zihintpause
--
2.39.0
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH v1 0/3] Remove toolchain dependencies for Zicbom
2023-01-08 16:33 [PATCH v1 0/3] Remove toolchain dependencies for Zicbom Conor Dooley
` (2 preceding siblings ...)
2023-01-08 16:33 ` [PATCH v1 3/3] RISC-V: remove toolchain version checks for Zicbom Conor Dooley
@ 2023-01-09 10:33 ` Andrew Jones
2023-02-15 14:56 ` Palmer Dabbelt
2023-02-15 18:40 ` patchwork-bot+linux-riscv
5 siblings, 0 replies; 7+ messages in thread
From: Andrew Jones @ 2023-01-09 10:33 UTC (permalink / raw)
To: Conor Dooley
Cc: palmer, Conor Dooley, Arnd Bergmann, Geert Uytterhoeven,
Heiko Stuebner, Guo Ren, Lad Prabhakar, linux-riscv
On Sun, Jan 08, 2023 at 04:33:53PM +0000, Conor Dooley wrote:
> From: Conor Dooley <conor.dooley@microchip.com>
>
> Hey all,
>
> I've yoinked patch 1 from Drew's series adding support for Zicboz &
> attached two more patches here that remove the need for, and then drop
> the toolchain support checks for Zicbom. The goal is to remove the need
> for checking the presence of toolchain Zicbom support in the work being
> done to support non instruction based CMOs [1].
>
> I've tested compliation on a number of different configurations with
> the Zicbom config option enabled. The important ones to call out I
> guess are:
> - clang/llvm 14 w/ LLVM=1 which doesn't support Zicbom atm.
> - gcc 11 w/ binutils 2.37 which doesn't support Zicbom atm either.
> - clang/llvm 15 w/ LLVM=1 BUT with binutils 2.37's ld. This is the
> configuration that prompted adding the LD checks as cc/as supports
> Zicbom, but ld doesn't [2].
> - gcc 12 w/ binutils 2.39 & clang 15 w/ LLVM=1, both of these supported
> Zicbom before and still do.
>
> I also checked building the THEAD errata etc with
> CONFIG_RISCV_ISA_ZICBOM disabled, and there were no build issues there
> either.
>
> Drew - I took the liberty of dropping the cbo.zero addition from your
> patch.
Thanks, LGTM.
For the series,
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Thanks,
drew
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v1 0/3] Remove toolchain dependencies for Zicbom
2023-01-08 16:33 [PATCH v1 0/3] Remove toolchain dependencies for Zicbom Conor Dooley
` (3 preceding siblings ...)
2023-01-09 10:33 ` [PATCH v1 0/3] Remove toolchain dependencies " Andrew Jones
@ 2023-02-15 14:56 ` Palmer Dabbelt
2023-02-15 18:40 ` patchwork-bot+linux-riscv
5 siblings, 0 replies; 7+ messages in thread
From: Palmer Dabbelt @ 2023-02-15 14:56 UTC (permalink / raw)
To: Conor Dooley, Palmer Dabbelt
Cc: Geert Uytterhoeven, Lad Prabhakar, Guo Ren, linux-riscv,
Andrew Jones, Arnd Bergmann, Conor Dooley, Heiko Stuebner
On Sun, 8 Jan 2023 16:33:53 +0000, Conor Dooley wrote:
> From: Conor Dooley <conor.dooley@microchip.com>
>
> Hey all,
>
> I've yoinked patch 1 from Drew's series adding support for Zicboz &
> attached two more patches here that remove the need for, and then drop
> the toolchain support checks for Zicbom. The goal is to remove the need
> for checking the presence of toolchain Zicbom support in the work being
> done to support non instruction based CMOs [1].
>
> [...]
Applied, thanks!
[1/3] RISC-V: insn-def: Add I-type insn-def
https://git.kernel.org/palmer/c/6067c3aae52f
[2/3] RISC-V: replace cbom instructions with an insn-def
https://git.kernel.org/palmer/c/dd23e9535889
[3/3] RISC-V: remove toolchain version checks for Zicbom
https://git.kernel.org/palmer/c/75c53905f873
Best regards,
--
Palmer Dabbelt <palmer@rivosinc.com>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH v1 0/3] Remove toolchain dependencies for Zicbom
2023-01-08 16:33 [PATCH v1 0/3] Remove toolchain dependencies for Zicbom Conor Dooley
` (4 preceding siblings ...)
2023-02-15 14:56 ` Palmer Dabbelt
@ 2023-02-15 18:40 ` patchwork-bot+linux-riscv
5 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+linux-riscv @ 2023-02-15 18:40 UTC (permalink / raw)
To: Conor Dooley
Cc: linux-riscv, palmer, conor.dooley, arnd, geert+renesas, heiko,
guoren, ajones, prabhakar.mahadev-lad.rj
Hello:
This series was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:
On Sun, 8 Jan 2023 16:33:53 +0000 you wrote:
> From: Conor Dooley <conor.dooley@microchip.com>
>
> Hey all,
>
> I've yoinked patch 1 from Drew's series adding support for Zicboz &
> attached two more patches here that remove the need for, and then drop
> the toolchain support checks for Zicbom. The goal is to remove the need
> for checking the presence of toolchain Zicbom support in the work being
> done to support non instruction based CMOs [1].
>
> [...]
Here is the summary with links:
- [v1,1/3] RISC-V: insn-def: Add I-type insn-def
https://git.kernel.org/riscv/c/6067c3aae52f
- [v1,2/3] RISC-V: replace cbom instructions with an insn-def
https://git.kernel.org/riscv/c/dd23e9535889
- [v1,3/3] RISC-V: remove toolchain version checks for Zicbom
https://git.kernel.org/riscv/c/75c53905f873
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 7+ messages in thread