Skip to content

Commit 71746c9

Browse files
rmurphy-armwilldeacon
authored andcommitted
perf/arm-cmn: Fix DTC reset
It turns out that my naive DTC reset logic fails to work as intended, since, after checking with the hardware designers, the PMU actually needs to be fully enabled in order to correctly clear any pending overflows. Therefore, invert the sequence to start with turning on both enables so that we can reliably get the DTCs into a known state, then moving to our normal counters-stopped state from there. Since all the DTM counters have already been unpaired during the initial discovery pass, we just need to additionally reset the cycle counters to ensure that no other unexpected overflows occur during this period. Fixes: 0ba6477 ("perf: Add Arm CMN-600 PMU driver") Reported-by: Geoff Blake <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/0ea4559261ea394f827c9aee5168c77a60aaee03.1684946389.git.robin.murphy@arm.com Signed-off-by: Will Deacon <[email protected]>
1 parent 7bd42f1 commit 71746c9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/perf/arm-cmn.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,9 +1899,10 @@ static int arm_cmn_init_dtc(struct arm_cmn *cmn, struct arm_cmn_node *dn, int id
18991899
if (dtc->irq < 0)
19001900
return dtc->irq;
19011901

1902-
writel_relaxed(0, dtc->base + CMN_DT_PMCR);
1902+
writel_relaxed(CMN_DT_DTC_CTL_DT_EN, dtc->base + CMN_DT_DTC_CTL);
1903+
writel_relaxed(CMN_DT_PMCR_PMU_EN | CMN_DT_PMCR_OVFL_INTR_EN, dtc->base + CMN_DT_PMCR);
1904+
writeq_relaxed(0, dtc->base + CMN_DT_PMCCNTR);
19031905
writel_relaxed(0x1ff, dtc->base + CMN_DT_PMOVSR_CLR);
1904-
writel_relaxed(CMN_DT_PMCR_OVFL_INTR_EN, dtc->base + CMN_DT_PMCR);
19051906

19061907
return 0;
19071908
}
@@ -1961,7 +1962,7 @@ static int arm_cmn_init_dtcs(struct arm_cmn *cmn)
19611962
dn->type = CMN_TYPE_CCLA;
19621963
}
19631964

1964-
writel_relaxed(CMN_DT_DTC_CTL_DT_EN, cmn->dtc[0].base + CMN_DT_DTC_CTL);
1965+
arm_cmn_set_state(cmn, CMN_STATE_DISABLED);
19651966

19661967
return 0;
19671968
}

0 commit comments

Comments
 (0)