]>
Commit | Line | Data |
---|---|---|
ea78042b SL |
1 | From d71a39d2ed9c2646aff2590b4f7591aa24957f58 Mon Sep 17 00:00:00 2001 |
2 | From: Sasha Levin <sashal@kernel.org> | |
3 | Date: Tue, 12 Mar 2024 01:20:53 +0000 | |
4 | Subject: drivers/perf: riscv: Disable PERF_SAMPLE_BRANCH_* while not supported | |
5 | ||
6 | From: Pu Lehui <pulehui@huawei.com> | |
7 | ||
8 | [ Upstream commit ea6873118493019474abbf57d5a800da365734df ] | |
9 | ||
10 | RISC-V perf driver does not yet support branch sampling. Although the | |
11 | specification is in the works [0], it is best to disable such events | |
12 | until support is available, otherwise we will get unexpected results. | |
13 | Due to this reason, two riscv bpf testcases get_branch_snapshot and | |
14 | perf_branches/perf_branches_hw fail. | |
15 | ||
16 | Link: https://github.com/riscv/riscv-control-transfer-records [0] | |
17 | Fixes: f5bfa23f576f ("RISC-V: Add a perf core library for pmu drivers") | |
18 | Signed-off-by: Pu Lehui <pulehui@huawei.com> | |
19 | Reviewed-by: Atish Patra <atishp@rivosinc.com> | |
20 | Reviewed-by: Conor Dooley <conor.dooley@microchip.com> | |
21 | Link: https://lore.kernel.org/r/20240312012053.1178140-1-pulehui@huaweicloud.com | |
22 | Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com> | |
23 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
24 | --- | |
25 | drivers/perf/riscv_pmu.c | 4 ++++ | |
26 | 1 file changed, 4 insertions(+) | |
27 | ||
28 | diff --git a/drivers/perf/riscv_pmu.c b/drivers/perf/riscv_pmu.c | |
29 | index 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 | -- | |
44 | 2.43.0 | |
45 |