[PATCH v6 5/7] perf: imx_perf: fix counter start and config sequence

From: Xu Yang
Date: Thu Mar 07 2024 - 05:02:59 EST


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.

Signed-off-by: Xu Yang <xu.yang_2@xxxxxxx>

---
Changes in v5:
- new patch
Changes in v6:
- no changes
---
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 4e8a3a4349c5..52234b97d0cb 100644
--- a/drivers/perf/fsl_imx9_ddr_perf.c
+++ b/drivers/perf/fsl_imx9_ddr_perf.c
@@ -543,12 +543,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