Skip to content

Commit cddd638

Browse files
charlie-rivospalmer-dabbelt
authored andcommitted
riscv: Add thead and xtheadvector as a vendor extension
Add support to the kernel for THead vendor extensions with the target of the new extension xtheadvector. Signed-off-by: Charlie Jenkins <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Tested-by: Yangyu Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent ce1daee commit cddd638

File tree

6 files changed

+59
-0
lines changed

6 files changed

+59
-0
lines changed

arch/riscv/Kconfig.vendor

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

19+
menu "T-Head"
20+
config RISCV_ISA_VENDOR_EXT_THEAD
21+
bool "T-Head vendor extension support"
22+
select RISCV_ISA_VENDOR_EXT
23+
default y
24+
help
25+
Say N here to disable detection of and support for all T-Head vendor
26+
extensions. Without this option enabled, T-Head vendor extensions will
27+
not be detected at boot and their presence not reported to userspace.
28+
29+
If you don't know what to do here, say Y.
30+
endmenu
31+
1932
endmenu
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_THEAD_H
3+
#define _ASM_RISCV_VENDOR_EXTENSIONS_THEAD_H
4+
5+
#include <asm/vendor_extensions.h>
6+
7+
#include <linux/types.h>
8+
9+
/*
10+
* Extension keys must be strictly less than RISCV_ISA_VENDOR_EXT_MAX.
11+
*/
12+
#define RISCV_ISA_VENDOR_EXT_XTHEADVECTOR 0
13+
14+
extern struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_thead;
15+
16+
#endif

arch/riscv/kernel/cpufeature.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <asm/sbi.h>
2626
#include <asm/vector.h>
2727
#include <asm/vendor_extensions.h>
28+
#include <asm/vendor_extensions/thead.h>
2829

2930
#define NUM_ALPHA_EXTS ('z' - 'a' + 1)
3031

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/thead.h>
910

1011
#include <linux/array_size.h>
1112
#include <linux/types.h>
@@ -14,6 +15,9 @@ struct riscv_isa_vendor_ext_data_list *riscv_isa_vendor_ext_list[] = {
1415
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_ANDES
1516
&riscv_isa_vendor_ext_list_andes,
1617
#endif
18+
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_THEAD
19+
&riscv_isa_vendor_ext_list_thead,
20+
#endif
1721
};
1822

1923
const size_t riscv_isa_vendor_ext_list_size = ARRAY_SIZE(riscv_isa_vendor_ext_list);
@@ -41,6 +45,12 @@ bool __riscv_isa_vendor_extension_available(int cpu, unsigned long vendor, unsig
4145
cpu_bmap = riscv_isa_vendor_ext_list_andes.per_hart_isa_bitmap;
4246
break;
4347
#endif
48+
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_THEAD
49+
case THEAD_VENDOR_ID:
50+
bmap = &riscv_isa_vendor_ext_list_thead.all_harts_isa_bitmap;
51+
cpu_bmap = riscv_isa_vendor_ext_list_thead.per_hart_isa_bitmap;
52+
break;
53+
#endif
4454
default:
4555
return false;
4656
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22

33
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_ANDES) += andes.o
4+
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_THEAD) += thead.o
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
3+
#include <asm/cpufeature.h>
4+
#include <asm/vendor_extensions.h>
5+
#include <asm/vendor_extensions/thead.h>
6+
7+
#include <linux/array_size.h>
8+
#include <linux/types.h>
9+
10+
/* All T-Head vendor extensions supported in Linux */
11+
static const struct riscv_isa_ext_data riscv_isa_vendor_ext_thead[] = {
12+
__RISCV_ISA_EXT_DATA(xtheadvector, RISCV_ISA_VENDOR_EXT_XTHEADVECTOR),
13+
};
14+
15+
struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_thead = {
16+
.ext_data_count = ARRAY_SIZE(riscv_isa_vendor_ext_thead),
17+
.ext_data = riscv_isa_vendor_ext_thead,
18+
};

0 commit comments

Comments
 (0)