@@ -96,3 +96,5 @@ The following keys are defined:
* :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned accesses are
not supported at all and will generate a misaligned address fault.
+
+* :c:macro:`RISCV_HWPROBE_KEY_MTIME_FREQ`: Frequency (in Hz) of `mtime`.
@@ -8,6 +8,6 @@
#include <uapi/asm/hwprobe.h>
-#define RISCV_HWPROBE_MAX_KEY 5
+#define RISCV_HWPROBE_MAX_KEY 6
#endif
@@ -36,6 +36,7 @@ struct riscv_hwprobe {
#define RISCV_HWPROBE_MISALIGNED_FAST (3 << 0)
#define RISCV_HWPROBE_MISALIGNED_UNSUPPORTED (4 << 0)
#define RISCV_HWPROBE_MISALIGNED_MASK (7 << 0)
+#define RISCV_HWPROBE_KEY_MTIME_FREQ 6
/* Increase RISCV_HWPROBE_MAX_KEY when adding items. */
#endif
@@ -8,6 +8,7 @@
#include <linux/syscalls.h>
#include <asm/cacheflush.h>
#include <asm/cpufeature.h>
+#include <asm/delay.h>
#include <asm/hwprobe.h>
#include <asm/sbi.h>
#include <asm/vector.h>
@@ -215,6 +216,10 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair,
pair->value = hwprobe_misaligned(cpus);
break;
+ case RISCV_HWPROBE_KEY_MTIME_FREQ:
+ pair->value = riscv_timebase;
+ break;
+
/*
* For forward compatibility, unknown keys don't fail the whole
* call, but get their element key set to -1 and value set to 0
A handful of user-visible behavior is based on the frequency of the machine-mode time. Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> --- "Stat_headcrabed" on IRC asked for this. I said it was easy and they should do it themselves, but they'd logged off by the time I got around to reading messages this morning. This is more of an example than anything, but I figured it'd be easier to just send it. We likely need to think a bit about exactly how this is defined: there's more than just mtime now, and we've also got things like virtualization and perf. I'm not even sure it's sane to put this in hwprobe as opposed to providing it via some perf-related infrastructure... It's the merge window so I'm not going to think about it, if someone wants to pick this up they're more than welcome to. --- Documentation/riscv/hwprobe.rst | 2 ++ arch/riscv/include/asm/hwprobe.h | 2 +- arch/riscv/include/uapi/asm/hwprobe.h | 1 + arch/riscv/kernel/sys_riscv.c | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-)