Skip to content

Commit 1a6274f

Browse files
cyanyang-sifivepalmer-dabbelt
authored andcommitted
riscv: hwprobe: Add SiFive vendor extension support and probe for xsfqmaccdod and xsfqmaccqoq
Add a new hwprobe key "RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0" which allows userspace to probe for the new vendor extensions from SiFive. Also, add new hwprobe for SiFive "xsfvqmaccdod" and "xsfvqmaccqoq" vendor extensions. Signed-off-by: Cyan Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent e8fd215 commit 1a6274f

File tree

6 files changed

+50
-0
lines changed

6 files changed

+50
-0
lines changed

arch/riscv/include/asm/hwprobe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 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
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
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)

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/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_ANDES) += andes.o
44
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE) += sifive.o
5+
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE) += sifive_hwprobe.o
56
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_THEAD) += thead.o
67
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_THEAD) += thead_hwprobe.o
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
3+
#include <asm/vendor_extensions/sifive.h>
4+
#include <asm/vendor_extensions/sifive_hwprobe.h>
5+
#include <asm/vendor_extensions/vendor_hwprobe.h>
6+
7+
#include <linux/cpumask.h>
8+
#include <linux/types.h>
9+
10+
#include <uapi/asm/hwprobe.h>
11+
#include <uapi/asm/vendor/sifive.h>
12+
13+
void hwprobe_isa_vendor_ext_sifive_0(struct riscv_hwprobe *pair, const struct cpumask *cpus)
14+
{
15+
VENDOR_EXTENSION_SUPPORTED(pair, cpus,
16+
riscv_isa_vendor_ext_list_sifive.per_hart_isa_bitmap, {
17+
VENDOR_EXT_KEY(XSFVQMACCDOD);
18+
VENDOR_EXT_KEY(XSFVQMACCQOQ);
19+
});
20+
}

0 commit comments

Comments
 (0)