riscv: Add bfloat16 instruction support
Subsystems (3)
v4 cover riscv: Add bfloat16 instruction support
Add description for the BFloat16 precision Floating-Point ISA extension, (Zfbfmin, Zvfbfmin, Zvfbfwma). which was ratified in commit 4dc23d62 ("Added Chapter title to BF16") of the riscv-isa-manual.
Changed from v3:
1. rebase for v6.14-rc1
2. patch2: add validate for zfbfmin, zvfbfmin, zvfbfwma
3. patch2: apply Clément's tag
Changed from v2:
1. rebase for v6.13-rc1
Changed from v1:
1. patch3: add missing code in sys_hwprobe.c
Inochi Amaoto (3):
dt-bindings: riscv: add bfloat16 ISA extension description
riscv: add ISA extension parsing for bfloat16 ISA extension
riscv: hwprobe: export bfloat16 ISA extension
Documentation/arch/riscv/hwprobe.rst | 12 +++++ .../devicetree/bindings/riscv/extensions.yaml | 45 +++++++++++++++++++ arch/riscv/include/asm/hwcap.h | 3 ++ arch/riscv/include/uapi/asm/hwprobe.h | 3 ++ arch/riscv/kernel/cpufeature.c | 35 +++++++++++++++ arch/riscv/kernel/sys_hwprobe.c | 3 ++ 6 files changed, 101 insertions(+)
--
2.48.1
PATCH v4 1/3 dt-bindings: riscv: add bfloat16 ISA extension description
Add description for the BFloat16 precision Floating-Point ISA extension, (Zfbfmin, Zvfbfmin, Zvfbfwma). which was ratified in commit 4dc23d62 ("Added Chapter title to BF16") of the riscv-isa-manual.
--- .../devicetree/bindings/riscv/extensions.yaml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+)
Documentation/devicetree/bindings/riscv/extensions.yaml +45 -0
@@ -329,6 +329,12 @@ properties: instructions, as ratified in commit 056b6ff ("Zfa is ratified") of riscv-isa-manual. + - const: zfbfmin + description: + The standard Zfbfmin extension which provides minimal support for + 16-bit half-precision brain floating-point instructions, as ratified + in commit 4dc23d62 ("Added Chapter title to BF16") of riscv-isa-manual. + - const: zfh description: The standard Zfh extension for 16-bit half-precision binary
@@ -525,6 +531,18 @@ properties: in commit 6f702a2 ("Vector extensions are now ratified") of riscv-v-spec. + - const: zvfbfmin + description: + The standard Zvfbfmin extension for minimal support for vectored + 16-bit half-precision brain floating-point instructions, as ratified + in commit 4dc23d62 ("Added Chapter title to BF16") of riscv-isa-manual. + + - const: zvfbfwma + description: + The standard Zvfbfwma extension for vectored half-precision brain + floating-point widening multiply-accumulate instructions, as ratified + in commit 4dc23d62 ("Added Chapter title to BF16") of riscv-isa-manual. + - const: zvfh description: The standard Zvfh extension for vectored half-precision
@@ -673,6 +691,33 @@ properties: then: contains: const: zca + # Zfbfmin depends on F + - if: + contains: + const: zfbfmin + then: + contains: + const: f + # Zvfbfmin depends on V or Zve32f + - if: + contains: + const: zvfbfmin + then: + oneOf: + - contains: + const: v + - contains: + const: zve32f + # Zvfbfwma depends on Zfbfmin and Zvfbfmin + - if: + contains: + const: zvfbfwma + then: + allOf: + - contains: + const: zfbfmin + - contains: + const: zvfbfmin allOf: # Zcf extension does not exist on rv64
Signature · 1 line
2.48.1
PATCH v4 2/3 riscv: add ISA extension parsing for bfloat16 ISA extension
In reply to Inochi AmaotoAdd parsing for Zfbmin, Zvfbfmin, Zvfbfwma ISA extension which were ratified in 4dc23d62 ("Added Chapter title to BF16") of the riscv-isa-manual.
--- arch/riscv/include/asm/hwcap.h | 3 +++ arch/riscv/kernel/cpufeature.c | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+)
arch/riscv/include/asm/hwcap.h +3 -0
@@ -100,6 +100,9 @@#define RISCV_ISA_EXT_ZICCRSE 91#define RISCV_ISA_EXT_SVADE 92#define RISCV_ISA_EXT_SVADU 93 +#define RISCV_ISA_EXT_ZFBFMIN 94 +#define RISCV_ISA_EXT_ZVFBFMIN 95 +#define RISCV_ISA_EXT_ZVFBFWMA 96#define RISCV_ISA_EXT_XLINUXENVCFG 127
arch/riscv/kernel/cpufeature.c +35 -0
@@ -80,6 +80,15 @@ bool __riscv_isa_extension_available(const unsigned long *isa_bitmap, unsigned i }EXPORT_SYMBOL_GPL (__riscv_isa_extension_available); +static int riscv_ext_f_depends (const struct riscv_isa_ext_data *data, +const unsigned long *isa_bitmap) +{ +if (__riscv_isa_extension_available (isa_bitmap, RISCV_ISA_EXT_f)) +return 0 ; + +return -EPROBE_DEFER ; +} +static int riscv_ext_zicbom_validate (const struct riscv_isa_ext_data *data,const unsigned long *isa_bitmap) {
@@ -140,6 +149,28 @@ static int riscv_ext_zcf_validate(const struct riscv_isa_ext_data *data,return -EPROBE_DEFER ; } +static int riscv_vector_f_validate (const struct riscv_isa_ext_data *data, +const unsigned long *isa_bitmap) +{ +if (!IS_ENABLED (CONFIG_RISCV_ISA_V )) +return -EINVAL ; + +if (__riscv_isa_extension_available (isa_bitmap,RISCV_ISA_EXT_ZVE32F )) +return 0 ; + +return -EPROBE_DEFER ; +} + +static int riscv_ext_zvfbfwma_validate (const struct riscv_isa_ext_data *data, +const unsigned long *isa_bitmap) +{ +if (__riscv_isa_extension_available (isa_bitmap,RISCV_ISA_EXT_ZFBFMIN ) && +__riscv_isa_extension_available (isa_bitmap,RISCV_ISA_EXT_ZVFBFMIN )) +return 0 ; + +return -EPROBE_DEFER ; +} +static int riscv_ext_svadu_validate (const struct riscv_isa_ext_data *data,const unsigned long *isa_bitmap) {
@@ -345,6 +376,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_DATA (zacas,RISCV_ISA_EXT_ZACAS ),__RISCV_ISA_EXT_DATA (zawrs,RISCV_ISA_EXT_ZAWRS ),__RISCV_ISA_EXT_DATA (zfa,RISCV_ISA_EXT_ZFA ), +__RISCV_ISA_EXT_DATA_VALIDATE (zfbfmin,RISCV_ISA_EXT_ZFBFMIN , riscv_ext_f_depends),__RISCV_ISA_EXT_DATA (zfh,RISCV_ISA_EXT_ZFH ),__RISCV_ISA_EXT_DATA (zfhmin,RISCV_ISA_EXT_ZFHMIN ), __RISCV_ISA_EXT_DATA(zca, RISCV_ISA_EXT_ZCA),
@@ -377,6 +409,9 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {__RISCV_ISA_EXT_SUPERSET (zve64d,RISCV_ISA_EXT_ZVE64D , riscv_zve64d_exts),__RISCV_ISA_EXT_SUPERSET (zve64f,RISCV_ISA_EXT_ZVE64F , riscv_zve64f_exts),__RISCV_ISA_EXT_SUPERSET (zve64x,RISCV_ISA_EXT_ZVE64X , riscv_zve64x_exts), +__RISCV_ISA_EXT_DATA_VALIDATE (zvfbfmin,RISCV_ISA_EXT_ZVFBFMIN , riscv_vector_f_validate), +__RISCV_ISA_EXT_DATA_VALIDATE (zvfbfwma,RISCV_ISA_EXT_ZVFBFWMA , + riscv_ext_zvfbfwma_validate),__RISCV_ISA_EXT_DATA (zvfh,RISCV_ISA_EXT_ZVFH ),__RISCV_ISA_EXT_DATA (zvfhmin,RISCV_ISA_EXT_ZVFHMIN ), __RISCV_ISA_EXT_DATA(zvkb, RISCV_ISA_EXT_ZVKB),
Signature · 1 line
2.48.1
PATCH v4 3/3 riscv: hwprobe: export bfloat16 ISA extension
In reply to Inochi AmaotoExport Zfbmin, Zvfbfmin, Zvfbfwma ISA extension through hwprobe.
--- Documentation/arch/riscv/hwprobe.rst | 12 ++++++++++++ arch/riscv/include/uapi/asm/hwprobe.h | 3 +++ arch/riscv/kernel/sys_hwprobe.c | 3 +++ 3 files changed, 18 insertions(+)
Documentation/arch/riscv/hwprobe.rst +12 -0
@@ -242,6 +242,18 @@ The following keys are defined: * :c:macro:`RISCV_HWPROBE_EXT_SUPM`: The Supm extension is supported as defined in version 1.0 of the RISC-V Pointer Masking extensions. + * :c:macro:`RISCV_HWPROBE_EXT_ZFBFMIN`: The Zfbfmin extension is supported as + defined in the RISC-V ISA manual starting from commit 4dc23d6229de + ("Added Chapter title to BF16"). + + * :c:macro:`RISCV_HWPROBE_EXT_ZVFBFMIN`: The Zvfbfmin extension is supported as + defined in the RISC-V ISA manual starting from commit 4dc23d6229de + ("Added Chapter title to BF16"). + + * :c:macro:`RISCV_HWPROBE_EXT_ZVFBFWMA`: The Zvfbfwma extension is supported as + defined in the RISC-V ISA manual starting from commit 4dc23d6229de + ("Added Chapter title to BF16"). + * :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: Deprecated. Returns similar values to :c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`, but the key was mistakenly classified as a bitmask rather than a value.
arch/riscv/include/uapi/asm/hwprobe.h +3 -0
@@ -73,6 +73,9 @@ struct riscv_hwprobe {#define RISCV_HWPROBE_EXT_ZCMOP (1ULL << 47)#define RISCV_HWPROBE_EXT_ZAWRS (1ULL << 48)#define RISCV_HWPROBE_EXT_SUPM (1ULL << 49) +#define RISCV_HWPROBE_EXT_ZFBFMIN (1ULL << 50) +#define RISCV_HWPROBE_EXT_ZVFBFMIN (1ULL << 51) +#define RISCV_HWPROBE_EXT_ZVFBFWMA (1ULL << 52)#define RISCV_HWPROBE_KEY_CPUPERF_0 5#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
arch/riscv/kernel/sys_hwprobe.c +3 -0
@@ -132,6 +132,8 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,EXT_KEY (ZVE64D );EXT_KEY (ZVE64F );EXT_KEY (ZVE64X ); +EXT_KEY (ZVFBFMIN ); +EXT_KEY (ZVFBFWMA );EXT_KEY (ZVFH );EXT_KEY (ZVFHMIN );EXT_KEY (ZVKB );
@@ -148,6 +150,7 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,EXT_KEY (ZCD );EXT_KEY (ZCF );EXT_KEY (ZFA ); +EXT_KEY (ZFBFMIN );EXT_KEY (ZFH );EXT_KEY (ZFHMIN ); }
Signature · 1 line
2.48.1
Quoted 28 lines · Inochi Amaoto
Add description for the BFloat16 precision Floating-Point ISA extension, (Zfbfmin, Zvfbfmin, Zvfbfwma). which was ratified in commit
4dc23d62("Added Chapter title to BF16") of the riscv-isa-manual.Changed from v3:
1. rebase for v6.14-rc1
2. patch2: add validate for zfbfmin, zvfbfmin, zvfbfwma
3. patch2: apply Clément's tagChanged from v2:
1. rebase for v6.13-rc1Changed from v1:
1. patch3: add missing code insys_hwprobe.cInochi Amaoto (3):
dt-bindings: riscv: add bfloat16 ISA extension description
riscv: add ISA extension parsing for bfloat16 ISA extension
riscv: hwprobe: export bfloat16 ISA extensionDocumentation/arch/riscv/hwprobe.rst | 12 +++++ .../devicetree/bindings/riscv/extensions.yaml | 45 +++++++++++++++++++ arch/riscv/include/asm/hwcap.h | 3 ++ arch/riscv/include/uapi/asm/hwprobe.h | 3 ++ arch/riscv/kernel/cpufeature.c | 35 +++++++++++++++ arch/riscv/kernel/sys_hwprobe.c | 3 ++ 6 files changed, 101 insertions(+)
Quoted 3 lines
--
2.48.1
I wonder whether this patch could get merged? So I can submit the SG2044 board dts without this as dependency.
Regards,
Inochi
Alexandre Ghiti
reviewerHi Inochi,
Quoted 29 lines · Inochi Amaoto
Quoted 28 lines · Inochi Amaoto
Add description for the BFloat16 precision Floating-Point ISA extension, (Zfbfmin, Zvfbfmin, Zvfbfwma). which was ratified in commit
4dc23d62("Added Chapter title to BF16") of the riscv-isa-manual.Changed from v3:
1. rebase for v6.14-rc1
2. patch2: add validate for zfbfmin, zvfbfmin, zvfbfwma
3. patch2: apply Clément's tagChanged from v2:
1. rebase for v6.13-rc1Changed from v1:
1. patch3: add missing code insys_hwprobe.cInochi Amaoto (3):
dt-bindings: riscv: add bfloat16 ISA extension description
riscv: add ISA extension parsing for bfloat16 ISA extension
riscv: hwprobe: export bfloat16 ISA extensionDocumentation/arch/riscv/hwprobe.rst | 12 +++++ .../devicetree/bindings/riscv/extensions.yaml | 45 +++++++++++++++++++ arch/riscv/include/asm/hwcap.h | 3 ++ arch/riscv/include/uapi/asm/hwprobe.h | 3 ++ arch/riscv/kernel/cpufeature.c | 35 +++++++++++++++ arch/riscv/kernel/sys_hwprobe.c | 3 ++ 6 files changed, 101 insertions(+)
Quoted 5 lines
Quoted 3 lines
--
2.48.1I wonder whether this patch could get merged? So I can submit the SG2044 board dts without this as dependency.
It is on my list for for-next so it *should* be merged in 6.15.
Thanks,
Alex
Quoted 8 lines
Regards,
Inochi_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 39 lines · Alexandre Ghiti
Hi Inochi,
Quoted 29 lines · Inochi Amaoto
Quoted 28 lines · Inochi Amaoto
Add description for the BFloat16 precision Floating-Point ISA extension, (Zfbfmin, Zvfbfmin, Zvfbfwma). which was ratified in commit
4dc23d62("Added Chapter title to BF16") of the riscv-isa-manual.Changed from v3:
1. rebase for v6.14-rc1
2. patch2: add validate for zfbfmin, zvfbfmin, zvfbfwma
3. patch2: apply Clément's tagChanged from v2:
1. rebase for v6.13-rc1Changed from v1:
1. patch3: add missing code insys_hwprobe.cInochi Amaoto (3):
dt-bindings: riscv: add bfloat16 ISA extension description
riscv: add ISA extension parsing for bfloat16 ISA extension
riscv: hwprobe: export bfloat16 ISA extensionDocumentation/arch/riscv/hwprobe.rst | 12 +++++ .../devicetree/bindings/riscv/extensions.yaml | 45 +++++++++++++++++++ arch/riscv/include/asm/hwcap.h | 3 ++ arch/riscv/include/uapi/asm/hwprobe.h | 3 ++ arch/riscv/kernel/cpufeature.c | 35 +++++++++++++++ arch/riscv/kernel/sys_hwprobe.c | 3 ++ 6 files changed, 101 insertions(+)Quoted 5 lines
Quoted 3 lines
--
2.48.1I wonder whether this patch could get merged? So I can submit the SG2044 board dts without this as dependency.
Quoted 6 lines
It is on my list for for-next so it *should* be merged in 6.15.
Thanks,
Alex
Thanks, I will wait for it.
Regards,
Inochi
This series was applied to riscv/linux.git (for-next) by Alexandre Ghiti <[email protected]>:
Hello:
This series was applied to riscv/linux.git (for-next) by Alexandre Ghiti <[email protected]>:
Quoted 10 lines · On Thu, 13 Feb 2025 08:38:44 +0800 you wrote:
Add description for the BFloat16 precision Floating-Point ISA extension, (Zfbfmin, Zvfbfmin, Zvfbfwma). which was ratified in commit
4dc23d62("Added Chapter title to BF16") of the riscv-isa-manual.Changed from v3:
1. rebase for v6.14-rc1
2. patch2: add validate for zfbfmin, zvfbfmin, zvfbfwma
3. patch2: apply Clément's tag[...]
Here is the summary with links:
- [v4,1/3] dt-bindings: riscv: add bfloat16 ISA extension description
https://git.kernel.org/riscv/c/35bc1883733c - [v4,2/3] riscv: add ISA extension parsing for bfloat16 ISA extension https://git.kernel.org/riscv/c/e186c28dda11 - [v4,3/3] riscv: hwprobe: export bfloat16 ISA extension https://git.kernel.org/riscv/c/a4863e002cf0
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html