mirror of
https://github.com/torvalds/linux.git
synced 2024-12-12 14:12:51 +00:00
arm64: perf: Refactor PMU init callbacks
The PMU init callbacks are already drowning in boilerplate, so before doubling the number of supported PMU models, give it a sensible refactor to significantly reduce the bloat, both in source and object code. Although nobody uses non-default sysfs attributes today, there's minimal impact to preserving the notion that maybe, some day, somebody might, so we may as well keep up appearances. Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
parent
aaa1972715
commit
e424b17985
@ -953,7 +953,10 @@ static int armv8pmu_probe_pmu(struct arm_pmu *cpu_pmu)
|
|||||||
return probe.present ? 0 : -ENODEV;
|
return probe.present ? 0 : -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int armv8_pmu_init(struct arm_pmu *cpu_pmu)
|
static int armv8_pmu_init(struct arm_pmu *cpu_pmu, char *name,
|
||||||
|
int (*map_event)(struct perf_event *event),
|
||||||
|
const struct attribute_group *events,
|
||||||
|
const struct attribute_group *format)
|
||||||
{
|
{
|
||||||
int ret = armv8pmu_probe_pmu(cpu_pmu);
|
int ret = armv8pmu_probe_pmu(cpu_pmu);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -972,135 +975,62 @@ static int armv8_pmu_init(struct arm_pmu *cpu_pmu)
|
|||||||
cpu_pmu->set_event_filter = armv8pmu_set_event_filter;
|
cpu_pmu->set_event_filter = armv8pmu_set_event_filter;
|
||||||
cpu_pmu->filter_match = armv8pmu_filter_match;
|
cpu_pmu->filter_match = armv8pmu_filter_match;
|
||||||
|
|
||||||
|
cpu_pmu->name = name;
|
||||||
|
cpu_pmu->map_event = map_event;
|
||||||
|
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] = events ?
|
||||||
|
events : &armv8_pmuv3_events_attr_group;
|
||||||
|
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] = format ?
|
||||||
|
format : &armv8_pmuv3_format_attr_group;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int armv8_pmuv3_init(struct arm_pmu *cpu_pmu)
|
static int armv8_pmuv3_init(struct arm_pmu *cpu_pmu)
|
||||||
{
|
{
|
||||||
int ret = armv8_pmu_init(cpu_pmu);
|
return armv8_pmu_init(cpu_pmu, "armv8_pmuv3",
|
||||||
if (ret)
|
armv8_pmuv3_map_event, NULL, NULL);
|
||||||
return ret;
|
|
||||||
|
|
||||||
cpu_pmu->name = "armv8_pmuv3";
|
|
||||||
cpu_pmu->map_event = armv8_pmuv3_map_event;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] =
|
|
||||||
&armv8_pmuv3_events_attr_group;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] =
|
|
||||||
&armv8_pmuv3_format_attr_group;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int armv8_a35_pmu_init(struct arm_pmu *cpu_pmu)
|
static int armv8_a35_pmu_init(struct arm_pmu *cpu_pmu)
|
||||||
{
|
{
|
||||||
int ret = armv8_pmu_init(cpu_pmu);
|
return armv8_pmu_init(cpu_pmu, "armv8_cortex_a35",
|
||||||
if (ret)
|
armv8_a53_map_event, NULL, NULL);
|
||||||
return ret;
|
|
||||||
|
|
||||||
cpu_pmu->name = "armv8_cortex_a35";
|
|
||||||
cpu_pmu->map_event = armv8_a53_map_event;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] =
|
|
||||||
&armv8_pmuv3_events_attr_group;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] =
|
|
||||||
&armv8_pmuv3_format_attr_group;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int armv8_a53_pmu_init(struct arm_pmu *cpu_pmu)
|
static int armv8_a53_pmu_init(struct arm_pmu *cpu_pmu)
|
||||||
{
|
{
|
||||||
int ret = armv8_pmu_init(cpu_pmu);
|
return armv8_pmu_init(cpu_pmu, "armv8_cortex_a53",
|
||||||
if (ret)
|
armv8_a53_map_event, NULL, NULL);
|
||||||
return ret;
|
|
||||||
|
|
||||||
cpu_pmu->name = "armv8_cortex_a53";
|
|
||||||
cpu_pmu->map_event = armv8_a53_map_event;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] =
|
|
||||||
&armv8_pmuv3_events_attr_group;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] =
|
|
||||||
&armv8_pmuv3_format_attr_group;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int armv8_a57_pmu_init(struct arm_pmu *cpu_pmu)
|
static int armv8_a57_pmu_init(struct arm_pmu *cpu_pmu)
|
||||||
{
|
{
|
||||||
int ret = armv8_pmu_init(cpu_pmu);
|
return armv8_pmu_init(cpu_pmu, "armv8_cortex_a57",
|
||||||
if (ret)
|
armv8_a57_map_event, NULL, NULL);
|
||||||
return ret;
|
|
||||||
|
|
||||||
cpu_pmu->name = "armv8_cortex_a57";
|
|
||||||
cpu_pmu->map_event = armv8_a57_map_event;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] =
|
|
||||||
&armv8_pmuv3_events_attr_group;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] =
|
|
||||||
&armv8_pmuv3_format_attr_group;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int armv8_a72_pmu_init(struct arm_pmu *cpu_pmu)
|
static int armv8_a72_pmu_init(struct arm_pmu *cpu_pmu)
|
||||||
{
|
{
|
||||||
int ret = armv8_pmu_init(cpu_pmu);
|
return armv8_pmu_init(cpu_pmu, "armv8_cortex_a72",
|
||||||
if (ret)
|
armv8_a57_map_event, NULL, NULL);
|
||||||
return ret;
|
|
||||||
|
|
||||||
cpu_pmu->name = "armv8_cortex_a72";
|
|
||||||
cpu_pmu->map_event = armv8_a57_map_event;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] =
|
|
||||||
&armv8_pmuv3_events_attr_group;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] =
|
|
||||||
&armv8_pmuv3_format_attr_group;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int armv8_a73_pmu_init(struct arm_pmu *cpu_pmu)
|
static int armv8_a73_pmu_init(struct arm_pmu *cpu_pmu)
|
||||||
{
|
{
|
||||||
int ret = armv8_pmu_init(cpu_pmu);
|
return armv8_pmu_init(cpu_pmu, "armv8_cortex_a73",
|
||||||
if (ret)
|
armv8_a73_map_event, NULL, NULL);
|
||||||
return ret;
|
|
||||||
|
|
||||||
cpu_pmu->name = "armv8_cortex_a73";
|
|
||||||
cpu_pmu->map_event = armv8_a73_map_event;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] =
|
|
||||||
&armv8_pmuv3_events_attr_group;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] =
|
|
||||||
&armv8_pmuv3_format_attr_group;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int armv8_thunder_pmu_init(struct arm_pmu *cpu_pmu)
|
static int armv8_thunder_pmu_init(struct arm_pmu *cpu_pmu)
|
||||||
{
|
{
|
||||||
int ret = armv8_pmu_init(cpu_pmu);
|
return armv8_pmu_init(cpu_pmu, "armv8_cavium_thunder",
|
||||||
if (ret)
|
armv8_thunder_map_event, NULL, NULL);
|
||||||
return ret;
|
|
||||||
|
|
||||||
cpu_pmu->name = "armv8_cavium_thunder";
|
|
||||||
cpu_pmu->map_event = armv8_thunder_map_event;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] =
|
|
||||||
&armv8_pmuv3_events_attr_group;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] =
|
|
||||||
&armv8_pmuv3_format_attr_group;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int armv8_vulcan_pmu_init(struct arm_pmu *cpu_pmu)
|
static int armv8_vulcan_pmu_init(struct arm_pmu *cpu_pmu)
|
||||||
{
|
{
|
||||||
int ret = armv8_pmu_init(cpu_pmu);
|
return armv8_pmu_init(cpu_pmu, "armv8_brcm_vulcan",
|
||||||
if (ret)
|
armv8_vulcan_map_event, NULL, NULL);
|
||||||
return ret;
|
|
||||||
|
|
||||||
cpu_pmu->name = "armv8_brcm_vulcan";
|
|
||||||
cpu_pmu->map_event = armv8_vulcan_map_event;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_EVENTS] =
|
|
||||||
&armv8_pmuv3_events_attr_group;
|
|
||||||
cpu_pmu->attr_groups[ARMPMU_ATTR_GROUP_FORMATS] =
|
|
||||||
&armv8_pmuv3_format_attr_group;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id armv8_pmu_of_device_ids[] = {
|
static const struct of_device_id armv8_pmu_of_device_ids[] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user