From patchwork Thu Jun 1 03:01:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13262927 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 D2997C7EE2E for ; Thu, 1 Jun 2023 03:03:32 +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=AIS7r+sl8U8RA2HWNjZKRuzPXv/jbuTwWPykXmgM2ao=; b=qua8Ox4AaBSCRp FFME2nExmWilWdgzQj17DPLHQrWILAOepZHgRs8B0JXq96eINEqTPsK1C4N4NPJmx3kK9V6YigNC2 mqxDuV6DO2iAd0W3TTry2ZZRkFtmhS3mAOQgcchAtmFQWA885f0gg3+gTIDf8T8JfHNJn/QCOpkjA QetsF97g2AzECJvcsgeBkxT4vJJBcn9XJzdM40zmUl9vKexij+NGzusmQTo5GeLlCItD0szH20P76 XBa4d1m4oTeB61889VlvjxYCZ97G8flMq7gxm4wULRHvp/LkJA3unOuKwX1Cwu1caQskzM/of42pm OVn01LcsBmnij34hibuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4Yah-001lVJ-0L; Thu, 01 Jun 2023 03:03:07 +0000 Received: from mail-mw2nam04on20728.outbound.protection.outlook.com ([2a01:111:f400:7e8c::728] helo=NAM04-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4YaO-001lOq-1m for linux-arm-kernel@lists.infradead.org; Thu, 01 Jun 2023 03:02:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q0nloie8MgHPcYKjAtMhK9c4102aaUTlpbQg7crnkkpLOjWhAa4ZYBDkZyOajM1w4YMfT7UOxTLoPg2NvL8mBLiyba0ukcwmLcUta9uxUFjkZ9clWEo2ON1dJUPChHhAmXp9obo9yDwQdY519BkJSCJOffwdUk0f9pVctKvSDakaHGtvZR8eKD1jQDIOxTUoljXVvxSqpetvQynjLZKATtD2myWbTfGoqThxcxqoWGUVwevbjRrVuydalntSbVAhJ6hswJiEBzcnj2/ED8JWFjfmsKs8rz/a7JEbulSizd7YWVRQMYyrUvG2PFalLrv0MDFuTwvCVxH7dlo7LDF7/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=mlCrTF6C2+up+uJwUz/+2GQjwEbJPa3IZKxxzBeUoXE=; b=CiANRHIw8kVRRlCLenSd+DO1gVTgNOtdApCjPj9p7yhyzLOLVscL/ujl1relfF1ZeSCX9/jyH7miC5XUh6TJyr8VrBkKCPdNxmpi36KVL6IrBCM7xu7yHK7AwJYp0SPFaAbU27BMbjaCsFiP1UCkYBFazfPkE2lcn1+TQMuDxp9T7nBuCiwvDLCFrjhFraF/zBFj1NWBq/UrDeuekXGYYufCor6CatA3XCEx0QJc6N+vbL5E34J4iZRnpcACqX37JRxuX7s9VOtxtGkCcErYRotEOVylcc4HLMJtYrhxS0j4pm0rTee4O3W5nszMfudoWBlGtecKldOqnUX+PLwdqg== 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=mlCrTF6C2+up+uJwUz/+2GQjwEbJPa3IZKxxzBeUoXE=; b=HVL6ZH4CkeWlKSDgx4fu2ZPVM+g+/fVtyTwNDEQQXJ3X3fRyGOzzvgR2xBsrij9S8+vyjPNR8c5/tsHUXG9JMyaRtzKV9rnLBNIRT60okeGt+wEcKaHRrTnJ8P1LN0fwKXISUMe8pBtmkUMdPhfmFLDikV7Wr8v3EvI0BYp/eiM= 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 CO1PR01MB6709.prod.exchangelabs.com (2603:10b6:303:f9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 03:02: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.6433.022; Thu, 1 Jun 2023 03:02: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 v2 4/5] perf: arm_cspmu: Support implementation specific event validation Date: Wed, 31 May 2023 20:01:43 -0700 Message-Id: <20230601030144.3458136-5-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230601030144.3458136-1-ilkka@os.amperecomputing.com> References: <20230601030144.3458136-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH0PR08CA0015.namprd08.prod.outlook.com (2603:10b6:610:33::20) To DM5PR0102MB3590.prod.exchangelabs.com (2603:10b6:4:a4::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM5PR0102MB3590:EE_|CO1PR01MB6709:EE_ X-MS-Office365-Filtering-Correlation-Id: c046a792-e1dd-490b-3e1b-08db624cad06 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2jABTIAZk2xCzdtSGHYRJ0W4m2jqkQfB1h+8l4Xey0nI/hYzgF1kaZciGa+KYfxg7YskqnVQFjux4b8Zl6Mm1Y88q3/agYvtWoftZDA+l8ZcIqyXaFqxRVGhXXhiB41ZZEN8ihhZfILfHLQYF0UBak0BMCrk+S4GgNyy4r0bY2ExahHZqFaUzAgq3WuxPCJ42v/fHCCrH/6cl5WyfCrJ8OqTvW6jXUay36R/zA3MbZsJWkn/g8h1r9J7DkUreWJhUx/yWheXSea8GynNb2K6gK8axoh2bnW93YOC6kmgFse7iNnxuMQ3WDoA98WrICZcFyis08l8j4o+RVCsNYuA4+PllIvmqgKl1W60kloKRzmSrD33otpwFlp8YDKij3nTyQk9RFU2h5GwdHUtZoMCXVOlQmAwQwx2mtn6bcYTpubrVaNwj8INjIDVzYOWfLuviQ1mxL7a4vjwkJmeKuPbX+4V5obGToS//3nYbFTUTAxukWe3+tZEHCDEshdY9m15KgpdXUR1/x19ja7RoRuttgjc7p5ILNO6SX0wprFQGw5cyJfy92sg6W4mePV7pYXc4vcvNmqyFRflMALQJ19YesrEO8inEKZVHQvaOohi15RIECxdAjbOJv4Vv7Z9tmHL8cxLPX6Ap09vXiozemZ0jQfYJsuIqJYA/fJUYp4P8b8= 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)(39860400002)(136003)(366004)(376002)(346002)(451199021)(316002)(83380400001)(2906002)(110136005)(6506007)(1076003)(38100700002)(26005)(6512007)(66556008)(66476007)(4326008)(38350700002)(66946007)(86362001)(2616005)(478600001)(5660300002)(186003)(6666004)(41300700001)(52116002)(6486002)(8676002)(8936002)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GaZ2/dinyw/19s2oqrnfp/E20hQ2GTysaNpFDOHo1I2FewjOIMrglvqJL7bbUQN++UXvZhc/5MQrBudRLfH5Zylywi/w4lsM60EgzkZIfjv54lMzOm8+pJQr9E+gAtqE7vHW9/ZtBryLP9B3E+LqsTfudskOmShMJW0ySJizH4kwzADCmEVHTnMLCiAaRs8YLKFCjHNXe5nbJm8JAGE5jwVakoygBeczzXuSOSir1+pxburmQA854ZMpl8R5uJCBfz1ULGFP4eSlXzuqF0e1QtUGxm185594ZG6gRW5Iji0qOAOkBlX6eTK6290PPNcEB9qMv8MAm85xG1AUf+kZv9MV92g7uyjMvDtLlxYGLD2tI3a/THK5dHc6l0/bIpnRK2I1s6nUTLqrXjEyDTMiCmqnPc4sghEcqGRB+7KQWEjMFL8jDpXeX1l7EY6032ajulAlXiArFJp/72x2AhKIqkefcGGWNiE1A8Wblj4KhVv47fduuBrx1L3q45qwtoRjJm81JmvHH8azIG/5Zr8xLa1VxziK594c9pZcPviDKH+Gy7xPS0M2hbvetFMHDdCzwZ8I+40wej3ienqaT6zvusen9zkiebeCEiFMcBo8FtWsWfRP45y7G7y/MjLCLmX9ZLbc4mnF1fCp48zgkosQyoJjztLhOEgRd34F9SM/Ut8lmpUJEBavOjDNncc9qjLt86KW7EuJwiXF+JDF4IAJNb3au+ENJOK/ahZtxqwrfVObjQWAWBINz0f+a63yfvOR+Zb/kat5coc32H1OXjjhRDTcsDTXltgUyMtyQXREm5RTQHgnERzHj+XsvGjYXhDqt9sDIMveRitQeyC6C3iPW0I7iKYTyuGTP2DPGQ1NuIlEKIfzbapoKduxLN75vxhAalY/95oNgx1cIJCI6Ra/98zzTpMcHvyY7xHwgN2k7/fv8QlPO/QcUDFmQeYKnPyxRmGh1NrzDDSFukdJyPlc3HbWSW91STmTgbNzpcvdYA7rXaAXEuFnUj3S95gEGOFbaJG9SUqMVjyLgYOzMVpY7Gb+GN8QZeP5lE4puhSWBjvHdztxgpRVb0HGYGzZ8moSgVOFXaRwvnM255dA7k+Putqdqe6u98Op9OyvhBZ70sV+sO+GJJSRWBN+1JEjfNZ8N9SaAmcfzu/rylirUuTj63snuw+Ee9N1BfC6RApcz6SG2GuRI1oijXVIWE3grNI4fvuQmCNIWyqubAqz7Khrcglx6lA4MssBpqwEu6adqoI4YP23MZBdPMb/vMqPUSj40ghTx8CGD9VK6EbHpwjSQsiem/Xp7Bxh1zSEwI83B7ZLrLsCiDBqXa5JjYOMQ/iN7WG5uFr51TlYqK3n4i1JlRNds7/wL2gXmPyPwDkXZpF9JvMwub4eAqfTQwF2tMqXH9yZm4FYWqmhHt4Ct7oZZmkbP3lBYUpj0Mka2GPmip/FPfJJs9s6R9T7HjwDDQFOaIyeVg2yHtLrcS1exgS0vSaRDyNMUpMxcVkxGJHzTgpE8ZBmgZNaykz5IWhUqwergP0RHcwZq3bu+MwFE3d1oN7bipUiEpX8aMEtt4Udhosl7l37c273YfawBJyotoACCQhiC4Nc8lhEWd7MGLUHzs+o6MrJi0JTSG93c3e17I4= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: c046a792-e1dd-490b-3e1b-08db624cad06 X-MS-Exchange-CrossTenant-AuthSource: DM5PR0102MB3590.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 03:02:46.4733 (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: G+S9Uj10Icce90UndLwZS1N6xtVkKxuuUb4F4UK4AVUqZMdkTdJCsjyA852dskSRvjKv8jPmY5D0ML294STTURL4BrAlgvKgCmIkZBp0pPfTnYMpkqXx/IJ5NMgMre9d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR01MB6709 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230531_200248_597590_0865B104 X-CRM114-Status: GOOD ( 11.70 ) 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. Signed-off-by: Ilkka Koskinen --- drivers/perf/arm_cspmu/arm_cspmu.c | 4 ++++ drivers/perf/arm_cspmu/arm_cspmu.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/arm_cspmu.c index b4c4ef81c719..a26f484e06b1 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -593,6 +593,10 @@ 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 && + !cspmu->impl.ops.validate_event(cspmu, event)) + return -EAGAIN; + 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 4a29b921f7e8..0e5c316c96f9 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.h +++ b/drivers/perf/arm_cspmu/arm_cspmu.h @@ -106,6 +106,8 @@ struct arm_cspmu_impl_ops { void (*set_ev_filter)(struct arm_cspmu *cspmu, struct hw_perf_event *hwc, u32 filter); + /* Implementation specific event validation */ + bool (*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);