Skip to content

Commit 1a3f698

Browse files
Merge patch series "riscv: Add vendor extensions support for SiFive"
Cyan Yang <[email protected]> says: This patch set adds four vendor-specific ISA extensions from SiFive: "xsfvqmaccdod", "xsfvqmaccqoq", "xsfvfnrclipxfqf", and "xsfvfwmaccqqq". Additionally, a new hwprobe key, RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0, has been added to query which SiFive vendor extensions are supported on the current platform. Signed-off-by: Cyan Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] * b4-shazam-merge: riscv: hwprobe: Add SiFive xsfvfwmaccqqq vendor extension riscv: hwprobe: Document SiFive xsfvfwmaccqqq vendor extension riscv: Add SiFive xsfvfwmaccqqq vendor extension dt-bindings: riscv: Add xsfvfwmaccqqq ISA extension description riscv: hwprobe: Add SiFive xsfvfnrclipxfqf vendor extension riscv: hwprobe: Document SiFive xsfvfnrclipxfqf vendor extension riscv: Add SiFive xsfvfnrclipxfqf vendor extension dt-bindings: riscv: Add xsfvfnrclipxfqf ISA extension description riscv: hwprobe: Add SiFive vendor extension support and probe for xsfqmaccdod and xsfqmaccqoq riscv: hwprobe: Document SiFive xsfvqmaccdod and xsfvqmaccqoq vendor extensions riscv: Add SiFive xsfvqmaccdod and xsfvqmaccqoq vendor extensions dt-bindings: riscv: Add xsfvqmaccdod and xsfvqmaccqoq ISA extension description Signed-off-by: Palmer Dabbelt <[email protected]>
2 parents 2940954 + d9669e3 commit 1a3f698

File tree

13 files changed

+164
-1
lines changed

13 files changed

+164
-1
lines changed

Documentation/arch/riscv/hwprobe.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,25 @@ The following keys are defined:
335335

336336
* :c:macro:`RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE`: An unsigned int which
337337
represents the size of the Zicbom block in bytes.
338+
339+
* :c:macro:`RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0`: A bitmask containing the
340+
sifive vendor extensions that are compatible with the
341+
:c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`: base system behavior.
342+
343+
* SIFIVE
344+
345+
* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVQMACCDOD`: The Xsfqmaccdod vendor
346+
extension is supported in version 1.1 of SiFive Int8 Matrix Multiplication
347+
Extensions Specification.
348+
349+
* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVQMACCQOQ`: The Xsfqmaccqoq vendor
350+
extension is supported in version 1.1 of SiFive Int8 Matrix Multiplication
351+
Instruction Extensions Specification.
352+
353+
* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVFNRCLIPXFQF`: The Xsfvfnrclipxfqf
354+
vendor extension is supported in version 1.0 of SiFive FP32-to-int8 Ranged
355+
Clip Instructions Extensions Specification.
356+
357+
* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVFWMACCQQQ`: The Xsfvfwmaccqqq
358+
vendor extension is supported in version 1.0 of Matrix Multiply Accumulate
359+
Instruction Extensions Specification.

Documentation/devicetree/bindings/riscv/extensions.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,31 @@ properties:
662662
Registers in the AX45MP datasheet.
663663
https://www.andestech.com/wp-content/uploads/AX45MP-1C-Rev.-5.0.0-Datasheet.pdf
664664

665+
# SiFive
666+
- const: xsfvqmaccdod
667+
description:
668+
SiFive Int8 Matrix Multiplication Extensions Specification.
669+
See more details in
670+
https://www.sifive.com/document-file/sifive-int8-matrix-multiplication-extensions-specification
671+
672+
- const: xsfvqmaccqoq
673+
description:
674+
SiFive Int8 Matrix Multiplication Extensions Specification.
675+
See more details in
676+
https://www.sifive.com/document-file/sifive-int8-matrix-multiplication-extensions-specification
677+
678+
- const: xsfvfnrclipxfqf
679+
description:
680+
SiFive FP32-to-int8 Ranged Clip Instructions Extensions Specification.
681+
See more details in
682+
https://www.sifive.com/document-file/fp32-to-int8-ranged-clip-instructions
683+
684+
- const: xsfvfwmaccqqq
685+
description:
686+
SiFive Matrix Multiply Accumulate Instruction Extensions Specification.
687+
See more details in
688+
https://www.sifive.com/document-file/matrix-multiply-accumulate-instruction
689+
665690
# T-HEAD
666691
- const: xtheadvector
667692
description:

arch/riscv/Kconfig.vendor

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ config RISCV_ISA_VENDOR_EXT_ANDES
1616
If you don't know what to do here, say Y.
1717
endmenu
1818

19+
menu "SiFive"
20+
config RISCV_ISA_VENDOR_EXT_SIFIVE
21+
bool "SiFive vendor extension support"
22+
select RISCV_ISA_VENDOR_EXT
23+
default y
24+
help
25+
Say N here if you want to disable all SiFive vendor extension
26+
support. This will cause any SiFive vendor extensions that are
27+
requested by hardware probing to be ignored.
28+
29+
If you don't know what to do here, say Y.
30+
endmenu
31+
1932
menu "T-Head"
2033
config RISCV_ISA_VENDOR_EXT_THEAD
2134
bool "T-Head vendor extension support"

arch/riscv/include/asm/hwprobe.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <uapi/asm/hwprobe.h>
1010

11-
#define RISCV_HWPROBE_MAX_KEY 12
11+
#define RISCV_HWPROBE_MAX_KEY 13
1212

1313
static inline bool riscv_hwprobe_key_is_valid(__s64 key)
1414
{
@@ -22,6 +22,7 @@ static inline bool hwprobe_key_is_bitmask(__s64 key)
2222
case RISCV_HWPROBE_KEY_IMA_EXT_0:
2323
case RISCV_HWPROBE_KEY_CPUPERF_0:
2424
case RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0:
25+
case RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0:
2526
return true;
2627
}
2728

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_RISCV_VENDOR_EXTENSIONS_SIFIVE_H
3+
#define _ASM_RISCV_VENDOR_EXTENSIONS_SIFIVE_H
4+
5+
#include <asm/vendor_extensions.h>
6+
7+
#include <linux/types.h>
8+
9+
#define RISCV_ISA_VENDOR_EXT_XSFVQMACCDOD 0
10+
#define RISCV_ISA_VENDOR_EXT_XSFVQMACCQOQ 1
11+
#define RISCV_ISA_VENDOR_EXT_XSFVFNRCLIPXFQF 2
12+
#define RISCV_ISA_VENDOR_EXT_XSFVFWMACCQQQ 3
13+
14+
extern struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_sifive;
15+
16+
#endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_RISCV_VENDOR_EXTENSIONS_SIFIVE_HWPROBE_H
3+
#define _ASM_RISCV_VENDOR_EXTENSIONS_SIFIVE_HWPROBE_H
4+
5+
#include <linux/cpumask.h>
6+
7+
#include <uapi/asm/hwprobe.h>
8+
9+
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE
10+
void hwprobe_isa_vendor_ext_sifive_0(struct riscv_hwprobe *pair, const struct cpumask *cpus);
11+
#else
12+
static inline void hwprobe_isa_vendor_ext_sifive_0(struct riscv_hwprobe *pair,
13+
const struct cpumask *cpus)
14+
{
15+
pair->value = 0;
16+
}
17+
#endif
18+
19+
#endif

arch/riscv/include/uapi/asm/hwprobe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ struct riscv_hwprobe {
104104
#define RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED 4
105105
#define RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0 11
106106
#define RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE 12
107+
#define RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0 13
107108
/* Increase RISCV_HWPROBE_MAX_KEY when adding items. */
108109

109110
/* Flags */
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
3+
#define RISCV_HWPROBE_VENDOR_EXT_XSFVQMACCDOD (1 << 0)
4+
#define RISCV_HWPROBE_VENDOR_EXT_XSFVQMACCQOQ (1 << 1)
5+
#define RISCV_HWPROBE_VENDOR_EXT_XSFVFNRCLIPXFQF (1 << 2)
6+
#define RISCV_HWPROBE_VENDOR_EXT_XSFVFWMACCQQQ (1 << 3)

arch/riscv/kernel/sys_hwprobe.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <asm/uaccess.h>
1616
#include <asm/unistd.h>
1717
#include <asm/vector.h>
18+
#include <asm/vendor_extensions/sifive_hwprobe.h>
1819
#include <asm/vendor_extensions/thead_hwprobe.h>
1920
#include <vdso/vsyscall.h>
2021

@@ -300,6 +301,10 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair,
300301
pair->value = riscv_timebase;
301302
break;
302303

304+
case RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0:
305+
hwprobe_isa_vendor_ext_sifive_0(pair, cpus);
306+
break;
307+
303308
case RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0:
304309
hwprobe_isa_vendor_ext_thead_0(pair, cpus);
305310
break;

arch/riscv/kernel/vendor_extensions.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <asm/vendorid_list.h>
77
#include <asm/vendor_extensions.h>
88
#include <asm/vendor_extensions/andes.h>
9+
#include <asm/vendor_extensions/sifive.h>
910
#include <asm/vendor_extensions/thead.h>
1011

1112
#include <linux/array_size.h>
@@ -15,6 +16,9 @@ struct riscv_isa_vendor_ext_data_list *riscv_isa_vendor_ext_list[] = {
1516
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_ANDES
1617
&riscv_isa_vendor_ext_list_andes,
1718
#endif
19+
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE
20+
&riscv_isa_vendor_ext_list_sifive,
21+
#endif
1822
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_THEAD
1923
&riscv_isa_vendor_ext_list_thead,
2024
#endif
@@ -45,6 +49,12 @@ bool __riscv_isa_vendor_extension_available(int cpu, unsigned long vendor, unsig
4549
cpu_bmap = riscv_isa_vendor_ext_list_andes.per_hart_isa_bitmap;
4650
break;
4751
#endif
52+
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE
53+
case SIFIVE_VENDOR_ID:
54+
bmap = &riscv_isa_vendor_ext_list_sifive.all_harts_isa_bitmap;
55+
cpu_bmap = riscv_isa_vendor_ext_list_sifive.per_hart_isa_bitmap;
56+
break;
57+
#endif
4858
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_THEAD
4959
case THEAD_VENDOR_ID:
5060
bmap = &riscv_isa_vendor_ext_list_thead.all_harts_isa_bitmap;

0 commit comments

Comments
 (0)