Skip to content

Commit f9a7a91

Browse files
ilkka-koskinenwilldeacon
authored andcommitted
perf/arm-cmn: Enable support for tertiary match group
Add support for tertiary match group. Signed-off-by: Ilkka Koskinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 4a11258 commit f9a7a91

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

drivers/perf/arm-cmn.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,8 @@
174174
#define CMN_CONFIG_WP_COMBINE GENMASK_ULL(30, 27)
175175
#define CMN_CONFIG_WP_DEV_SEL GENMASK_ULL(50, 48)
176176
#define CMN_CONFIG_WP_CHN_SEL GENMASK_ULL(55, 51)
177-
/* Note that we don't yet support the tertiary match group on newer IPs */
178-
#define CMN_CONFIG_WP_GRP BIT_ULL(56)
179-
#define CMN_CONFIG_WP_EXCLUSIVE BIT_ULL(57)
177+
#define CMN_CONFIG_WP_GRP GENMASK_ULL(57, 56)
178+
#define CMN_CONFIG_WP_EXCLUSIVE BIT_ULL(58)
180179
#define CMN_CONFIG1_WP_VAL GENMASK_ULL(63, 0)
181180
#define CMN_CONFIG2_WP_MASK GENMASK_ULL(63, 0)
182181

@@ -1384,7 +1383,7 @@ static void arm_cmn_claim_wp_idx(struct arm_cmn_dtm *dtm,
13841383
arm_cmn_set_wp_idx(hw->wp_idx, pos, wp_idx - CMN_EVENT_EVENTID(event));
13851384
}
13861385

1387-
static u32 arm_cmn_wp_config(struct perf_event *event)
1386+
static u32 arm_cmn_wp_config(struct perf_event *event, int wp_idx)
13881387
{
13891388
u32 config;
13901389
u32 dev = CMN_EVENT_WP_DEV_SEL(event);
@@ -1394,14 +1393,20 @@ static u32 arm_cmn_wp_config(struct perf_event *event)
13941393
u32 combine = CMN_EVENT_WP_COMBINE(event);
13951394
bool is_cmn600 = to_cmn(event->pmu)->part == PART_CMN600;
13961395

1396+
/* CMN-600 supports only primary and secondary matching groups */
1397+
if (is_cmn600)
1398+
grp &= 1;
1399+
13971400
config = FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_DEV_SEL, dev) |
13981401
FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_CHN_SEL, chn) |
13991402
FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_GRP, grp) |
14001403
FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_DEV_SEL2, dev >> 1);
14011404
if (exc)
14021405
config |= is_cmn600 ? CMN600_WPn_CONFIG_WP_EXCLUSIVE :
14031406
CMN_DTM_WPn_CONFIG_WP_EXCLUSIVE;
1404-
if (combine && !grp)
1407+
1408+
/* wp_combine is available only on WP0 and WP2 */
1409+
if (combine && !(wp_idx & 0x1))
14051410
config |= is_cmn600 ? CMN600_WPn_CONFIG_WP_COMBINE :
14061411
CMN_DTM_WPn_CONFIG_WP_COMBINE;
14071412
return config;
@@ -1898,12 +1903,14 @@ static int arm_cmn_event_add(struct perf_event *event, int flags)
18981903
input_sel = CMN__PMEVCNT0_INPUT_SEL_XP + dtm_idx;
18991904
} else if (type == CMN_TYPE_WP) {
19001905
int tmp, wp_idx;
1901-
u32 cfg = arm_cmn_wp_config(event);
1906+
u32 cfg;
19021907

19031908
wp_idx = arm_cmn_find_free_wp_idx(dtm, event);
19041909
if (wp_idx < 0)
19051910
goto free_dtms;
19061911

1912+
cfg = arm_cmn_wp_config(event, wp_idx);
1913+
19071914
tmp = dtm->wp_event[wp_idx ^ 1];
19081915
if (tmp >= 0 && CMN_EVENT_WP_COMBINE(event) !=
19091916
CMN_EVENT_WP_COMBINE(cmn->dtc[d].counters[tmp]))

0 commit comments

Comments
 (0)