riscv: Add bfloat16 instruction support
Subsystems (3)
v3 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 v2:
1. rebase for v6.13-rc1
Changed from v1:
1. 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 | 3 ++ arch/riscv/kernel/sys_hwprobe.c | 3 ++ 6 files changed, 69 insertions(+)
--
2.47.1
PATCH v3 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
@@ -663,6 +681,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.47.1
Re: [PATCH v3 1/3] dt-bindings: riscv: add bfloat16 ISA extension description
Quoted 15 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.Signed-off-by Inochi Amaoto <[email protected]>Acked-by Conor Dooley <[email protected]>--- .../devicetree/bindings/riscv/extensions.yaml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+)Documentation/devicetree/bindings/riscv/extensions.yaml +0
-0
Documentation/devicetree/bindings/riscv/extensions.yaml properties: · line 335
Quoted 7 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +4
-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
I think you mean "binary" here and in the entries below, not "brain".
Quoted 58 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +41
-0+ 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@@ -663,6 +681,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
Re: [PATCH v3 1/3] dt-bindings: riscv: add bfloat16 ISA extension description
Quoted 20 lines · Samuel Holland
Quoted 18 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.Signed-off-by Inochi Amaoto <[email protected]>Acked-by Conor Dooley <[email protected]>---
.../devicetree/bindings/riscv/extensions.yaml| 45 +++++++++++++++++++1 file changed, 45 insertions(+)Documentation/devicetree/bindings/riscv/extensions.yaml +0
-0@@ -329,6 +329,12 @@ properties: instructions, as ratified in commit 056b6ff ("Zfa is ratified") of riscv-isa-manual.
Quoted 6 lines
Documentation/devicetree/bindings/riscv/extensions.yaml properties: · line 335
Quoted 4 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +4
-0+ - const: zfbfmin + description: + The standard Zfbfmin extension which provides minimal support for + 16-bit half-precision brain floating-point instructions, as ratifiedI think you mean "binary" here and in the entries below, not "brain”.
No, that’s Zfhmin / FP16 / binary16, not Zfbfmin / BF16 / BFloat16? The B is for Brain as it came out of Google Brain.
https://en.wikipedia.org/wiki/Bfloat16_floating-point_format
Jess
Re: [PATCH v3 1/3] dt-bindings: riscv: add bfloat16 ISA extension description
Quoted 28 lines · Jessica Clarke
Quoted 20 lines · Samuel Holland
Quoted 18 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.Signed-off-by Inochi Amaoto <[email protected]>Acked-by Conor Dooley <[email protected]>---
.../devicetree/bindings/riscv/extensions.yaml| 45 +++++++++++++++++++1 file changed, 45 insertions(+)Documentation/devicetree/bindings/riscv/extensions.yaml +0
-0@@ -329,6 +329,12 @@ properties: instructions, as ratified in commit 056b6ff ("Zfa is ratified") of riscv-isa-manual.Quoted 6 lines
Documentation/devicetree/bindings/riscv/extensions.yaml properties: · line 335
Quoted 4 lines
Documentation/devicetree/bindings/riscv/extensions.yaml +4
-0+ - const: zfbfmin + description: + The standard Zfbfmin extension which provides minimal support for + 16-bit half-precision brain floating-point instructions, as ratifiedI think you mean "binary" here and in the entries below, not "brain”.
Quoted 4 lines
No, that’s Zfhmin / FP16 / binary16, not Zfbfmin / BF16 / BFloat16? The B is for Brain as it came out of Google Brain.
https://en.wikipedia.org/wiki/Bfloat16_floating-point_format
Ah, yes, I was the confused one here. Sorry for the noise.
PATCH v3 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 | 3 +++ 2 files changed, 6 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 +3 -0
@@ -341,6 +341,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 (zfbfmin,RISCV_ISA_EXT_ZFBFMIN ),__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),
@@ -373,6 +374,8 @@ 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 (zvfbfmin,RISCV_ISA_EXT_ZVFBFMIN ), +__RISCV_ISA_EXT_DATA (zvfbfwma,RISCV_ISA_EXT_ZVFBFWMA ),__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.47.1
Re: [PATCH v3 2/3] riscv: add ISA extension parsing for bfloat16 ISA extension
Quoted 29 lines · Inochi Amaoto
Add parsing for Zfbmin, Zvfbfmin, Zvfbfwma ISA extension which were ratified in
4dc23d62("Added Chapter title to BF16") of the riscv-isa-manual.Signed-off-by Inochi Amaoto <[email protected]>--- arch/riscv/include/asm/hwcap.h | 3 +++ arch/riscv/kernel/cpufeature.c | 3 +++ 2 files changed, 6 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 127arch/riscv/kernel/cpufeature.c +0
-0
arch/riscv/kernel/cpufeature.c const struct riscv_isa_ext_data riscv_isa_ext[] = { · line 344
Quoted 4 lines
arch/riscv/kernel/cpufeature.c +1
-0@@ -341,6 +341,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(zfbfmin, RISCV_ISA_EXT_ZFBFMIN),
Hi Inochi,
You could add a validation callback to that extension:
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;
} ...
__RISCV_ISA_EXT_DATA_VALIDATE(zfbfmin, RISCV_ISA_EXT_ZFBFMIN,riscv_ext_f_depends),
But I'm ok with the current state of that patch since I have the same thing coming for other extensions as well. So with or without my previous comment fixed:
Thanks,
Clément
Quoted 12 lines
arch/riscv/kernel/cpufeature.c +2
-0__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),@@ -373,6 +374,8 @@ 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 (zvfbfmin,RISCV_ISA_EXT_ZVFBFMIN ), +__RISCV_ISA_EXT_DATA (zvfbfwma,RISCV_ISA_EXT_ZVFBFWMA ),__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),
Re: [PATCH v3 2/3] riscv: add ISA extension parsing for bfloat16 ISA extension
Quoted 50 lines · Clément Léger
Quoted 29 lines · Inochi Amaoto
Add parsing for Zfbmin, Zvfbfmin, Zvfbfwma ISA extension which were ratified in
4dc23d62("Added Chapter title to BF16") of the riscv-isa-manual.Signed-off-by Inochi Amaoto <[email protected]>--- arch/riscv/include/asm/hwcap.h | 3 +++ arch/riscv/kernel/cpufeature.c | 3 +++ 2 files changed, 6 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 127arch/riscv/kernel/cpufeature.c +0
-0arch/riscv/kernel/cpufeature.c const struct riscv_isa_ext_data riscv_isa_ext[] = { · line 344
Quoted 4 lines
arch/riscv/kernel/cpufeature.c +1
-0@@ -341,6 +341,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(zfbfmin, RISCV_ISA_EXT_ZFBFMIN),Hi Inochi,
You could add a validation callback to that extension:
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; }
Quoted 7 lines
...
__RISCV_ISA_EXT_DATA_VALIDATE(zfbfmin,RISCV_ISA_EXT_ZFBFMIN,riscv_ext_f_depends),But I'm ok with the current state of that patch since I have the same thing coming for other extensions as well.
I think it is good for me to add the check, and I wonder it is possible to add the extra check for zvfbfmin and zvfbfwma like this:
static int riscv_ext_zvfbfmin_validate(const struct riscv_isa_ext_data *data,
const unsigned long *isa_bitmap)
{
if (__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_v))
return 0;
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;
}Quoted 8 lines
So with or without my previous comment fixed:
Reviewed-by Clément Léger <[email protected]>Thanks,
Clément
Thanks,
Regards,
Inochi
Quoted 13 lines
Quoted 12 lines
arch/riscv/kernel/cpufeature.c +2
-0__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),@@ -373,6 +374,8 @@ 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 (zvfbfmin,RISCV_ISA_EXT_ZVFBFMIN ), +__RISCV_ISA_EXT_DATA (zvfbfwma,RISCV_ISA_EXT_ZVFBFWMA ),__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),
Re: [PATCH v3 2/3] riscv: add ISA extension parsing for bfloat16 ISA extension
Quoted 60 lines · Inochi Amaoto
Quoted 50 lines · Clément Léger
Quoted 29 lines · Inochi Amaoto
Add parsing for Zfbmin, Zvfbfmin, Zvfbfwma ISA extension which were ratified in
4dc23d62("Added Chapter title to BF16") of the riscv-isa-manual.Signed-off-by Inochi Amaoto <[email protected]>--- arch/riscv/include/asm/hwcap.h | 3 +++ arch/riscv/kernel/cpufeature.c | 3 +++ 2 files changed, 6 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 127arch/riscv/kernel/cpufeature.c +0
-0arch/riscv/kernel/cpufeature.c const struct riscv_isa_ext_data riscv_isa_ext[] = { · line 344
Quoted 4 lines
arch/riscv/kernel/cpufeature.c +1
-0@@ -341,6 +341,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(zfbfmin, RISCV_ISA_EXT_ZFBFMIN),Hi Inochi,
You could add a validation callback to that extension:
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; }Quoted 7 lines
...
__RISCV_ISA_EXT_DATA_VALIDATE(zfbfmin,RISCV_ISA_EXT_ZFBFMIN,riscv_ext_f_depends),But I'm ok with the current state of that patch since I have the same thing coming for other extensions as well.
Quoted 8 lines
I think it is good for me to add the check, and I wonder it is possible to add the extra check for zvfbfmin and zvfbfwma like this:
static int riscv_ext_zvfbfmin_validate(const struct
riscv_isa_ext_data*data,
const unsigned long*isa_bitmap){ if (__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_v)) return 0;
This is not needed I think, V "turns on" Zve32f. If anything, you should be checking for CONFIG_RISCV_ISA_V here ^^
You /could/ call the resulting riscv_vector_f_validate(), since this is nothing specific to Zvfvfmin, and could be used for another extension that requires a Zve32f or Zve64 minimum base.
Quoted 44 lines
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; }Quoted 8 lines
So with or without my previous comment fixed:
Reviewed-by Clément Léger <[email protected]>Thanks,
Clément
Thanks,
Regards,
InochiQuoted 13 lines
Quoted 12 lines
arch/riscv/kernel/cpufeature.c +2
-0__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),@@ -373,6 +374,8 @@ 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 (zvfbfmin,RISCV_ISA_EXT_ZVFBFMIN ), +__RISCV_ISA_EXT_DATA (zvfbfwma,RISCV_ISA_EXT_ZVFBFWMA ),__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),
Re: [PATCH v3 2/3] riscv: add ISA extension parsing for bfloat16 ISA extension
Quoted 64 lines · Conor Dooley
Quoted 63 lines · Inochi Amaoto
Quoted 50 lines · Clément Léger
Quoted 29 lines · Inochi Amaoto
Add parsing for Zfbmin, Zvfbfmin, Zvfbfwma ISA extension which were ratified in
4dc23d62("Added Chapter title to BF16") of the riscv-isa-manual.Signed-off-by Inochi Amaoto <[email protected]>--- arch/riscv/include/asm/hwcap.h | 3 +++ arch/riscv/kernel/cpufeature.c | 3 +++ 2 files changed, 6 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 127arch/riscv/kernel/cpufeature.c +0
-0arch/riscv/kernel/cpufeature.c const struct riscv_isa_ext_data riscv_isa_ext[] = { · line 344
Quoted 4 lines
arch/riscv/kernel/cpufeature.c +1
-0@@ -341,6 +341,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(zfbfmin, RISCV_ISA_EXT_ZFBFMIN),Hi Inochi,
You could add a validation callback to that extension:
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; }Quoted 7 lines
...
__RISCV_ISA_EXT_DATA_VALIDATE(zfbfmin,RISCV_ISA_EXT_ZFBFMIN,riscv_ext_f_depends),But I'm ok with the current state of that patch since I have the same thing coming for other extensions as well.
I think it is good for me to add the check, and I wonder it is possible to add the extra check for zvfbfmin and zvfbfwma like this:
Quoted 9 lines
Quoted 5 lines
static int riscv_ext_zvfbfmin_validate(const struct
riscv_isa_ext_data*data,
const unsigned long*isa_bitmap){ if (__riscv_isa_extension_available(isa_bitmap, RISCV_ISA_EXT_v)) return 0;This is not needed I think, V "turns on" Zve32f. If anything, you should be checking for
CONFIG_RISCV_ISA_Vhere ^^
Thanks for pointing it. I will change the check.
Quoted 4 lines
You /could/ call the resulting
riscv_vector_f_validate(), since this is nothing specific to Zvfvfmin, and could be used for another extension that requires a Zve32f or Zve64 minimum base.
It is OK for me, I will change its name.
Regards,
Inochi
PATCH v3 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
@@ -131,6 +131,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 );
@@ -147,6 +149,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.47.1
Re: [PATCH v3 3/3] riscv: hwprobe: export bfloat16 ISA extension
Possible conflict with: https://lore.kernel.org/linux-riscv/[email protected]/
Quoted 61 lines · Inochi Amaoto
Export Zfbmin, Zvfbfmin, Zvfbfwma ISA extension through hwprobe.
Signed-off-by Inochi Amaoto <[email protected]>Reviewed-by Clément Léger <[email protected]>--- 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 +2
-0@@ -131,6 +131,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 );
arch/riscv/kernel/sys_hwprobe.c static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, · line 155
Quoted 7 lines
arch/riscv/kernel/sys_hwprobe.c +1
-0@@ -147,6 +149,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 ); }
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v3 3/3] riscv: hwprobe: export bfloat16 ISA extension
Quoted 2 lines · Yangyu Chen
Possible conflict with: https://lore.kernel.org/linux-riscv/[email protected]/
Yeah, I know the conflict. As the time of merging these patch is uncertain, what I can do now is to match the upstream code.
Regards,
Inochi
Quoted 74 lines · Inochi Amaoto
Quoted 60 lines
Export Zfbmin, Zvfbfmin, Zvfbfwma ISA extension through hwprobe.
Signed-off-by Inochi Amaoto <[email protected]>Reviewed-by Clément Léger <[email protected]>--- 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 +2
-0@@ -131,6 +131,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 );arch/riscv/kernel/sys_hwprobe.c static void hwprobe_isa_ext0(struct riscv_hwprobe *pair, · line 155
Quoted 7 lines
arch/riscv/kernel/sys_hwprobe.c +1
-0@@ -147,6 +149,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 ); }_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v3 3/3] riscv: hwprobe: export bfloat16 ISA extension
Quoted 6 lines · Inochi Amaoto
Quoted 2 lines · Yangyu Chen
Possible conflict with: https://lore.kernel.org/linux-riscv/[email protected]/
Yeah, I know the conflict. As the time of merging these patch is uncertain, what I can do now is to match the upstream code.
The solution is to not worry about it. Palmer can resolve trivial numerical conflicts like this.
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 8 lines · On Fri, 6 Dec 2024 13:58:26 +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 v2:
1. rebase for v6.13-rc1[...]
Here is the summary with links:
- [v3,1/3] dt-bindings: riscv: add bfloat16 ISA extension description
https://git.kernel.org/riscv/c/35bc1883733c - [v3,2/3] riscv: add ISA extension parsing for bfloat16 ISA extension (no matching commit) - [v3,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