Skip to content

Commit ab33c66

Browse files
rmurphy-armwilldeacon
authored andcommitted
perf/arm-cmn: Enable per-DTC counter allocation
Finally enable independent per-DTC-domain counter allocation, except on CMN-600 where we still need to cope with not knowing the domain topology and thus keep counter indices sychronised across domains. This allows users to simultaneously count up to 8 targeted events per domain, rather than 8 globally, for up to 4x wider coverage on maximum configurations. Even though this now looks deceptively simple, I stand by my previous assertion that it was a flippin' nightmare to implement; all the real head-scratchers are hidden in the foundations in the previous patch... Signed-off-by: Robin Murphy <[email protected]> Link: https://lore.kernel.org/r/849f65566582cb102c6d0843d0f26e231180f8ac.1697824215.git.robin.murphy@arm.com Signed-off-by: Will Deacon <[email protected]>
1 parent 7633ec2 commit ab33c66

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

drivers/perf/arm-cmn.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ struct arm_cmn_val {
15701570
u8 dtm_count[CMN_MAX_DTMS];
15711571
u8 occupid[CMN_MAX_DTMS][SEL_MAX];
15721572
u8 wp[CMN_MAX_DTMS][4];
1573-
int dtc_count;
1573+
int dtc_count[CMN_MAX_DTCS];
15741574
bool cycles;
15751575
};
15761576

@@ -1591,7 +1591,8 @@ static void arm_cmn_val_add_event(struct arm_cmn *cmn, struct arm_cmn_val *val,
15911591
return;
15921592
}
15931593

1594-
val->dtc_count++;
1594+
for_each_hw_dtc_idx(hw, dtc, idx)
1595+
val->dtc_count[dtc]++;
15951596

15961597
for_each_hw_dn(hw, dn, i) {
15971598
int wp_idx, dtm = dn->dtm, sel = hw->filter_sel;
@@ -1638,8 +1639,9 @@ static int arm_cmn_validate_group(struct arm_cmn *cmn, struct perf_event *event)
16381639
goto done;
16391640
}
16401641

1641-
if (val->dtc_count == CMN_DT_NUM_COUNTERS)
1642-
goto done;
1642+
for (i = 0; i < CMN_MAX_DTCS; i++)
1643+
if (val->dtc_count[i] == CMN_DT_NUM_COUNTERS)
1644+
goto done;
16431645

16441646
for_each_hw_dn(hw, dn, i) {
16451647
int wp_idx, wp_cmb, dtm = dn->dtm, sel = hw->filter_sel;
@@ -1806,9 +1808,9 @@ static int arm_cmn_event_add(struct perf_event *event, int flags)
18061808
return 0;
18071809
}
18081810

1809-
/* Grab a free global counter first... */
1811+
/* Grab the global counters first... */
18101812
for_each_hw_dtc_idx(hw, j, idx) {
1811-
if (j > 0) {
1813+
if (cmn->part == PART_CMN600 && j > 0) {
18121814
idx = hw->dtc_idx[0];
18131815
} else {
18141816
idx = 0;
@@ -1819,10 +1821,10 @@ static int arm_cmn_event_add(struct perf_event *event, int flags)
18191821
hw->dtc_idx[j] = idx;
18201822
}
18211823

1822-
/* ...then the local counters to feed it. */
1824+
/* ...then the local counters to feed them */
18231825
for_each_hw_dn(hw, dn, i) {
18241826
struct arm_cmn_dtm *dtm = &cmn->dtms[dn->dtm] + hw->dtm_offset;
1825-
unsigned int dtm_idx, shift, d = 0;
1827+
unsigned int dtm_idx, shift, d = max_t(int, dn->dtc, 0);
18261828
u64 reg;
18271829

18281830
dtm_idx = 0;

0 commit comments

Comments
 (0)