Message ID | 20240322063930.749126-1-xu.yang_2@nxp.com |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | [v8,1/8] dt-bindings: perf: fsl-imx-ddr: Add i.MX95 compatible | expand |
Context | Check | Description |
---|---|---|
robh/checkpatch | success | |
robh/patch-applied | success | |
robh/dtbs-check | warning | build log |
robh/dt-meta-schema | success |
On Fri, Mar 22, 2024 at 02:39:26PM +0800, Xu Yang wrote: > This driver is initinally used to support imx93 Soc and now it's time to > add support for imx95 Soc. However, some macro definitions and events are > different on these two Socs. For preparing imx95 supports, this will > refactor driver for imx93. > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> > > --- > Changes in v4: > - new patch > Changes in v5: > - use is_visible to hide unwanted attributes as suggested by Will > Changes in v6: > - improve imx93_ddr_perf_monitor_config() > Changes in v7: > - improve imx93_ddr_perf_monitor_config() as suggested by Frank > Changes in v8: > - adjust is_visable() as suggested by Frank > --- > drivers/perf/fsl_imx9_ddr_perf.c | 106 ++++++++++++++++++++----------- > 1 file changed, 68 insertions(+), 38 deletions(-) > > diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c > index b728719b494c..011377c01dea 100644 > --- a/drivers/perf/fsl_imx9_ddr_perf.c > +++ b/drivers/perf/fsl_imx9_ddr_perf.c > @@ -11,14 +11,14 @@ > #include <linux/perf_event.h> > > /* Performance monitor configuration */ > -#define PMCFG1 0x00 > -#define PMCFG1_RD_TRANS_FILT_EN BIT(31) > -#define PMCFG1_WR_TRANS_FILT_EN BIT(30) > -#define PMCFG1_RD_BT_FILT_EN BIT(29) > -#define PMCFG1_ID_MASK GENMASK(17, 0) > +#define PMCFG1 0x00 > +#define MX93_PMCFG1_RD_TRANS_FILT_EN BIT(31) > +#define MX93_PMCFG1_WR_TRANS_FILT_EN BIT(30) > +#define MX93_PMCFG1_RD_BT_FILT_EN BIT(29) > +#define MX93_PMCFG1_ID_MASK GENMASK(17, 0) > > -#define PMCFG2 0x04 > -#define PMCFG2_ID GENMASK(17, 0) > +#define PMCFG2 0x04 > +#define MX93_PMCFG2_ID GENMASK(17, 0) > > /* Global control register affects all counters and takes priority over local control registers */ > #define PMGC0 0x40 > @@ -76,6 +76,11 @@ static const struct imx_ddr_devtype_data imx93_devtype_data = { > .identifier = "imx93", > }; > > +static inline bool is_imx93(struct ddr_pmu *pmu) > +{ > + return pmu->devtype_data == &imx93_devtype_data; > +} > + > static const struct of_device_id imx_ddr_pmu_dt_ids[] = { > {.compatible = "fsl,imx93-ddr-pmu", .data = &imx93_devtype_data}, > { /* sentinel */ } > @@ -123,23 +128,36 @@ static const struct attribute_group ddr_perf_cpumask_attr_group = { > .attrs = ddr_perf_cpumask_attrs, > }; > > +struct imx9_pmu_events_attr { > + struct device_attribute attr; > + u64 id; > + const void *devtype_data; > +}; > + > static ssize_t ddr_pmu_event_show(struct device *dev, > struct device_attribute *attr, char *page) > { > - struct perf_pmu_events_attr *pmu_attr; > + struct imx9_pmu_events_attr *pmu_attr; > > - pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr); > + pmu_attr = container_of(attr, struct imx9_pmu_events_attr, attr); > return sysfs_emit(page, "event=0x%02llx\n", pmu_attr->id); > } > > #define ID(counter, id) ((counter << CONFIG_COUNTER_OFFSET) | id) > > -#define IMX9_DDR_PMU_EVENT_ATTR(_name, _id) \ > - (&((struct perf_pmu_events_attr[]) { \ > +#define DDR_PMU_EVENT_ATTR_COMM(_name, _id, _data) \ > + (&((struct imx9_pmu_events_attr[]) { \ > { .attr = __ATTR(_name, 0444, ddr_pmu_event_show, NULL),\ > - .id = _id, } \ > + .id = _id, \ > + .devtype_data = _data, } \ > })[0].attr.attr) > > +#define IMX9_DDR_PMU_EVENT_ATTR(_name, _id) \ > + DDR_PMU_EVENT_ATTR_COMM(_name, _id, NULL) > + > +#define IMX93_DDR_PMU_EVENT_ATTR(_name, _id) \ > + DDR_PMU_EVENT_ATTR_COMM(_name, _id, &imx93_devtype_data) > + > static struct attribute *ddr_perf_events_attrs[] = { > /* counter0 cycles event */ > IMX9_DDR_PMU_EVENT_ATTR(cycles, 0), > @@ -185,7 +203,7 @@ static struct attribute *ddr_perf_events_attrs[] = { > IMX9_DDR_PMU_EVENT_ATTR(ddrc_ld_wiq_6, ID(2, 70)), > IMX9_DDR_PMU_EVENT_ATTR(ddrc_ld_wiq_7, ID(2, 71)), > IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pmon_empty, ID(2, 72)), > - IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_trans_filt, ID(2, 73)), > + IMX93_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_trans_filt, ID(2, 73)), /* imx93 specific*/ > > /* counter3 specific events */ > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_collision_0, ID(3, 64)), > @@ -197,7 +215,7 @@ static struct attribute *ddr_perf_events_attrs[] = { > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_collision_6, ID(3, 70)), > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_collision_7, ID(3, 71)), > IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pmon_full, ID(3, 72)), > - IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pm_wr_trans_filt, ID(3, 73)), > + IMX93_DDR_PMU_EVENT_ATTR(eddrtq_pm_wr_trans_filt, ID(3, 73)), /* imx93 specific*/ > > /* counter4 specific events */ > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_open_0, ID(4, 64)), > @@ -209,7 +227,7 @@ static struct attribute *ddr_perf_events_attrs[] = { > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_open_6, ID(4, 70)), > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_open_7, ID(4, 71)), > IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pmon_ld_rdq2_rmw, ID(4, 72)), > - IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_beat_filt, ID(4, 73)), > + IMX93_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_beat_filt, ID(4, 73)), /* imx93 specific*/ > > /* counter5 specific events */ > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_valid_start_0, ID(5, 64)), > @@ -244,9 +262,29 @@ static struct attribute *ddr_perf_events_attrs[] = { > NULL, > }; > > +static umode_t > +ddr_perf_events_attrs_is_visible(struct kobject *kobj, > + struct attribute *attr, int unused) > +{ > + struct pmu *pmu = dev_get_drvdata(kobj_to_dev(kobj)); > + struct ddr_pmu *ddr_pmu = to_ddr_pmu(pmu); > + struct imx9_pmu_events_attr *eattr; > + > + eattr = container_of(attr, typeof(*eattr), attr.attr); > + > + if (!eattr->devtype_data) > + return attr->mode; > + > + if (eattr->devtype_data != ddr_pmu->devtype_data) > + return 0; > + > + return attr->mode; > +} > + > static const struct attribute_group ddr_perf_events_attr_group = { > .name = "events", > .attrs = ddr_perf_events_attrs, > + .is_visible = ddr_perf_events_attrs_is_visible, > }; > > PMU_FORMAT_ATTR(event, "config:0-15"); > @@ -368,36 +406,28 @@ static void ddr_perf_counter_local_config(struct ddr_pmu *pmu, int config, > } > } > > -static void ddr_perf_monitor_config(struct ddr_pmu *pmu, int event, > - int counter, int axi_id, int axi_mask) > +static void imx93_ddr_perf_monitor_config(struct ddr_pmu *pmu, int event, > + int counter, int axi_id, int axi_mask) > { > u32 pmcfg1, pmcfg2; > + u32 mask[] = { MX93_PMCFG1_RD_TRANS_FILT_EN, > + MX93_PMCFG1_WR_TRANS_FILT_EN, > + MX93_PMCFG1_RD_BT_FILT_EN }; > > pmcfg1 = readl_relaxed(pmu->base + PMCFG1); > > - if (counter == 2 && event == 73) > - pmcfg1 |= PMCFG1_RD_TRANS_FILT_EN; > - else if (counter == 2 && event != 73) > - pmcfg1 &= ~PMCFG1_RD_TRANS_FILT_EN; > - > - if (counter == 3 && event == 73) > - pmcfg1 |= PMCFG1_WR_TRANS_FILT_EN; > - else if (counter == 3 && event != 73) > - pmcfg1 &= ~PMCFG1_WR_TRANS_FILT_EN; > - > - if (counter == 4 && event == 73) > - pmcfg1 |= PMCFG1_RD_BT_FILT_EN; > - else if (counter == 4 && event != 73) > - pmcfg1 &= ~PMCFG1_RD_BT_FILT_EN; > + if (counter >= 2 && counter <= 4) > + pmcfg1 = event == 73 ? pmcfg1 | mask[counter - 2] : > + pmcfg1 & ~mask[counter - 2]; > > - pmcfg1 &= ~FIELD_PREP(PMCFG1_ID_MASK, 0x3FFFF); > - pmcfg1 |= FIELD_PREP(PMCFG1_ID_MASK, axi_mask); > - writel(pmcfg1, pmu->base + PMCFG1); > + pmcfg1 &= ~FIELD_PREP(MX93_PMCFG1_ID_MASK, 0x3FFFF); > + pmcfg1 |= FIELD_PREP(MX93_PMCFG1_ID_MASK, axi_mask); > + writel_relaxed(pmcfg1, pmu->base + PMCFG1); > > pmcfg2 = readl_relaxed(pmu->base + PMCFG2); > - pmcfg2 &= ~FIELD_PREP(PMCFG2_ID, 0x3FFFF); > - pmcfg2 |= FIELD_PREP(PMCFG2_ID, axi_id); > - writel(pmcfg2, pmu->base + PMCFG2); > + pmcfg2 &= ~FIELD_PREP(MX93_PMCFG2_ID, 0x3FFFF); > + pmcfg2 |= FIELD_PREP(MX93_PMCFG2_ID, axi_id); > + writel_relaxed(pmcfg2, pmu->base + PMCFG2); > } > > static void ddr_perf_event_update(struct perf_event *event) > @@ -513,7 +543,7 @@ static int ddr_perf_event_add(struct perf_event *event, int flags) > ddr_perf_event_start(event, flags); > > /* read trans, write trans, read beat */ > - ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2); > + imx93_ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2); > > return 0; > } > -- > 2.34.1 >
On Fri, Mar 22, 2024 at 02:39:27PM +0800, Xu Yang wrote: > In current driver, the counter will start firstly and then be configured. > This sequence is not correct for AXI filter events since the correct > AXI_MASK and AXI_ID are not set yet. Then the results may be inaccurate. > > Fixes: 55691f99d417 ("drivers/perf: imx_ddr: Add support for NXP i.MX9 SoC DDRC PMU driver") > cc: <stable@vger.kernel.org> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> > > --- > Changes in v5: > - new patch > Changes in v6: > - no changes > Changes in v7: > - no changes > Changes in v8: > - add fix tag > --- > drivers/perf/fsl_imx9_ddr_perf.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c > index 011377c01dea..fab6596d3e28 100644 > --- a/drivers/perf/fsl_imx9_ddr_perf.c > +++ b/drivers/perf/fsl_imx9_ddr_perf.c > @@ -539,12 +539,12 @@ static int ddr_perf_event_add(struct perf_event *event, int flags) > hwc->idx = counter; > hwc->state |= PERF_HES_STOPPED; > > - if (flags & PERF_EF_START) > - ddr_perf_event_start(event, flags); > - > /* read trans, write trans, read beat */ > imx93_ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2); > > + if (flags & PERF_EF_START) > + ddr_perf_event_start(event, flags); > + > return 0; > } > > -- > 2.34.1 >
On Fri, Mar 22, 2024 at 02:39:28PM +0800, Xu Yang wrote: > i.MX95 has a DDR PMU which is almostly same as i.MX93, it now supports > read beat and write beat filter capabilities. This will add support for > i.MX95 and enhance the driver to support specific filter handling for it. > > Usage: > > For read beat: > ~# perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_rd_beat_filt2,axi_mask=ID_MASK,axi_id=ID/ > ~# perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_rd_beat_filt1,axi_mask=ID_MASK,axi_id=ID/ > ~# perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_rd_beat_filt0,axi_mask=ID_MASK,axi_id=ID/ > eg: For edma2: perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_rd_beat_filt0,axi_mask=0x00f,axi_id=0x00c/ > > For write beat: > ~# perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_wr_beat_filt,axi_mask=ID_MASK,axi_id=ID/ > eg: For edma2: perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_wr_beat_filt,axi_mask=0x00f,axi_id=0x00c/ > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> > > --- > Changes in v2: > - put soc spefific axi filter events to drvdata according > to franks suggestions. > - adjust pmcfg axi_id and axi_mask config > Changes in v3: > - no changes > Changes in v4: > - only contain imx95 parts > Changes in v5: > - improve imx95_ddr_perf_monitor_config() > - use write_relaxed to pair read_relaxed > Changes in v6: > - no changes > Changes in v7: > - no changes > Changes in v8: > - add definition IMX95_DDR_PMU_EVENT_ATTR > --- > drivers/perf/fsl_imx9_ddr_perf.c | 89 ++++++++++++++++++++++++++++++-- > 1 file changed, 86 insertions(+), 3 deletions(-) > > diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c > index fab6596d3e28..9dcab4192d6e 100644 > --- a/drivers/perf/fsl_imx9_ddr_perf.c > +++ b/drivers/perf/fsl_imx9_ddr_perf.c > @@ -17,9 +17,19 @@ > #define MX93_PMCFG1_RD_BT_FILT_EN BIT(29) > #define MX93_PMCFG1_ID_MASK GENMASK(17, 0) > > +#define MX95_PMCFG1_WR_BEAT_FILT_EN BIT(31) > +#define MX95_PMCFG1_RD_BEAT_FILT_EN BIT(30) > + > #define PMCFG2 0x04 > #define MX93_PMCFG2_ID GENMASK(17, 0) > > +#define PMCFG3 0x08 > +#define PMCFG4 0x0C > +#define PMCFG5 0x10 > +#define PMCFG6 0x14 > +#define MX95_PMCFG_ID_MASK GENMASK(9, 0) > +#define MX95_PMCFG_ID GENMASK(25, 16) > + > /* Global control register affects all counters and takes priority over local control registers */ > #define PMGC0 0x40 > /* Global control register bits */ > @@ -76,13 +86,23 @@ static const struct imx_ddr_devtype_data imx93_devtype_data = { > .identifier = "imx93", > }; > > +static const struct imx_ddr_devtype_data imx95_devtype_data = { > + .identifier = "imx95", > +}; > + > static inline bool is_imx93(struct ddr_pmu *pmu) > { > return pmu->devtype_data == &imx93_devtype_data; > } > > +static inline bool is_imx95(struct ddr_pmu *pmu) > +{ > + return pmu->devtype_data == &imx95_devtype_data; > +} > + > static const struct of_device_id imx_ddr_pmu_dt_ids[] = { > - {.compatible = "fsl,imx93-ddr-pmu", .data = &imx93_devtype_data}, > + { .compatible = "fsl,imx93-ddr-pmu", .data = &imx93_devtype_data }, > + { .compatible = "fsl,imx95-ddr-pmu", .data = &imx95_devtype_data }, > { /* sentinel */ } > }; > MODULE_DEVICE_TABLE(of, imx_ddr_pmu_dt_ids); > @@ -158,6 +178,9 @@ static ssize_t ddr_pmu_event_show(struct device *dev, > #define IMX93_DDR_PMU_EVENT_ATTR(_name, _id) \ > DDR_PMU_EVENT_ATTR_COMM(_name, _id, &imx93_devtype_data) > > +#define IMX95_DDR_PMU_EVENT_ATTR(_name, _id) \ > + DDR_PMU_EVENT_ATTR_COMM(_name, _id, &imx95_devtype_data) > + > static struct attribute *ddr_perf_events_attrs[] = { > /* counter0 cycles event */ > IMX9_DDR_PMU_EVENT_ATTR(cycles, 0), > @@ -204,6 +227,7 @@ static struct attribute *ddr_perf_events_attrs[] = { > IMX9_DDR_PMU_EVENT_ATTR(ddrc_ld_wiq_7, ID(2, 71)), > IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pmon_empty, ID(2, 72)), > IMX93_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_trans_filt, ID(2, 73)), /* imx93 specific*/ > + IMX95_DDR_PMU_EVENT_ATTR(eddrtq_pm_wr_beat_filt, ID(2, 73)), /* imx95 specific*/ > > /* counter3 specific events */ > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_collision_0, ID(3, 64)), > @@ -216,6 +240,7 @@ static struct attribute *ddr_perf_events_attrs[] = { > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_collision_7, ID(3, 71)), > IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pmon_full, ID(3, 72)), > IMX93_DDR_PMU_EVENT_ATTR(eddrtq_pm_wr_trans_filt, ID(3, 73)), /* imx93 specific*/ > + IMX95_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_beat_filt2, ID(3, 73)), /* imx95 specific*/ > > /* counter4 specific events */ > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_open_0, ID(4, 64)), > @@ -228,6 +253,7 @@ static struct attribute *ddr_perf_events_attrs[] = { > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_open_7, ID(4, 71)), > IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pmon_ld_rdq2_rmw, ID(4, 72)), > IMX93_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_beat_filt, ID(4, 73)), /* imx93 specific*/ > + IMX95_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_beat_filt1, ID(4, 73)), /* imx95 specific*/ > > /* counter5 specific events */ > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_valid_start_0, ID(5, 64)), > @@ -239,6 +265,7 @@ static struct attribute *ddr_perf_events_attrs[] = { > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_valid_start_6, ID(5, 70)), > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_valid_start_7, ID(5, 71)), > IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pmon_ld_rdq1, ID(5, 72)), > + IMX95_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_beat_filt0, ID(5, 73)), /* imx95 specific*/ > > /* counter6 specific events */ > IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_valid_end_0, ID(6, 64)), > @@ -430,6 +457,57 @@ static void imx93_ddr_perf_monitor_config(struct ddr_pmu *pmu, int event, > writel_relaxed(pmcfg2, pmu->base + PMCFG2); > } > > +static void imx95_ddr_perf_monitor_config(struct ddr_pmu *pmu, int event, > + int counter, int axi_id, int axi_mask) > +{ > + u32 pmcfg1, pmcfg, offset = 0; > + > + pmcfg1 = readl_relaxed(pmu->base + PMCFG1); > + > + if (event == 73) { > + switch (counter) { > + case 2: > + pmcfg1 |= MX95_PMCFG1_WR_BEAT_FILT_EN; > + offset = PMCFG3; > + break; > + case 3: > + pmcfg1 |= MX95_PMCFG1_RD_BEAT_FILT_EN; > + offset = PMCFG4; > + break; > + case 4: > + pmcfg1 |= MX95_PMCFG1_RD_BEAT_FILT_EN; > + offset = PMCFG5; > + break; > + case 5: > + pmcfg1 |= MX95_PMCFG1_RD_BEAT_FILT_EN; > + offset = PMCFG6; > + break; > + } > + } else { > + switch (counter) { > + case 2: > + pmcfg1 &= ~MX95_PMCFG1_WR_BEAT_FILT_EN; > + break; > + case 3: > + case 4: > + case 5: > + pmcfg1 &= ~MX95_PMCFG1_RD_BEAT_FILT_EN; > + break; > + } > + } > + > + writel_relaxed(pmcfg1, pmu->base + PMCFG1); > + > + if (offset) { > + pmcfg = readl_relaxed(pmu->base + offset); > + pmcfg &= ~(FIELD_PREP(MX95_PMCFG_ID_MASK, 0x3FF) | > + FIELD_PREP(MX95_PMCFG_ID, 0x3FF)); > + pmcfg |= (FIELD_PREP(MX95_PMCFG_ID_MASK, axi_mask) | > + FIELD_PREP(MX95_PMCFG_ID, axi_id)); > + writel_relaxed(pmcfg, pmu->base + offset); > + } > +} > + > static void ddr_perf_event_update(struct perf_event *event) > { > struct ddr_pmu *pmu = to_ddr_pmu(event->pmu); > @@ -539,8 +617,13 @@ static int ddr_perf_event_add(struct perf_event *event, int flags) > hwc->idx = counter; > hwc->state |= PERF_HES_STOPPED; > > - /* read trans, write trans, read beat */ > - imx93_ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2); > + if (is_imx93(pmu)) > + /* read trans, write trans, read beat */ > + imx93_ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2); > + > + if (is_imx95(pmu)) > + /* write beat, read beat2, read beat1, read beat */ > + imx95_ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2); > > if (flags & PERF_EF_START) > ddr_perf_event_start(event, flags); > -- > 2.34.1 >
On Fri, Mar 22, 2024 at 02:39:30PM +0800, Xu Yang wrote: > Add JSON metrics for i.MX93 DDR Performance Monitor. > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> > > --- > Changes in v7: > - new patch > Changes in v8: > - no changes > --- > .../arch/arm64/freescale/imx93/sys/ddrc.json | 9 +++++++ > .../arm64/freescale/imx93/sys/metrics.json | 26 +++++++++++++++++++ > 2 files changed, 35 insertions(+) > create mode 100644 tools/perf/pmu-events/arch/arm64/freescale/imx93/sys/ddrc.json > create mode 100644 tools/perf/pmu-events/arch/arm64/freescale/imx93/sys/metrics.json > > diff --git a/tools/perf/pmu-events/arch/arm64/freescale/imx93/sys/ddrc.json b/tools/perf/pmu-events/arch/arm64/freescale/imx93/sys/ddrc.json > new file mode 100644 > index 000000000000..eeeae4d49fce > --- /dev/null > +++ b/tools/perf/pmu-events/arch/arm64/freescale/imx93/sys/ddrc.json > @@ -0,0 +1,9 @@ > +[ > + { > + "BriefDescription": "ddr cycles event", > + "EventCode": "0x00", > + "EventName": "imx93_ddr.cycles", > + "Unit": "imx9_ddr", > + "Compat": "imx93" > + } > +] > diff --git a/tools/perf/pmu-events/arch/arm64/freescale/imx93/sys/metrics.json b/tools/perf/pmu-events/arch/arm64/freescale/imx93/sys/metrics.json > new file mode 100644 > index 000000000000..4d2454ca1259 > --- /dev/null > +++ b/tools/perf/pmu-events/arch/arm64/freescale/imx93/sys/metrics.json > @@ -0,0 +1,26 @@ > +[ > + { > + "BriefDescription": "bandwidth usage for lpddr4x evk board", > + "MetricName": "imx93_bandwidth_usage.lpddr4x", > + "MetricExpr": "(((( imx9_ddr0@ddrc_pm_0@ ) * 2 * 8 ) + (( imx9_ddr0@ddrc_pm_3@ + imx9_ddr0@ddrc_pm_5@ + imx9_ddr0@ddrc_pm_7@ + imx9_ddr0@ddrc_pm_9@ - imx9_ddr0@ddrc_pm_2@ - imx9_ddr0@ddrc_pm_4@ - imx9_ddr0@ddrc_pm_6@ - imx9_ddr0@ddrc_pm_8@ ) * 32 )) / duration_time) / (3733 * 1000000 * 2)", > + "ScaleUnit": "1e2%", > + "Unit": "imx9_ddr", > + "Compat": "imx93" > + }, > + { > + "BriefDescription": "bytes all masters read from ddr", > + "MetricName": "imx93_ddr_read.all", > + "MetricExpr": "( imx9_ddr0@ddrc_pm_0@ ) * 2 * 8", > + "ScaleUnit": "9.765625e-4KB", > + "Unit": "imx9_ddr", > + "Compat": "imx93" > + }, > + { > + "BriefDescription": "bytes all masters write to ddr", > + "MetricName": "imx93_ddr_write.all", > + "MetricExpr": "( imx9_ddr0@ddrc_pm_3@ + imx9_ddr0@ddrc_pm_5@ + imx9_ddr0@ddrc_pm_7@ + imx9_ddr0@ddrc_pm_9@ - imx9_ddr0@ddrc_pm_2@ - imx9_ddr0@ddrc_pm_4@ - imx9_ddr0@ddrc_pm_6@ - imx9_ddr0@ddrc_pm_8@ ) * 32", > + "ScaleUnit": "9.765625e-4KB", > + "Unit": "imx9_ddr", > + "Compat": "imx93" > + } > +] > -- > 2.34.1 >
On Fri, Mar 22, 2024 at 02:39:25PM +0800, Xu Yang wrote: > In current design, the user of perf app needs to input counter ID to count > events. However, this is not user-friendly since the user needs to lookup > the map table to find the counter. Instead of letting the user to input > the counter, let this driver to manage the counters in this patch. I think we still have to support the old interface so that we don't break those existing users (even if the driver just ignores whatever counter ID is provided in a backwards-compatible way). > This will be implemented by: > 1. allocate counter 0 for cycle event. > 2. find unused counter from 1-10 for reference events. > 3. allocate specific counter for counter-specific events. > > In this patch, counter attribute is removed too. To mark counter-specific > events, counter ID will be encoded into perf_pmu_events_attr.id. > > Reviewed-by: Frank Li <Frank.Li@nxp.com> > Signed-off-by: Xu Yang <xu.yang_2@nxp.com> > > --- > Changes in v6: > - new patch > Changes in v7: > - no changes > Changes in v8: > - add Rb tag > --- > drivers/perf/fsl_imx9_ddr_perf.c | 168 ++++++++++++++++++------------- > 1 file changed, 99 insertions(+), 69 deletions(-) > > diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c > index 0017f2c9ef91..b728719b494c 100644 > --- a/drivers/perf/fsl_imx9_ddr_perf.c > +++ b/drivers/perf/fsl_imx9_ddr_perf.c > @@ -245,14 +249,12 @@ static const struct attribute_group ddr_perf_events_attr_group = { > .attrs = ddr_perf_events_attrs, > }; > > -PMU_FORMAT_ATTR(event, "config:0-7"); > -PMU_FORMAT_ATTR(counter, "config:8-15"); > +PMU_FORMAT_ATTR(event, "config:0-15"); Sadly, this is a user-visible change so I think it will break old tools, won't it? Will
Hi Will, > > On Fri, Mar 22, 2024 at 02:39:25PM +0800, Xu Yang wrote: > > In current design, the user of perf app needs to input counter ID to count > > events. However, this is not user-friendly since the user needs to lookup > > the map table to find the counter. Instead of letting the user to input > > the counter, let this driver to manage the counters in this patch. > > I think we still have to support the old interface so that we don't break > those existing users (even if the driver just ignores whatever counter ID > is provided in a backwards-compatible way). > > > This will be implemented by: > > 1. allocate counter 0 for cycle event. > > 2. find unused counter from 1-10 for reference events. > > 3. allocate specific counter for counter-specific events. > > > > In this patch, counter attribute is removed too. To mark counter-specific > > events, counter ID will be encoded into perf_pmu_events_attr.id. > > > > Reviewed-by: Frank Li <Frank.Li@nxp.com> > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com> > > > > --- > > Changes in v6: > > - new patch > > Changes in v7: > > - no changes > > Changes in v8: > > - add Rb tag > > --- > > drivers/perf/fsl_imx9_ddr_perf.c | 168 ++++++++++++++++++------------- > > 1 file changed, 99 insertions(+), 69 deletions(-) > > > > diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c > > index 0017f2c9ef91..b728719b494c 100644 > > --- a/drivers/perf/fsl_imx9_ddr_perf.c > > +++ b/drivers/perf/fsl_imx9_ddr_perf.c > > @@ -245,14 +249,12 @@ static const struct attribute_group ddr_perf_events_attr_group = { > > .attrs = ddr_perf_events_attrs, > > }; > > > > -PMU_FORMAT_ATTR(event, "config:0-7"); > > -PMU_FORMAT_ATTR(counter, "config:8-15"); > > +PMU_FORMAT_ATTR(event, "config:0-15"); > > Sadly, this is a user-visible change so I think it will break old tools, > won't it? For imx ddr pmu, most of the people will use metrics rather event itself, and we have speficy the format of event parameters in metrics table. The parameters is also updated in this patchset. And to easy use for user, the counter should be hidden (transparent) to user after I had talk with Frank. Then, the user need't to look up the event table to find which counter to use. So this patchset will basically not break the usage of perf tools and will improve practicality. Thanks, Xu Yang > > Will
On Wed, Apr 10, 2024 at 07:39:46AM +0000, Xu Yang wrote: > > On Fri, Mar 22, 2024 at 02:39:25PM +0800, Xu Yang wrote: > > > In current design, the user of perf app needs to input counter ID to count > > > events. However, this is not user-friendly since the user needs to lookup > > > the map table to find the counter. Instead of letting the user to input > > > the counter, let this driver to manage the counters in this patch. > > > > I think we still have to support the old interface so that we don't break > > those existing users (even if the driver just ignores whatever counter ID > > is provided in a backwards-compatible way). > > > > > This will be implemented by: > > > 1. allocate counter 0 for cycle event. > > > 2. find unused counter from 1-10 for reference events. > > > 3. allocate specific counter for counter-specific events. > > > > > > In this patch, counter attribute is removed too. To mark counter-specific > > > events, counter ID will be encoded into perf_pmu_events_attr.id. > > > > > > Reviewed-by: Frank Li <Frank.Li@nxp.com> > > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com> > > > > > > --- > > > Changes in v6: > > > - new patch > > > Changes in v7: > > > - no changes > > > Changes in v8: > > > - add Rb tag > > > --- > > > drivers/perf/fsl_imx9_ddr_perf.c | 168 ++++++++++++++++++------------- > > > 1 file changed, 99 insertions(+), 69 deletions(-) > > > > > > diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c > > > index 0017f2c9ef91..b728719b494c 100644 > > > --- a/drivers/perf/fsl_imx9_ddr_perf.c > > > +++ b/drivers/perf/fsl_imx9_ddr_perf.c > > > @@ -245,14 +249,12 @@ static const struct attribute_group ddr_perf_events_attr_group = { > > > .attrs = ddr_perf_events_attrs, > > > }; > > > > > > -PMU_FORMAT_ATTR(event, "config:0-7"); > > > -PMU_FORMAT_ATTR(counter, "config:8-15"); > > > +PMU_FORMAT_ATTR(event, "config:0-15"); > > > > Sadly, this is a user-visible change so I think it will break old tools, > > won't it? > > For imx ddr pmu, most of the people will use metrics rather event itself, > and we have speficy the format of event parameters in metrics table. > The parameters is also updated in this patchset. > > And to easy use for user, the counter should be hidden (transparent) to > user after I had talk with Frank. Then, the user need't to look up the event > table to find which counter to use. > > So this patchset will basically not break the usage of perf tools and will > improve practicality. Sorry, but I don't agree. The original commit adding this driver (55691f99d417) gives the following examples in the commit message: For example: perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_rd_trans_filt,counter=2,axi_mask=ID_MASK,axi_id=ID/ perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_wr_trans_filt,counter=3,axi_mask=ID_MASK,axi_id=ID/ perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_rd_beat_filt,counter=4,axi_mask=ID_MASK,axi_id=ID/ I don't think these will work any more if we apply this patch. Will
On Wed, Apr 10, 2024 at 04:45:47PM +0100, Will Deacon wrote: > On Wed, Apr 10, 2024 at 07:39:46AM +0000, Xu Yang wrote: > > > On Fri, Mar 22, 2024 at 02:39:25PM +0800, Xu Yang wrote: > > > > In current design, the user of perf app needs to input counter ID to count > > > > events. However, this is not user-friendly since the user needs to lookup > > > > the map table to find the counter. Instead of letting the user to input > > > > the counter, let this driver to manage the counters in this patch. > > > > > > I think we still have to support the old interface so that we don't break > > > those existing users (even if the driver just ignores whatever counter ID > > > is provided in a backwards-compatible way). > > > > > > > This will be implemented by: > > > > 1. allocate counter 0 for cycle event. > > > > 2. find unused counter from 1-10 for reference events. > > > > 3. allocate specific counter for counter-specific events. > > > > > > > > In this patch, counter attribute is removed too. To mark counter-specific > > > > events, counter ID will be encoded into perf_pmu_events_attr.id. > > > > > > > > Reviewed-by: Frank Li <Frank.Li@nxp.com> > > > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com> > > > > > > > > --- > > > > Changes in v6: > > > > - new patch > > > > Changes in v7: > > > > - no changes > > > > Changes in v8: > > > > - add Rb tag > > > > --- > > > > drivers/perf/fsl_imx9_ddr_perf.c | 168 ++++++++++++++++++------------- > > > > 1 file changed, 99 insertions(+), 69 deletions(-) > > > > > > > > diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c > > > > index 0017f2c9ef91..b728719b494c 100644 > > > > --- a/drivers/perf/fsl_imx9_ddr_perf.c > > > > +++ b/drivers/perf/fsl_imx9_ddr_perf.c > > > > @@ -245,14 +249,12 @@ static const struct attribute_group ddr_perf_events_attr_group = { > > > > .attrs = ddr_perf_events_attrs, > > > > }; > > > > > > > > -PMU_FORMAT_ATTR(event, "config:0-7"); > > > > -PMU_FORMAT_ATTR(counter, "config:8-15"); > > > > +PMU_FORMAT_ATTR(event, "config:0-15"); > > > > > > Sadly, this is a user-visible change so I think it will break old tools, > > > won't it? > > > > For imx ddr pmu, most of the people will use metrics rather event itself, > > and we have speficy the format of event parameters in metrics table. > > The parameters is also updated in this patchset. > > > > And to easy use for user, the counter should be hidden (transparent) to > > user after I had talk with Frank. Then, the user need't to look up the event > > table to find which counter to use. > > > > So this patchset will basically not break the usage of perf tools and will > > improve practicality. > > Sorry, but I don't agree. The original commit adding this driver > (55691f99d417) gives the following examples in the commit message: > > For example: > perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_rd_trans_filt,counter=2,axi_mask=ID_MASK,axi_id=ID/ > perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_wr_trans_filt,counter=3,axi_mask=ID_MASK,axi_id=ID/ > perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_rd_beat_filt,counter=4,axi_mask=ID_MASK,axi_id=ID/ > > I don't think these will work any more if we apply this patch. Yang: keep compatible is important. Please try well's suggestion "if the driver just ignores whatever counter ID is provided in a backwards-compatible way)." If you have further question, you can ping directly. Please avoid use outlook to reply community email. It always append annoised "EXT". Frank > > Will
diff --git a/Documentation/devicetree/bindings/perf/fsl-imx-ddr.yaml b/Documentation/devicetree/bindings/perf/fsl-imx-ddr.yaml index 6c96a4204e5d..37e8b98f2cdc 100644 --- a/Documentation/devicetree/bindings/perf/fsl-imx-ddr.yaml +++ b/Documentation/devicetree/bindings/perf/fsl-imx-ddr.yaml @@ -30,6 +30,9 @@ properties: - items: - const: fsl,imx8dxl-ddr-pmu - const: fsl,imx8-ddr-pmu + - items: + - const: fsl,imx95-ddr-pmu + - const: fsl,imx93-ddr-pmu reg: maxItems: 1