Skip to content

Commit 51b9f16

Browse files
Leo-Yanwilldeacon
authored andcommitted
perf: arm_spe: Expose event filter
Expose an "event_filter" entry in the caps folder to inform user space about which events can be filtered. Change the return type of arm_spe_pmu_cap_get() from u32 to u64 to accommodate the added event filter entry. Signed-off-by: Leo Yan <[email protected]> Tested-by: Leo Yan <[email protected]> Signed-off-by: James Clark <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent b440140 commit 51b9f16

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

drivers/perf/arm_spe_pmu.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,15 @@ enum arm_spe_pmu_capabilities {
116116
SPE_PMU_CAP_FEAT_MAX,
117117
SPE_PMU_CAP_CNT_SZ = SPE_PMU_CAP_FEAT_MAX,
118118
SPE_PMU_CAP_MIN_IVAL,
119+
SPE_PMU_CAP_EVENT_FILTER,
119120
};
120121

121122
static int arm_spe_pmu_feat_caps[SPE_PMU_CAP_FEAT_MAX] = {
122123
[SPE_PMU_CAP_ARCH_INST] = SPE_PMU_FEAT_ARCH_INST,
123124
[SPE_PMU_CAP_ERND] = SPE_PMU_FEAT_ERND,
124125
};
125126

126-
static u32 arm_spe_pmu_cap_get(struct arm_spe_pmu *spe_pmu, int cap)
127+
static u64 arm_spe_pmu_cap_get(struct arm_spe_pmu *spe_pmu, int cap)
127128
{
128129
if (cap < SPE_PMU_CAP_FEAT_MAX)
129130
return !!(spe_pmu->features & arm_spe_pmu_feat_caps[cap]);
@@ -133,6 +134,8 @@ static u32 arm_spe_pmu_cap_get(struct arm_spe_pmu *spe_pmu, int cap)
133134
return spe_pmu->counter_sz;
134135
case SPE_PMU_CAP_MIN_IVAL:
135136
return spe_pmu->min_period;
137+
case SPE_PMU_CAP_EVENT_FILTER:
138+
return ~spe_pmu->pmsevfr_res0;
136139
default:
137140
WARN(1, "unknown cap %d\n", cap);
138141
}
@@ -149,7 +152,19 @@ static ssize_t arm_spe_pmu_cap_show(struct device *dev,
149152
container_of(attr, struct dev_ext_attribute, attr);
150153
int cap = (long)ea->var;
151154

152-
return sysfs_emit(buf, "%u\n", arm_spe_pmu_cap_get(spe_pmu, cap));
155+
return sysfs_emit(buf, "%llu\n", arm_spe_pmu_cap_get(spe_pmu, cap));
156+
}
157+
158+
static ssize_t arm_spe_pmu_cap_show_hex(struct device *dev,
159+
struct device_attribute *attr,
160+
char *buf)
161+
{
162+
struct arm_spe_pmu *spe_pmu = dev_get_drvdata(dev);
163+
struct dev_ext_attribute *ea =
164+
container_of(attr, struct dev_ext_attribute, attr);
165+
int cap = (long)ea->var;
166+
167+
return sysfs_emit(buf, "0x%llx\n", arm_spe_pmu_cap_get(spe_pmu, cap));
153168
}
154169

155170
#define SPE_EXT_ATTR_ENTRY(_name, _func, _var) \
@@ -159,12 +174,15 @@ static ssize_t arm_spe_pmu_cap_show(struct device *dev,
159174

160175
#define SPE_CAP_EXT_ATTR_ENTRY(_name, _var) \
161176
SPE_EXT_ATTR_ENTRY(_name, arm_spe_pmu_cap_show, _var)
177+
#define SPE_CAP_EXT_ATTR_ENTRY_HEX(_name, _var) \
178+
SPE_EXT_ATTR_ENTRY(_name, arm_spe_pmu_cap_show_hex, _var)
162179

163180
static struct attribute *arm_spe_pmu_cap_attr[] = {
164181
SPE_CAP_EXT_ATTR_ENTRY(arch_inst, SPE_PMU_CAP_ARCH_INST),
165182
SPE_CAP_EXT_ATTR_ENTRY(ernd, SPE_PMU_CAP_ERND),
166183
SPE_CAP_EXT_ATTR_ENTRY(count_size, SPE_PMU_CAP_CNT_SZ),
167184
SPE_CAP_EXT_ATTR_ENTRY(min_interval, SPE_PMU_CAP_MIN_IVAL),
185+
SPE_CAP_EXT_ATTR_ENTRY_HEX(event_filter, SPE_PMU_CAP_EVENT_FILTER),
168186
NULL,
169187
};
170188

0 commit comments

Comments
 (0)