From patchwork Fri Jul 14 01:01:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13312815 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 6692FC001DE for ; Fri, 14 Jul 2023 01:03:13 +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=2LmdVSd/nSn4i3TwycF2oK+Ty3tmmPGnuP+wALcJgcQ=; b=e6BIsAf3wDUBsZ 447GViUlSkoD/S5XsnGfo7JShf5ZrXasw5Db1FKbF5XWdpG0jkFZ4VT/sgL2ZpUHXzgzqesbFBf9D ZDHSf49s/mq5KyWzIWfN+Re33fsFRfW7tldDIxAtMkexsN4l8M3Ey8nOTtvKcwiEfH4offgnOdlQl fZRY7k+wwmE26QNiAwCJrwN9RZnSMgxanrALo9/HePCtUucFs/sVwj8zaMOdot7stxQycjRmkXq1V ZLgdBLVwa0OeaNkFjo3ZrMdj/OI4jDw6YmtBjoD1TkloiGQyR/7KPc+hy3nm4phyvMKoAo2HCsWhr 1SkBmI5TueO8W2MNwG/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qK7Co-004fsm-04; Fri, 14 Jul 2023 01:02:46 +0000 Received: from mail-dm6nam10on20712.outbound.protection.outlook.com ([2a01:111:f400:7e88::712] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qK7Cc-004fox-04 for linux-arm-kernel@lists.infradead.org; Fri, 14 Jul 2023 01:02:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KgN0HferY5jf21gGY+3Cq4XL0myk3K4p82RORmPmwHRMz9nosUSTbRigq5xMFsuvs50fKmRY3WjLJO3vNYvJLH4LLpMezX99dQVa0mqB2rbOlb1luRl/Ai6M2tTduW2D0jiCIfP9MXomaRw0UTjdxywF5YvF+VhLVdipH94Ha9eT0zVLGZZQLSSO5JaGDv2ujMNGQaS4ZmqFo75uMwBQJtVB4ZMUdWsRkLLXhTVFj0mgiHvQDfNz5iCmzTiJSf8F6COTC7/KDyXwQPm+0pTNEZdxwmN7oYMw0OiKln5jUEWtwlcj+eOQX2C865II/lRGaTaHFYbH0gSv9CXfpA7/Rg== 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=UyYUQQp9yBc4hP0w+WM6rga4/CQa0V5X5PZ+PPakvrs=; b=OgDDkzNGpUTtLBijQWfFIB7xQX9oX1Tj58YUMKHeDHTB+A+QI9MTiD+wDv1LlWvpB7llpms66iPInjVtEksJd2FLUuj6tqNi2CsrPeksNsY2Es357TJEukpMmPpPOFEJIjpXBQi+KOpzT7FHrWg7Z6q4NDiFebG3NY2gDxpY2G8kMcpS4cHluhPLOCtwRA1W9njm+MpCA8EeW/qoRhalmwiJ/tc5XOtskXeKrzn79o6qacPi6d0p73I1tDVkma7KTd6PPG969pqsK5N2FOEfkEiPGV8kuk0sG63vCIj6GeJSbIXkqVi3gpdSYyimfKqeraoy6HI16VyKVbwFyKYOlw== 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=UyYUQQp9yBc4hP0w+WM6rga4/CQa0V5X5PZ+PPakvrs=; b=g/d+4zTXQh4OoDbHKvnOS6uGKb2OF5TnOHGU4D+bjVkryi1uplC/q+DFOgqMv4c7R84isfs67MiSq6BMAa4sq/NINGvJts/z3F3elZSdIm1N4tVSrpu/ylu7CLupAZD81lyGvMChiZkY8rUg9ANHNcmOVVM0cWzI9uuUSAbof4M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) by BY3PR01MB6611.prod.exchangelabs.com (2603:10b6:a03:36a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Fri, 14 Jul 2023 01:02:25 +0000 Received: from DM5PR0102MB3590.prod.exchangelabs.com ([fe80::235a:622:9239:3963]) by DM5PR0102MB3590.prod.exchangelabs.com ([fe80::235a:622:9239:3963%7]) with mapi id 15.20.6588.017; Fri, 14 Jul 2023 01:02:25 +0000 From: Ilkka Koskinen To: Will Deacon , Robin Murphy , Besar Wicaksono , Jonathan Cameron , Suzuki K Poulose , Mark Rutland , Jonathan Corbet Cc: Ilkka Koskinen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v5 1/4] perf: arm_cspmu: Split 64-bit write to 32-bit writes Date: Thu, 13 Jul 2023 18:01:38 -0700 Message-Id: <20230714010141.824226-2-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230714010141.824226-1-ilkka@os.amperecomputing.com> References: <20230714010141.824226-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH0P223CA0013.NAMP223.PROD.OUTLOOK.COM (2603:10b6:610:116::30) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR0102MB3590:EE_|BY3PR01MB6611:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e29187d-a754-43b8-178c-08db8405fc93 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kd5LZAYiQ6Lgo7MVla34/8WlwTAEnrsf/WbGyOaXmwUkhnq2iXVb4lMn5v2GTgOE+5799l5sCoWZNXl9DIDgzxGD4adq3nt7po66+2U+h1am6rO9l0uYFysVBywf1lUWCH8LHUoWEUdny8XWdJSdGXWRd0i7r1H5fsA4txHn/b7XGpwEkG66Rw/U4pcAAt2yNAFGSoaU+59kuUwh+t8pYzWb/vhaVtTq/UUYg5hPQ/kgcOO87lwSiNV3yJXnTJVvf6IcmCRV8tbEMifkg/jW7dggak4FQpnre60MfVZcKZOQkGBvRuEAF+HBmuFgNgpirWJXJo8tDRTwfQLaD8t9yVhOPu5iGY7SrXk2/q/jUQSOgyO3dxziJQnv1z/xbaro+7QIW5Wvi3/yzokrRYG4e8SRxziyR4Cz12z7uVwfbmkBVr1BQTdyPfxx8zxNA/jnQJb5Vxbz4pkirlzJy8CMXftoiH92YC6z+C6rh1karT+aPZCrEvYJUvOnxEJjpYhlNcaCwuyEeUN0bkCvbEktltCIHpBzofA2iUt4Zgb7rNY/cGDW9ydJaYrMaUJPNR6c+xW8VV0oaJTFGnxTdaXXDoOFqUvurDhk7bqhglthNsKmHcHFl05jZnNxv1DRM3sY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR0102MB3590.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(346002)(136003)(39850400004)(376002)(451199021)(2906002)(38100700002)(38350700002)(6512007)(83380400001)(186003)(2616005)(26005)(1076003)(86362001)(6506007)(5660300002)(8676002)(8936002)(4744005)(7416002)(110136005)(478600001)(6486002)(52116002)(6666004)(41300700001)(66946007)(66556008)(66476007)(316002)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BGzk/j4u/X1AVOBZPe682S2I8XmnbqEWAGbkcIEkENyMU9qx81XvM2i1q8NQb5MIuVl3iXG0stII0B+U+KRfrkvb8ZVo6i17NWesZdbJN8YGGYPxhZT+jnJi0jOZYP8+2pb6Z6hY4477jVIQ43M7oEk2Uy7e369BHb1A4mRtT3yfFuJKUOkygikAKg3DkmQtfZB8oyLWZpPFQg5mp912cFe4xbNp/Y6JiiWGegoU8vR6wTTL5G1FABWPnQDWKJiSkHqt+71Xd5XW18+gZzS8M4LBiQ+99/ou9jOvVDA+lEb+68U0Xgvr56uGnbMt5gYzFhpo+69tWaS6A8+nyZVVGgvqoY2QxQx4W6/8/8S8vlvWYBXYUu5kYVApaj1MBf9a/hh65Q2qLBRUtjrKNbIw9Q0WC967q9EvkP7PywifZkTrZywgkxcBroRdrUja+NYNtUvMEfACO5kiaxC+pVmOwJAAcJzpLQn9x1SKk6MHvXToWEtyhM+J/QpYhVwxyCb4S3S6jpkofoG1gHtgfjSiNaiU5Uz6MhD3gJsKLqL5mVbPtlSgFulu24uLElgyBbRG9x7dk4f9Nq8bWc4yX598qdJpskfa4Il3KUxW4WTRN/R3ZQ8prWfUtbExGDAZ2oOF4kWXFY3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-178c-08db8405fc93 X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 01:02:25.1959 (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+wi/Wgs2LAVthooEQ1PuD0IBFpKqx6zJsutQXPFymyxLjccluSphvHHrvnTIfeF7CB6DVia/1xeFCh8YGzFxMX+XvEFeyYs2lfLhAgEzv01ILAaJRY4NC2VKY5H3aoB X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY3PR01MB6611 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_180234_071970_DE5139C9 X-CRM114-Status: GOOD ( 11.80 ) 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 Split the 64-bit register accesses if 64-bit access is not supported by the PMU. Signed-off-by: Ilkka Koskinen Reviewed-by: Besar Wicaksono --- drivers/perf/arm_cspmu/arm_cspmu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c index e2b7827c4563..0f517152cb4e 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -696,7 +696,10 @@ static void arm_cspmu_write_counter(struct perf_event *event, u64 val) if (use_64b_counter_reg(cspmu)) { offset = counter_offset(sizeof(u64), event->hw.idx); - writeq(val, cspmu->base1 + offset); + if (cspmu->has_atomic_dword) + writeq(val, cspmu->base1 + offset); + else + lo_hi_writeq(val, cspmu->base1 + offset); } else { offset = counter_offset(sizeof(u32), event->hw.idx); From patchwork Fri Jul 14 01:01:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13312816 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 C28EAC001DE for ; Fri, 14 Jul 2023 01:03:16 +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=Fzh/Bd8dI9mtYHCXjvSE/duU8SlQvyN7IUU5YBzq39I=; b=uSqemDYKFTXxkw VmrlpVRpT8YD+9DO49Ef4dLXRdKpCqxijIPcB105vI3M3MC36GJS4T7/ZENkh1qV3V7zclpQGTeN8 eBb3BTH/LVPrO5IHsVyfSM+amZyLfJcE6LmdUG6ZGHDhdZ5a/+YDJIE51S5sEeK3twxl1pj7qKuUB BE0Wgwfrc96FFWjWK2Fnw1D689n+i2CnqLuGXzn39wEm8ke6c6rZ5NXSy4KpCDqGZWmQFU3TgRk4z das4p4Ws8VaqcT4c7rkal0uawa8qyUpNaUZzrJrxt8oO9NdP1Xr8h4VjlWME3M8xe69ntici+SxaA hM7B1Jz9FqGyETF2F4jg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qK7Co-004ftO-1s; Fri, 14 Jul 2023 01:02:46 +0000 Received: from mail-dm6nam10on20712.outbound.protection.outlook.com ([2a01:111:f400:7e88::712] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qK7Cd-004fox-2L for linux-arm-kernel@lists.infradead.org; Fri, 14 Jul 2023 01:02:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fHeU2yNLQDMVsU6RgKmeoOMkijXIkLhVg2rCgH75qH+xg1d/Vol6fL7kqn+eCyBS+ua4HWDJpy4z3QOpHonWSD4aXFs+iyl7b++phSWfuKX8Ubb4Wt4ofW8SGB2duHXpqkdFcAVGSgYVFSfgXx/cculF1oOlQbWGQecj9pO3KTskkjA7TDBhUuxxG+ecVLAUM+yBfgwQ7Gk/TE0bW3i+V5yOP3T0mPgMutKlxNPXZlBBr+neXkDV9DDf7Sfgt6Czsf9FNlPtPimoQaV7tl3sOgh3s0BoqtjkCeQlhNsWgmdRyEwbxhvwn/OXfd/VdZ6gFBUdFAm/moSNT4DlbvhjHg== 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=Qoqy0gmISfnAljfEMv75zDnA84+ti8B1BA7M8aLiHP0=; b=JTeonWsYPwZ9gGlm9+kfV9XeU16G829FanVORThq+RLCKfhCzkF78dY3dd3RMSQO3VOKXetwtjE3U/PFz3naboIKxnKAvjJ39U0etW3oHhJsjuDs7MZjSB8KwyXhsE3mBWilNzegif+t37h9WvzG5eCf8f+gxw9jI1j2PunoribPzmQ6Dxdl7ZQrUKOw4bXfNKwUz7UZ0HuBQnJBrMPUfV+2rVePs92WkUUFn0XpscrcimV5MDkbGHcARaGLY5WQ4nc+89ajsFJ5JvKMlIvzb6P5pMuz4RdfJPAOwbIk6Z/QKGWLfKD6HWtPVf2sJeCSOPYBC6UvE9VlPl//1wOM9w== 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=Qoqy0gmISfnAljfEMv75zDnA84+ti8B1BA7M8aLiHP0=; b=HNuVm+K1RvW/QGsC3Jhp9OV+/GKIAcWTorNfpvWH5+18F+YlRDKlcpTTby+ck3u6QrMgQ81fItd05mBSxK26TlydASVmmmpI5lvTf9Cnh3H+iikztYU3VzEBLQQ1Onufp68NDna+GJiwA0dgnpCdDEmkyVbp5bjR+aRTBl+YIbg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) by BY3PR01MB6611.prod.exchangelabs.com (2603:10b6:a03:36a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Fri, 14 Jul 2023 01:02:29 +0000 Received: from DM5PR0102MB3590.prod.exchangelabs.com ([fe80::235a:622:9239:3963]) by DM5PR0102MB3590.prod.exchangelabs.com ([fe80::235a:622:9239:3963%7]) with mapi id 15.20.6588.017; Fri, 14 Jul 2023 01:02:28 +0000 From: Ilkka Koskinen To: Will Deacon , Robin Murphy , Besar Wicaksono , Jonathan Cameron , Suzuki K Poulose , Mark Rutland , Jonathan Corbet Cc: Ilkka Koskinen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v5 2/4] perf: arm_cspmu: Support implementation specific filters Date: Thu, 13 Jul 2023 18:01:39 -0700 Message-Id: <20230714010141.824226-3-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230714010141.824226-1-ilkka@os.amperecomputing.com> References: <20230714010141.824226-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH0P223CA0013.NAMP223.PROD.OUTLOOK.COM (2603:10b6:610:116::30) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR0102MB3590:EE_|BY3PR01MB6611:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d4e5565-fa4b-4140-e6ec-08db8405fe6f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: blLD09utF7Y4Q84tvg5mA0Pa+ug8T5C1vuxOzC2305qBuxWOUg+J88j/GOuBBUmuSu2xKlGAIR3i1FhAzjIZFotdb3cbS+FPBAZ461bsfCZEnGl6a/jD7YU3GqtmazUB/BTohQxGDZO71ztNSu91A0C2H5nrbBrtADVaAFq/kzOamYbsNh6oKqL+5bftM0gT9eRntxKN7hjPK0ys+Hs/GX3f66JniIjppTJWzE+BbcY8jha3PpZMG3fIaJn9mTpt6lIOwx9akhME+/q9OIHALo+FEwPCkEX86l+5LKSX+JNGwdbYU5j6DpkW9TjVQUcOmEHuc9bxbbCDFug+sm+dAREq4LpJTX3889L6ZieFDb8V9Y7iVRtCK1naH2kb4DK4+6lxO/yWIlfoCmqDCijkMao6Rz/ZZ98lyGGBJ/VbHxD7aHNd+4vePRNTO9xoUQbHZsFHVamozeDESC6/n65SzBGdtJKpO8fU+j6aPaQjTr0fGRVTdDcgtt/jWna2t/gMFHSrdgb2wX9HMRst+WD0Zc3leFUBC2b+teaSrHuMyfNvgP8H88O6LB5l579V1dz9nLdbhGAhM2y5afKYb/dxnnvQo5sadBYxVeCW5hShg3Q= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR0102MB3590.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(346002)(136003)(39850400004)(376002)(451199021)(2906002)(38100700002)(966005)(38350700002)(6512007)(83380400001)(186003)(2616005)(26005)(1076003)(86362001)(6506007)(5660300002)(8676002)(8936002)(7416002)(110136005)(478600001)(6486002)(52116002)(6666004)(41300700001)(66946007)(66556008)(66476007)(316002)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aAiIPmHOdsrvaWZkkgRuoExrV2NXHE+sTjPLOgEHhJGEDrDr1+BpSDZCFnXeBps+FIHL0Ol5CYYLeVYIB/R6xLWpYSept0hxLfhqzXgEs+xD26ckok6XEJwf5F8KFCJWNnGCuGu3ZGGNfREtw/LYHGRY+PZsJPu8Lcll8rPD5DYFJJnVBsqZZejaHGJjCuBXnzTluV/jbP4GBFRPztjOOCxiMt2hIkxDosFNVm3pVSfGrTsSPioqyh5wb8JJ9T6m+KkoGg26eBvAZfUrGTD1MimJyMdyQCITVInUxKedAgBFyMogl41leql9tM2NroRZnBMhpErvncvMxb92xa54w2YNc54YlYwxxlCYV47dJOv0E9rGeyBHyZ0xlXlJoAORShUIGkOATxVaf4Wtjpp9/y+cA9Y+u4o6xW8KHI9sKxrWy8UF8Cr1irojdyIY5gCvP1mGeOukVFvz3/DNFpxxZC6WB+2AR1QcRMC82/9ZXYblVFlMhFNzx63lQkOgptwMlyaYRA8pLQu/+hZeFNPW3vst9crMv1Y49N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orOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d4e5565-fa4b-4140-e6ec-08db8405fe6f X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 01:02:28.3131 (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: 0r5Na3f7pflSwPBg19EXTN0hoi8jCjxaIe/1ZLQis4y4IMMll4xudE6oxnPiC2tQfGar8xIAE6aJjAFOYn0UQe7MAhUFq0Z2/OX5wsyRyZ96di49QOct+uGLCq0i9qq5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY3PR01MB6611 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_180235_765576_FA2C670A X-CRM114-Status: GOOD ( 13.30 ) 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 ARM Coresight PMU architecture specification [1] defines PMEVTYPER and PMEVFILT* registers as optional in Chapter 2.1. Moreover, implementers may choose to use PMIMPDEF* registers (offset: 0xD80-> 0xDFF) to filter the events. Add support for those by adding implementation specific filter callback function. [1] https://developer.arm.com/documentation/ihi0091/latest Signed-off-by: Ilkka Koskinen Reviewed-by: Besar Wicaksono --- drivers/perf/arm_cspmu/arm_cspmu.c | 8 ++++++-- drivers/perf/arm_cspmu/arm_cspmu.h | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c index 0f517152cb4e..fafd734c3218 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -117,6 +117,9 @@ static unsigned long arm_cspmu_cpuhp_state; +static void arm_cspmu_set_ev_filter(struct arm_cspmu *cspmu, + struct hw_perf_event *hwc, u32 filter); + static struct acpi_apmt_node *arm_cspmu_apmt_node(struct device *dev) { return *(struct acpi_apmt_node **)dev_get_platdata(dev); @@ -426,6 +429,7 @@ static int arm_cspmu_init_impl_ops(struct arm_cspmu *cspmu) CHECK_DEFAULT_IMPL_OPS(impl_ops, event_type); CHECK_DEFAULT_IMPL_OPS(impl_ops, event_filter); CHECK_DEFAULT_IMPL_OPS(impl_ops, event_attr_is_visible); + CHECK_DEFAULT_IMPL_OPS(impl_ops, set_ev_filter); return 0; } @@ -792,7 +796,7 @@ static inline void arm_cspmu_set_event(struct arm_cspmu *cspmu, writel(hwc->config, cspmu->base0 + offset); } -static inline void arm_cspmu_set_ev_filter(struct arm_cspmu *cspmu, +static void arm_cspmu_set_ev_filter(struct arm_cspmu *cspmu, struct hw_perf_event *hwc, u32 filter) { @@ -826,7 +830,7 @@ static void arm_cspmu_start(struct perf_event *event, int pmu_flags) arm_cspmu_set_cc_filter(cspmu, filter); } else { arm_cspmu_set_event(cspmu, hwc); - arm_cspmu_set_ev_filter(cspmu, hwc, filter); + cspmu->impl.ops.set_ev_filter(cspmu, hwc, filter); } hwc->state = 0; diff --git a/drivers/perf/arm_cspmu/arm_cspmu.h b/drivers/perf/arm_cspmu/arm_cspmu.h index 83df53d1c132..d6d88c246a23 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.h +++ b/drivers/perf/arm_cspmu/arm_cspmu.h @@ -101,6 +101,9 @@ struct arm_cspmu_impl_ops { u32 (*event_type)(const struct perf_event *event); /* Decode filter value from configs */ u32 (*event_filter)(const struct perf_event *event); + /* Set event filter */ + void (*set_ev_filter)(struct arm_cspmu *cspmu, + struct hw_perf_event *hwc, u32 filter); /* Hide/show unsupported events */ umode_t (*event_attr_is_visible)(struct kobject *kobj, struct attribute *attr, int unused); From patchwork Fri Jul 14 01:01:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13312814 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 93642C001B0 for ; Fri, 14 Jul 2023 01:03:11 +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=D2TIQxz/II5A4rsgzNN1Dg3a0GtOL5a5xZcelyuBILA=; b=iVdeRVXGaVnyQh BI9lFEguxyLf4zwe5SeUcz0fQ3jg+FrmCjruMn5drHu7UY1HafFOeJrfbXq8pB4M00D4tJ1dv6S4x zVwiACd5i4GISWgIWcgKz3sQ3hDPPzBiTDfKrWTJ+gx77aaeWWlI+p+AKPpJ2xumPMIs5783s0SrG tqLG8Mm7HHGDsicZ6Y4Xf4I/gbdPlDZNG4oa7SISbA/n42jtt0TD4lOC9yWr+zkXCZ42A9hXq5YsM Tjgljtu2iDrjoLvitZ8DoD4Vyz2IOeAMsDCikn8Kjt7FNnDEkHQ8XviuB/Z/FMj5gXIqP5FXtHUt5 6ruNQK0GSxmgOwsfaWIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qK7Cp-004ftn-0a; Fri, 14 Jul 2023 01:02:47 +0000 Received: from mail-dm6nam10on20712.outbound.protection.outlook.com ([2a01:111:f400:7e88::712] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qK7Cf-004fox-1U for linux-arm-kernel@lists.infradead.org; Fri, 14 Jul 2023 01:02:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZmEY7TvI9bnz0cTMlwVyy2i9GRMvm/h7xNthtzeSHl9sFtCoaUgZukrLv0mx3DTtMuYpU/QqsciWG4iEs+cCPAgRfbo5Y3IqKwfGWlf65bNon+8W2h6dFOc3THu7sA3Mb+8IKHHfUQY5BaevdvqX37+Rf+pfOSi+cbIk5UxG2JwJprTLYcREDL6uIDUWJfhN1fiF4dnbLG5Mgu7FqFCvhngXeZiyFTjaALO7SIDHZPfP6EYzsPSOLrWQeOo400ygpNUtmoU4iiR7zYy0J6BFVVFYuuolEVKd5W/llH69Unvan0VQ7wh7UcljTmpRpLY52Cn1zS+ecpomBkt6wyyPUw== 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=+9tazuVe05QCK17nT3MvqQqUmm72WRzCSQgnqL1GZGM=; b=QZURTLfi6MOeCPNrtrAlEeFdhQn+UgZC3d9/zWKOu38Vm9w+oJziN/Zz+F9bzcDuOQ9cqWXZvP6cll0yBga7gSwsZjGBUo6Vo/fXtCsmnhq6NOrsJSPdTkvVbYkz+S7UYJw6vmYIIOFb9lQYlq9KZcaEDAb/gcijNmK37qx40xdWBeBeJDCuUR3Nxk+0JFRkYt8GJv4ZOkEcEj+OCc1Ipe8Au6Quw5QLE6XsHRsxd7r1S+ybBxkFwpNVoecaXAiURZ3BAhoPzLgZT2hPWF6GTMjpDk1WIf1V6u2/dMgpzQGxi7c3jBeSZY6B7ikNgAKhSeWEQW/+eTxUgFVf0vMg5w== 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=+9tazuVe05QCK17nT3MvqQqUmm72WRzCSQgnqL1GZGM=; b=afUr4LR8ytU7YvSkWMALrkgsykVssMNCu60GY3wme04hMlOoIFvXuZetjaaMDrTsLTr5zA+tBlFSfsnkR8I0g+nHcjMKeWuiZ+WOWEfRGQBgDZ7TvRB2xaZPMSHlGYTku+Ot1ITGl5GrxwI+XBCXlCW2OW6s4v0LdfRq1Gn38cU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) by BY3PR01MB6611.prod.exchangelabs.com (2603:10b6:a03:36a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Fri, 14 Jul 2023 01:02:31 +0000 Received: from DM5PR0102MB3590.prod.exchangelabs.com ([fe80::235a:622:9239:3963]) by DM5PR0102MB3590.prod.exchangelabs.com ([fe80::235a:622:9239:3963%7]) with mapi id 15.20.6588.017; Fri, 14 Jul 2023 01:02:31 +0000 From: Ilkka Koskinen To: Will Deacon , Robin Murphy , Besar Wicaksono , Jonathan Cameron , Suzuki K Poulose , Mark Rutland , Jonathan Corbet Cc: Ilkka Koskinen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v5 3/4] perf: arm_cspmu: Support implementation specific validation Date: Thu, 13 Jul 2023 18:01:40 -0700 Message-Id: <20230714010141.824226-4-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230714010141.824226-1-ilkka@os.amperecomputing.com> References: <20230714010141.824226-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH0P223CA0013.NAMP223.PROD.OUTLOOK.COM (2603:10b6:610:116::30) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR0102MB3590:EE_|BY3PR01MB6611:EE_ X-MS-Office365-Filtering-Correlation-Id: dccc69be-d871-44f6-b83f-08db8406002d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kx4b5ouMq/YFSKJVYW96DTkOe9jF6CldRekkQKm52kNqaO++H9O2fRzB6urOBOGnt0KrE+L7vag3PcWwIVm3trG7makW8z0lydx6kB+eHTJssEypr83C+dRdPyImmVVl0ZGBjzNGYI120X5d4t1RBP6vka2T728BODh8XvjijQZ8xNkn3xtBEWTNUaRyg5WLkevBmf57nAtv5+BAzBjapbjho/uy0ssNeQkFJLKcXy+1PQBvwZAxSQ2lUMNl3V+1CYnawn0FDmHe0UPdBWwi0Cz/qdEXLXi1NA1hWkglSfGiJzgiF5qgSLfSCXzsaFptlcb/6DX2LBAgOQCJVpqwcLoKMg4DqU8EnTWwnbQRfoyBGzlpi6qNUX37iC2Jgt75Hb3BcpNLj9ZHBFSD00ZeycpmpRSAa1Coq5yYvTEwTufqrYXhwl1pM+Pn/9EIx2QAE5YRwTAHERO7AY3ttwyxrFu+YXYgY504IbpymbAbDJgFmP1TtHDAKj+ajs70SnX3Io3Ev1Ac1dV5Jo3SX2igYImce11/2FYE+SaiWwJcxqgskdf5Fw2iCGDXFc4Jiv19b+4SgmxESjH2JTb3m5AqKrLO+eTWjVsqC7sJymfu/3Za3048ijLLssiQl45rNLMO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR0102MB3590.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(346002)(136003)(39850400004)(376002)(451199021)(2906002)(38100700002)(38350700002)(6512007)(83380400001)(186003)(2616005)(26005)(1076003)(86362001)(6506007)(5660300002)(8676002)(8936002)(7416002)(110136005)(478600001)(6486002)(52116002)(6666004)(41300700001)(66946007)(66556008)(66476007)(316002)(4326008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0c7sVpTBWFN2ChyTz119wBvWNXTXcmHh8Gw2ZD8NNrUH7E8USNnzjOAu99GyMfGESYnIFIxERTe9C+M8CZoA5/i5fPqSH0arszcb4w7BWcjy2+xaGvkZP5vwELziwTV9jHsCSDe44PRXAyac/GDjEqAL5fzMiG1tBKRTNhdCbBVgxvLlFZbK4+bDlOSZCacyQ9/krUjDXMY950epQPqJD9ACkagAd2jsiijK023FV2ej18vxzqSdADDHUgzOY24iRtROIE0oCqe7LKYivCx3BdB1Rcrx7T0kop6KsapquVNk2VJb+KyxsJzkhr8foW6ZvjHOYzI1gOQGWe3uc0JsUggLl/9nuMjsmUANgvSpjaKtIk4Vgg19utKjjNehUiwtaQwgzqkdSHHUl7tkMHy61NCgvyvH4b4KgvpkehImvwklsZf4UnF7FnnX5o8Hg/7JmuzNegzrOlClHlVvdpZZ8R56B2uBfKNyaPyulaj52CUZ3cmHJELtHPh8T/o35WTusqD49y9/Y9as6NULvy8B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63EWi5Fe2j634bNpAhVw= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: dccc69be-d871-44f6-b83f-08db8406002d X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 01:02:31.2553 (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: FFNDnIvJ1DniGw68Z/UZMvSgbAKGw6z7nUAgguYeH8XR2Mq4SjFR6Xccx9dD/LD3tRWUMUB/MryvID/Ov3RDG0dpMMh7Gw3rkqAM41z4R1Sj5wbFDX/7dn4OImT5rT5Z X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY3PR01MB6611 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_180237_499067_F634C20A X-CRM114-Status: GOOD ( 13.82 ) 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 Some platforms may use e.g. different filtering mechanism and, thus, may need different way to validate the events and group. Signed-off-by: Ilkka Koskinen Reviewed-by: Jonathan Cameron --- drivers/perf/arm_cspmu/arm_cspmu.c | 8 +++++++- drivers/perf/arm_cspmu/arm_cspmu.h | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c index fafd734c3218..471d6d7ac81a 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -553,7 +553,7 @@ static void arm_cspmu_disable(struct pmu *pmu) static int arm_cspmu_get_event_idx(struct arm_cspmu_hw_events *hw_events, struct perf_event *event) { - int idx; + int idx, ret; struct arm_cspmu *cspmu = to_arm_cspmu(event->pmu); if (supports_cycle_counter(cspmu)) { @@ -587,6 +587,12 @@ static int arm_cspmu_get_event_idx(struct arm_cspmu_hw_events *hw_events, if (idx >= cspmu->num_logical_ctrs) return -EAGAIN; + if (cspmu->impl.ops.validate_event) { + ret = cspmu->impl.ops.validate_event(cspmu, event); + if (ret) + return ret; + } + set_bit(idx, hw_events->used_ctrs); return idx; diff --git a/drivers/perf/arm_cspmu/arm_cspmu.h b/drivers/perf/arm_cspmu/arm_cspmu.h index d6d88c246a23..5070d34c2285 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.h +++ b/drivers/perf/arm_cspmu/arm_cspmu.h @@ -104,6 +104,9 @@ struct arm_cspmu_impl_ops { /* Set event filter */ void (*set_ev_filter)(struct arm_cspmu *cspmu, struct hw_perf_event *hwc, u32 filter); + /* Implementation specific event validation */ + int (*validate_event)(struct arm_cspmu *cspmu, + struct perf_event *event); /* Hide/show unsupported events */ umode_t (*event_attr_is_visible)(struct kobject *kobj, struct attribute *attr, int unused); From patchwork Fri Jul 14 01:01:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13312817 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 09707C001DF for ; Fri, 14 Jul 2023 01:03:19 +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=wjnpXjcoHwMVZ86+8LUEWqkYEks2F5HuR81rPvGFSNs=; b=ditzI1sW8vPBM8 9hJ8e9yiuuDwgWDTB8bO/z2bFY/Qd8AV35nQcHzQl+MbSWXL+BLwf6CIYoqgMualWldidbX5S82jv r3ri+XUkspUm6W4tPw3hWlk4CosGVxB3r/m67TH5Q5WRHbSyy+XBoOqcXor2U2qv2iIFtONfr0W7I Xc8MSqDdg5Y2thhDYulCOTvE2S8IbHUT5ya8MX6oZFo4/vYk+KT+qP+FLw8QpXVnVsK+NrdQNSxV7 nYk8hQxI3NLYELeYI5tRSYd04n3wUP9N/bdWzwl3h8e6Uf79UCGY2pONUs/jgv+qXHuzHr1zMM6tN 1DHHBUliMqhT+kJRwEpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qK7Cp-004fu8-2O; Fri, 14 Jul 2023 01:02:47 +0000 Received: from mail-dm6nam10on20712.outbound.protection.outlook.com ([2a01:111:f400:7e88::712] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qK7Cg-004fox-2w for linux-arm-kernel@lists.infradead.org; Fri, 14 Jul 2023 01:02:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XIO2aaLgwdQjH7RjFcYSVSMzeETjDkeKNjy5RzIz+8SCs1zrGcyrJWcf4yUX1WY7Dle7wVyw1baUS4TLEE+22cYa7pJppUs4zCky0BZCkyUzAju43Pyie5/SVOty9k++W4nUpBhC1Ce2WoiowkUQ/KQpq17qZgTz7Hw2uUDyIu/WGjhZSR5I0opB8HDh0LkjElhV8/WB8U8G0fos6jppAIdLdfk9JFKeRaIwJnPy+8mcKJbHFmxtdxOQhTCH9LmRbC51eUu6UD65oTiFaHqaZz2Kp8O0dKxBxRBgtlECk94wCKnANpMAA2Xc8dUbUOF06iBkeeU3Q9UDu8INjL2D9w== 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=KIA3BobmIQp2sWJuWbi2lQbPJe7Nqnxq9l9pxYxcgAA=; b=GI4BLaMhw8OaKNlGi25uu75+PXqO1HjyY+iXSbcg2N+zGNr7B4DzRc8qoa74qgeaR8lGf2K57r05BqN1fX4Ul0gJvGITrxj+tazsrMj9/ri8rifg/PNPz4n7aLUT+61NNgWopwCCJjOYkQJFycMnnaZDuBZNTAUFwvzakKBPOnh9u0D5pKT0Gtlf/gAVs7IZK23AGhgZ9eMIGNw5MknOtCJcVXu3SvqotZ5tH4h+0vLggJdOJaci4MB/1TH2icdcnO6vN27caaFPXCHKMwZ3WLolIhiiJahGUxlMsSuHWFbqpAYPi2qvz7PwsPOloP0TpkiU6esoq2EU21MfwBwsxQ== 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=KIA3BobmIQp2sWJuWbi2lQbPJe7Nqnxq9l9pxYxcgAA=; b=E8FSmHRwwtmeXmgmTm7Q8GZ7F10qK/ILE81yjRsZ6vYgW0YUSsKzHmqTpKgXyna9onK0CiEhyD4C4tD48RjAcKHHBY6QCAchpR1QJ2Q3GuagawPpXCr76g6rGUBsEG0a9SAkIr3sfcYafPzS9QoWnuvYT7xpatHf0YxBVGfz4Jk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) by BY3PR01MB6611.prod.exchangelabs.com (2603:10b6:a03:36a::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.27; Fri, 14 Jul 2023 01:02:35 +0000 Received: from DM5PR0102MB3590.prod.exchangelabs.com ([fe80::235a:622:9239:3963]) by DM5PR0102MB3590.prod.exchangelabs.com ([fe80::235a:622:9239:3963%7]) with mapi id 15.20.6588.017; Fri, 14 Jul 2023 01:02:35 +0000 From: Ilkka Koskinen To: Will Deacon , Robin Murphy , Besar Wicaksono , Jonathan Cameron , Suzuki K Poulose , Mark Rutland , Jonathan Corbet Cc: Ilkka Koskinen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v5 4/4] perf: arm_cspmu: ampere_cspmu: Add support for Ampere SoC PMU Date: Thu, 13 Jul 2023 18:01:41 -0700 Message-Id: <20230714010141.824226-5-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230714010141.824226-1-ilkka@os.amperecomputing.com> References: <20230714010141.824226-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH0P223CA0013.NAMP223.PROD.OUTLOOK.COM (2603:10b6:610:116::30) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR0102MB3590:EE_|BY3PR01MB6611:EE_ X-MS-Office365-Filtering-Correlation-Id: c243c8a1-345e-41be-5b22-08db84060260 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bsNT27R3ZCnXzHg/J8CZewj68WhbnaeNwXe5W6BrsmAZAue5trt/+63Wvi+T77fNun+SyGWAbijas8of/Szka4I9yoFljgXWZ2Hee9ZpCt3lnJzltK1zWr1D9HIx3oVGoorcOKdGcu3ukGwzmZpKQqnZn8hCoW/pZpO+aBziN1uin8njem9BJgz26Yf2EZKtNxKCUK4H9gyh6iUPaeV1Gq3LVUxwlOlwKsEtv8rthNyPnzsLHptbHYOQIacBpCKVDLPGN8GwF+oTqH/M2swUgf2Gq7xGH6lK2A1tRJ+uCPzlH0g4xLd4d2ab5+Ap4EqpFrgAMNsle+Hu4yyCpe2hvjF017FwQwjMM2sKV1xlDiLixepww4i3vTR9FTTJhEnBvrSlVU2LzLhlfNgbqW1tBBFktXbU22GD33ii1SFCiHr4lOgu4bxk7XZxGu0Nwop1eJVqTnwxdhgk+FowTwE412MDNX0jh2MzyqMJy3+GIDksD05QPAfNdfEVfAwjO/KCHzVHiy+jb/5Kh0Ug3fugaFmZfozV4WTP704IXZHQj1KM6IUrLy+gJqLMPnza0RfXD7qrFgBzreRlnodLWuyMXFMr2vOz/KXFCOsyMZ6jNfqCMeI6KSNNLAFGBHYjBFg3 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR0102MB3590.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(346002)(136003)(39850400004)(376002)(451199021)(2906002)(38100700002)(38350700002)(6512007)(83380400001)(186003)(2616005)(26005)(1076003)(86362001)(6506007)(5660300002)(8676002)(8936002)(7416002)(30864003)(110136005)(478600001)(6486002)(52116002)(6666004)(41300700001)(66946007)(66556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X3IZeW582UFlnx4gzY8UwsJ2pgV35AjrpGZOAD+ZRx4bEqm0SO+KCuc711a7FeoaYcTlbIqbcWVBRlSQ42505gQEkT0JyCcT/6jgwqGjtnZmTkNsY8vIf3OkZWAf6nGXYHb9CQuYaPGmKW1UZ6jazDNEo7so4NMvjsfC//EYySpms6FGk/WLDYZFZcFD+96VRR9zUqMzPzQNSV9+4aQwjb2QXJRfstl+0vTmcZct1dYTYuZ6Ht6sPdyZN0d3oWnMM2WGQfqH3Oq6SAu8BjuafGDGTw7+/xpQRZBzOxxJk/0k5lARK60XvMmr3w5Q1IE8LRE+WJgUIQmRLUSFojFW25aAGbc4xcCYg22Sr53765YGHAjzJSR/aWGKyMAG0VtP9yaXAbfxPoAAEqK/zdN80je1TuvOosEdainbu4Vn4kZuLkgDnChjhx4LBB/IINblSji3GsOFOguFrN2KrVpPZIVe2vRy9KfKXe8QYiAFenuP5yEbCdZSWkfU6RgilHiwzKrAV9cQ0AF5xvCM4iRujVMVtDs+u+/MxpPeyJ0YLU6q3VKbG6WqGl5ipUn+GQKbKAHu3w1vxbQhD/wtAsk8iYe/68xX1sjZGAkuvhEjKT7+llDDXA0olWq781Ycb4+Q== X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: c243c8a1-345e-41be-5b22-08db84060260 X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2023 01:02:34.9309 (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: kMki6SCdhjcaS+cU5TrfgGwzuf4zL46po50ZpIFOmbGSJK3XU8VQ3ho2x0Ou8b0C0ZkPSCDfap7Drg3pFQSt1EQohU7AEUjO5kZw5qi0EiJRnUmIJHlo3CcTWA8+RZkA X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY3PR01MB6611 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230713_180238_955755_C73BA570 X-CRM114-Status: GOOD ( 19.04 ) 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 Ampere SoC PMU follows CoreSight PMU architecture. It uses implementation specific registers to filter events rather than PMEVFILTnR registers. Signed-off-by: Ilkka Koskinen --- .../admin-guide/perf/ampere_cspmu.rst | 29 +++ drivers/perf/arm_cspmu/Makefile | 2 +- drivers/perf/arm_cspmu/ampere_cspmu.c | 243 ++++++++++++++++++ drivers/perf/arm_cspmu/ampere_cspmu.h | 17 ++ drivers/perf/arm_cspmu/arm_cspmu.c | 8 + 5 files changed, 298 insertions(+), 1 deletion(-) create mode 100644 Documentation/admin-guide/perf/ampere_cspmu.rst create mode 100644 drivers/perf/arm_cspmu/ampere_cspmu.c create mode 100644 drivers/perf/arm_cspmu/ampere_cspmu.h diff --git a/Documentation/admin-guide/perf/ampere_cspmu.rst b/Documentation/admin-guide/perf/ampere_cspmu.rst new file mode 100644 index 000000000000..94f93f5aee6c --- /dev/null +++ b/Documentation/admin-guide/perf/ampere_cspmu.rst @@ -0,0 +1,29 @@ +.. SPDX-License-Identifier: GPL-2.0 + +============================================ +Ampere SoC Performance Monitoring Unit (PMU) +============================================ + +Ampere SoC PMU is a generic PMU IP that follows Arm CoreSight PMU architecture. +Therefore, the driver is implemented as a submodule of arm_cspmu driver. At the +first phase it's used for counting MCU events on AmpereOne. + + +MCU PMU events +-------------- + +The PMU driver supports setting filters for "rank", "bank", and "threshold". +Note, that the filters are per PMU instance rather than per event. + + +Example for perf tool use:: + + / # perf list ampere + + ampere_mcu_pmu_0/act_sent/ [Kernel PMU event] + <...> + ampere_mcu_pmu_1/rd_sent/ [Kernel PMU event] + <...> + + / # perf stat -a -e ampere_mcu_pmu_0/act_sent,bank=5,rank=3,threshold=2/,ampere_mcu_pmu_1/rd_sent/ \ + sleep 1 diff --git a/drivers/perf/arm_cspmu/Makefile b/drivers/perf/arm_cspmu/Makefile index fedb17df982d..b80a8bd8da54 100644 --- a/drivers/perf/arm_cspmu/Makefile +++ b/drivers/perf/arm_cspmu/Makefile @@ -3,4 +3,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_ARM_CORESIGHT_PMU_ARCH_SYSTEM_PMU) += arm_cspmu_module.o -arm_cspmu_module-y := arm_cspmu.o nvidia_cspmu.o +arm_cspmu_module-y := arm_cspmu.o nvidia_cspmu.o ampere_cspmu.o diff --git a/drivers/perf/arm_cspmu/ampere_cspmu.c b/drivers/perf/arm_cspmu/ampere_cspmu.c new file mode 100644 index 000000000000..cfafc093b694 --- /dev/null +++ b/drivers/perf/arm_cspmu/ampere_cspmu.c @@ -0,0 +1,243 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Ampere SoC PMU (Performance Monitor Unit) + * + * Copyright (c) 2023, Ampere Computing LLC + */ + +#include "ampere_cspmu.h" + +#define PMAUXR0 0xD80 +#define PMAUXR1 0xD84 +#define PMAUXR2 0xD88 +#define PMAUXR3 0xD8C + +#define to_ampere_cspmu_ctx(cspmu) ((struct ampere_cspmu_ctx *)(cspmu->impl.ctx)) + +struct ampere_cspmu_ctx { + const char *name; + struct attribute **event_attr; + struct attribute **format_attr; +}; + +static DEFINE_IDR(mcu_pmu_idr); + +#define SOC_PMU_EVENT_ATTR_EXTRACTOR(_name, _config, _start, _end) \ + static inline u32 get_##_name(const struct perf_event *event) \ + { \ + return FIELD_GET(GENMASK_ULL(_end, _start), \ + event->attr._config); \ + } \ + +SOC_PMU_EVENT_ATTR_EXTRACTOR(event, config, 0, 8); +SOC_PMU_EVENT_ATTR_EXTRACTOR(threshold, config1, 0, 7); +SOC_PMU_EVENT_ATTR_EXTRACTOR(rank, config1, 8, 23); +SOC_PMU_EVENT_ATTR_EXTRACTOR(bank, config1, 24, 55); + +static struct attribute *ampereone_mcu_pmu_event_attrs[] = { + ARM_CSPMU_EVENT_ATTR(cycle_count, 0x00), + ARM_CSPMU_EVENT_ATTR(act_sent, 0x01), + ARM_CSPMU_EVENT_ATTR(pre_sent, 0x02), + ARM_CSPMU_EVENT_ATTR(rd_sent, 0x03), + ARM_CSPMU_EVENT_ATTR(rda_sent, 0x04), + ARM_CSPMU_EVENT_ATTR(wr_sent, 0x05), + ARM_CSPMU_EVENT_ATTR(wra_sent, 0x06), + ARM_CSPMU_EVENT_ATTR(pd_entry_vld, 0x07), + ARM_CSPMU_EVENT_ATTR(sref_entry_vld, 0x08), + ARM_CSPMU_EVENT_ATTR(prea_sent, 0x09), + ARM_CSPMU_EVENT_ATTR(pre_sb_sent, 0x0a), + ARM_CSPMU_EVENT_ATTR(ref_sent, 0x0b), + ARM_CSPMU_EVENT_ATTR(rfm_sent, 0x0c), + ARM_CSPMU_EVENT_ATTR(ref_sb_sent, 0x0d), + ARM_CSPMU_EVENT_ATTR(rfm_sb_sent, 0x0e), + ARM_CSPMU_EVENT_ATTR(rd_rda_sent, 0x0f), + ARM_CSPMU_EVENT_ATTR(wr_wra_sent, 0x10), + ARM_CSPMU_EVENT_ATTR(raw_hazard, 0x11), + ARM_CSPMU_EVENT_ATTR(war_hazard, 0x12), + ARM_CSPMU_EVENT_ATTR(waw_hazard, 0x13), + ARM_CSPMU_EVENT_ATTR(rar_hazard, 0x14), + ARM_CSPMU_EVENT_ATTR(raw_war_waw_hazard, 0x15), + ARM_CSPMU_EVENT_ATTR(hprd_lprd_wr_req_vld, 0x16), + ARM_CSPMU_EVENT_ATTR(lprd_req_vld, 0x17), + ARM_CSPMU_EVENT_ATTR(hprd_req_vld, 0x18), + ARM_CSPMU_EVENT_ATTR(hprd_lprd_req_vld, 0x19), + ARM_CSPMU_EVENT_ATTR(prefetch_tgt, 0x1a), + ARM_CSPMU_EVENT_ATTR(wr_req_vld, 0x1b), + ARM_CSPMU_EVENT_ATTR(partial_wr_req_vld, 0x1c), + ARM_CSPMU_EVENT_ATTR(rd_retry, 0x1d), + ARM_CSPMU_EVENT_ATTR(wr_retry, 0x1e), + ARM_CSPMU_EVENT_ATTR(retry_gnt, 0x1f), + ARM_CSPMU_EVENT_ATTR(rank_change, 0x20), + ARM_CSPMU_EVENT_ATTR(dir_change, 0x21), + ARM_CSPMU_EVENT_ATTR(rank_dir_change, 0x22), + ARM_CSPMU_EVENT_ATTR(rank_active, 0x23), + ARM_CSPMU_EVENT_ATTR(rank_idle, 0x24), + ARM_CSPMU_EVENT_ATTR(rank_pd, 0x25), + ARM_CSPMU_EVENT_ATTR(rank_sref, 0x26), + ARM_CSPMU_EVENT_ATTR(queue_fill_gt_thresh, 0x27), + ARM_CSPMU_EVENT_ATTR(queue_rds_gt_thresh, 0x28), + ARM_CSPMU_EVENT_ATTR(queue_wrs_gt_thresh, 0x29), + ARM_CSPMU_EVENT_ATTR(phy_updt_complt, 0x2a), + ARM_CSPMU_EVENT_ATTR(tz_fail, 0x2b), + ARM_CSPMU_EVENT_ATTR(dram_errc, 0x2c), + ARM_CSPMU_EVENT_ATTR(dram_errd, 0x2d), + ARM_CSPMU_EVENT_ATTR(read_data_return, 0x32), + ARM_CSPMU_EVENT_ATTR(chi_wr_data_delta, 0x33), + ARM_CSPMU_EVENT_ATTR(zq_start, 0x34), + ARM_CSPMU_EVENT_ATTR(zq_latch, 0x35), + ARM_CSPMU_EVENT_ATTR(wr_fifo_full, 0x36), + ARM_CSPMU_EVENT_ATTR(info_fifo_full, 0x37), + ARM_CSPMU_EVENT_ATTR(cmd_fifo_full, 0x38), + ARM_CSPMU_EVENT_ATTR(dfi_nop, 0x39), + ARM_CSPMU_EVENT_ATTR(dfi_cmd, 0x3a), + ARM_CSPMU_EVENT_ATTR(rd_run_len, 0x3b), + ARM_CSPMU_EVENT_ATTR(wr_run_len, 0x3c), + + ARM_CSPMU_EVENT_ATTR(cycles, ARM_CSPMU_EVT_CYCLES_DEFAULT), + NULL, +}; + +static struct attribute *ampereone_mcu_format_attrs[] = { + ARM_CSPMU_FORMAT_EVENT_ATTR, + ARM_CSPMU_FORMAT_ATTR(threshold, "config1:0-7"), + ARM_CSPMU_FORMAT_ATTR(rank, "config1:8-23"), + ARM_CSPMU_FORMAT_ATTR(bank, "config1:24-55"), + NULL, +}; + +static struct attribute ** +ampere_cspmu_get_event_attrs(const struct arm_cspmu *cspmu) +{ + const struct ampere_cspmu_ctx *ctx = to_ampere_cspmu_ctx(cspmu); + + return ctx->event_attr; +} + +static struct attribute ** +ampere_cspmu_get_format_attrs(const struct arm_cspmu *cspmu) +{ + const struct ampere_cspmu_ctx *ctx = to_ampere_cspmu_ctx(cspmu); + + return ctx->format_attr; +} + +static const char * +ampere_cspmu_get_name(const struct arm_cspmu *cspmu) +{ + const struct ampere_cspmu_ctx *ctx = to_ampere_cspmu_ctx(cspmu); + + return ctx->name; +} + +static u32 ampere_cspmu_event_filter(const struct perf_event *event) +{ + /* + * PMEVFILTR or PMCCFILTR aren't used in Ampere SoC PMU but are marked + * as RES0. Make sure, PMCCFILTR is written zero. + */ + return 0; +} + +static void ampere_cspmu_set_ev_filter(struct arm_cspmu *cspmu, + struct hw_perf_event *hwc, + u32 filter) +{ + struct perf_event *event; + unsigned int idx; + u32 threshold, rank, bank; + + /* + * At this point, all the events have the same filter settings. + * Therefore, take the first event and use its configuration. + */ + idx = find_first_bit(cspmu->hw_events.used_ctrs, + cspmu->cycle_counter_logical_idx); + + event = cspmu->hw_events.events[idx]; + + threshold = get_threshold(event); + rank = get_rank(event); + bank = get_bank(event); + + writel(threshold, cspmu->base0 + PMAUXR0); + writel(rank, cspmu->base0 + PMAUXR1); + writel(bank, cspmu->base0 + PMAUXR2); +} + +static int ampere_cspmu_validate_configs(struct perf_event *event, + struct perf_event *event2) +{ + if (get_threshold(event) != get_threshold(event2) || + get_rank(event) != get_rank(event2) || + get_bank(event) != get_bank(event2)) + return -EINVAL; + + return 0; +} + +static int ampere_cspmu_validate_event(struct arm_cspmu *cspmu, + struct perf_event *new) +{ + struct perf_event *curr, *leader = new->group_leader; + unsigned int idx; + int ret; + + ret = ampere_cspmu_validate_configs(new, leader); + if (ret) + return ret; + + /* We compare the global filter settings to the existing events */ + idx = find_first_bit(cspmu->hw_events.used_ctrs, + cspmu->cycle_counter_logical_idx); + + /* This is the first event, thus any configuration is fine */ + if (idx == cspmu->cycle_counter_logical_idx) + return 0; + + curr = cspmu->hw_events.events[idx]; + + return ampere_cspmu_validate_configs(curr, new); +} + +static char *ampere_cspmu_format_name(const struct arm_cspmu *cspmu, + const char *name_pattern) +{ + struct device *dev = cspmu->dev; + int id; + + id = idr_alloc(&mcu_pmu_idr, NULL, 0, 0, GFP_KERNEL); + if (id < 0) + return ERR_PTR(id); + + return devm_kasprintf(dev, GFP_KERNEL, name_pattern, id); +} + +int ampere_cspmu_init_ops(struct arm_cspmu *cspmu) +{ + struct device *dev = cspmu->dev; + struct ampere_cspmu_ctx *ctx; + struct arm_cspmu_impl_ops *impl_ops = &cspmu->impl.ops; + + ctx = devm_kzalloc(dev, sizeof(struct ampere_cspmu_ctx), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + ctx->event_attr = ampereone_mcu_pmu_event_attrs; + ctx->format_attr = ampereone_mcu_format_attrs; + ctx->name = ampere_cspmu_format_name(cspmu, "ampere_mcu_pmu_%d"); + if (IS_ERR_OR_NULL(ctx->name)) + return ctx->name ? PTR_ERR(ctx->name) : -ENOMEM; + + cspmu->impl.ctx = ctx; + + impl_ops->event_filter = ampere_cspmu_event_filter; + impl_ops->set_ev_filter = ampere_cspmu_set_ev_filter; + impl_ops->validate_event = ampere_cspmu_validate_event; + impl_ops->get_name = ampere_cspmu_get_name; + impl_ops->get_event_attrs = ampere_cspmu_get_event_attrs; + impl_ops->get_format_attrs = ampere_cspmu_get_format_attrs; + + return 0; +} + +MODULE_LICENSE("GPL"); diff --git a/drivers/perf/arm_cspmu/ampere_cspmu.h b/drivers/perf/arm_cspmu/ampere_cspmu.h new file mode 100644 index 000000000000..9b3e1628d1d6 --- /dev/null +++ b/drivers/perf/arm_cspmu/ampere_cspmu.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +/* + * Ampere SoC PMU (Performance Monitor Unit) + * + * Copyright (c) 2023, Ampere Computing LLC + */ + +#ifndef __AMPERE_CSPMU_H__ +#define __AMPERE_CSPMU_H__ + +#include "arm_cspmu.h" + +/* Allocate AMPERE descriptor. */ +int ampere_cspmu_init_ops(struct arm_cspmu *cspmu); + +#endif /* __AMPERE_CSPMU_H__ */ diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c index 471d6d7ac81a..579f2697b419 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -30,6 +30,8 @@ #include #include "arm_cspmu.h" + +#include "ampere_cspmu.h" #include "nvidia_cspmu.h" #define PMUNAME "arm_cspmu" @@ -114,6 +116,7 @@ /* JEDEC-assigned JEP106 identification code */ #define ARM_CSPMU_IMPL_ID_NVIDIA 0x36B +#define ARM_CSPMU_IMPL_ID_AMPERE 0xA16 static unsigned long arm_cspmu_cpuhp_state; @@ -388,6 +391,11 @@ static const struct impl_match impl_match[] = { .mask = ARM_CSPMU_PMIIDR_IMPLEMENTER, .impl_init_ops = nv_cspmu_init_ops }, + { + .pmiidr = ARM_CSPMU_IMPL_ID_AMPERE, + .mask = ARM_CSPMU_PMIIDR_IMPLEMENTER, + .impl_init_ops = ampere_cspmu_init_ops + }, {} };