Skip to content

Commit c625154

Browse files
Pu Lehuipalmer-dabbelt
authored andcommitted
drivers/perf: riscv: Align errno for unsupported perf event
RISC-V perf driver does not yet support PERF_TYPE_BREAKPOINT. It would be more appropriate to return -EOPNOTSUPP or -ENOENT for this type in pmu_sbi_event_map. Considering that other implementations return -ENOENT for unsupported perf types, let's synchronize this behavior. Due to this reason, a riscv bpf testcases perf_skip fail. Meanwhile, align that behavior to the rest of proper place. Signed-off-by: Pu Lehui <[email protected]> Reviewed-by: Atish Patra <[email protected]> Fixes: 9b3e150 ("RISC-V: Add a simple platform driver for RISC-V legacy perf") Fixes: 16d3b1a ("perf: RISC-V: Check standard event availability") Fixes: e999143 ("RISC-V: Add perf platform driver based on SBI PMU extension") Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 9852d85 commit c625154

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/perf/riscv_pmu_legacy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ static int pmu_legacy_ctr_get_idx(struct perf_event *event)
2222
struct perf_event_attr *attr = &event->attr;
2323

2424
if (event->attr.type != PERF_TYPE_HARDWARE)
25-
return -EOPNOTSUPP;
25+
return -ENOENT;
2626
if (attr->config == PERF_COUNT_HW_CPU_CYCLES)
2727
return RISCV_PMU_LEGACY_CYCLE;
2828
else if (attr->config == PERF_COUNT_HW_INSTRUCTIONS)
2929
return RISCV_PMU_LEGACY_INSTRET;
3030
else
31-
return -EOPNOTSUPP;
31+
return -ENOENT;
3232
}
3333

3434
/* For legacy config & counter index are same */

drivers/perf/riscv_pmu_sbi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static void pmu_sbi_check_event(struct sbi_pmu_event_data *edata)
309309
ret.value, 0x1, SBI_PMU_STOP_FLAG_RESET, 0, 0, 0);
310310
} else if (ret.error == SBI_ERR_NOT_SUPPORTED) {
311311
/* This event cannot be monitored by any counter */
312-
edata->event_idx = -EINVAL;
312+
edata->event_idx = -ENOENT;
313313
}
314314
}
315315

@@ -556,7 +556,7 @@ static int pmu_sbi_event_map(struct perf_event *event, u64 *econfig)
556556
}
557557
break;
558558
default:
559-
ret = -EINVAL;
559+
ret = -ENOENT;
560560
break;
561561
}
562562

0 commit comments

Comments
 (0)