From patchwork Tue Jun 18 00:50:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13701648 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 E1C73C27C79 for ; Tue, 18 Jun 2024 00:51:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=RgCVxU8gDmcDqevGGX50xb2hvEd7LRwWj8UR2cpUb68=; b=ix9VNf6m7TeA4k1kJa1WSyIJrw Nixy3aVpvgQXAX4sfimsB6UQcLq99JezZu7IDZMjky2sXyr3UIOc5s58TXaFsqJvYe0VLaQBCMOmt D8rAEPvaiKHSZaZYlqP3N9/LwqY2BRJ35SLF+H6JIkQRQhy/6d5zlRGDrGpbSoJkGotbOTE+pRx/d HBDwLkD2BUsj87mvWPCfA3XGp1qF8lq9/tLXmLlI8Oolje0kXzxmi4m66n8vldYgdavlUzqEuwD0E 8nmGO7a5X3RnwtYXGlhL+Flyxdd+ehBWv7xU3RRQbemQxyYFPeGmkM3poAuQf6SDiTG0cSVgFRIXg f/KXxO8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJN4d-0000000D7Kp-00WO; Tue, 18 Jun 2024 00:51:47 +0000 Received: from mail-mw2nam12on20709.outbound.protection.outlook.com ([2a01:111:f403:200a::709] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sJN4U-0000000D7Fi-1pWK for linux-arm-kernel@lists.infradead.org; Tue, 18 Jun 2024 00:51:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M4yK1LD5WTpVSLmMXjC2r8s9ro2izlWVl4Yf1sFGq/XTek9smB3FLc7cDArkzTa4w6pz5mtHvvdcW0xhd4GkNZC+Ykg/B6lDzVtDGJ9Cq+ZwG76ON576KHJCGx3Mwm34Sx967AxIr6LB1O9pzBceuqSrHWnBOt/uDGpe+y1nzoWJ25nOg9+6cUeCAKQNJC93f0rFBxWjSq+qTuTNpY4ARRWjYbqRpzRuqwA+5YsJcFDJFGFBOnZ+fG2kUoHVSv19aRSQd1qQrvvVvXq/N9rkpyrGWrVVvWXZ924437Ry1CrAQTNaDCgz12UCZUXPfZo+BVzUwplMPQ2QXGdgTSF4FA== 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=RgCVxU8gDmcDqevGGX50xb2hvEd7LRwWj8UR2cpUb68=; b=AlALk9QLaVq8OKu8CeZWl8ZdReBxyv6yAcSW4iqYNsgCPu673DDJGQ/CmPCwZxF/mOZZOYgKSaMiPR/V8k5qzWdXtGW8vptfmdWB2J5e5vLOSISnTcYwBdIDTZ/7CXbAdGoALX3y83OBX80K+AXew1O8PIwQpwXSwLA9Th6QWXBlCyxCWgwljEYQChbYHwJI9HzhDaYmT5fFfE7r96eu4CDpG6hcYDVTw923GY4i7Z0PER4K6HeMNn65Rho367fN1Hri3Fxkl7NEMl7LUzPHesg3MAqmW+HjlPSRNqM/t2aDXAhBaZdcVhZUyc9A6retywIigvFyg9F+gwwQ2+cqrw== 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=RgCVxU8gDmcDqevGGX50xb2hvEd7LRwWj8UR2cpUb68=; b=tfEUgCQweCtXlCxenwjvOrpYXA6Mgp8QE2jeSSmC2z1i33DZVZSg9aiDBl65fVgO8fux1WxCPvRxliOtHqhzgV/kK7AevLixl8L4qBJ89UD5DUN25t07K/zwWnDNT3RuNHQklZlxNAAvEMYPejmDeo/z85zLz0zR+nvE5kRAsy0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from MW4PR01MB6228.prod.exchangelabs.com (2603:10b6:303:76::7) by CYYPR01MB8410.prod.exchangelabs.com (2603:10b6:930:c9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Tue, 18 Jun 2024 00:51:35 +0000 Received: from MW4PR01MB6228.prod.exchangelabs.com ([fe80::13ba:df5b:8558:8bba]) by MW4PR01MB6228.prod.exchangelabs.com ([fe80::13ba:df5b:8558:8bba%3]) with mapi id 15.20.7677.030; Tue, 18 Jun 2024 00:51:35 +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 v4 2/2] perf/arm-cmn: Enable support for tertiary match group Date: Mon, 17 Jun 2024 17:50:56 -0700 Message-Id: <20240618005056.3092866-3-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240618005056.3092866-1-ilkka@os.amperecomputing.com> References: <20240618005056.3092866-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH2PR02CA0025.namprd02.prod.outlook.com (2603:10b6:610:4e::35) To MW4PR01MB6228.prod.exchangelabs.com (2603:10b6:303:76::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR01MB6228:EE_|CYYPR01MB8410:EE_ X-MS-Office365-Filtering-Correlation-Id: 205fce94-c872-443d-886b-08dc8f30ce0d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|376011|52116011|366013|38350700011; X-Microsoft-Antispam-Message-Info: Jyt/lJwsGOoI6bjr0zFG40ERIAFpsdurldYbvPcFugrsIqC5fE8tjjmp6XinSO29rNKqAGIfj8Okwz5htxXmDpBpN+B0o4HnIka9wuY/BqQCFS+Byu5ZTHeUw03eXmzk41gLrHvcr/pvHYjOcPIoChetTtcvb6TiQbSZP1mKv0fQqdj0FGNDJNA/+cLnEcD9opamzeTzhIw8z02Duw1sqN4b/t+2ONWquvhoM2unaf1iTXvs3B2ZsriQ8VLjollPSmYv96n1lCM0NUIQMtl/YaePAhvXrrxSewyTDcf3wdaUeah+50FAXwVMtmsyWohKmdzSd67PwXgnhVxELD9AeGiSscR02KyrL87aKxZwBmyCaHb902nZ9FDol0zS91XMGnePrISUUv3BiExZwvh5qNhW83ldHnq92Y0aUYRmMiKNT/syFICecUfOYEQ4XWMVw5nXh85zv0ZhY1DxtVEPcBok1rrnJedwX0Qigbzx/6tWmpoXKpzBKtiGmheq1OQuCYiuoCLLUrorx8hIYNIkccxRpT0ME1/ZUuam29+FKdLlZRTxfvPdv9hbHMHj4KrQqVDl0+IgvEW+3jX2SQRU6uoP66lPXhHQpiQe+QVhwUDkwNH6yAP05q2SQYawSjk+nOVXQwLcEjF2I/uMEoGyPmybFcPx+t2VVRvGBMEN4oyMxbjuVvLALvzpH94+SRU56a75b0EYPbrljS/dIQRL9yw09d5kR1tewvfKHGs0JqpAg2oIBb7gs+vOqSsrKs66ibkL7MtxgAOMFIgZbSG4AkxqOF3Ayg+TbhIA3ByQ8nHFlWW/Bm2+KfD7JDwsJG7wk1la/su5w0QhCytnViSzxiWM/Wcolg+Tpol8+DmxKOz1cUUXek4/+U8+5i6K2dLdBa6LvOUCLeMNxC3aNbsG9YT/s8kzgtXAutjDbjOHdzD+7tcoiMAOj9OwgFXPJWb8kRRscrkfoweCxftRDYhq94mle2OvqVVHpsMjCYA2IUyRxv4Nsh5x3E8MwuhNQqCZl5rEsDEgT5+porddumYvvsoBxzt+gDun9WkkHww3oqC3y1wSw4Xfb8YyZHnavIsXU2EDXLMefzNVu6v2d5QfuxRTJfSQYZS+/mZT/WyDVb2kit8OxlQgoTla6VyhcHwVOS7cOx3IQmM4px1aaEDm/f1iBKXxiZFloAcxtVkp+1w/i/2YnjPuQM7ZmjeH9CDzhbgMnXlf5Tt44NxqToXKZJ4iwoehPc8K4a0/4sgVZcImvLaU7dJxKY5w7k1hFgUAB/JlUfYoGubevH3HCPHi6sUrFfNpDPKwoT8/MW6y/BZZmMjyUp2785iOFInkp+chPoVZfF2+OaOuNLv4OJGkNPJVSLqBE9MpMa0Iyu/emOY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR01MB6228.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230037)(1800799021)(376011)(52116011)(366013)(38350700011);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AfuWgEyGd/FVYzG98QU0UO8HWCz7uaLDG5953Rbsb701yxqbijdzKGIjVM30yDigfZCADJIX31Pg+YZ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OQ+SEBrGHQK76Hk2A4xrmB9caG3xYhJ9sVVc1RD4NJ0AdjQ6rURNaQIVHVEa1QHsrwgCa92+9GkGdY8L1y3kBdiUVFqPeAr4TJxZIQR7KKwVcM6cOpN4hV3r/VSnY7F5exQZAXOnhExC5eZEYdypRZjKsQQspmBnXzCfJMdoJe6jyFJQLr4BLplCNxSOktShS1pz3XfbHBLAIBF3t07gG1V7KljAijpgLH0vVj9/ZfBRdIPiUj1bzUq/2xLIcCiX/vdHgQDx4myuBbWFoEfIriM05rSkao4ZZekLW0M646mfeLjI3cblP3l/9WDLONBhbFjQHgz+GuCijItRr4espM4aK2E97z1vs0Yh6AoqkdzlIMUAfj2DBPR8Xvmo3j9SrhbjVcqQzR2xaQ42kU3MY4WCVskfxTiJRQw0U7EkLy2ehwmILFitYC8lMzoeNOKUmcnfA0O3iGCVQyTIK6rfMIoJ5JpxKFHr1l/XtLr2Bw0+y4Q= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 205fce94-c872-443d-886b-08dc8f30ce0d X-MS-Exchange-CrossTenant-AuthSource: MW4PR01MB6228.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jun 2024 00:51:35.9020 (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: Fw35DyKlFrc0H/XY4p+5cAbXzS6yY5Kn/1v4Oe1Pkt4OBKmRBKTrrg9PNVPjDc9A66MjNBc8M1/5ZQrAp9MtcdSA+8rIgjvOuMnbHYHvRDRMuIRATgqtQCyJ3/N+yXIV X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR01MB8410 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240617_175138_547156_D7EC5588 X-CRM114-Status: GOOD ( 14.47 ) 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 f2349d23df57..c932d9d355cf 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]))