]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drivers/perf: riscv: Align errno for unsupported perf event
authorPu Lehui <pulehui@huawei.com>
Sat, 31 Aug 2024 07:15:20 +0000 (07:15 +0000)
committerPalmer Dabbelt <palmer@rivosinc.com>
Tue, 1 Oct 2024 09:47:39 +0000 (02:47 -0700)
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 <pulehui@huawei.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Fixes: 9b3e150e310e ("RISC-V: Add a simple platform driver for RISC-V legacy perf")
Fixes: 16d3b1af0944 ("perf: RISC-V: Check standard event availability")
Fixes: e9991434596f ("RISC-V: Add perf platform driver based on SBI PMU extension")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240831071520.1630360-1-pulehui@huaweicloud.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
drivers/perf/riscv_pmu_legacy.c
drivers/perf/riscv_pmu_sbi.c

index 04487ad7fba0b538508ba3ae3628e437d2dc1b53..93c8e0fdb5898587e89115c10587d69380da19ec 100644 (file)
@@ -22,13 +22,13 @@ static int pmu_legacy_ctr_get_idx(struct perf_event *event)
        struct perf_event_attr *attr = &event->attr;
 
        if (event->attr.type != PERF_TYPE_HARDWARE)
-               return -EOPNOTSUPP;
+               return -ENOENT;
        if (attr->config == PERF_COUNT_HW_CPU_CYCLES)
                return RISCV_PMU_LEGACY_CYCLE;
        else if (attr->config == PERF_COUNT_HW_INSTRUCTIONS)
                return RISCV_PMU_LEGACY_INSTRET;
        else
-               return -EOPNOTSUPP;
+               return -ENOENT;
 }
 
 /* For legacy config & counter index are same */
index 5c39fbd8ed04d6fc222ae8ee0c0945f407ee9d86..391ca1422caec15b69b747bc8bcaef3c9faead23 100644 (file)
@@ -309,7 +309,7 @@ static void pmu_sbi_check_event(struct sbi_pmu_event_data *edata)
                          ret.value, 0x1, SBI_PMU_STOP_FLAG_RESET, 0, 0, 0);
        } else if (ret.error == SBI_ERR_NOT_SUPPORTED) {
                /* This event cannot be monitored by any counter */
-               edata->event_idx = -EINVAL;
+               edata->event_idx = -ENOENT;
        }
 }
 
@@ -556,7 +556,7 @@ static int pmu_sbi_event_map(struct perf_event *event, u64 *econfig)
                }
                break;
        default:
-               ret = -EINVAL;
+               ret = -ENOENT;
                break;
        }