Skip to content

Commit f3edf03

Browse files
Xu Yangwilldeacon
authored andcommitted
perf: imx9_perf: Introduce AXI filter version to refactor the driver and better extension
The imx93 is the first supported DDR PMU that supports read transaction, write transaction and read beats events which corresponding respecitively to counter 2, 3 and 4. However, transaction-based AXI match has low accuracy when get total bits compared to beats-based. And imx93 doesn't assign AXI_ID to each master. So axi filter is not used widely on imx93. This could be regards as AXI filter version 1. To improve the AXI filter capability, imx95 supports 1 read beats and 3 write beats event which corresponding respecitively to counter 2-5. imx95 also detailed AXI_ID allocation so that most of the master could be count individually. This could be regards as AXI filter version 2. This will introduce AXI filter version to refactor the driver and support better extension, such as coming imx943. This is also a potential fix on imx91 when configure axi filter. Fixes: 44798fe ("perf: imx_perf: add support for i.MX91 platform") Cc: stable@vger.kernel.org Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Xu Yang <xu.yang_2@nxp.com> Link: https://lore.kernel.org/r/20241212065708.1353513-1-xu.yang_2@nxp.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent e49ecdf commit f3edf03

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

drivers/perf/fsl_imx9_ddr_perf.c

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,21 @@
6363

6464
static DEFINE_IDA(ddr_ida);
6565

66+
/*
67+
* V1 support 1 read transaction, 1 write transaction and 1 read beats
68+
* event which corresponding respecitively to counter 2, 3 and 4.
69+
*/
70+
#define DDR_PERF_AXI_FILTER_V1 0x1
71+
72+
/*
73+
* V2 support 1 read beats and 3 write beats events which corresponding
74+
* respecitively to counter 2-5.
75+
*/
76+
#define DDR_PERF_AXI_FILTER_V2 0x2
77+
6678
struct imx_ddr_devtype_data {
6779
const char *identifier; /* system PMU identifier for userspace */
80+
unsigned int filter_ver; /* AXI filter version */
6881
};
6982

7083
struct ddr_pmu {
@@ -83,24 +96,27 @@ struct ddr_pmu {
8396

8497
static const struct imx_ddr_devtype_data imx91_devtype_data = {
8598
.identifier = "imx91",
99+
.filter_ver = DDR_PERF_AXI_FILTER_V1
86100
};
87101

88102
static const struct imx_ddr_devtype_data imx93_devtype_data = {
89103
.identifier = "imx93",
104+
.filter_ver = DDR_PERF_AXI_FILTER_V1
90105
};
91106

92107
static const struct imx_ddr_devtype_data imx95_devtype_data = {
93108
.identifier = "imx95",
109+
.filter_ver = DDR_PERF_AXI_FILTER_V2
94110
};
95111

96-
static inline bool is_imx93(struct ddr_pmu *pmu)
112+
static inline bool axi_filter_v1(struct ddr_pmu *pmu)
97113
{
98-
return pmu->devtype_data == &imx93_devtype_data;
114+
return pmu->devtype_data->filter_ver == DDR_PERF_AXI_FILTER_V1;
99115
}
100116

101-
static inline bool is_imx95(struct ddr_pmu *pmu)
117+
static inline bool axi_filter_v2(struct ddr_pmu *pmu)
102118
{
103-
return pmu->devtype_data == &imx95_devtype_data;
119+
return pmu->devtype_data->filter_ver == DDR_PERF_AXI_FILTER_V2;
104120
}
105121

106122
static const struct of_device_id imx_ddr_pmu_dt_ids[] = {
@@ -155,7 +171,7 @@ static const struct attribute_group ddr_perf_cpumask_attr_group = {
155171
struct imx9_pmu_events_attr {
156172
struct device_attribute attr;
157173
u64 id;
158-
const void *devtype_data;
174+
const struct imx_ddr_devtype_data *devtype_data;
159175
};
160176

161177
static ssize_t ddr_pmu_event_show(struct device *dev,
@@ -307,7 +323,8 @@ ddr_perf_events_attrs_is_visible(struct kobject *kobj,
307323
if (!eattr->devtype_data)
308324
return attr->mode;
309325

310-
if (eattr->devtype_data != ddr_pmu->devtype_data)
326+
if (eattr->devtype_data != ddr_pmu->devtype_data &&
327+
eattr->devtype_data->filter_ver != ddr_pmu->devtype_data->filter_ver)
311328
return 0;
312329

313330
return attr->mode;
@@ -624,11 +641,11 @@ static int ddr_perf_event_add(struct perf_event *event, int flags)
624641
hwc->idx = counter;
625642
hwc->state |= PERF_HES_STOPPED;
626643

627-
if (is_imx93(pmu))
644+
if (axi_filter_v1(pmu))
628645
/* read trans, write trans, read beat */
629646
imx93_ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2);
630647

631-
if (is_imx95(pmu))
648+
if (axi_filter_v2(pmu))
632649
/* write beat, read beat2, read beat1, read beat */
633650
imx95_ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2);
634651

0 commit comments

Comments
 (0)