Skip to content

Commit 049d919

Browse files
Joakim Zhangwilldeacon
authored andcommitted
drivers/perf: fsl_imx8_ddr: Correct the CLEAR bit definition
When disabling a counter from ddr_perf_event_stop(), the counter value is reset to 0 at the same time. Preserve the counter value by performing a read-modify-write of the PMU register and clearing only the enable bit. Signed-off-by: Joakim Zhang <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent dcde237 commit 049d919

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/perf/fsl_imx8_ddr_perf.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,17 +388,19 @@ static void ddr_perf_counter_enable(struct ddr_pmu *pmu, int config,
388388

389389
if (enable) {
390390
/*
391-
* must disable first, then enable again
392-
* otherwise, cycle counter will not work
393-
* if previous state is enabled.
391+
* cycle counter is special which should firstly write 0 then
392+
* write 1 into CLEAR bit to clear it. Other counters only
393+
* need write 0 into CLEAR bit and it turns out to be 1 by
394+
* hardware. Below enable flow is harmless for all counters.
394395
*/
395396
writel(0, pmu->base + reg);
396397
val = CNTL_EN | CNTL_CLEAR;
397398
val |= FIELD_PREP(CNTL_CSV_MASK, config);
398399
writel(val, pmu->base + reg);
399400
} else {
400401
/* Disable counter */
401-
writel(0, pmu->base + reg);
402+
val = readl_relaxed(pmu->base + reg) & CNTL_EN_MASK;
403+
writel(val, pmu->base + reg);
402404
}
403405
}
404406

0 commit comments

Comments
 (0)