From patchwork Wed Jun 7 08:31:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13270163 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 162B4C8300C for ; Wed, 7 Jun 2023 08:33: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=OcJHDuprvhkN4yVJWmDava5C43rcr9sYpI1GaXAfctY=; b=Jo6pXVDTUgibyq AmE/jmxkHLWALMxAC7zNXh0C/cFm6EsSvnYVGJdghKrElA7SWblhTcgADlifqrxicgzMwq0Ao1wCK YEw11IZ5gUtmB7dMB7kW8zTWdCfDLzMZbqwXg4mnZl/IN9WUBoMwdwYPD8ytOLLsI7n+q4vQQl3tq Xs7OnC0VHatQ8b6p3tamRRO9HkEiX6zgUzN9ApPNbro3SkrrrQ4g59GwnbWxji33qV+IxpJBHB7Fy etRTbcU4MydQclEhJHo4ab0a/aPc2JTvNWUy//Sa83FmCcoXKkBQmaO1GO+c5bUIXHIqxKTvFiYYE og2acqQqEbcaSnq/eliQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6ob4-004yl3-0Y; Wed, 07 Jun 2023 08:32:50 +0000 Received: from mail-dm6nam12on20720.outbound.protection.outlook.com ([2a01:111:f400:fe59::720] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6ob0-004yiq-0v for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 08:32:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eLWXgikKLtuRonol6spYzSaenBmzB0an3gPpZcgP5IZLnTFZtbhLArXIQNMxkp+M6V74QVJt8Jhy+wb3udgd1kUTDDNgDGPqPDpOr+D4wWWKqVFeGscQBeQCOrO/wkxmOM+eJgf043SEgd+a9arK5p/GdafGlPrZFazx3xTXHpIvoHZjhnievrv/3WDB62wH4/NtB9zuugoIvRI88Z4WwpeFVom//raw/9C3kMhk0WeXJ8AHQ633MlyhYe/IggZMJ7WclObnUffQL0HJ9B4Wqo+5k0mSdwHZV5Nh4Y/nvh86IPdwgq5hOFQ+9nB+5Mw7TlBx/WAh139H0/UaTQZFeQ== 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=qRZxhGQrvCK/OKIHPpTr118yEW8wCmUFrDRdcojm2Gg=; b=ZLTa4MyxcppcH04rDyfE7/qmzZ2VMo42ScYlNO+8Wi+Nx+Jc3SBfc5EHs0qm3krKNwEdgcG5FuhXcS7dMZCb6BZ1yJ/i3+5lXNT6/ckbFASRs194M0pk8GYYS/f9UlLZ4S8S0IOVmmg2bh6d9FjJrTr3+FSSR+sQnncgCp/nezis6bEJviBwqyL5rYO6bOx2pjnsRfg/cwgjjdU4NffyUkrJeRajUqgvK2Nv2sn4T4NAm3qLneXIQQJQJbAy/NlKRxBtrw5Rqi0UVlb2bGTuPfMsERmDP/c09y0+Jz6eRyZoUTpgSjlP/u4HhuCyMSkwy+kJPQchFSO8DXpstH6jwQ== 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=qRZxhGQrvCK/OKIHPpTr118yEW8wCmUFrDRdcojm2Gg=; b=ZhnG+3T9rLLg0mlIAQKOdpfFtE1JoefF1cM1DWvjbsF4vDDUDinIZ1YHL3PX5rX8iXmOjstI5uplAdkfPRhkbJIXM4TZbWYamjrNjj74FavbXqfIg4VzFM5nUzSl/7g2zteeMT1hBxVhV32TaylSslwG1u4EDysHW4d6jpBymBU= 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 SJ0PR01MB6304.prod.exchangelabs.com (2603:10b6:a03:297::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Wed, 7 Jun 2023 08:32:43 +0000 Received: from DM5PR0102MB3590.prod.exchangelabs.com ([fe80::5aae:2a5e:15f5:8196]) by DM5PR0102MB3590.prod.exchangelabs.com ([fe80::5aae:2a5e:15f5:8196%2]) with mapi id 15.20.6455.030; Wed, 7 Jun 2023 08:32:43 +0000 From: Ilkka Koskinen To: Jonathan Corbet , Will Deacon , Mark Rutland , Besar Wicaksono , Suzuki K Poulose , Robin Murphy Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ilkka Koskinen Subject: [PATCH v3 1/4] perf: arm_cspmu: Split 64-bit write to 32-bit writes Date: Wed, 7 Jun 2023 01:31:36 -0700 Message-Id: <20230607083139.3498788-2-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607083139.3498788-1-ilkka@os.amperecomputing.com> References: <20230607083139.3498788-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH2PR19CA0009.namprd19.prod.outlook.com (2603:10b6:610:4d::19) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR0102MB3590:EE_|SJ0PR01MB6304:EE_ X-MS-Office365-Filtering-Correlation-Id: 377a1352-ecfb-440e-a4e9-08db6731c33c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4wB8M7nkXrsw/zPVL7RaFOj+qSoo1GmryHXnmSr8QDIqfbI4kq6DeEhluW7yTpfzawXMEdlOLQkqaf/Sx2lfX6YQByfTmj6Ge00+5OYXOVUwGLyG+rRDu4o59Md8hNlBnWiZaS6ufX0n4maar03HHgJJkpFFWIi4xdWsdWv/G6/Zo+P2DkX3Y/mSzfvLl9Q7yyhmBPVRqCpRCA5d5RLk7yYS5QIA0v6OLMWW2FQ11GBC5n5MwDIMQikfDHuVdcZ5hn355Ltv+v+PqBk65w8he0ceCMEs4gEvwLSyBOm0eZ+ZnwVC9jbaiShJxJLkIouUQEdBCsGxkcyFoInNH68vumni6wAZ8Nx0WoqLamWduhKEf0t80XU1C3JQjyyllj1/e+0SGkGDEg5D0jckLmxSTjEjwxRcwRhK2Zwj4IDxbRMa5g7SUeLutldLbxGKRoUUj0fRo51s7K8t9joZQk2BOGcNhKwBmP/5cut6iEKzAByVPojr219zKLuRE/pwBskBNyslK/RGIy0HeyosdYMVutlYVmRSxrBei4MeRASlD0y78IE5OPpyo57amMU9yiLUGwbaxJ8KZJakzejrE20n5o5g1e+AvbuqLkp8iN/Z/YKlnCFlJnY5Qwf9UvZHITDJ 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)(136003)(39860400002)(346002)(366004)(376002)(396003)(451199021)(107886003)(6506007)(1076003)(186003)(26005)(6512007)(2616005)(83380400001)(52116002)(6486002)(6666004)(4744005)(2906002)(8676002)(8936002)(110136005)(478600001)(41300700001)(5660300002)(316002)(38350700002)(86362001)(38100700002)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /NyPUTRQifks3ng3fY3UyWvMrde3UKKjDnf4UIjRafhMDuOxQYHYw6kjiVWigdVYqieb+Nce3wF3ZMWhWXoh3V29LNClCLGZBkDRwSPPU6EqGeJMtvOVIbno0aTnEwy29nkfwg+Hk2PU1gMzJ/xzxPNmN/guUIP4wQj5DIqcG8kQOZ/fTcximX5YQToXuJ0LzcpPhcqAS2l666Vg5/P8PvYmBTI+XflmuWeSbivQ0V/ptW250DpDT67aPQh8wUjISz24jqv1JKJk9QgJId2AFmbjFfsbTCvCShBZzZRazs8b2aMVE61YnwKs4IEFcE/9fA4BTnm7UvAdLPxJ2BH7+qQnrmln7nMUKs5gpuwYUr6uzzM/ee6SyRJ2EFBSvDH0yBIH+ZTsiZ95A2PcqZ0MSpAdFKQFvZ6quWAa9SST+oFiy2n+5PUHy5mZNJ/5JcHq10Ysym1JQCo9/Z11qcVGH+rauunqKNFaqv5IUgbHEI1dwaAxkqL4u4BPW2qGURmyRtLBzkAbMzhjpygSjK6lpeGclZP2YK7bzOMSf6UOio5VippeW+qhIi+5XpcIi8NXepYL8J5CXEFgPJREPNzuv+j+92z3TxcvJEhAP1LNG1BNK0x+9SIwfoEv95lB9TXBZVSoiZa/4iaiX2w92trp2o4gCRF8h7dvareQ1M7aux8J+UGph6ThWqq2gVZfSQpUhD+BNeqig3lB4JEaWvN9BKzxT0/pQHYiS7xZa6HGcNPMN7WDrVyeVzRPf3cAhaOwSP1QA0ZCE9bGy4tT0Lc47vWyQPm7GGdXInQ3r4sfJwQuwI2lVSw9jOmsDhCvLsHqeCoXVM98okKK70Zn0fSJLJdvhNjC+nZvURWaHHisEGhgBcIZgJxQJrhdukCZ9rdwOQES5uHo5OiHEpJvz45DhoxWTM6LXS4U5mADowFyr9BbFCR95LQeWtOOrGgcz7G+PhvrcO5O12thpyZs5YQP/g2G9ZIbu45Ew4v7gMWJMELBnDeA4EArlNdlOKiNxLulDQgqm053e0Ell7Epz++DM5WBDT1oCPpTE6luCjycu2aQaPS0PgOYNpWe68WKbRXLJw3JXiV7uiTPieTSIJDO1a3jDAFv16PP+9Jf86cqBocWpxNizMRkbhSWfUELTHrs2hFEAye9QcJWBrk6b89FfDstb3Rz98xt0MdDaNAosWhUw+AQRWzmRIvQG2WfAyGiNKqMahVoYJuXa4zd3CLZVr5gmwycooPqs6XhUxkkfrt/knlzDbEFhj2m+/YTvyk4AGgPipHhPzRAPY1zESSx1orGAqp6blAUabhYwcNqKow9sXbEWXe/3MxbBfQmosGMHMkBuhXQ7XyMBX1o2Nt3XpMCDKVsMRVSwlq+aZBcRpcnmGYnvCw39Y7VuLeKea8zDqQMPiLMDUwUuezGqsr3sVQ6rokY1bjELXqquzTjLlEZTjWxpXGV1EjBkda/h3H7dCp+Ouzn/DRXobvfxqdnUkxb6efuQJe+58R+HsRP6GQq4rTrR6+4DnoewvkcP94DOkeLGu3bR5/mXegMWv/DHkFCtJEgIz72wMNS90umgGwaifi4Etp2heAZ6Mw3whxGGy76O82gA9FtkAYdoMZ2Uw== X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 377a1352-ecfb-440e-a4e9-08db6731c33c X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2023 08:32:43.1132 (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: DH00x18ptTWAQoPpvPNhCBu1vwb7i5syYSjB9SW2DFaY1MDktKkPjInxOYO/kb1scBjT4qDmlCarnwawPA6YLZW1KnqCTsqc1NNoWtrMAH6kqN+su6fE1LvX4L7VWMqE X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6304 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_013246_329184_CAFC8337 X-CRM114-Status: GOOD ( 12.84 ) 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 --- 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 a3f1c410b417..f8b4a149eb88 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -702,7 +702,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 (supports_64bit_atomics(cspmu)) + writeq(val, cspmu->base1 + offset); + else + lo_hi_writeq(val, cspmu->base1 + offset); } else { offset = counter_offset(sizeof(u32), event->hw.idx); From patchwork Wed Jun 7 08:31:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13270165 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 505DDC7EE29 for ; Wed, 7 Jun 2023 08:33:18 +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=5YzRkJYpRubhUPad00ooBUbEe1ItI2nuDjIlyfUiB4o=; b=QkgapNWSWLj9KQ 4VnL2d9z3+nE6nQz9C6lppjrHvOVdk0y087W+y3gDvO2MH+D3g+MBnBr0scdCX2qbzt/Kv7WiUQPB NsP0rdbjE1+S+HIrwdbSAiXXEOlZ0AobnXhz0KgOFizqDZfjjHu9ZJL0pmPmHLBVzoHa5wA4pg6I8 Q2o4xuLDDMoM87I14x9BZUFrG+Dlnfd3VfTn9WKqSeZYbtuvsE35Ugi0Jg35MEZylKU+GSx3/ng4c b8UIR0PZriiblQk4EXCh2noAm2B2ZL11L4a2vIQqiPbRvv+jxJa+qF2v9oCCW7Aysf8hZeZsohYm/ YA1uQBeTBFiX8qB5YH4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6ob6-004ylu-2n; Wed, 07 Jun 2023 08:32:52 +0000 Received: from mail-dm6nam12on2070c.outbound.protection.outlook.com ([2a01:111:f400:fe59::70c] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6ob4-004ykM-1M for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 08:32:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GCgeJ1WaOVE1i9+jWkVoPTaWYjcrSjW2U4dRcbNblPkLNTtJVDmBTRhAdgix1FlFQnK1IgvkrQUNJ+yWtaVbCa40n/eo5PYX5TRELiG8AQNydm4PtsjCk2BRQWne2FMe/gCpt5OhsXDgl2fbo52K1M1lvq+j6pVMiuGKpCIxM1Eu6TQMneui0qLNgyE822Pgy99FDoq/wee7Soai4dyWJ/LWFQNyfWXOnSp3tQhxpc0RkcRWlbBk2uGiDHtU03tBv8NRipw2TK4TADIyzeO2pFZhKPjIgkSxqQ6naeep08cNl9tNkAKi0Lu21Ehgf1Q5eRmb8RqV0Vl34zqT4LIlOA== 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=z0eoh+Vvo8fahUMSQ/WbE/8KYLoyFe/I0uhsa3+sAt4=; b=DCEhp/pLzpibRxCja7I4FhfEatjw6bw56YFjUjhXY5bo0Oy0K0Dx6xZBNDUV4uYkx3eOzRs/ERXLLPEQvwsbj+zz5w6F00DK7WIw65hh3tH724EcUYdr51O/CR+PO5zsNQrVf7jnqXmU1kwSAR1JgLC2XaiA0wyRCfrE+v+euCphApUbLE77ZMmJJqP/FGvGD87vhN25VwCrNzCaZg/3PQL4o8WGvqOsHM2E9FK6RplYNaBBWRvZwhIW+IUuQx9xPqYsQ71iiBtHtpBVppnsZMb0TPynwJURQYTs3J8PMQJG6IhGuPO1wZzA2PWDZVcwNxaxbEnWhil7sCe4gzzv9w== 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=z0eoh+Vvo8fahUMSQ/WbE/8KYLoyFe/I0uhsa3+sAt4=; b=oz38jWuBYXEBfTzj2RO0sLiw82zJHuPecL73JO4SGV4vxX5I3EELBPhqd37oPDZLWzyYXZF4Jr1VQeQx1l4FVeYYvxsFrqZ9f5JHArHHH1XrbHCQdtE7AUDgbZiCW+a3y51KJ/fPtJP/PuA7whAh3uQxrRvxVpvxIGZA3wqLlVM= 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 SJ0PR01MB6304.prod.exchangelabs.com (2603:10b6:a03:297::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Wed, 7 Jun 2023 08:32:46 +0000 Received: from DM5PR0102MB3590.prod.exchangelabs.com ([fe80::5aae:2a5e:15f5:8196]) by DM5PR0102MB3590.prod.exchangelabs.com ([fe80::5aae:2a5e:15f5:8196%2]) with mapi id 15.20.6455.030; Wed, 7 Jun 2023 08:32:46 +0000 From: Ilkka Koskinen To: Jonathan Corbet , Will Deacon , Mark Rutland , Besar Wicaksono , Suzuki K Poulose , Robin Murphy Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ilkka Koskinen Subject: [PATCH v3 2/4] perf: arm_cspmu: Support implementation specific filters Date: Wed, 7 Jun 2023 01:31:37 -0700 Message-Id: <20230607083139.3498788-3-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607083139.3498788-1-ilkka@os.amperecomputing.com> References: <20230607083139.3498788-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH2PR19CA0009.namprd19.prod.outlook.com (2603:10b6:610:4d::19) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR0102MB3590:EE_|SJ0PR01MB6304:EE_ X-MS-Office365-Filtering-Correlation-Id: edc0abf7-958b-4da6-976e-08db6731c55e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dCarWHALdyP/0WlcbHtxdJ2LBe+WEeqjuEU2fIeajcYbYyFCB1S/uITYRz4KxL7oTq57F2ExpVSA3u3IR5FQzu3B6801qM4BFvql8i/GLGfzlfFIQCz7Dpd/3FTFNfqqqlJowexD9J5OJztMPx4Waon70+JNsgP4K57udozDUrzIbQryHAW6KhYaEUIMkWcxHY+RBuvPAz3LsRkM5bZU40y0o+T9Jp2IcdZ3LI47M7wRKWCxbF1/PR6o63TEHdnyeY4zeEiMKQDne5Br4XppXh4ZMw2hEDxgsCL7Bv7iSHQ8VQKpXOOCSQo/woPXNU9Bv3CHfNuYyVAPbDmQpU4Lg9w71usLRDuhslho3LTk1Y1QtgYuRDL4FafjnS94B7WoX09m8imkqPrL5HnjgZZ7UB4vdmY9V1e87enq+GQlxTry8EUPL8cml2fySSP1mIgkJ4aIRHOkmIPHHBtL95akKgQ3sR8DP4n1//yiXDv/fjiNdTMb4v/XWvfEC82lweejrynccGEk9JjJ1nnIhYxh2xe6W/B5abfcqdDVxTBtLcde9X1ndZqB0ZijNUkJ5LmQncFBiqXOjU+xMgVOJk5HjntwIa20HE99e9Rm0xBN5kO3UWPIwhu+Ojrss/kSBy1/ 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)(136003)(39860400002)(346002)(366004)(376002)(396003)(451199021)(107886003)(6506007)(1076003)(186003)(26005)(6512007)(2616005)(83380400001)(52116002)(6486002)(6666004)(2906002)(8676002)(8936002)(110136005)(478600001)(41300700001)(5660300002)(316002)(38350700002)(86362001)(38100700002)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: v0Wsy+ITHFmbbqq0MEbheCfqqosoWjprTArzFbToxiWKKTSZczB6EwzX7eE77UVAukawyHHiQwFisIm1r3U83zUErPW1U6rdRza9qs6apKZT49UWt7w8cFShY8vIUnX2MW/Ii9N2vPyudb4C3Oc47sIss3E6xho+5PvMrjwRBzSxjucMzM44ktw+DM5mcAZdpTUTb2CZQYvjhcAIcPDhiRxQ5NTmvbUme5AeM8dl2SVk+t06RlXR87BghO+2CBbSlfcAjcKnmHJ7OGbWSJQh6buBxPNSJnb+AqkcJurPvXW9HcIBbaJYdr3CMnYFe2I/NDSkqrtgTK2abxW7XMJG1wFbDQQcZ+JuxtVeFwS2wTOnWxtMEQCvKqxawqHOkk62alol6r7GRLVL7kFXYKzPJmLJ3gkKObf8lghwaT2B1w5ZO62x0mzq6Qv2A4c7yU3qql9zIX88symR+lb51Q6IFdsf9C/eaeHKI/eqXqruch/WrVaplgIH1Xv6pB+RoHjHZknK2yPurRD+vCvHwtdu07JYMafQRAA3VIGuKAFiW0KkiLU9cbphdFuTGdwc1efz54Z5tjQGHznfa0wShbw/0jIYPOpgogzIS0I8l90QeBOoA9ZU2djlHH08l1xwBm8mYvXVw5Q7m0ey+aOaAxzH40zAn33pwmT+XgafvfF5X9RK1f/cT2UYBMdpc7cZHPx2YqpbgLOiJMsZUmQxoO+LN/0ch5/m3IutNqh2NQ0NRtKgTpuRgwqtKnf4Mcb+d3VQnxgS2TuvT1i5Gs/dvyHet6FSUFHfV4U3ZgGg+DPk4h+9cUuQyPOdzMENuRQmgH2gGFLXjPc6TikXpRz3yLZ6yeWz1eM9q0xgtIPHTXb8oJkCfPkA5qZOujG1/4y0qlYjcWLWv1dX2/qY95Df+yE5eh6FoWgNM04/BSkHBocVJnecifjGaYDqQk9R76zo2+yiIuJ8Cfz8aG510oKWd7v8Vo/nv2XIflGd1kVl2Z9gGVpsDtLGGuyODpl16bIvJUa5PYNGXx5qEMkmx8urg4CGxnAv8XUiDyD1EVqpwIqNvTW/wJCUZpz9D7DlvDzVTUHQMEABPlPkl+TJhtkCapdGM9EK80bKARYfABF1Ob/gS0rbxmvvm6xqfmDGoWrSEcQkFdbOIMrTvy86yq4q7OZAQW6ojrSMnkGbkE9tmBmVpNumYM626ITI49/0Tq8AxDfqw47ytI0XtjIe6T7KrIp+ErYE8bMvZORogYowEN1+wB+Mcxtxil8JzIlUPzDnmRsX1Pgw74uvknktFfOd2Vz9WtS9IZrb2EGqOO0n5ybYU6HFLEDGeafVKqGVoYib9/uIIJCfZU+/+VEcmz+1CNUYGBGa8ED11iHHDAfiEw5Ra7nm4NiWSPTg04u9gH3oyZ83FVSuN3EFPz+mwVG3wVSdBEmnCQFAVOY562Lr5tvL4fk9/leD8v5IPVctPAfuCqIBLtw79SVcJ0tVqDpM27u+ZUOnc7Ew5XUgLvD3qq0BzGFEdTUzcqY5Le/LGktSb0yEZ8umCboYx9fmW7sjp1oyT43t0czFh1rYGK9HZ7E6bv4Wply2CZ8ZnpOf42Plx2ejnKHeuaPDYlyHEz/mDPooSg== X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: edc0abf7-958b-4da6-976e-08db6731c55e X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2023 08:32:46.6864 (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: omVLUv0nnBTFjFIGr+qZn5cYNJdLCxsuvNIO984HygXu+Who/Lg6Nxhh4qEJjT1fbctt3bMWSIxgFFO8CP1O0L8FvOPaZ42BUfsqSi9krTkyam70F9rRFTcusKUGzXVF X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6304 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_013250_470115_7C7555D0 X-CRM114-Status: GOOD ( 14.54 ) 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 Generic filters aren't used in all the platforms. Instead, the platforms may use different means to filter events. Add support for implementation specific filters. Signed-off-by: Ilkka Koskinen Reviewed-by: Besar Wicaksono --- drivers/perf/arm_cspmu/arm_cspmu.c | 8 ++++++-- drivers/perf/arm_cspmu/arm_cspmu.h | 4 ++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c index f8b4a149eb88..72ca4f56347c 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -122,6 +122,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); + /* * In CoreSight PMU architecture, all of the MMIO registers are 32-bit except * counter register. The counter register can be implemented as 32-bit or 64-bit @@ -432,6 +435,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; } @@ -798,7 +802,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) { @@ -832,7 +836,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 51323b175a4a..f89ae2077164 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.h +++ b/drivers/perf/arm_cspmu/arm_cspmu.h @@ -102,6 +102,10 @@ 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 Wed Jun 7 08:31: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: 13270166 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 DEF09C77B7A for ; Wed, 7 Jun 2023 08:33:24 +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=kWzUzwztEmGvAehb3uV47uUbqNx4I+JcW1XAjOzoh/s=; b=k9I/C5DUTa3YCp 1h+3+lbqv/uW0Iisa5wegSF4uQLsrncWLZ9TKkIZ6Cm9gxx+LC1y3caAq8WZqv56bkDdNaAtlc1c0 jQy55dBbYB/c63ZAYn8nsYOJcxGoa9lU6ISSWdXfEchD+LOf1oPtrsgzbS0YtIE9GSv67ta2N1h4p Zp4CFEBPuIzwceXttSRzyjEQ95fxG0kcyWtjXSjs0M0Ra+9E8jQ0kH5/VmfPKGOaspxPZ3vY0DAHH AC4UEeWGJCqEsgEbtTqgazoEf2HgUriW2IhkhN3/aOOw1wFyNMHyOu9wTj4X4FEerwplOm6rwWGxi cXj6o+L+cz1LYCcs77wA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6obD-004yof-1w; Wed, 07 Jun 2023 08:32:59 +0000 Received: from mail-bn1nam02on20715.outbound.protection.outlook.com ([2a01:111:f400:7eb2::715] helo=NAM02-BN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6obA-004ymV-1C for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 08:32:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cL8aH1h/1sL4INO5HupaiXjZzDIsSRpFI7s+44RCoeaCJ+nMOWaxmps12TYp/RFu7CpnS87oAB5mHtr8Sdz2XpLfsx4u7HbXcytWkr109eqs8czTxMcsIvrhYRKbEjvk/RnYMaZkQ//QTK9cdc1Q63/7Xm4fUkizMXluYM645jJaSc47/Z5udOODC93MBr+k6+6GZbXphLB1rCF0j33mtIts5ReE97G5KjcggMeTK126byQ7KJBMYYBrigXDt9vOV3oI5HVZOxlxmDap6ujR/C9hySpf3JX15iKLu0REApnzkpldv4Wsr971qhov1kdO+L82Mi0OeHdFeBSJrniv/w== 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=yjxAoSfZQ8qgcO7MR9/+POxtx+TQexaZJm7xrMM5Wyc=; b=C/4zFXMHDLNs2il30mDWEEfs2twSq6HJAn5HH5TofiHfF+vixewENKjvmwOGtTKpGqNg8WhhHRmjW+hE8SGi5X/ib1G2yiA7tXz6kLYHQ9LouQcoLTNlLUYmunFjfaS778DNlqZjGub0aBg8lQaP9SDt9ze5qjQLKwVSW5IjTKZh6sH99P839pkku3R7ucnPQ5f27Modl2P8tUi+uIHOX8WCve6mh8AIpOK2SjKiKKbCykTLShWL82UWbk6lAPsIu3whI9coVbhD8+H92OghQQhLacaBdxngwXIEArlxYSCNkIXsa2PP8KmK9mul/IQ50gzkO0jenC07BECh7RALEQ== 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=yjxAoSfZQ8qgcO7MR9/+POxtx+TQexaZJm7xrMM5Wyc=; b=Q1OJgEx3t4wzdAy9u59HL2tvxbCtDMo+uwsjyM9EYaoWsnu0HyqcpHuug8JC5ENTru6Q1l9hvYRnf57oIxgmGktz88LwDnzzV0TzFqUJ8DPJXUo8J9BgdccoBVNPmkAG6HwH7ZWjH8JnA8INN5BmzQmP7JuCln4VUvIIYTQyQ64= 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 SJ0PR01MB6304.prod.exchangelabs.com (2603:10b6:a03:297::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Wed, 7 Jun 2023 08:32:51 +0000 Received: from DM5PR0102MB3590.prod.exchangelabs.com ([fe80::5aae:2a5e:15f5:8196]) by DM5PR0102MB3590.prod.exchangelabs.com ([fe80::5aae:2a5e:15f5:8196%2]) with mapi id 15.20.6455.030; Wed, 7 Jun 2023 08:32:51 +0000 From: Ilkka Koskinen To: Jonathan Corbet , Will Deacon , Mark Rutland , Besar Wicaksono , Suzuki K Poulose , Robin Murphy Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ilkka Koskinen Subject: [PATCH v3 3/4] perf: arm_cspmu: Support implementation specific validation Date: Wed, 7 Jun 2023 01:31:38 -0700 Message-Id: <20230607083139.3498788-4-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607083139.3498788-1-ilkka@os.amperecomputing.com> References: <20230607083139.3498788-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH2PR19CA0009.namprd19.prod.outlook.com (2603:10b6:610:4d::19) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR0102MB3590:EE_|SJ0PR01MB6304:EE_ X-MS-Office365-Filtering-Correlation-Id: 475f0c83-cc23-4494-1a7d-08db6731c857 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k3oG+wrTuXUQ+/9UTCWe3zc7snU3Sh6bOVYOIGRDQQfmfCRLHLb6Wku92jrs3VkGUqVP3OSgw8yljf5jkR3oTuVDTHXXedOgoomheRL4IbgvE6zcOjMrZWhpNagNVoWMF+F+3/4C42IEooX4dgQiZugqZdaL/QLrClOZAM70BG8vpb3Vvr7iUn/SGhEFNd3K/HyzPLys8p27e9kRbzxGnfzYTcnkNMJWKKFYHUc4xdlOnnzVxUNK1Lx0C2ECvX9QOiARFVkASAR7cEhV5A+5Ep0ExIUOD4UOgHc4maHNBMq1NqMzpOagWK7j4hYAEHS3+VHKLiCFnazKlbT/GozIEtf+YCZJw+AcgV8dO5VixCU5AcHxl1z2SUTLgQ7H6/AYhCEJVtCKYCkiMWSD3jijKG0rdrw08MjZ4rmCyYZrGCJN/0VVJMoMT6g/ihjekeePVNjrGW+dwxTyxAHyE+fqu4LUVWXcYvQ+BkeFR9aFORmKFZoGUzWs3oJsdTJZv9gqvZmQI6PhyJZCsNQQN0jqQ281wpVudaPwuYeXMlKRyPxVZ2ikUVWKjf4AJz96hGErUJK8k+D86FtTlVnWhsxPYuMNBG2ZTDJWicLTB0GMEKIuQ4NRA8F98QJD1x3WQSk/ 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)(136003)(39860400002)(346002)(366004)(376002)(396003)(451199021)(107886003)(6506007)(1076003)(186003)(26005)(6512007)(2616005)(83380400001)(52116002)(6486002)(6666004)(2906002)(8676002)(8936002)(110136005)(478600001)(41300700001)(5660300002)(316002)(38350700002)(86362001)(38100700002)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L2MWHXjPDdRdBTZU7dnEyPvxgwfZ4UXU4OsyZjeLj0s5wDhlxhF/2OxQQB0tZfDq6E7TxkkXgQWMu9uebz3HVd5jEI9ZULp/UcSZEo6Xm0vbOTNXRRLLOfbRph8yqjuHYbGLHsso1tIv2+mQZajlKVu++t1Y05ZbSPq7/OrFFPm4lACnQOL8igIlp+ZWEZKJa2Qh8WerPJ7yb8QgCWrVKlk+UC+CWU9mWlLU5pBEHiyG7WIPUtSl5iZTBbIiSpY6tlJac7JpGewnaYvTk2WT9W8soHK2PBxXG9C9fQTbj60nL8GHAtSx/EPHvcdotR/mLFQvqFOawLQ3gVdYytmgrNMQf149RwI6xo+PfkexpNNKOab05qCOMxeIPTIFFNf2mPWehMlYjBfKwTuGAjiACucCEkO+Q18In71alcLpNUtKaIj/uq6w4+ROwV4RJAZvxmlVu6XSK6bSkmDg25R7t+w5MN7mzgou4QH3UbeL152VvEKPbbXURUr9iG7qcPffdwRydKVJkE9AhueO2PsEc273e5W4k/bHeP7HZDkJsDMB15/xKVzM9mfzmdI3DVYXMHKyyhuk0HtrvapuR2w0qZOQsNC3kXILV6OslKrOQJumu5KIFF7ljU2XYn2Gs3ddEfCNBi3v0UdM7vAFd3E+bJL4oRAhu4IprHyyZo0LVsiBdOjN0ocXYG1TBlgMgZVxdpFnMcKQKLOaafpDt9q2H0wVB30CjLTB9gX88PxzH7TMEB8UGVGKbcD92c2QStFf0uxW+RYn3FCRKYA5cXBnWIDFFWETMXfjckgAoN3sWXoaQEIFiD9gvajMP5FIhhC980OmDZlcpyb+kMOK0OMHf+sIJftXwKJQ832YCTNI47wDwWtTyT4mxTyikm9zev4UNjR2NwUA/bIUHKDsAN7f7aX4uoxdRtk+CD4ViFq4ptEBIezvaGoIAlFAyHC1zld5Ax95ka/27mlfj7FL6TtF3I1aw4G59XkyxZXYoX2G+yqPi3EMvBWEpRKc14RlIkDqXaAAZKwuC0tGz3Fdi79m596TITGHM3G8wHmXF0NIH5KnL4EJ27UWcH4GbCyHNJCdw78PtNm3k05MD68SSzdAUEYMANgNn3kFhmeRrnehrZMC3v8wFommQNSgO/O9tnXbdXeqR/mLUF3SMUUc1NVcCq3xDu7yo7NPmWd+3I/mnaTxhydejkGvJYNBN0G4+5HPRYKQ1OPrdL7RiUOH5tCBgGdG9tqtQ5nAskiJFb6kC8YNEDK8tLeLMxv9qBO7VGSgfhMNCnKCKsY8lUeaaansPSeTE1c0iBdo7p9kvdsaB4wgfEri1rhFAIBnlBdB1LjtdLMoaAct5LsXLFS53B5Mrd2Iq33Dq67aYJICXYNMF67ZXNkcXEo8DqGcwSaHa5aMDRXFM+Z0L1mP77JhYQfv5BJzzP/K6F8xNfXJOcRalp6gl6Fy+k45bpIIDBRLQ12oYgS1f28nkj7R/ftiwfbBavnzZawueP+6tR7t/7Pe5hmwoicFvw22qH/Q8i5mFmEjGsghLvAdWPgOHOrW1GBlS439OdgY+rM/HIi4nsYgC4gtSxJJenJyTHMHImJVz/BQzhDVKs2MEQ7s7sedcEnlrw== X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 475f0c83-cc23-4494-1a7d-08db6731c857 X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2023 08:32:51.6637 (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: +ogIkfR074TxTPQS3Pv205KYCImmD/BVogpcSmkSbu3B1YI4o2CySygF4JWuEw0487VUDoS8ElJ5pfmwbICzjQPCyRgiU21q5VSqVmPsSYtJUv7vk1pKpH6FK382SDS2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6304 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_013256_418876_77DD63E4 X-CRM114-Status: GOOD ( 14.45 ) 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 --- drivers/perf/arm_cspmu/arm_cspmu.c | 13 ++++++++++++- drivers/perf/arm_cspmu/arm_cspmu.h | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c index 72ca4f56347c..9021d1878250 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -559,7 +559,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)) { @@ -593,6 +593,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; @@ -618,6 +624,7 @@ static bool arm_cspmu_validate_event(struct pmu *pmu, */ static bool arm_cspmu_validate_group(struct perf_event *event) { + struct arm_cspmu *cspmu = to_arm_cspmu(event->pmu); struct perf_event *sibling, *leader = event->group_leader; struct arm_cspmu_hw_events fake_hw_events; @@ -635,6 +642,10 @@ static bool arm_cspmu_validate_group(struct perf_event *event) return false; } + if (cspmu->impl.ops.validate_group && + cspmu->impl.ops.validate_group(event)) + return false; + return arm_cspmu_validate_event(event->pmu, &fake_hw_events, event); } diff --git a/drivers/perf/arm_cspmu/arm_cspmu.h b/drivers/perf/arm_cspmu/arm_cspmu.h index f89ae2077164..291cedb196ea 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.h +++ b/drivers/perf/arm_cspmu/arm_cspmu.h @@ -106,6 +106,10 @@ struct arm_cspmu_impl_ops { void (*set_ev_filter)(struct arm_cspmu *cspmu, struct hw_perf_event *hwc, u32 filter); + /* Implementation specific group validation */ + int (*validate_group)(struct perf_event *event); + /* Implementation specific event validation */ + int (*validate_event)(struct arm_cspmu *cspmu, struct perf_event *new); /* Hide/show unsupported events */ umode_t (*event_attr_is_visible)(struct kobject *kobj, struct attribute *attr, int unused); From patchwork Wed Jun 7 08:31: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: 13270167 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 69E8DC77B7A for ; Wed, 7 Jun 2023 08:33:36 +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=p8ed7/SemOXQBaP4oj5KNYLIBWS9kOYGqG3wgsJLF8U=; b=HACafcxI78jPPO /qO6XAejpxx6aWYmyMz7IUuucb8wGEis7aVEniaf6bb9T6PNBfAQjYf9vxI5lxxKqyJywoQim2k3G hxMeNrGI8cGHVNCcKKsbLAjwmSZxIkqHM5j3DhbZX4UJ7YyWs1yirKCvVDnsZ3rAxExqskb4/gsSM sZLmNLOdSoEmChR4Ep/iZc5HEx/CZWo/Z3TSeoGqIPZHJV7h/Oi7mgz57x2eSN/dWRmrPzCnH2LgG S9ckXjlBQpzRWibmj1JFM3aVbUsYFGysoc5Sr3NGA6Ls/ocjogCe81hZ4RPriGVqp8OZS99eAljpT 562ftg8xGnWoiDsiUuCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6obK-004yrd-1K; Wed, 07 Jun 2023 08:33:06 +0000 Received: from mail-dm6nam12on20712.outbound.protection.outlook.com ([2a01:111:f400:fe59::712] helo=NAM12-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6obG-004ypj-2f for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2023 08:33:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RXmSFKiKWtP60Nm1shUUTAd1hCx3v49mHIdzJXkNZ4wR/JXj2B/+8E56Psb2m9R/oeI5GpDuG+WqDqPbGHK/LwMQcAbV1Fr+uCAFwoIuaS+xjxBSyLk8ugCIHX6E5fQ7md0/F8jZMSO5TSaDkXoDVVG9xGvsNPbK1/+uDO5TaX94YuTTgIjmUD8v4zvErA9a+MMApzjY5gTSagHA02wEbRIl9mLQt3FIMLWNNupVVj1MBzmtkjveUYgb5zfsn5Vpjou6sraaLRi+RX+q0bmX8ocFcOk5UJBh64rkyI9cgEln77lVU52FD0u8p2/nubfWw+L/WdwZ1S8voL77oyvQmA== 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=LMHx0l0kalUhGd26c392PtqTJJnl0JPQWJmrDNddKio=; b=flo9AEINpLXR6pebzN7MV6mR7wKj72gRzU89LVDi3uCsxWdWNQkOPnQioD4sUdVv/Udf8M/jwaZXzSu7uFhHyLcBe+oXtjMNxw5jcB2sWCf8IMzr1xKBPHeYgG3EgyTmM/QFDHkiQuRj4akFo+bdeCS12V523hVf0HKIAybmMx+XtHo5gsR7H+SsAtc7fJ2MANZJF27GE/G0UrAwdym0juj+1wrh5LmYMDtiKrPcZUB7d50mVywcNE6LOwaQXBJPM6UjPvil36aEnEZWgDTDReCSWXS4WAMXh0hxUA+x5trxwF1xWfHTuj6G3AIwE3Y1MlQ1V2rhkJf3ANFW7C90MQ== 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=LMHx0l0kalUhGd26c392PtqTJJnl0JPQWJmrDNddKio=; b=DrAW/Nitkmsy2gKYG3+prYPSSS6+5n30/6BMFCmqzgRogoJpzqDh16VmewnfF41AMeLlseUWtE6pAiZMGBt1mLNzxIMPR8U1zLF3k7XK12mK4FhNR5BZw3EV2phT5FbxH0jPC1RPsaf6qm770qAEBTyOW+fuMTQQ2O04UPCenHU= 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 SJ0PR01MB6304.prod.exchangelabs.com (2603:10b6:a03:297::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.32; Wed, 7 Jun 2023 08:32:58 +0000 Received: from DM5PR0102MB3590.prod.exchangelabs.com ([fe80::5aae:2a5e:15f5:8196]) by DM5PR0102MB3590.prod.exchangelabs.com ([fe80::5aae:2a5e:15f5:8196%2]) with mapi id 15.20.6455.030; Wed, 7 Jun 2023 08:32:57 +0000 From: Ilkka Koskinen To: Jonathan Corbet , Will Deacon , Mark Rutland , Besar Wicaksono , Suzuki K Poulose , Robin Murphy Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ilkka Koskinen Subject: [PATCH v3 4/4] perf: arm_cspmu: ampere_cspmu: Add support for Ampere SoC PMU Date: Wed, 7 Jun 2023 01:31:39 -0700 Message-Id: <20230607083139.3498788-5-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230607083139.3498788-1-ilkka@os.amperecomputing.com> References: <20230607083139.3498788-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH2PR19CA0009.namprd19.prod.outlook.com (2603:10b6:610:4d::19) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR0102MB3590:EE_|SJ0PR01MB6304:EE_ X-MS-Office365-Filtering-Correlation-Id: 84ea2b9e-6f57-4743-56ee-08db6731cc0e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jL9l2/1nCgevr/sqDzCU9X/IuSMuySqLazS3Lnsm5Nj71vx9HaS9VzGJJgoGu0g6tEubByVlBo6GvUvEYznnkJinlfePdn4P0J8tEjXg07CNeQoR+ynuZRMK4jaQM9Ec01+1lFo+HeKSQRPAlKEZOYDL0k9VsL/jlorvyPS6D5DxSztgOK8EylKX356UiBaTPshqTYvj8O2AWmekUEKI88/LLgfZCwm5fosFiruda6o+tADps+OBH+J5ilbYkbxQzLHSzWzDmGb4mryjIqMxz2wUMj2vU5hTSaBrTPzgkKP+I4HNWKmXvyAad54zCl4UPj6k4/cwm0FspuurqXDlRIQyXU6jVoqFeZdNnHUSOJNfAdyOfcwl2YdT5CA/xXOehKsd2LfWWEducTZyi63RSoTaKAHA0irR7qSZ75Z/GL0PAphxNVw2//F9x2+eHM9Sep1TdTzjGMqYoIY741siseRHcy+Rt+a+K6D6ihmLCVNEaaFVB5ws7JBHHKevO9bz6RNjs8NwAUXxJz4kxDN0Pzkoe0LRmaD2/6lOvivtokD1ULyztv0oK6x7fv1zmPyvmf+e1RthjP3Rgbq+h3YnO9JNSrcqAPaFueHVuI5Ri6sAl58peUsL78z6/+HNDPPY 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)(136003)(39860400002)(346002)(366004)(376002)(396003)(451199021)(107886003)(6506007)(1076003)(186003)(26005)(6512007)(2616005)(83380400001)(52116002)(6486002)(6666004)(30864003)(2906002)(8676002)(8936002)(110136005)(478600001)(41300700001)(5660300002)(316002)(38350700002)(86362001)(38100700002)(4326008)(66476007)(66556008)(66946007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9/W+frkZY+CWoKv1oHLKM3gQPe3Ruz5pzCFMX9F9paN2SpTcyksjU+N8DGm9UfUVlAfcFO4LeYMiAbtNeQUHeaeY10VAytLHW+VHpoXTw6P0e7nMpX/DRJGi/MkPib2QdJaQoITqn2hUsSL4yvntTtKjESG2H17IaryJumDYoaWtGSdmk0F2QMH/9lD7H6Es1ACLwDAhlUA6ws2vWewfcKELLlmzjQawRjWicU7sCn2RlmlV5bM+wyRb6tQPJ3QJr7M1Xw5AyOpAuWKvWrW+Ahz8aDoKORQXCylRJCiSbLr5ePt5GCOnQO1HccTOdg31g6Xxd2vkSB8C7DXdxuYInW9bJJloTAjE+vLCfbYE3d5dV7Dm9faqYYsIwZp3hlEDZkD7e1u/REtHi6I+xbOQZ5OrSEf+OK3NIxs01rhWgQtkuzZZVOX0xijBb2sGPNAH5hqxl+ThezLnSPLVHT0VkkfDEJN3QNbOYzox7d6+xJC1lFEW1kWd+e2+BbkXStgDZOIe7o8FALxDyl38WckWY3rwasNv4hlyfaFw8jekM7ei6T9MufHr/g204gEmcL0BX9bV4lyI+joPvavOyo4NJFcWaVqSATSOV1PFGF6NxSiNf7O9RN0LmS8RYXbsjsKuJQJLxWyuhYHChWv5B9kU3iVveH3HmvPfVv6/d96kpQOTYWLHh1GVvlYOaRKU+fUBUEY/dzLVrXlw0mcllrb4p26+RlQ1s5+uKGe2xYNECNzQyusADgu5zv+q60eZbz9G47pf9uF9vXlJiRJVwZe+750K7IyiVzi2uJpe8gq8Ik0qWzdlrEGoEXP7H05seORG8wA/tETX9++gCIQCrEScV5QoqJxmRqbfozvE6/vt5z8I7kUp1+AujjNPjbQfi7Ce77XsDlEuqcijhwYSCUk0r9UdXPimz64fCpkd0jMozvNOMRy2JRe94/TwS8XA5ETAduXoXDuUKrzY6yeX/QvieSYOdixxiOyeDHuV8a8tHXiaD2VKnW6v1tdJjaU5KlYf09zI9AdLJkNMkBLOvfq7mEmP8Qb1pbD6n+OKIiNluXcsCZ0ZvhyioBV6BaDAA2mJX0rdJWhw8TrSoBKVEu4muzkG6keiaYGd92NfNFeYUUsAfDdUb8LbDFz7xu5XjHixKmKNR4U7BlU+oc1voxUO9+PSHIG1qSklMvyXYQSrM7ZSfFYk3OrE1gQNNdkJDp8iPiLNzY9mC3eVogjaVzvh7VteTAHpm9Egy9Rj9uD8m9bhVHsKZwQUeHgECvsm3ad3DrvLsPO4aO1nCi6f8XFoV7J/nNJdnUCLciPQItTBFUnKxzV5caS+vneEToiDV6u0WUD/EGYqv91/DwGSxM9reMafnj4KFZvdSelZbrV5yQmhg9eGvRpoRA5SUzuPCc6hl6kIsELwa8pW+J8Xassg5c/BCsG1oAQwB3BbsJbZHx9hAuIdsuwQSSmsK0FnMgRfiXGkLRe6slhXNgVzbVI/NsM3F8pCHPa/2P8mszpiNnbb7k6/dlcLdKWAHi1MUbP/GTzlcq48LPPPfJLo+cJy1E2wzg0AP7iT8dU5lzILeLHc97/ceOCgQ1D3J0b+6I3hVqjEQ9KJv/z/siXDiXGogw== X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84ea2b9e-6f57-4743-56ee-08db6731cc0e X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2023 08:32:57.9245 (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: Tn+q3x4GVYhSzDaK9sBELVI+dDC/Q0DHsVMZl8SwI5Y5f3UIAJTy3EQAHw7uYXp8tYAaRBvDberwY6bLIRJW2oUAmxJ/v7WADQH7cr+GrGgMuGq6wlrs/9DQdMaPiVzd X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6304 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230607_013302_917549_165DDE4F X-CRM114-Status: GOOD ( 19.49 ) 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 | 7 + 5 files changed, 297 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..1c57feb4b6ce --- /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; +}; + +#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, config2, 0, 31); + +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, "config2:0-31"), + 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) +{ + 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_params(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_group(struct perf_event *event) +{ + struct perf_event *sibling, *leader = event->group_leader; + int ret; + + ret = ampere_cspmu_validate_params(event, leader); + if (ret) + return ret; + + for_each_sibling_event(sibling, leader) { + ret = ampere_cspmu_validate_params(sibling, leader); + if (ret) + return ret; + } + + return 0; +} + +static int ampere_cspmu_validate_event(struct arm_cspmu *cspmu, + struct perf_event *new) +{ + struct perf_event *curr; + unsigned int idx; + + /* We compare the global filter settings to existing events */ + idx = find_first_bit(cspmu->hw_events.used_ctrs, + cspmu->cycle_counter_logical_idx); + + /* This is the first event */ + if (idx == cspmu->cycle_counter_logical_idx) + return 0; + + curr = cspmu->hw_events.events[idx]; + + return ampere_cspmu_validate_params(curr, new); +} + +static char *ampere_cspmu_format_name(const struct arm_cspmu *cspmu, + const char *name_pattern) +{ + struct device *dev = cspmu->dev; + static atomic_t pmu_generic_idx = {0}; + + return devm_kasprintf(dev, GFP_KERNEL, name_pattern, + atomic_fetch_inc(&pmu_generic_idx)); +} + +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_%u"); + 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_group = ampere_cspmu_validate_group; + 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; +} 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 9021d1878250..885393ed993e 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -30,6 +30,7 @@ #include #include +#include "ampere_cspmu.h" #include "arm_cspmu.h" #include "nvidia_cspmu.h" @@ -119,6 +120,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; @@ -394,6 +396,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 + }, {} };