Skip to content

Commit

Permalink
drivers/perf: fsl_imx8_ddr: Correct the CLEAR bit definition
Browse files Browse the repository at this point in the history
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 <qiangqing.zhang@nxp.com>
Signed-off-by: Will Deacon <will@kernel.org>
  • Loading branch information
Joakim Zhang authored and willdeacon committed Mar 2, 2020
1 parent dcde237 commit 049d919
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/perf/fsl_imx8_ddr_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,17 +388,19 @@ 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;
val |= FIELD_PREP(CNTL_CSV_MASK, 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);
}
}

Expand Down

0 comments on commit 049d919

Please sign in to comment.