Skip to content

Commit eb10039

Browse files
cuiyunhuiAlexandre Ghiti
authored andcommitted
RISC-V: hwprobe: Expose Zicbom extension and its block size
Expose Zicbom through hwprobe and also provide a key to extract its respective block size. [ alex: Fix merge conflicts and hwprobe numbering ] Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Signed-off-by: Yunhui Cui <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Ghiti <[email protected]>
1 parent de70b53 commit eb10039

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

Documentation/arch/riscv/hwprobe.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ The following keys are defined:
260260
defined in the RISC-V ISA manual starting from commit 4dc23d6229de
261261
("Added Chapter title to BF16").
262262

263+
* :c:macro:`RISCV_HWPROBE_EXT_ZICBOM`: The Zicbom extension is supported, as
264+
ratified in commit 3dd606f ("Create cmobase-v1.0.pdf") of riscv-CMOs.
265+
263266
* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: Deprecated. Returns similar values to
264267
:c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`, but the key was
265268
mistakenly classified as a bitmask rather than a value.
@@ -321,3 +324,6 @@ The following keys are defined:
321324
* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XTHEADVECTOR`: The xtheadvector vendor
322325
extension is supported in the T-Head ISA extensions spec starting from
323326
commit a18c801634 ("Add T-Head VECTOR vendor extension. ").
327+
328+
* :c:macro:`RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE`: An unsigned int which
329+
represents the size of the Zicbom block in bytes.

arch/riscv/include/asm/hwprobe.h

Lines changed: 1 addition & 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 11
11+
#define RISCV_HWPROBE_MAX_KEY 12
1212

1313
static inline bool riscv_hwprobe_key_is_valid(__s64 key)
1414
{

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ struct riscv_hwprobe {
7878
#define RISCV_HWPROBE_EXT_ZFBFMIN (1ULL << 52)
7979
#define RISCV_HWPROBE_EXT_ZVFBFMIN (1ULL << 53)
8080
#define RISCV_HWPROBE_EXT_ZVFBFWMA (1ULL << 54)
81+
#define RISCV_HWPROBE_EXT_ZICBOM (1ULL << 55)
8182
#define RISCV_HWPROBE_KEY_CPUPERF_0 5
8283
#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)
8384
#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
@@ -100,6 +101,7 @@ struct riscv_hwprobe {
100101
#define RISCV_HWPROBE_MISALIGNED_VECTOR_FAST 3
101102
#define RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED 4
102103
#define RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0 11
104+
#define RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE 12
103105
/* Increase RISCV_HWPROBE_MAX_KEY when adding items. */
104106

105107
/* Flags */

arch/riscv/kernel/sys_hwprobe.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
107107
EXT_KEY(ZCA);
108108
EXT_KEY(ZCB);
109109
EXT_KEY(ZCMOP);
110+
EXT_KEY(ZICBOM);
110111
EXT_KEY(ZICBOZ);
111112
EXT_KEY(ZICNTR);
112113
EXT_KEY(ZICOND);
@@ -166,7 +167,7 @@ static void hwprobe_isa_ext0(struct riscv_hwprobe *pair,
166167
pair->value &= ~missing;
167168
}
168169

169-
static bool hwprobe_ext0_has(const struct cpumask *cpus, unsigned long ext)
170+
static bool hwprobe_ext0_has(const struct cpumask *cpus, u64 ext)
170171
{
171172
struct riscv_hwprobe pair;
172173

@@ -284,6 +285,11 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair,
284285
if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOZ))
285286
pair->value = riscv_cboz_block_size;
286287
break;
288+
case RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE:
289+
pair->value = 0;
290+
if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOM))
291+
pair->value = riscv_cbom_block_size;
292+
break;
287293
case RISCV_HWPROBE_KEY_HIGHEST_VIRT_ADDRESS:
288294
pair->value = user_max_virt_addr();
289295
break;

0 commit comments

Comments
 (0)