]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/6.6.26/drivers-perf-riscv-disable-perf_sample_branch_-while.patch
Linux 6.6.26
[thirdparty/kernel/stable-queue.git] / releases / 6.6.26 / drivers-perf-riscv-disable-perf_sample_branch_-while.patch
CommitLineData
ea78042b
SL
1From d71a39d2ed9c2646aff2590b4f7591aa24957f58 Mon Sep 17 00:00:00 2001
2From: Sasha Levin <sashal@kernel.org>
3Date: Tue, 12 Mar 2024 01:20:53 +0000
4Subject: drivers/perf: riscv: Disable PERF_SAMPLE_BRANCH_* while not supported
5
6From: Pu Lehui <pulehui@huawei.com>
7
8[ Upstream commit ea6873118493019474abbf57d5a800da365734df ]
9
10RISC-V perf driver does not yet support branch sampling. Although the
11specification is in the works [0], it is best to disable such events
12until support is available, otherwise we will get unexpected results.
13Due to this reason, two riscv bpf testcases get_branch_snapshot and
14perf_branches/perf_branches_hw fail.
15
16Link: https://github.com/riscv/riscv-control-transfer-records [0]
17Fixes: f5bfa23f576f ("RISC-V: Add a perf core library for pmu drivers")
18Signed-off-by: Pu Lehui <pulehui@huawei.com>
19Reviewed-by: Atish Patra <atishp@rivosinc.com>
20Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
21Link: https://lore.kernel.org/r/20240312012053.1178140-1-pulehui@huaweicloud.com
22Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
23Signed-off-by: Sasha Levin <sashal@kernel.org>
24---
25 drivers/perf/riscv_pmu.c | 4 ++++
26 1 file changed, 4 insertions(+)
27
28diff --git a/drivers/perf/riscv_pmu.c b/drivers/perf/riscv_pmu.c
29index c78a6fd6c57f6..b4efdddb2ad91 100644
30--- a/drivers/perf/riscv_pmu.c
31+++ b/drivers/perf/riscv_pmu.c
32@@ -313,6 +313,10 @@ static int riscv_pmu_event_init(struct perf_event *event)
33 u64 event_config = 0;
34 uint64_t cmask;
35
36+ /* driver does not support branch stack sampling */
37+ if (has_branch_stack(event))
38+ return -EOPNOTSUPP;
39+
40 hwc->flags = 0;
41 mapped_event = rvpmu->event_map(event, &event_config);
42 if (mapped_event < 0) {
43--
442.43.0
45