From patchwork Fri Mar 29 01:32:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13609872 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 767A3CD128A for ; Fri, 29 Mar 2024 01:33:14 +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=InYL8z+AlIv1V6tj+E2FX2yyEoSWkdyNyt81lKaXNRU=; b=JO5HsZe9zbr11u zWkez2pWjlrlucObGzsyRdr5RY4k2DrFCIw92pYaNhCbT+hzb87wASnwh6lMyzUjC1dnoa2r1IvF+ cCoMw5nK9emXy+azMlHGDfBY3LLYu3yPSO/+k71vRIGDnPu6qvj2T1gB/HKwdg5GB3M0Tw2P3e0mb K2ugRlTdzSB8exIRheXI/k6o2gDj79l9aa5XgpYSRoJlYEp4ghpoNuWmpGWc2flj/YP/0QQyio5Bp r2fOSDchRaSL2RpyG53PExEGVR8VYpk3odck10QBxmpUd3UDJM+SqfVT3PMC2R/wQimsgUwQ28spb EOPZjmPQc8CKBzGJ/e9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq178-0000000GOHk-1RnT; Fri, 29 Mar 2024 01:33:02 +0000 Received: from mail-co1nam11on20701.outbound.protection.outlook.com ([2a01:111:f403:2416::701] helo=NAM11-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rq16y-0000000GOBw-0rCs for linux-arm-kernel@lists.infradead.org; Fri, 29 Mar 2024 01:32:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GqITA1LouALJWQmaMV0ViwNFD5ljTXS++aaPmdcyeF15KIoPa81icz77QQ4dTRjA2KTH3eCtv/G9vS1Vg9xyywxFS6glX9QnhAGoc1DJ24Zx5/JKCN3duv0KQLhdtpAXdYuC45oWYsUMG1iUDzaQ1RWEJ3yjdTbiE9+ZkpbJ9PcyEOzwyfM1O+h3NhLGSnBS5g67wmzNZlrh8FfFgWXi/LANGL/UazuWbCRlDaJkdUyWX6W45mLBhm2JtujUPLRrdMHoL1/N5eJC39cZWrsHW9muk7TDk0lzTlhJNd5R69lMq5lpWpPMb/UieFp41vsAReh8W5Cwi67DhkHflgb6bA== 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=yIlgrDq++UMPhf1VB0EHtOXrFD9q9CvhESCm85k9EgE=; b=KdvXTooXWV1mpeG8zSwSTj4PJxjEwYR3PEi3bagSyJWodAqjRRwptXDEcdEd2yyHG5GY1gU+HacLbbTmccJGPQhqpua5sQA7CDEZcAdFN2xbnl3ANUzlxq2OB9b8z8jx6AdnBWrFa8OsjELGu5eAH7otJnZKvcwmRk9BPTocViP8w6ldikWeu7zRRUHH3KK8w3YACUkMSkR5keZtjjEvqdZf6Y3zOx1JYAzxUlkCtvPs4bbWjW7/GnbD1KaJKf32LrQkDD+N15kEMYBPwS+Q4iOtVH6gtSIKzFMu+kEUuqEcUx4DQ82f7enIWXZyFl2IZAT4TteZJyhXi0UFK4mudA== 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=yIlgrDq++UMPhf1VB0EHtOXrFD9q9CvhESCm85k9EgE=; b=JLWKVD+zcZWtpKY6+tAzTfA8mYyw6P/qGcDTG08anUzDwaHBCQLvLedm+VNJ1jK5ODRCaHrfUR8PapK4ALDoJgbc3EYNScDqQejVEeJtyRgAlIritTzOGAjTFXVW5OFSS5/0lnOKtMAfQFg8nFDkECXk9day8EQEIFHtGdYV3HI= Received: from BL0PR01MB4226.prod.exchangelabs.com (2603:10b6:208:49::30) by DS7PR01MB7878.prod.exchangelabs.com (2603:10b6:8:81::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.32; Fri, 29 Mar 2024 01:32:48 +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.7409.038; Fri, 29 Mar 2024 01:32:47 +0000 From: Ilkka Koskinen To: Robin Murphy , Will Deacon Cc: Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jing Zhang , Ilkka Koskinen Subject: [PATCH v3 2/2] perf/arm-cmn: Enable support for tertiary match group Date: Thu, 28 Mar 2024 18:32:15 -0700 Message-ID: <20240329013215.169345-3-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329013215.169345-1-ilkka@os.amperecomputing.com> References: <20240329013215.169345-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH0PR13CA0008.namprd13.prod.outlook.com (2603:10b6:610:b1::13) To BL0PR01MB4226.prod.exchangelabs.com (2603:10b6:208:49::30) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL0PR01MB4226:EE_|DS7PR01MB7878:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SbG9qLf69RV3Fnf4b+OGbXFBCzBb7MIom/4VY0Zaa8TF6eVblRVeXaZVScbTKq8CIYxIMONmJ3vtRJGbUUhQC/y+KkDWHdqcCbU1ILGMRQ7w5XR1gk5WKe6EitvOFBp3G/FoSZhP1fp54huO2AIHfXM43qjlb2lHWzTQNdbjGOAc5T0FAU5H+sBiXL+7UEIGqdZZcQvSouXT3w+8TVKCjwWn1zBMy5v7MRO1lQS6SktVISkvA6l2n6t7KzqUvVM5HHSEgu0de0UCeyBKNmC1p2XyDzcC2Q3+rWZkpPTbWevRPniVXGtq0uIUwHJfnxnbDuMrwfpgtig7j4aqQF4hBz0ypg7AoQp0BDiDM1MVb/PMOCqKc/TjtiT6m7EznhhSbotfqgx8dyEw7S0Hb7d2tnTf5etDoDo2fZygGKSgUepKJk0HReiafJYC1MYLF6Uk1hAzb/t+4rR6z89tmv3mPM/Dyp3jl4AQH/6tePQGux+eAbeeKCZgvChBvuekc3fsRzjCoVttQ0JDjm8zjPRnfqu/zssXgvS2GOf3MGH2qNyOZ4BqtD0JxPdSHDonSKiV2J4ZMmE1tTgd9y8QE740yEPDXfEIbDuteIPhiF8IzwITd1AwcIZKnrXZX7pyJ6XoRZ194F/MRsotI44O8/OZurkFYDwjpwAsQtG5IFgFo0AZrT8xG4FJ3JYt3WKv4EYtiEt/RFX7pu84Imk+sHryXkaW4UcrHxdc5ICTkepx1OQ= 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)(366007)(376005)(1800799015)(52116005)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vxYU38GydlZDKK9eTTbvg+mPbf07/ZwL4A0OjJP+Vt3f4PbgKgbJ03Pl3YfTal3YVJ/GPVkjWL8DJM+vPqJO59l06l8f/ZFau4D9ZiKYjtCAqGPRKgDXYjJj9ULb7CD9lBSGzYBQ1sQ7y/OR0qX6L5vxK6nO4jkjcQIF9BMt/MP9rDs20hbYh2jHR2KVBCt8XEhYgGFck3v5/AMshoXDwEEm1ZdQ7YweetrazvF0LG6Up+lUa3wciOksdSyn1ZCnnA427Anvh6/c4rgrEjpsurMgobSobDkUHkxnmjRbY2fRObUXltZnrYDRJAFLcrKkwVpRVoFqukta3OQ00u/n79Zqo5zbNKHZxnL9zm3fam16yOBQEVDpuAwa8g0CmHy64tOXro+HGl6OM+zNiXv+rLbrubnpZwqH4xvAJQafqkKUz5V+/+AInxLqaFg5Llf0AY9e0XrauhqsGEVqOUMHl5X7dfYoKCqUShRWyXWFYPXZ2fP3sxZcXUAV6fatObZ8AUipw2iUSxRUZZ8IxCc7bcSD3RNeGhw+0IbczEzxowvlvp/+5eAnVlgdcoDbKRM/EM6TCyDB42QiMPVM3NBz3s8d1EQMqj2GdcF6FNE9tmpYJC8HXPiNvslh/GQa7470y5ZIsakCGnoiM4rPo7kfCCw9zhb/k4hrmCL1++GHg/Vl9aCaXRPMLRGMW/shHliUkfE/kZbvp/bP6CFbYKpCzlJMpAHA6px4FTlnAKJJx5TwLNa/hZlmNCYN+JIgqHJ0qVaisDjT9UWpvwRdJ9uHZ+9hAGhIY7md3OR4sWV6LIqYH+qq5546QrCAXfYGRrQeMDYJZ1xo0+NGhKqZsAJGSCGapZC1AXzYZtRS7vn2qsdSxM4cFggr2e+raPhWCnovwN7idE8ZeTm1N7NMVKnBpSY31NXl4S/WWkQ0Ruy+uHCRFgWOsgLCkOB/T9XhIHdIbk3EN1vtbye/BrdTKHtqDCjRb8Ftqm86MM2sDXTrqsE6fKJJaAO3p2mt63qSXH9qIhsLqwt87B3mC+KP1K66aTUqGJe5VZfp9Y1DF4RtgREH1Yl4A63TVV3YeFgvlvtc5U6zkjRfpPJNckWV5ygoDrHh5C16+QCj1TaLVu8Uv6y2lSYWcL+7iCfsboexJkC/S8XAdxqknfq0fGYVN2p9mkpUg8FamN9u3Nz7WzTR0KjaY0DjCP6nitAFROUmkQv2aU3uuz69MvDDZFbh6THGJFMa3d/gZzXEYgSy1JNVT/+669nLTJFsmJG1L4gkkvqIWYyPJkAYXFb1m9/6buNEoT3V715ETxjEAp2UBPStxidK5zDy6qDJVFivdFmjOJY+bhCsAYtKJ3iOkpIpuSF1iuIXJwQmei0S/WzZ6YhyebJJgP6TSRbYYcM9EVYi4lxtP3fmfb+liG+yUuVFMhd53wMp5vQQrRmfCrKtXrAMBVfwmoywkaza/I1DPWxOqUndkTe4CwzaW00KbXtki+RNxZArvq8Yhkn1iFjkznlkOZ1ktFHASA4tiuUK+cG+5t7lV3Fvax41cq8QjtEnTZM5KoeF9SrgHppR0i5m04GBUy5dwiJYpbnrDIDxvIGp6hAf1Lzk6RpuddgX6j1WRs0KSSeaPKiABz4UMePKboiJtBQ= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9bf73bd7-063d-4b83-a274-08dc4f9023b5 X-MS-Exchange-CrossTenant-AuthSource: BL0PR01MB4226.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Mar 2024 01:32:47.6464 (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: R0lKLplhGi/g1nPtOodfCYXCNQJSENvHtDEfowBHtIz4tptaSRNEoAgRDlyB64UJ5e2cMp620RB1FVZ+/98jZoaXYqHPcJiF76FBsliF2wceTXEU4lEdimXRhHRwoOOv X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR01MB7878 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240328_183252_301945_D8872C61 X-CRM114-Status: GOOD ( 14.69 ) 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 9f4a82861faa..3d7db1254753 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) @@ -1384,7 +1383,7 @@ static void arm_cmn_claim_wp_idx(struct arm_cmn_dtm *dtm, arm_cmn_set_wp_idx(hw->wp_idx, pos, wp_idx - CMN_EVENT_EVENTID(event)); } -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); @@ -1394,6 +1393,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) | @@ -1401,7 +1404,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; @@ -1898,12 +1903,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(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]))