Skip to content

Commit e999143

Browse files
atishp04palmer-dabbelt
authored andcommitted
RISC-V: Add perf platform driver based on SBI PMU extension
RISC-V SBI specification added a PMU extension that allows to configure start/stop any pmu counter. The RISC-V perf can use most of the generic perf features except interrupt overflow and event filtering based on privilege mode which will be added in future. It also allows to monitor a handful of firmware counters that can provide insights into firmware activity during a performance analysis. Signed-off-by: Atish Patra <atish.patra@wdc.com> Signed-off-by: Atish Patra <atishp@rivosinc.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 90beae5 commit e999143

6 files changed

Lines changed: 596 additions & 2 deletions

File tree

drivers/perf/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ config RISCV_PMU_LEGACY
7676
of cycle/instruction counter and doesn't support counter overflow,
7777
or programmable counters. It will be removed in future.
7878

79+
config RISCV_PMU_SBI
80+
depends on RISCV_PMU && RISCV_SBI
81+
bool "RISC-V PMU based on SBI PMU extension"
82+
default y
83+
help
84+
Say y if you want to use the CPU performance monitor
85+
using SBI PMU extension on RISC-V based systems. This option provides
86+
full perf feature support i.e. counter overflow, privilege mode
87+
filtering, counter configuration.
88+
7989
config ARM_PMU_ACPI
8090
depends on ARM_PMU && ACPI
8191
def_bool y

drivers/perf/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ obj-$(CONFIG_QCOM_L2_PMU) += qcom_l2_pmu.o
1212
obj-$(CONFIG_QCOM_L3_PMU) += qcom_l3_pmu.o
1313
obj-$(CONFIG_RISCV_PMU) += riscv_pmu.o
1414
obj-$(CONFIG_RISCV_PMU_LEGACY) += riscv_pmu_legacy.o
15+
obj-$(CONFIG_RISCV_PMU_SBI) += riscv_pmu_sbi.o
1516
obj-$(CONFIG_THUNDERX2_PMU) += thunderx2_pmu.o
1617
obj-$(CONFIG_XGENE_PMU) += xgene_pmu.o
1718
obj-$(CONFIG_ARM_SPE_PMU) += arm_spe_pmu.o

drivers/perf/riscv_pmu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <linux/printk.h>
1616
#include <linux/smp.h>
1717

18+
#include <asm/sbi.h>
19+
1820
static unsigned long csr_read_num(int csr_num)
1921
{
2022
#define switchcase_csr_read(__csr_num, __val) {\

0 commit comments

Comments
 (0)