All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] perf/imx_ddr: Correct the CLEAR bit definition
@ 2020-02-25 12:56 Joakim Zhang
  2020-02-25 12:56 ` [PATCH 2/2] perf/imx_ddr: Add stop counter support for i.MX8MP Joakim Zhang
  2020-03-02 11:25 ` [PATCH 1/2] perf/imx_ddr: Correct the CLEAR bit definition Will Deacon
  0 siblings, 2 replies; 9+ messages in thread
From: Joakim Zhang @ 2020-02-25 12:56 UTC (permalink / raw)
  To: will, mark.rutland, robin.murphy; +Cc: linux-imx, linux-arm-kernel

ddr_perf_event_stop will firstly call ddr_perf_counter_enable to disable
the counter, and then call ddr_perf_event_update to read the counter value.

When disable the counter, it will write 0 into COUNTER_CNTL[CLEAR] bit
which cause the counter value cleared. Counter value will always be 0
when update the counter.

The correct definition of CLEAR bit is that write 0 to clear the counter
value.

Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
---
 drivers/perf/fsl_imx8_ddr_perf.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c
index 95dca2cb5265..90884d14f95f 100644
--- a/drivers/perf/fsl_imx8_ddr_perf.c
+++ b/drivers/perf/fsl_imx8_ddr_perf.c
@@ -388,9 +388,10 @@ static void ddr_perf_counter_enable(struct ddr_pmu *pmu, int config,
 
 	if (enable) {
 		/*
-		 * must disable first, then enable again
-		 * otherwise, cycle counter will not work
-		 * if previous state is enabled.
+		 * cycle counter is special which should firstly write 0 then
+		 * write 1 into CLEAR bit to clear it. Other counters only
+		 * need write 0 into CLEAR bit and it turns out to be 1 by
+		 * hardware. Below enable flow is harmless for all counters.
 		 */
 		writel(0, pmu->base + reg);
 		val = CNTL_EN | CNTL_CLEAR;
@@ -398,7 +399,8 @@ static void ddr_perf_counter_enable(struct ddr_pmu *pmu, int config,
 		writel(val, pmu->base + reg);
 	} else {
 		/* Disable counter */
-		writel(0, pmu->base + reg);
+		val = readl_relaxed(pmu->base + reg) & CNTL_EN_MASK;
+		writel(val, pmu->base + reg);
 	}
 }
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-05-21  4:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25 12:56 [PATCH 1/2] perf/imx_ddr: Correct the CLEAR bit definition Joakim Zhang
2020-02-25 12:56 ` [PATCH 2/2] perf/imx_ddr: Add stop counter support for i.MX8MP Joakim Zhang
2020-03-02 11:24   ` Will Deacon
2020-03-03  5:34     ` Joakim Zhang
2020-04-16  9:51       ` Joakim Zhang
2020-05-20  7:51         ` Will Deacon
2020-05-21  4:57           ` Joakim Zhang
2020-03-02 11:25 ` [PATCH 1/2] perf/imx_ddr: Correct the CLEAR bit definition Will Deacon
2020-03-03  5:34   ` Joakim Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.