[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230607083139.3498788-4-ilkka@os.amperecomputing.com>
Date: Wed, 7 Jun 2023 01:31:38 -0700
From: Ilkka Koskinen <ilkka@...amperecomputing.com>
To: Jonathan Corbet <corbet@....net>, Will Deacon <will@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Besar Wicaksono <bwicaksono@...dia.com>,
Suzuki K Poulose <suzuki.poulose@....com>,
Robin Murphy <robin.murphy@....com>
Cc: linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
Ilkka Koskinen <ilkka@...amperecomputing.com>
Subject: [PATCH v3 3/4] perf: arm_cspmu: Support implementation specific validation
Some platforms may use e.g. different filtering mechanism and, thus,
may need different way to validate the events and group.
Signed-off-by: Ilkka Koskinen <ilkka@...amperecomputing.com>
---
drivers/perf/arm_cspmu/arm_cspmu.c | 13 ++++++++++++-
drivers/perf/arm_cspmu/arm_cspmu.h | 4 ++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c
index 72ca4f56347c..9021d1878250 100644
--- a/drivers/perf/arm_cspmu/arm_cspmu.c
+++ b/drivers/perf/arm_cspmu/arm_cspmu.c
@@ -559,7 +559,7 @@ static void arm_cspmu_disable(struct pmu *pmu)
static int arm_cspmu_get_event_idx(struct arm_cspmu_hw_events *hw_events,
struct perf_event *event)
{
- int idx;
+ int idx, ret;
struct arm_cspmu *cspmu = to_arm_cspmu(event->pmu);
if (supports_cycle_counter(cspmu)) {
@@ -593,6 +593,12 @@ static int arm_cspmu_get_event_idx(struct arm_cspmu_hw_events *hw_events,
if (idx >= cspmu->num_logical_ctrs)
return -EAGAIN;
+ if (cspmu->impl.ops.validate_event) {
+ ret = cspmu->impl.ops.validate_event(cspmu, event);
+ if (ret)
+ return ret;
+ }
+
set_bit(idx, hw_events->used_ctrs);
return idx;
@@ -618,6 +624,7 @@ static bool arm_cspmu_validate_event(struct pmu *pmu,
*/
static bool arm_cspmu_validate_group(struct perf_event *event)
{
+ struct arm_cspmu *cspmu = to_arm_cspmu(event->pmu);
struct perf_event *sibling, *leader = event->group_leader;
struct arm_cspmu_hw_events fake_hw_events;
@@ -635,6 +642,10 @@ static bool arm_cspmu_validate_group(struct perf_event *event)
return false;
}
+ if (cspmu->impl.ops.validate_group &&
+ cspmu->impl.ops.validate_group(event))
+ return false;
+
return arm_cspmu_validate_event(event->pmu, &fake_hw_events, event);
}
diff --git a/drivers/perf/arm_cspmu/arm_cspmu.h b/drivers/perf/arm_cspmu/arm_cspmu.h
index f89ae2077164..291cedb196ea 100644
--- a/drivers/perf/arm_cspmu/arm_cspmu.h
+++ b/drivers/perf/arm_cspmu/arm_cspmu.h
@@ -106,6 +106,10 @@ struct arm_cspmu_impl_ops {
void (*set_ev_filter)(struct arm_cspmu *cspmu,
struct hw_perf_event *hwc,
u32 filter);
+ /* Implementation specific group validation */
+ int (*validate_group)(struct perf_event *event);
+ /* Implementation specific event validation */
+ int (*validate_event)(struct arm_cspmu *cspmu, struct perf_event *new);
/* Hide/show unsupported events */
umode_t (*event_attr_is_visible)(struct kobject *kobj,
struct attribute *attr, int unused);
--
2.40.1
Powered by blists - more mailing lists