From patchwork Thu Mar 7 23:09:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13586338 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D1BE9C54E58 for ; Thu, 7 Mar 2024 23:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=w0FHU+2Tw5FtU+xxCFXgVja2j7agVPp3eXi6ocUGLkU=; b=ElNo6pxiGBNLIV TpZFqPvDMZofROgObDgn7t8Xx1QevK1vR3IVcpcG9+p0TPDtva6yhHZgi2DoXA9suDunocHon/lSQ ljjOLhpSicUYXY9mXHFxAzSy5WJuqP/DJnX2X8z5LQqQCd1EI+8hNsguwFGo2TPlfiLyb7jMx9c6B MlULTRQI4Dg4D+B9hnFtqanz6uDyNquF12bMvnWTmT8aF34QlDct3JS+DTuAQnCurzh9aZ3IAyBRM L1XkRLuySY0VBtd/BhyBMDBjQpPJXkpZnQLBLLfvEwS15YLPQLK0SzKRGIPCC8C6bpw50Vip1g97S PyRrr20OoUG5DKWVVpmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1riMsW-00000006kwL-2Xt3; Thu, 07 Mar 2024 23:10:20 +0000 Received: from mail-bn8nam12on20701.outbound.protection.outlook.com ([2a01:111:f403:2418::701] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1riMsR-00000006kqw-2BRa for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2024 23:10:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z+yhcpa0v7wGPpPoxfhxvXRnUQh1FNNQU93zKHepp8ItqmomFbI+u1rpJJHgy02osVsTnX9/SKh18N7hU9RRny/PtEN+EOJK8A2/OMN7mGLmyhhD6q1kR2F7XyaJvxFc4E5zseJLP1kol9neBzhKFyUyx3IHGbfVyr82aojMUW010G0tjDlUBnSxZxIA6xPYdXM0JgCaNLyknAeeIWfIyMb5ibA/SqQWJ23VkR+Zb7sPWgiAKNgZ0ss83kTDlVPu4ZyyuJmNE6rLqrMNkFA9tGum5Pcwm+ouWjV42aLmitO+gPw8hBkU2I4bjEMR0Hyn9O7I9e+07a36C4Nw6txSTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Yz9PQEvFfwG6wVXiBGYiS73jbjIkADRgYDz8OtJmYoM=; b=jOqIdda4OrQbWTsjSQuoETlAcjxKgnRguKiVDltYWqeL9pmitnitw+qk6yUGdR42sFIxkp56vsYGwLFzPzUXbL+vYX2wf/EVWGHjwO0bDZDMH1CAV584R4+lfHV+uuU7beEYp26S8W+ToHYmZm5pJ1xkmCBXiW8N8jY+t9IAEtLK5qJSdjdSNaW03IY2XR4u2CXUIKYcArUeDmfzj+BDuDbt+h0/X+vH8uI6FWnYd6mslLhnZXZ/jFm7v/og3KYtAg0HZSH1LRlLwG+yN6vRWhH1UH3wK7p+Y9LWfhDdO6Nu1SUkQAtXCdImOhOgYZTfJ8m8IqH+oNc03DlG8BVy6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Yz9PQEvFfwG6wVXiBGYiS73jbjIkADRgYDz8OtJmYoM=; b=WJwRndHNBEaiJz6AA0tyhCvYvzrrGisVqZo7PsOwSBH3L9WuBq4nki7hQhrPG8o+nmGrtljFiIEHtt8WspBvPOGM+XwigNo2tg632ACKZunrUrxRHvUuAAfe9e5qncG54cZ+dnUWsV5ZTpMg4DHy3wGoG+Hxdf54mnxdxKegswg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from BL0PR01MB4226.prod.exchangelabs.com (2603:10b6:208:49::30) by BL3PR01MB7116.prod.exchangelabs.com (2603:10b6:208:33b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27; Thu, 7 Mar 2024 23:10:05 +0000 Received: from BL0PR01MB4226.prod.exchangelabs.com ([fe80::12be:916:b914:8b26]) by BL0PR01MB4226.prod.exchangelabs.com ([fe80::12be:916:b914:8b26%7]) with mapi id 15.20.7362.024; Thu, 7 Mar 2024 23:10:05 +0000 From: Ilkka Koskinen To: Robin Murphy , Will Deacon Cc: Mark Rutland , Jing Zhang , Ilkka Koskinen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] perf/arm-cmn: Enable support for tertiary match group Date: Thu, 7 Mar 2024 15:09:29 -0800 Message-ID: <20240307230929.6233-3-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240307230929.6233-1-ilkka@os.amperecomputing.com> References: <20240307230929.6233-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH0PR13CA0057.namprd13.prod.outlook.com (2603:10b6:610:b2::32) To BL0PR01MB4226.prod.exchangelabs.com (2603:10b6:208:49::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL0PR01MB4226:EE_|BL3PR01MB7116:EE_ X-MS-Office365-Filtering-Correlation-Id: ccb123db-7ca0-4f9d-b3b3-08dc3efbb9d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jOQtDABqmR9uIgWGtPO0Q3SqDtAVee7QHs6ZaC8EJN2o2opehU+naT90MKnEgzwXDFWtoX4TfZ0UchIc1FyP8OUnxSW98qqfSn4d+V0ywCPAt3iEZvaUz5soc/1pfC2IEW03RTWZ3eh3c7wc+jy2prLWpnWIWQbWrexfeK4KdMwVQtKtMmjL9yTgflOjQROjo8hUKo0AxvApEgugwv7I0PvXZknv8M4JubC2U0G/RYyolO3et51RozsmL8XK4C1dJxIhjY4JgD9cjmahrN67HM10SnkrRJi95VNU3ydOq4OzKFQf90rCLkN4sEJmT5qepJ67I97d8BiQdUiuOt7554oP8Lq8KBuA9aw+9Sxiwn7OKWCL9dDHomvAF2L5adk35gnkHfaM/X7RTjcVBx3MySAW4NS11blX/dgrRPU3fUHl/f5httEYRPhU6H0jrJEOtzMnFusrvgHYlcSgOcCLp8LNJRpxegGnt5TfcL7c79FbWtHtSHVSh0azA2kK8KFyKTm1zMntK4gT3X7T9gGEMzqI8vyRXHhvHj9vv4T6xbUirY5J/3MYgizlEMfZHv8vRaZzUgQsSLrkxEyLRiKBoeCVcAGVo1FAZYt09HJfX8DUKZXFo0Bn6Ahi5VI7cIe3y2qFueqtkOR+FcS/VdmgRdJcMmAdwHjgzbE/R8++sdy33KuQaKk5Lz9LyFE++itD//VKQQrOuh310PGBtE1QxReyguZv3awMG80zbAxvkdc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL0PR01MB4226.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9nvlRhMR1pricGk1g5+nC6ET+hQo8yN9gXsaQCMlYQfwzpEGr0qGmu25nAfKRjEPZcqoWo/2upxBMiRidyN27+HWNDwaAuJkY3Sh9F7PR1CEXvm5IGShePfhfC8lxzCVsnNHtOGoivf4WjwtD/hvJ9T0Xwm3Yk4+PgGBDZOApww2eVLf0TiwmL1lAPReYyM46gxH0cIwop1wC420d8ndorRqTtO/Emcs3Q2RkYY+LtLSewOwlcF2c9YWFaxUIM3Rzj48Pd5cixG/3a4rZiFHDSjo8Cz0/hEBipA4EVUG33856BmaIBEJUa+e0MMVPalnJYAFUJ32vp7y29l/2PqyQssZv9SV3//vDuTwyPCeQfj+EKnbwkeYSxE/8jZYYho7y1PDEFRov0wm6o1mrEB/iPLo2mwpjT8EMPKcEoreCh1M1gialF80XswJjSMAfdd5O0RRzeg22F3OsE/Yguf77VXW6a3Ggdk/KfHv3btAnlch1BEQo7HFx5uxSyt0vErnvc4996caD8+kxp95xWQAix2XK40I5X7XllFrQYRlAgUK9Z7TzJHksINrOfYkyMnnjKVtim1SW5WUkLqA6Y7bVqaxFDowCPOr4LsPLtJfKWvGPktUdCxAySrcC02oLnJbttskOOuS6qIi5CPbNLVDP0Rgjufxy5BTyZkrcKLi38WnTmdEzOshjukQPEmyiLc+415jOfG7K3NxGB7pmqoIJbOOOmMdSP/ghghqLP3Z0bnJoen6198GtXE56Lv0ITD6sFtA9KBXhPAV0OtYM2jqhFLOZvPToePy6IS9FHvYMGNt69AwplZ7yyJyIgWRgTAyNx7YUbwPg+DYJ40cRVQ7037MWzwYtm53azgwucyVq5Y9o5T7NGH8s9PdA3chQ8YNiowROvtjJzD2nr6eTST8wMhTjocnKH/WoLc8sXWn/MMIvIdt5F2wvajXpRaif+EUdMavBkMyHcoHIgaaIT0vPSPIhD6BcueCm1dlqxMjlyHHVc+OxQc8PbY1Pouag6xnmSqrtiSc/0Pov4glZIlIAu/PIpGECv7TSAk2CThQ9SBO+RCo65R8SbbrfGv5EgDQfD195iN/QKi/KV65p2CdLcp/stE4e/9+m81xCRV10Yg2DNU2eYvlw7QJISeBr8Tgp1uceuv0I9qlwKtGfz/Qf4N3XmbxR/VT5FW7lA1uTJNqWyMv+LFHFPURN5C9Zw9pvyXMPF31+d5t1H7MDRLH8Z6Su9D+h5FuZO7fAfUDuF1WHPmshNy2WXDBj1AfNDbTC41ggaJ1H1R1J8Q/OB2dr62hrp8h65MqhFIMcPud2lNcrekFuFKyuROZvxoHaE/xHtDK/7T5TQNyAI8db0Up6NHjDz9Ro0Zg7PvPfjh4LfYsMyn0CBtQCO1CW+C0XLgg1bFUzDHZZs5hi1Rlo/x1WArYczorAMc+wuNy7sov0/ihluZSinfp3AeK6Lxi++/ntjsva4ja6Ehc+QwASfpVkuXcVhWFN46JHMiYunnlT4fTWAu28bLcYlsCNfzVhAueZE4xllDJH++fEUdFgJteD6ixNbBPi0qkDePfPBybiB02sPLIgp34+J3kzkvPmaQ24FJ21O1eOWA4dugIRAL5fsWervbOFTxMRjzqy75FGtQ= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: ccb123db-7ca0-4f9d-b3b3-08dc3efbb9d6 X-MS-Exchange-CrossTenant-AuthSource: BL0PR01MB4226.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2024 23:10:05.7255 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: M/OLTt8qYmRLHp2ovRFi/AtIIxIRRn4okPTc5dQcHUNqv1G7Gg8dbv7sDpeyxRPwGPtiio0kCiQtcgPCj4PmLIWv0B5zs5XyyT2r1mD3bpqxjSXB8lO9+ZoIB+2KdWIm X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR01MB7116 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240307_151015_602989_EFDFBC92 X-CRM114-Status: GOOD ( 15.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for tertiary match group. Signed-off-by: Ilkka Koskinen --- drivers/perf/arm-cmn.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index 29d46e0cf1cd..4a4cbda94907 100644 --- a/drivers/perf/arm-cmn.c +++ b/drivers/perf/arm-cmn.c @@ -174,9 +174,8 @@ #define CMN_CONFIG_WP_COMBINE GENMASK_ULL(30, 27) #define CMN_CONFIG_WP_DEV_SEL GENMASK_ULL(50, 48) #define CMN_CONFIG_WP_CHN_SEL GENMASK_ULL(55, 51) -/* Note that we don't yet support the tertiary match group on newer IPs */ -#define CMN_CONFIG_WP_GRP BIT_ULL(56) -#define CMN_CONFIG_WP_EXCLUSIVE BIT_ULL(57) +#define CMN_CONFIG_WP_GRP GENMASK_ULL(57, 56) +#define CMN_CONFIG_WP_EXCLUSIVE BIT_ULL(58) #define CMN_CONFIG1_WP_VAL GENMASK_ULL(63, 0) #define CMN_CONFIG2_WP_MASK GENMASK_ULL(63, 0) @@ -1389,7 +1388,7 @@ static void arm_cmn_claim_wp_idx(struct arm_cmn *cmn, set_bit(2 * xp_idx + (wp_idx & 1), hw->wp_cfg); } -static u32 arm_cmn_wp_config(struct perf_event *event) +static u32 arm_cmn_wp_config(struct perf_event *event, int wp_idx) { u32 config; u32 dev = CMN_EVENT_WP_DEV_SEL(event); @@ -1399,6 +1398,10 @@ static u32 arm_cmn_wp_config(struct perf_event *event) u32 combine = CMN_EVENT_WP_COMBINE(event); bool is_cmn600 = to_cmn(event->pmu)->part == PART_CMN600; + /* CMN-600 supports only primary and secondary matching groups */ + if (is_cmn600) + grp &= 1; + config = FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_DEV_SEL, dev) | FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_CHN_SEL, chn) | FIELD_PREP(CMN_DTM_WPn_CONFIG_WP_GRP, grp) | @@ -1406,7 +1409,9 @@ static u32 arm_cmn_wp_config(struct perf_event *event) if (exc) config |= is_cmn600 ? CMN600_WPn_CONFIG_WP_EXCLUSIVE : CMN_DTM_WPn_CONFIG_WP_EXCLUSIVE; - if (combine && !grp) + + /* wp_combine is available only on WP0 and WP2 */ + if (combine && !(wp_idx & 0x1)) config |= is_cmn600 ? CMN600_WPn_CONFIG_WP_COMBINE : CMN_DTM_WPn_CONFIG_WP_COMBINE; return config; @@ -1919,12 +1924,14 @@ static int arm_cmn_event_add(struct perf_event *event, int flags) input_sel = CMN__PMEVCNT0_INPUT_SEL_XP + dtm_idx; } else if (type == CMN_TYPE_WP) { int tmp, wp_idx; - u32 cfg = arm_cmn_wp_config(event); + u32 cfg; wp_idx = arm_cmn_find_free_wp_idx(cmn, dtm, event); if (wp_idx < 0) goto free_dtms; + cfg = arm_cmn_wp_config(event, wp_idx); + tmp = dtm->wp_event[wp_idx ^ 1]; if (tmp >= 0 && CMN_EVENT_WP_COMBINE(event) != CMN_EVENT_WP_COMBINE(cmn->dtc[d].counters[tmp]))