From nobody Sun Dec 14 13:49:49 2025 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013017.outbound.protection.outlook.com [52.101.67.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 149BA1DE3D2 for ; Wed, 11 Dec 2024 16:51:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.17 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935876; cv=fail; b=AV0klTfarm0sUkaArEfuhm/A0D7zaJmWoZIbH33x146+hbb8PWekxRgu+11GhsdwzJ0C0zo6O2iK66Zaqbk336h0O0m4RcGQFnb88NuEiEw5bMYMQZpc4bNSm25rL94tv95gvJaf0uJNq3WYC/aXngvtpiyZgNKSU4S5gls5RCA= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935876; c=relaxed/simple; bh=y+V5tHaB4VCBaWSRjrBGGaReYYahp0XSKHi/1ufhay8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ioDPbfCb+4k7QwXp6itg8/+ZWneokbZBtnQURG7LyMOWR7GiWIFw8cECiI3tk2x1ej9HlLC3Np9OIcLKXl7RN0SGlgG0Gfawr6kteVAE517Nk81e/DIsvy5oRmwYuONGCGYkxpVnw9k0LrmiYVeC91Ke9neRX3hx8UReTYDy2L4= ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=XFMgLd/L; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=XFMgLd/L; arc=fail smtp.client-ip=52.101.67.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="XFMgLd/L"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="XFMgLd/L" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=FhqKkMA2S4VoizAZ6xcfGMecS997LeWiLD0m1PjByN7nRWPcG9myquOwLZf8rgiNTiSACvQrQiSO9T+k1O74uThH+STXPszz7voOec2quol/GAep0e4QkBejsVeI7YVb1BrMGV5462BDXm9YM90WrDqyYAMjzMp8PbBZYFNNTQJkNX4eafSWe+v0vBtoPoSwcRIfqDX13F0rmudHfjfEDWvRagp+ZQ5ZYyJwKCmQKhDYpXINK0RlivBtz+vmIYOaAo7IchFRuoY2ThK1a+ogVjGz/xcvraEJyR1I6bo3HZsR5YQ9QuuysxIdyNmkxbithpcnxun0cYMBtOQCkPTCkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=AaX14YeBrqQ55oL90hZxXWkPfrsjE1oA4+6EggOQyC8=; b=Uf+ywg+b5cyczqh/tbS2tpQFbaJytRjCkFS0McD/cns+K8sXy+6I6B8Ihp3haLGJUJpKi+ZmPz+llgv7xLZSU3xSPEM+A7mgHfGz1AJT9jfYU10+yO87WH+/V4k4wAC2PR+3ASQHO4cKgAaB9Dq2v9cwqzfB6sztBL0fTx79W383VdWHzHFII/iBkpGjHsjzFoC2VsykkPhe80bHbgJglDc6GkWyIXntuhg8bkl8E8vd2Kt880gQrHJE8tdrPtucFsT6pv03a+vY+glLm0ayuB6HYKS89pIQ5INd8cta3AmggLRUsWJgkfHdv4EMPDqsP3V20GOsv65I1T7W8gom1Q== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AaX14YeBrqQ55oL90hZxXWkPfrsjE1oA4+6EggOQyC8=; b=XFMgLd/Ld6kKWf1W9JZ/+/jL8CKBtab8BGi8xXSmDX9/7P1tKFPXmw+YI6Ickk/Z3910I7iy/3z+Ki6rDC4lsCSd6DHu1Yb8m4yHwfasLjc4qMAzkquwuG/V0bqIdq4VwXC1Dx1TUEBZj9S5JDpKAsNeJkmBSLT/+XFdrgEy5+8= Received: from AM0PR01CA0081.eurprd01.prod.exchangelabs.com (2603:10a6:208:10e::22) by DBAPR08MB5607.eurprd08.prod.outlook.com (2603:10a6:10:1ae::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 16:51:04 +0000 Received: from AM3PEPF00009B9E.eurprd04.prod.outlook.com (2603:10a6:208:10e:cafe::a7) by AM0PR01CA0081.outlook.office365.com (2603:10a6:208:10e::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.20 via Frontend Transport; Wed, 11 Dec 2024 16:51:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM3PEPF00009B9E.mail.protection.outlook.com (10.167.16.23) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:03 +0000 Received: ("Tessian outbound b4c479532664:v524"); Wed, 11 Dec 2024 16:51:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6735a9b1c298019f X-TessianGatewayMetadata: mPGgXeDGlzWhPLjJz6rDC4d2cvl90ccw1fRBdYPODbBdthwifJsUQpXMkSSYO4HYLdF/lbY/4GIEGWHrxUc/3gfug4OnW+uzaDjU+TrLw0KfWPLN+uvOA9YNDRWg0llQWvD+d5yM+GMFOtr6HAJteQFnZsKOR6MHY8RK4JLxblQ= X-CR-MTA-TID: 64aa7808 Received: from Lb4d115023e01.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 08B2961B-B90F-474D-810F-F2A149523A9E.1; Wed, 11 Dec 2024 16:50:55 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Lb4d115023e01.1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 11 Dec 2024 16:50:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WsGj0TMHKm4PbUpHkC3vRJoagy6AH5peNiF+Htxn3EUrPhTNUAe5dPaFiSquqynr3IRyKTTADr96g6PkpCvirhZgANHKXjQCRrtU9Ni34mognSM4qexcrowSdW64B+DB2wWjeBvP6WuugzoGuncWjiq5O1tbqGvPLS1NpiPJ43RQHAH0cbjmk8lY5S0+4esvETTy7vApIIMJAhrIR2IY6xSuB9ZrLjcdFBcwtvWnzcyFLY7v5KNsbUXGhltIUAALZutTJJCBQ9Z1WSJ3kuy0TB1viVLfGEULE2ViCkBh39PqoMwqDn9djXUT3+iOqZzNp0KkkfR5Xm3whvu5ih8B6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=AaX14YeBrqQ55oL90hZxXWkPfrsjE1oA4+6EggOQyC8=; b=YJ1CHGpx9xf2GBJHz66izkfnNZS/zW94aez85YYiWPlfLx8LmLAepFCzeWe0xVM89IaU4oxcSJGPlweDJGY9jjGztBD/l9vULeKOcrLb8pSTudqe54e8lHjp3vGIN14QxH9FWs57ekprTVNYhFpwOGTuM9kjYo5uGvdrm3guTKya19JF6hcTtHrSBm/yUBNrkROlIxhLAkWN98SAywlaho958uc/KOWALNVdrzmO6Obsd3Cgs0REVP8XEC4kfyNdWH63p16/pBQl21ATcPVoUJ10v64TSdvAVGoi2U2JXJkigjfx0L9PRT0nhxYz4E09rkuC7mpEza4SnR+L+j8YOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AaX14YeBrqQ55oL90hZxXWkPfrsjE1oA4+6EggOQyC8=; b=XFMgLd/Ld6kKWf1W9JZ/+/jL8CKBtab8BGi8xXSmDX9/7P1tKFPXmw+YI6Ickk/Z3910I7iy/3z+Ki6rDC4lsCSd6DHu1Yb8m4yHwfasLjc4qMAzkquwuG/V0bqIdq4VwXC1Dx1TUEBZj9S5JDpKAsNeJkmBSLT/+XFdrgEy5+8= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) by DU0PR08MB8422.eurprd08.prod.outlook.com (2603:10a6:10:406::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 16:50:53 +0000 Received: from AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897]) by AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897%7]) with mapi id 15.20.8230.016; Wed, 11 Dec 2024 16:50:53 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Mihail Atanassov , nd@arm.com, Lukas Zapolskas Subject: [RFC v2 1/8] drm/panthor: Add performance counter uAPI Date: Wed, 11 Dec 2024 16:50:17 +0000 Message-Id: <20241211165024.490748-2-lukas.zapolskas@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241211165024.490748-1-lukas.zapolskas@arm.com> References: <20241211165024.490748-1-lukas.zapolskas@arm.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO2P265CA0300.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a5::24) To AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM6PR08MB3317:EE_|DU0PR08MB8422:EE_|AM3PEPF00009B9E:EE_|DBAPR08MB5607:EE_ X-MS-Office365-Filtering-Correlation-Id: 5b203ed8-628c-4738-fab5-08dd1a04000d X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: =?us-ascii?Q?f1x9mEA7Pj3F1p1p/MQTC81bMimZQHUpcizg8JG2def6O9fiVANiXt0gWMQb?= =?us-ascii?Q?vIanwAjF2mKoXt31s0nt5QnDRYyTguzVhv9+QvfX1c4MBfnVQUeIX0L3dD/J?= =?us-ascii?Q?72X26O5c95UxpJRNQcDFPMZU2mPaBfA5aWfQRR7Jx5tHhn9sL/pDbjo6KIDi?= =?us-ascii?Q?p2V1IjvB+4dFW1KLb0LwQGTf7dy5wt13MwJuH9YA1wjJPosWSQCXZFAE8DP4?= =?us-ascii?Q?NOTL7zjXLIER2mU9CmfHUoJGrgAfUwReQhvcs5eJHMtFRGLo1ucECITQph2a?= =?us-ascii?Q?KNaKjdOb5M4Sm3CA0AZZzlZ6FyZmeP5G1uUcusFzle6e16ZO/9GzxBR9OvbI?= =?us-ascii?Q?VlIdEKWO7z7uzmrvBU/qjm4j5GcVnkKChu9KSB0+TfLMOjXG+1/WjOaDSVm/?= =?us-ascii?Q?Li5RdNBS9Xm40bW2dP/XqA1brWyehRzvXAYT6spncc6OWXiw5thBXDNljfDW?= =?us-ascii?Q?8p/z3knW7/aqq1Nb79L++ags8/sLmwm9jzD+DI4PMdlGo+gUl63pXtzw7mH7?= =?us-ascii?Q?oeZFBnJgNbrbslf05Z/+Ovtzffa8t3rcFhKa1uvqsQOhqA3u3jtA0nO7vZvs?= =?us-ascii?Q?SI5ZkW/E6zn80e/I5Swwvpwrt2S7K/BN7pDAWa6+pOFhC0ely7jlyhCwMtl4?= =?us-ascii?Q?qiT0mxtv89TFemDbkW+0oHNv8pqecOz3TZNgqC4G+nFbuBDtNW0S1wA+shbo?= =?us-ascii?Q?nBRec5hnpnAp6EyvBZPi+2loATDkbctBJ9Y8oripV11Pf62a9uyY37sWnJi1?= =?us-ascii?Q?/PTju7HWWMQwZRwHQ6lLs0Tk7xQwWqIGcvBBlIVP10+JGGkVTTLiT6OQIen/?= =?us-ascii?Q?61zlaI2X6fr5aJUEha8eNJxG60TTKm7nQQ+w+YvhWebOoyhzgAdVEqBY/rOY?= =?us-ascii?Q?nEs5hxlVFhNO2yzp/rcdRhmlG1IJn0mvHQURPy2BfPldAZ8q948H0O5AXsPw?= =?us-ascii?Q?LVH/iddAFuU9I+cJ+93KguMrMGWR1xyO5ht5wdWWroclaKVB+pMfO+i4BRwX?= =?us-ascii?Q?mX4cY7/mSIfib7lRlIfO8LlsdGOQuO4j/dDTxZR/8459AgQPELOCdiQFs835?= =?us-ascii?Q?DOvnEF5A9REfS1OIylsgGGUmJsW2COMp4orrbOUCKgOExXRA5Jnw/Hff6fp5?= =?us-ascii?Q?uJxKl+LjQGAAlzCkYEj6heMPNpkbK4vLofHn9/OAsl6Ow1xED77eUkToqLlQ?= =?us-ascii?Q?H4kyEudwelnV31rt6G3WvuM3IT4P7/cHp2S2dwZXD08sgMJhJ8/ZLUQDtzze?= =?us-ascii?Q?U3PlBnrq6aqBRX/NFtVMPDlSxwaVXqmRRRwxoDwcWDy5rDwyF1saSQqilbX2?= =?us-ascii?Q?wiAaYwj2GrbU2Kv4YochJ8d9nEbEgD1Xa8RERsg56Me0Nw=3D=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR08MB3317.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8422 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:209:42::28];domain=AM6PR08MB3317.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM3PEPF00009B9E.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ec41d26e-bcb4-4b2b-c35c-08dd1a03f984 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|35042699022|14060799003|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?folsRg6V5DvbOfujZTi+P/OLhFL12ovIhcOOsepIP/73EuSp8wWJR+fd6iIB?= =?us-ascii?Q?gQpi+AOkP6B1HeCnb2IB50K5tI1RL3PRbfHj3ULxtQYLaKMHGkaSLhoKQ/9Z?= =?us-ascii?Q?yH2HEyqj4xRvXLIZmxCpRVCOh4p/TkZnKXMsV4bOQLvM231Q8lCqQtjWIXOO?= =?us-ascii?Q?oxyV+08p/4TsNsiYX07HJBrj4XL9NJ6xphajslmD1rjTTK+cM+OaA8wZ7QKR?= =?us-ascii?Q?Gpvjv8CmjaQIHXygVJYCTehmOc+gNGzOkOxyPdrLblSzmQ04GDALWagaYmZH?= =?us-ascii?Q?EI5W7XnvF0zA1molhY/3lU8oFECRTCW52H8mnKQUu8OOveoAjVVT3ra1Qaje?= =?us-ascii?Q?7S6zqBIvM0l16yJSJYYlbL/uSj2fY2d9l6MFj78HydSMc15HvfxMx1d6/jO8?= =?us-ascii?Q?6LaCyc8Ph0FwqBI9Ic1U/WpbcrfUn0GSwpwI6bAaFgSXFIH8a2gLPsvf51TR?= =?us-ascii?Q?G+8A6KsH77lISSSdepvOnbCv6SHuxlR1pFGLh7fJwogrxvbSbNC3WeyfUDzW?= =?us-ascii?Q?VdOzbK0w0GQA8IlxLvXPbr6DC7DpmdtTZEkkLKKr31IFmrr1XpvLah5oxpMw?= =?us-ascii?Q?vxHVjJJH82+SZdAC45cppy5E1EmMJb/CJG9tgCIHx2UkKMn+avUPnFF9v8eo?= =?us-ascii?Q?Q+RhdeY3/VXWqZ6W/myHoTJS9MXhgGXAdtLG8YjoqG4FnVis4wndZ20cTCHt?= =?us-ascii?Q?JxmrcaVUH9ZU6ZeiNDcqxDVdAU0HJsi18F0F0Zi2MP7u4sTwzi2syz1bbckw?= =?us-ascii?Q?JpoUwH9LTrMvi7Q4A0xSAot+OhKvjt4DnTUPYRAV9H529TkALfEmp3N5QGIh?= =?us-ascii?Q?qgw5K9H7W/4HrPyi54RBmOiISo73n+y5nwjULMl7Ozgf8hy8MJk6yflC4C6a?= =?us-ascii?Q?HQ1CNf7QBWgvuI0x5i1kFPklSh8R4jkmywQEKVovjMvIbaTx/g1SV3nC4iiD?= =?us-ascii?Q?6YVZwLJwKxcnBvznjFYCBL1d2lYNReonqjKLb2lBzpylqCPaGAxzmQSjaacT?= =?us-ascii?Q?MwmmaS4y31yiAW9kwvpjYnCwklsT0qxIuCukiRSwynoPDwv5lSI4btsGZZHc?= =?us-ascii?Q?o9BVIWNba25a2brdd0wUP2w8aWLGU5VUo9cCgc+/72jawJd55uegdqFGTp7Q?= =?us-ascii?Q?LYxreubpvy0xn8iBiGu7FBsE8u/Z9iYJUK7jSIlsn+kl4KuvUKZE9qDjfXzw?= =?us-ascii?Q?I2yqTsjidU/BEmCka5vdnuPsyeJ8FYhPMOt8kBhRFGSXxPcKZ8yLU4+BNRjt?= =?us-ascii?Q?ne879HDWKp6U4ZL3Rsfd/vdcrkmg5OhkzoavnZKszZhOjyPeq7r9W8hbPuxF?= =?us-ascii?Q?sAKq7lyN33WmvpmZZyFgL+A9Mt5AQmCqfn/4CSs/nIXpSmq/TeDFUdAcS4OS?= =?us-ascii?Q?kIoE1a3FoRxYQyPtt3sl+i6zmk7stnLrQbJ2odOAwxezlC7BA3jvsc8u/qgO?= =?us-ascii?Q?X8mjF2Nm43IMQsM4IWEXbiguqpoUoG2uCOP+yswY2mk4eTd9Zry9aw=3D=3D?= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:64aa7808-outbound-1.mta.getcheckrecipient.com;CAT:NONE;SFS:(13230040)(376014)(82310400026)(35042699022)(14060799003)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 16:51:03.8960 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5b203ed8-628c-4738-fab5-08dd1a04000d X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM3PEPF00009B9E.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5607 Content-Type: text/plain; charset="utf-8" This patch extends the DEV_QUERY ioctl to return information about the performance counter setup for userspace, and introduces the new ioctl DRM_PANTHOR_PERF_CONTROL in order to allow for the sampling of performance counters. The new design is inspired by the perf aux ringbuffer, with the insert and extract indices being mapped to userspace, allowing multiple samples to be exposed at any given time. To avoid pointer chasing, the sample metadata and block metadata are inline with the elements they describe. Userspace is responsible for passing in resources for samples to be exposed, including the event file descriptor for notification of new sample availability, the ringbuffer BO to store samples, and the control BO along with the offset for mapping the insert and extract indices. Though these indices are only a total of 8 bytes, userspace can then reuse the same physical page for tracking the state of multiple buffers by giving different offsets from the BO start to map them. Co-developed-by: Mihail Atanassov Signed-off-by: Mihail Atanassov Signed-off-by: Lukas Zapolskas --- include/uapi/drm/panthor_drm.h | 487 +++++++++++++++++++++++++++++++++ 1 file changed, 487 insertions(+) diff --git a/include/uapi/drm/panthor_drm.h b/include/uapi/drm/panthor_drm.h index 87c9cb555dd1..8a431431da6b 100644 --- a/include/uapi/drm/panthor_drm.h +++ b/include/uapi/drm/panthor_drm.h @@ -127,6 +127,9 @@ enum drm_panthor_ioctl_id { =20 /** @DRM_PANTHOR_TILER_HEAP_DESTROY: Destroy a tiler heap. */ DRM_PANTHOR_TILER_HEAP_DESTROY, + + /** @DRM_PANTHOR_PERF_CONTROL: Control a performance counter session. */ + DRM_PANTHOR_PERF_CONTROL, }; =20 /** @@ -170,6 +173,8 @@ enum drm_panthor_ioctl_id { DRM_IOCTL_PANTHOR(WR, TILER_HEAP_CREATE, tiler_heap_create) #define DRM_IOCTL_PANTHOR_TILER_HEAP_DESTROY \ DRM_IOCTL_PANTHOR(WR, TILER_HEAP_DESTROY, tiler_heap_destroy) +#define DRM_IOCTL_PANTHOR_PERF_CONTROL \ + DRM_IOCTL_PANTHOR(WR, PERF_CONTROL, perf_control) =20 /** * DOC: IOCTL arguments @@ -268,6 +273,9 @@ enum drm_panthor_dev_query_type { * @DRM_PANTHOR_DEV_QUERY_GROUP_PRIORITIES_INFO: Query allowed group prio= rities information. */ DRM_PANTHOR_DEV_QUERY_GROUP_PRIORITIES_INFO, + + /** @DRM_PANTHOR_DEV_QUERY_PERF_INFO: Query performance counter interface= information. */ + DRM_PANTHOR_DEV_QUERY_PERF_INFO, }; =20 /** @@ -421,6 +429,120 @@ struct drm_panthor_group_priorities_info { __u8 pad[3]; }; =20 +/** + * enum drm_panthor_perf_feat_flags - Performance counter configuration fe= ature flags. + */ +enum drm_panthor_perf_feat_flags { + /** @DRM_PANTHOR_PERF_BLOCK_STATES_SUPPORT: Coarse-grained block states a= re supported. */ + DRM_PANTHOR_PERF_BLOCK_STATES_SUPPORT =3D 1 << 0, +}; + +/** + * enum drm_panthor_perf_block_type - Performance counter supported block = types. + */ +enum drm_panthor_perf_block_type { + /** @DRM_PANTHOR_PERF_BLOCK_FW: The FW counter block. */ + DRM_PANTHOR_PERF_BLOCK_FW =3D 1, + + /** @DRM_PANTHOR_PERF_BLOCK_CSG: A CSG counter block. */ + DRM_PANTHOR_PERF_BLOCK_CSG, + + /** @DRM_PANTHOR_PERF_BLOCK_CSHW: The CSHW counter block. */ + DRM_PANTHOR_PERF_BLOCK_CSHW, + + /** @DRM_PANTHOR_PERF_BLOCK_TILER: The tiler counter block. */ + DRM_PANTHOR_PERF_BLOCK_TILER, + + /** @DRM_PANTHOR_PERF_BLOCK_MEMSYS: A memsys counter block. */ + DRM_PANTHOR_PERF_BLOCK_MEMSYS, + + /** @DRM_PANTHOR_PERF_BLOCK_SHADER: A shader core counter block. */ + DRM_PANTHOR_PERF_BLOCK_SHADER, +}; + +/** + * enum drm_panthor_perf_clock - Identifier of the clock used to produce t= he cycle count values + * in a given block. + * + * Since the integrator has the choice of using one or more clocks, there = may be some confusion + * as to which blocks are counted by which clock values unless this inform= ation is explicitly + * provided as part of every block sample. Not every single clock here can= be used: in the simplest + * case, all cycle counts will be associated with the top-level clock. + */ +enum drm_panthor_perf_clock { + /** @DRM_PANTHOR_PERF_CLOCK_TOPLEVEL: Top-level CSF clock. */ + DRM_PANTHOR_PERF_CLOCK_TOPLEVEL, + + /** + * @DRM_PANTHOR_PERF_CLOCK_COREGROUP: Core group clock, responsible for t= he MMU, L2 + * caches and the tiler. + */ + DRM_PANTHOR_PERF_CLOCK_COREGROUP, + + /** @DRM_PANTHOR_PERF_CLOCK_SHADER: Clock for the shader cores. */ + DRM_PANTHOR_PERF_CLOCK_SHADER, +}; + +/** + * struct drm_panthor_perf_info - Performance counter interface information + * + * Structure grouping all queryable information relating to the performanc= e counter + * interfaces. + */ +struct drm_panthor_perf_info { + /** + * @counters_per_block: The number of 8-byte counters available in a bloc= k. + */ + __u32 counters_per_block; + + /** + * @sample_header_size: The size of the header struct available at the be= ginning + * of every sample. + */ + __u32 sample_header_size; + + /** + * @block_header_size: The size of the header struct inline with the coun= ters for a + * single block. + */ + __u32 block_header_size; + + /** @flags: Combination of drm_panthor_perf_feat_flags flags. */ + __u32 flags; + + /** + * @supported_clocks: Bitmask of the clocks supported by the GPU. + * + * Each bit represents a variant of the enum drm_panthor_perf_clock. + * + * For the same GPU, different implementers may have different clocks for= the same hardware + * block. At the moment, up to four clocks are supported, and any clocks = that are present + * will be reported here. + */ + __u32 supported_clocks; + + /** @fw_blocks: Number of FW blocks available. */ + __u32 fw_blocks; + + /** @csg_blocks: Number of CSG blocks available. */ + __u32 csg_blocks; + + /** @cshw_blocks: Number of CSHW blocks available. */ + __u32 cshw_blocks; + + /** @tiler_blocks: Number of tiler blocks available. */ + __u32 tiler_blocks; + + /** @memsys_blocks: Number of memsys blocks available. */ + __u32 memsys_blocks; + + /** @shader_blocks: Number of shader core blocks available. */ + __u32 shader_blocks; + + /** @pad: MBZ. */ + __u32 pad; +}; + /** * struct drm_panthor_dev_query - Arguments passed to DRM_PANTHOR_IOCTL_DE= V_QUERY */ @@ -1010,6 +1132,371 @@ struct drm_panthor_tiler_heap_destroy { __u32 pad; }; =20 +/** + * DOC: Performance counter decoding in userspace. + * + * Each sample will be exposed to userspace in the following manner: + * + * +--------+--------+------------------------+--------+------------------= -------+-----+ + * | Sample | Block | Block | Block | Block = | ... | + * | header | header | counters | header | counters = | | + * +--------+--------+------------------------+--------+------------------= -------+-----+ + * + * Each sample will start with a sample header of type @struct drm_panthor= _perf_sample header, + * providing sample-wide information like the start and end timestamps, th= e counter set currently + * configured, and any errors that may have occurred during sampling. + * + * After the fixed size header, the sample will consist of blocks of + * 64-bit @drm_panthor_dev_query_perf_info::counters_per_block counters, e= ach prefaced with a + * header of its own, indicating source block type, as well as the cycle c= ount needed to normalize + * cycle values within that block, and a clock source identifier. + */ + +/** + * enum drm_panthor_perf_block_state - Bitmask of the power and execution = states that an individual + * hardware block went through in a sampling period. + * + * Because the sampling period is controlled from userspace, the block may= undergo multiple + * state transitions, so this must be interpreted as one or more such tran= sitions occurring. + */ +enum drm_panthor_perf_block_state { + /** + * @DRM_PANTHOR_PERF_BLOCK_STATE_UNKNOWN: The state of this block was unk= nown during + * the sampling period. + */ + DRM_PANTHOR_PERF_BLOCK_STATE_UNKNOWN =3D 0, + + /** + * @DRM_PANTHOR_PERF_BLOCK_STATE_ON: This block was powered on for some o= r all of + * the sampling period. + */ + DRM_PANTHOR_PERF_BLOCK_STATE_ON =3D 1 << 0, + + /** + * @DRM_PANTHOR_PERF_BLOCK_STATE_OFF: This block was powered off for some= or all of the + * sampling period. + */ + DRM_PANTHOR_PERF_BLOCK_STATE_OFF =3D 1 << 1, + + /** + * @DRM_PANTHOR_PERF_BLOCK_STATE_AVAILABLE: This block was available for = execution for + * some or all of the sampling period. + */ + DRM_PANTHOR_PERF_BLOCK_STATE_AVAILABLE =3D 1 << 2, + /** + * @DRM_PANTHOR_PERF_BLOCK_STATE_UNAVAILABLE: This block was unavailable = for execution for + * some or all of the sampling period. + */ + DRM_PANTHOR_PERF_BLOCK_STATE_UNAVAILABLE =3D 1 << 3, + + /** + * @DRM_PANTHOR_PERF_BLOCK_STATE_NORMAL: This block was executing in norm= al mode + * for some or all of the sampling period. + */ + DRM_PANTHOR_PERF_BLOCK_STATE_NORMAL =3D 1 << 4, + + /** + * @DRM_PANTHOR_PERF_BLOCK_STATE_PROTECTED: This block was executing in p= rotected mode + * for some or all of the sampling period. + */ + DRM_PANTHOR_PERF_BLOCK_STATE_PROTECTED =3D 1 << 5, +}; + +/** + * struct drm_panthor_perf_block_header - Header present before every bloc= k in the + * sample ringbuffer. + */ +struct drm_panthor_perf_block_header { + /** @block_type: Type of the block. */ + __u8 block_type; + + /** @block_idx: Block index. */ + __u8 block_idx; + + /** + * @block_states: Coarse-grained block transitions, bitmask of enum + * drm_panthor_perf_block_states. + */ + __u8 block_states; + + /** + * @clock: Clock used to produce the cycle count for this block, taken fr= om + * enum drm_panthor_perf_clock. The cycle counts are stored in the sample= header. + */ + __u8 clock; + + /** @pad: MBZ. */ + __u8 pad[4]; + + /** @enable_mask: Bitmask of counters requested during the session setup.= */ + __u64 enable_mask[2]; +}; + +/** + * enum drm_panthor_perf_sample_flags - Sample-wide events that occurred o= ver the sampling + * period. + */ +enum drm_panthor_perf_sample_flags { + /** + * @DRM_PANTHOR_PERF_SAMPLE_OVERFLOW: This sample contains overflows due = to the duration + * of the sampling period. + */ + DRM_PANTHOR_PERF_SAMPLE_OVERFLOW =3D 1 << 0, + + /** + * @DRM_PANTHOR_PERF_SAMPLE_ERROR: This sample encountered an error condi= tion during + * the sample duration. + */ + DRM_PANTHOR_PERF_SAMPLE_ERROR =3D 1 << 1, +}; + +/** + * struct drm_panthor_perf_sample_header - Header present before every sam= ple. + */ +struct drm_panthor_perf_sample_header { + /** + * @timestamp_start_ns: Earliest timestamp that values in this sample rep= resent, in + * nanoseconds. Derived from CLOCK_MONOTONIC_RAW. + */ + __u64 timestamp_start_ns; + + /** + * @timestamp_end_ns: Latest timestamp that values in this sample represe= nt, in + * nanoseconds. Derived from CLOCK_MONOTONIC_RAW. + */ + __u64 timestamp_end_ns; + + /** @block_set: Set of performance counter blocks. */ + __u8 block_set; + + /** @pad: MBZ. */ + __u8 pad[3]; + + /** @flags: Current sample flags, combination of drm_panthor_perf_sample_= flags. */ + __u32 flags; + + /** + * @user_data: User data provided as part of the command that triggered t= his sample. + * + * - Automatic samples (periodic ones or those around non-counting period= s or power state + * transitions) will be tagged with the user_data provided as part of the + * DRM_PANTHOR_PERF_COMMAND_START call. + * - Manual samples will be tagged with the user_data provided with the + * DRM_PANTHOR_PERF_COMMAND_SAMPLE call. + * - A session's final automatic sample will be tagged with the user_data= provided with the + * DRM_PANTHOR_PERF_COMMAND_STOP call. + */ + __u64 user_data; + + /** + * @toplevel_clock_cycles: The number of cycles elapsed between + * drm_panthor_perf_sample_header::timestamp_start_ns and + * drm_panthor_perf_sample_header::timestamp_end_ns on the top-level cloc= k if the + * corresponding bit is set in drm_panthor_perf_info::supported_clocks. + */ + __u64 toplevel_clock_cycles; + + /** + * @coregroup_clock_cycles: The number of cycles elapsed between + * drm_panthor_perf_sample_header::timestamp_start_ns and + * drm_panthor_perf_sample_header::timestamp_end_ns on the coregroup cloc= k if the + * corresponding bit is set in drm_panthor_perf_info::supported_clocks. + */ + __u64 coregroup_clock_cycles; + + /** + * @shader_clock_cycles: The number of cycles elapsed between + * drm_panthor_perf_sample_header::timestamp_start_ns and + * drm_panthor_perf_sample_header::timestamp_end_ns on the shader core cl= ock if the + * corresponding bit is set in drm_panthor_perf_info::supported_clocks. + */ + __u64 shader_clock_cycles; +}; + +/** + * enum drm_panthor_perf_command - Command type passed to the DRM_PANTHOR_= PERF_CONTROL + * IOCTL. + */ +enum drm_panthor_perf_command { + /** @DRM_PANTHOR_PERF_COMMAND_SETUP: Create a new performance counter sam= pling context. */ + DRM_PANTHOR_PERF_COMMAND_SETUP, + + /** @DRM_PANTHOR_PERF_COMMAND_TEARDOWN: Teardown a performance counter sa= mpling context. */ + DRM_PANTHOR_PERF_COMMAND_TEARDOWN, + + /** @DRM_PANTHOR_PERF_COMMAND_START: Start a sampling session on the indi= cated context. */ + DRM_PANTHOR_PERF_COMMAND_START, + + /** @DRM_PANTHOR_PERF_COMMAND_STOP: Stop the sampling session on the indi= cated context. */ + DRM_PANTHOR_PERF_COMMAND_STOP, + + /** + * @DRM_PANTHOR_PERF_COMMAND_SAMPLE: Request a manual sample on the indic= ated context. + * + * When the sampling session is configured with a non-zero sampling frequ= ency, any + * DRM_PANTHOR_PERF_CONTROL calls with this command will be ignored and r= eturn an + * -EINVAL. + */ + DRM_PANTHOR_PERF_COMMAND_SAMPLE, +}; + +/** + * struct drm_panthor_perf_control - Arguments passed to DRM_PANTHOR_IOCTL= _PERF_CONTROL. + */ +struct drm_panthor_perf_control { + /** @cmd: Command from enum drm_panthor_perf_command. */ + __u32 cmd; + + /** + * @handle: session handle. + * + * Returned by the DRM_PANTHOR_PERF_COMMAND_SETUP call. + * It must be used in subsequent commands for the same context. + */ + __u32 handle; + + /** + * @size: size of the command structure. + * + * If the pointer is NULL, the size is updated by the driver to provide t= he size of the + * output structure. If the pointer is not NULL, the driver will only cop= y min(size, + * struct_size) to the pointer and update the size accordingly. + */ + __u64 size; + + /** @pointer: user pointer to a command type struct. */ + __u64 pointer; +}; + + +/** + * struct drm_panthor_perf_cmd_setup - Arguments passed to DRM_PANTHOR_IOC= TL_PERF_CONTROL + * when the DRM_PANTHOR_PERF_COMMAND_SETUP command is specified. + */ +struct drm_panthor_perf_cmd_setup { + /** + * @block_set: Set of performance counter blocks. + * + * This is a global configuration and only one set can be active at a tim= e. If + * another client has already requested a counter set, any further reques= ts + * for a different counter set will fail and return an -EBUSY. + * + * If the requested set does not exist, the request will fail and return = an -EINVAL. + */ + __u8 block_set; + + /** @pad: MBZ. */ + __u8 pad[7]; + + /** @fd: eventfd for signalling the availability of a new sample. */ + __u32 fd; + + /** @ringbuf_handle: Handle to the BO to write perf counter sample to. */ + __u32 ringbuf_handle; + + /** + * @control_handle: Handle to the BO containing a contiguous 16 byte rang= e, used for the + * insert and extract indices for the ringbuffer. + */ + __u32 control_handle; + + /** + * @sample_slots: The number of slots available in the userspace-provided= BO. Must be + * a power of 2. + * + * If sample_slots * sample_size does not match the BO size, the setup re= quest will fail. + */ + __u32 sample_slots; + + /** + * @control_offset: Offset into the control BO where the insert and extra= ct indices are + * located. + */ + __u64 control_offset; + + /** + * @sample_freq_ns: Period between automatic counter sample collection in= nanoseconds. Zero + * disables automatic collection and all collection must be done through = explicit calls + * to DRM_PANTHOR_PERF_CONTROL.SAMPLE. Non-zero values will disable manua= l counter sampling + * via the DRM_PANTHOR_PERF_COMMAND_SAMPLE command. + * + * This disables software-triggered periodic sampling, but hardware will = still trigger + * automatic samples on certain events, including shader core power trans= itions, and + * entries to and exits from non-counting periods. The final stop command= will also + * trigger a sample to ensure no data is lost. + */ + __u64 sample_freq_ns; + + /** + * @fw_enable_mask: Bitmask of counters to request from the FW counter bl= ock. Any bits + * past the first drm_panthor_perf_info.counters_per_block bits will be i= gnored. + */ + __u64 fw_enable_mask[2]; + + /** + * @csg_enable_mask: Bitmask of counters to request from the CSG counter = blocks. Any bits + * past the first drm_panthor_perf_info.counters_per_block bits will be i= gnored. + */ + __u64 csg_enable_mask[2]; + + /** + * @cshw_enable_mask: Bitmask of counters to request from the CSHW counte= r block. Any bits + * past the first drm_panthor_perf_info.counters_per_block bits will be i= gnored. + */ + __u64 cshw_enable_mask[2]; + + /** + * @tiler_enable_mask: Bitmask of counters to request from the tiler coun= ter block. Any + * bits past the first drm_panthor_perf_info.counters_per_block bits will= be ignored. + */ + __u64 tiler_enable_mask[2]; + + /** + * @memsys_enable_mask: Bitmask of counters to request from the memsys co= unter blocks. Any + * bits past the first drm_panthor_perf_info.counters_per_block bits will= be ignored. + */ + __u64 memsys_enable_mask[2]; + + /** + * @shader_enable_mask: Bitmask of counters to request from the shader co= re counter blocks. + * Any bits past the first drm_panthor_perf_info.counters_per_block bits = will be ignored. + */ + __u64 shader_enable_mask[2]; +}; + +/** + * struct drm_panthor_perf_cmd_start - Arguments passed to DRM_PANTHOR_IOC= TL_PERF_CONTROL + * when the DRM_PANTHOR_PERF_COMMAND_START command is specified. + */ +struct drm_panthor_perf_cmd_start { + /** + * @user_data: User provided data that will be attached to automatic samp= les collected + * until the next DRM_PANTHOR_PERF_COMMAND_STOP. + */ + __u64 user_data; +}; + +/** + * struct drm_panthor_perf_cmd_stop - Arguments passed to DRM_PANTHOR_IOCT= L_PERF_CONTROL + * when the DRM_PANTHOR_PERF_COMMAND_STOP command is specified. + */ +struct drm_panthor_perf_cmd_stop { + /** + * @user_data: User provided data that will be attached to the automatic = sample collected + * at the end of this sampling session. + */ + __u64 user_data; +}; + +/** + * struct drm_panthor_perf_cmd_sample - Arguments passed to DRM_PANTHOR_IO= CTL_PERF_CONTROL + * when the DRM_PANTHOR_PERF_COMMAND_SAMPLE command is specified. + */ +struct drm_panthor_perf_cmd_sample { + /** @user_data: User provided data that will be attached to the sample.*/ + __u64 user_data; +}; + #if defined(__cplusplus) } #endif --=20 2.25.1 From nobody Sun Dec 14 13:49:49 2025 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2079.outbound.protection.outlook.com [40.107.20.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46EA11DE2CA for ; Wed, 11 Dec 2024 16:51:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.79 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935873; cv=fail; b=Xl5oRH6iT8+wLpCp12S3FHKqiHJ1O9oU4rXNkUbhHm47uW54yRZEK5MNcu++bCeqeKBOIi/nDPMPxfr5I+me6RYiD8QGSwNEagFQPfbHYCP0zpGdfo4sfVw20oAjKY07tQqUQgFgwyVg2scfeLQV2tesJQJUDyj703tLj1xCs0E= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935873; c=relaxed/simple; bh=tR+wnlwOItJCghUuyD5cB6uVsmeaAFpsCgu6H7Uab+g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Vx58QXs/9cH1qt1677GwUJOJTlT4IXP4P0jvjyyWkOqNvWj2I1Eka1+ym/5XNrMtNUd+u4s2wIbBIBmxD07/QOnvxUd+4ahyvDfpGbK8ewC8WxhZXx7z55cRjLE4grvMGAFtGWMA+myC/ujldBM1IEolCn7Jdhfx2CFdBCB6wPs= ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Eg2C9PJC; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Eg2C9PJC; arc=fail smtp.client-ip=40.107.20.79 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Eg2C9PJC"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Eg2C9PJC" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=E5V4aUtYnEacaDCJJiUjim4g79m1VEKR151/7iAsv40iyZoxQK7dX5qdyxQ1wZYglr4o1ZIXROAHfPKtgIsT6MSWnLUlS5AgP+yeM8NVUiVgr1o1Er7WW6UWRbiYz6STQ+PYWFS6bQzZwpGxWuwwBQp45yTYMFamDjsmhC5DROP5wS02i4pjFpYjSVZ2eWEwOzfgF1+wIKyqNEP6sPX8w23zPmAaoF01XYHQcEdhQOwKn1YknFZzoYvfQ6wfPiDtQ+jispml+pflcrQD6vOA9R9Tgv7fc5y0A6e+pn+z4ktmLG8rh9A7dpr6Hym1VGcCSuVmgkK5ehVhSRyLWGBPDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=PnRRPi1qgykoryDTpNMWdOoeaBEICiR/2/DWUN0P42I=; b=rJjSxFo7Q0RCKrgqm9mn/LeOro1BJxQp0nfo0/0NI3rJNBh/NfeKd/RW/LXTb3f26nad9AwfmfowhtmrzBkslNz6IDLy0+MzRQVQjjJPrByPllw0wfh7/w+iRFoRcBCxbJTcUyno+U1WUY0ghUeQP4fE6lNdtXc+vnz7Uoq55OyLILI+KkCmZgvfHMy7l6P6JONeCjoPJKkhApvJ06/PvyZpfI3eW6bfqeworzAZJcGITKlmJJvJvRu8zTIWNQrOfN8XjPL7E9eZlgF/sutGinl4Fe18pyUXysQnZOcWwHRegWiHTMJH80l5SAMwRfRuth1zeYqlOCawE92PcXKTAg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PnRRPi1qgykoryDTpNMWdOoeaBEICiR/2/DWUN0P42I=; b=Eg2C9PJC0Ctt8dr5Q85JZvFyITLvFihjQRZx85nQb0dRJJiOQNkWwRVehQxB5InvXILatnmiLS0ca6IyKca9xKYctypJtBP6iIK6Pz5tmT/ZSDolrwjnaCk9v4/s9T3nsWr3PkDO0Mgt15YCeemPFVBH3rpE+DrgPh2camk1bsQ= Received: from AS9P251CA0007.EURP251.PROD.OUTLOOK.COM (2603:10a6:20b:50f::9) by PAXPR08MB6701.eurprd08.prod.outlook.com (2603:10a6:102:132::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 16:51:05 +0000 Received: from AM3PEPF00009B9F.eurprd04.prod.outlook.com (2603:10a6:20b:50f:cafe::59) by AS9P251CA0007.outlook.office365.com (2603:10a6:20b:50f::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM3PEPF00009B9F.mail.protection.outlook.com (10.167.16.24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:04 +0000 Received: ("Tessian outbound b4c479532664:v524"); Wed, 11 Dec 2024 16:51:04 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 273b848151f7c5a6 X-TessianGatewayMetadata: zESo4hTlpDNPaXta/xOJhQiMWFWLFKIdZ1358u8XZBHJoi53weNnK/ZNKZx7p9x2HeYLU1lYq4M0FjXNh/q7smGZZQMvFsfZMDTxa7aU4yE2ZF+2WkU6jrWuDOIFH7k792OeEo5553vu7Df7ldVGZooXnb3UqZ3YtVttq8Yt1NI= X-CR-MTA-TID: 64aa7808 Received: from Le3bc87cfaf57.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D244D080-42E7-4966-9FE1-F7003380A67A.1; Wed, 11 Dec 2024 16:50:57 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Le3bc87cfaf57.1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 11 Dec 2024 16:50:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Hvpxv9WayDe3LCbh9ZDVua2Q8fFcUuq1OpmC0aXEqmvzZHNl8lleG0GKa9bfmdsKGu32UHwvrI8hzmql2tH+6TYrZrARZHJKkkJDRUKq97QhKvP8HNJYopfjm2Pz4tulerq6B/p+UynJKvGTzZl8p//yoNAL6X44bi9hu5y/mFe9OzwszbCUeWrv0z4poUcaBqLNOOVthq7Xgw5GPtj4wHqwOXCQxO6TqKK+acPZph7K/lqbMKH7Wr1UqcKRCq5LNwtMovRmRP3aKwmpdUNdR++mRBeli+LbPdTuF36RZy5tcc/XKCiWl04uABsu26hfAneUjXCLIZdyUtB2SQQIYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=PnRRPi1qgykoryDTpNMWdOoeaBEICiR/2/DWUN0P42I=; b=pxZTuTZFGkoLs43eWIFRTwl1FsRrUsLAy5nCdCidvstSjjibR5znq5nYBNJ3oVjEyV9mIEnpMccYFYwzPX3SWLBpGT3BL6lgwfxM8x32zzZMC3UelqcTO40AjZSng0IKs22qwbi3DDfvcIL9C9rK0Sqqi+2vmqV0G/DP762LT/zq2wRTzrapbONUyvaTgPKiYjHkA8BtzrRqO3PekAeKqY9ymLS0cwTJa/wT85eE5wruNO9rXL7PYoM6X6UsqwcYaFtqvrSwLUmXV7HqVFCxGV+y1dOiYOe8WbtkgAmiJtB1pK7bLyzw7nEhxOT2jcizX16Gy7PiaK3y8ea/edsjJw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PnRRPi1qgykoryDTpNMWdOoeaBEICiR/2/DWUN0P42I=; b=Eg2C9PJC0Ctt8dr5Q85JZvFyITLvFihjQRZx85nQb0dRJJiOQNkWwRVehQxB5InvXILatnmiLS0ca6IyKca9xKYctypJtBP6iIK6Pz5tmT/ZSDolrwjnaCk9v4/s9T3nsWr3PkDO0Mgt15YCeemPFVBH3rpE+DrgPh2camk1bsQ= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) by DU0PR08MB8422.eurprd08.prod.outlook.com (2603:10a6:10:406::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 16:50:54 +0000 Received: from AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897]) by AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897%7]) with mapi id 15.20.8230.016; Wed, 11 Dec 2024 16:50:54 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Mihail Atanassov , nd@arm.com, Lukas Zapolskas Subject: [RFC v2 2/8] drm/panthor: Add DEV_QUERY.PERF_INFO handling for Gx10 Date: Wed, 11 Dec 2024 16:50:18 +0000 Message-Id: <20241211165024.490748-3-lukas.zapolskas@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241211165024.490748-1-lukas.zapolskas@arm.com> References: <20241211165024.490748-1-lukas.zapolskas@arm.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO6P123CA0042.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:2fe::13) To AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM6PR08MB3317:EE_|DU0PR08MB8422:EE_|AM3PEPF00009B9F:EE_|PAXPR08MB6701:EE_ X-MS-Office365-Filtering-Correlation-Id: ca05156b-aa8a-4af8-f285-08dd1a0400ab X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: =?us-ascii?Q?fa2EnVB0DefRBAh0xIHXMtgpQW4qJ+KZdIokFSkwKwqagoRNRgS0MHwocF/n?= =?us-ascii?Q?33An7Auj7aIfiiPWuGovaZHDlUtm3QmFHToUKrewcWsPnjrq7+klTvGcZmCq?= =?us-ascii?Q?S9xVykjzY9Fnn54I23DMcXwdu7jvplyqAFMTndDPk7wWxw8HxZv1e/4ye8kd?= =?us-ascii?Q?t9xUdoH7UzFdPb2EwAIRysTAflAcJSfiXxPqApK72ciRAfdJ0ER0xv10APw0?= =?us-ascii?Q?yEIvhz2rqdoVIWfdwBMl5Jm1zvd4vxEa7yZsXM0mDxWyl+BSAOj2mPdhj6Pj?= =?us-ascii?Q?+A+do4tQyXkl0LC/o7dRwryAU2xGqgxvfBDRseOu1SwVluaDj6wRDKyeXbpi?= =?us-ascii?Q?qWxO1+ZqIGKLaQwgxT7mJY6nGcumK8tJ6DTl3JcG7zyWu2jh5I5Dxq5kWIET?= =?us-ascii?Q?hqYyMGWM4YYH5jJRM8Vf6jyYk5NZ9p1NhFTrd6lt/5uho5l4VgktMkguAmcS?= =?us-ascii?Q?R7OJpaIyxNfqZ/EqaJ/A4MKt3ituHpQscL3G58er/YXi2IP4Sfi1OFiYlBvE?= =?us-ascii?Q?1888UK9F14WB/G2gUSsuOV0OPVvOtSRTJ4BwDYXSJvKHdkVIr2OnnW6mnSDL?= =?us-ascii?Q?n7LfRWYGIR/IULBKE3LcmwQn82hBQRaB0JO048+JcqodTyrW8lxcxnGkONlc?= =?us-ascii?Q?ISrO5EhiKt/2tmx8kLBA8BL808B0rekjP+tIl/LHzacx6U1Q8TqlUblhbzsN?= =?us-ascii?Q?thI/4Arcv8q+7iALY4mNXLYlUfpbIcyUGOHlJro6J6vmGnqPeUEV2/U+dysn?= =?us-ascii?Q?t9GET6e1kxmlq6/yt1ADBg/LKeguyIGD0X93DUsHBhuArI4/JLUOf6nmrubD?= =?us-ascii?Q?oKcwBLDszqnjsowFz510GTLRG6EgvPjqiyVU65iT9ot/Xrq+Fylv2dia10U1?= =?us-ascii?Q?VkwOtuFf+pd3Ybon4iMtlWPdaINqJsWPKB4RVJYJN3Rc4A6VvgU8QO/Vrj4N?= =?us-ascii?Q?YctsZCR5KoVvoOuTo1WoUweqhd2j1Ln/tTT2spvmklovqLuEMmqVXr17ploY?= =?us-ascii?Q?Ax8zGhIvEl6/+pl9jr3IB6dNCj9p8LmVxHBj/Ms8yawlEb/Pzo9yneoNOJAa?= =?us-ascii?Q?nOQh4qRF5L8fuZkNe6DkW8aZ5aYqmXX/+uOlrfFKB9fvc8AbhG/hA26eM/YJ?= =?us-ascii?Q?b5t+WdmIcDUdARYygpcBzdl/2TRMr9EofkgrJJwRZCahovFSxCie30sbc7/2?= =?us-ascii?Q?6cYbpFBRrIed8XW1ugbM2r/qODbLdrq0t1sPlUOEkuAkKj5GKyfOgsBWAtmM?= =?us-ascii?Q?iGiBuDwBKivQjuhWbJenNauzsiVMAOMITCO6z7bnKgCrEsMMAn5Y7yf+7De3?= =?us-ascii?Q?YqmU71ZCnNEgIKhIPyudrNExJSirvSRSeW1vSfzJBqKQbw=3D=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR08MB3317.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8422 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:209:42::28];domain=AM6PR08MB3317.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM3PEPF00009B9F.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: f36cd835-dbd7-443e-4c92-08dd1a03fa8c X-Microsoft-Antispam: BCL:0;ARA:13230040|14060799003|376014|1800799024|36860700013|82310400026|35042699022; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?SeLZpXB1YE3O++YMT0/JtZnSL7K8dJGhDM5EjSXMHSXfLUgi7WlMpSxSh/4Z?= =?us-ascii?Q?oCEmJ8uWGZM9YumtgJY9l+tiqfZu8IPDF4pjayTSjKMHM0jGIUqy/WbT8oZ9?= =?us-ascii?Q?QJRGzrjjpcIwCRm/Bf95KsU7AgmHQV7P2ZqFeTvO4Ay3AL1n2WRbWwu/0M6p?= =?us-ascii?Q?V4zwkFVFQT3UPC1Q41nI2MD7mYVuoIO9k58nkluArf/x2VFUKmsm/8Gbs7xq?= =?us-ascii?Q?eXyzl5SXMP4CoYafT1ZU6KR9sETeCtlZeMIHnSDqtbPNyy1+nQV5lPauedz2?= =?us-ascii?Q?Zg9CD7uSn1NaW8WFUQgDs35gxivmMEUi8ufXHK4k9emFs9/pC/Z7U3b++OXn?= =?us-ascii?Q?cKh6hcZ90hA7c9xKO0RKk8n/RZZseTQj1YI9xII97vptqoTkX1T6qDwQPhmb?= =?us-ascii?Q?jRUsCxSzCFw4N17rBJAludG+hWmmYsQdwygOSIrS7l3YfYcdNmOQJTXNOP46?= =?us-ascii?Q?mfUOcqIl0oH5ZBoccn2ilU7tKUBoqxoTdCgZYs5mDdY+8HVlcHZOOAfhNAZT?= =?us-ascii?Q?DUP2kWIbYESGqL0hQ7DYbmVp1EVySCFHGUr/Lg1qb5ufK880elgaswISvORQ?= =?us-ascii?Q?aKPDp++mlgo267QnkiGSg7XmGdyZ5NTgH4lHePlz4L7nUtVUeFxoTWUU3fhO?= =?us-ascii?Q?10mizGty0Fo5v+3YZe36LiyT837pk2e/FYYn2E7NVP+/WNudmxvlobAlZ2x2?= =?us-ascii?Q?phOmaQ3EfxSDLQBLB6ArL+ZeTazkcHkxq7bGDhu6L7ZtwmGvfkZpKYswhQWd?= =?us-ascii?Q?5bN9rHm/tJYZxbIqva0+zMzAmkkR5zWKGvB+BnhHOPvRQN2MpVoF58oYw5Io?= =?us-ascii?Q?YJoeH+mmEfk7FTAL/URzbM2JAAgXaLam5zRxdllms/wVTPipDJmAq6b0J+FX?= =?us-ascii?Q?1rNwsQJSZ2IAwxHyEHIsGWSqo+95v0GOOkrgE4W5CuyqXjmGoao02lG3KOP5?= =?us-ascii?Q?QLtmeseK18RwlOueOEXPAn+ZBxr7RWqwb/QLQAU8Fepz1kdase8x3YBTJ097?= =?us-ascii?Q?PnP2XiqVF2sfqTIJh/wvnJl5F3AIyOlqJd0X2foK357MOgVEIKCGx5U3hQzm?= =?us-ascii?Q?/kwFoSSHDebb3D0brKEJPYfxIm+ZYfRPjua2xzTNt7WArFHPSLAAkbHog3vc?= =?us-ascii?Q?1X8XP4ROr1dAkHcj2ivszt3pPGzQ8ABE2BpsSPUxhHsSfy5ahf4+VZChwB5U?= =?us-ascii?Q?Tpfkj24G5zYGwd7C3jcBTsdO8OVuPS5770qhRQTiOzjlemGeT7I3dvkbzq7Y?= =?us-ascii?Q?NYl+niJsEpVyvcBuDALmW7VKfX0kyTxUtQyGD8yNraQJnUl+KQ+BrGqFpW55?= =?us-ascii?Q?ZNXbXLfL1sixaUT5kK/tY25rx1oIC1/snliZOTuQSXukAMczgNrE6CneqBdC?= =?us-ascii?Q?0BozF/3pgqrSAwafYlA79gomEW/+XS0UxEfqGvntWxsUHUjUAMMMgAXY/bwk?= =?us-ascii?Q?hxE1vErxSkU9Htg2vT8lKnMkvAGTZDMbUsjmyXBzfcvBKHaO3mEJcw=3D=3D?= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:64aa7808-outbound-1.mta.getcheckrecipient.com;CAT:NONE;SFS:(13230040)(14060799003)(376014)(1800799024)(36860700013)(82310400026)(35042699022);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 16:51:04.8688 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ca05156b-aa8a-4af8-f285-08dd1a0400ab X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM3PEPF00009B9F.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6701 Content-Type: text/plain; charset="utf-8" This change adds the IOCTL to query data about the performance counter setup. Some of this data was available via previous DEV_QUERY calls, for instance for GPU info, but exposing it via PERF_INFO minimizes the overhead of creating a single session to just the one aggregate IOCTL. To better align the FW interfaces with the arch spec, the patch also renames perfcnt to prfcnt. Signed-off-by: Lukas Zapolskas Reviewed-by: Adri=C3=A1n Larumbe --- drivers/gpu/drm/panthor/Makefile | 1 + drivers/gpu/drm/panthor/panthor_device.h | 3 ++ drivers/gpu/drm/panthor/panthor_drv.c | 11 +++++- drivers/gpu/drm/panthor/panthor_fw.c | 4 ++ drivers/gpu/drm/panthor/panthor_fw.h | 4 ++ drivers/gpu/drm/panthor/panthor_perf.c | 47 ++++++++++++++++++++++++ drivers/gpu/drm/panthor/panthor_perf.h | 12 ++++++ 7 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/panthor/panthor_perf.c create mode 100644 drivers/gpu/drm/panthor/panthor_perf.h diff --git a/drivers/gpu/drm/panthor/Makefile b/drivers/gpu/drm/panthor/Mak= efile index 15294719b09c..0df9947f3575 100644 --- a/drivers/gpu/drm/panthor/Makefile +++ b/drivers/gpu/drm/panthor/Makefile @@ -9,6 +9,7 @@ panthor-y :=3D \ panthor_gpu.o \ panthor_heap.o \ panthor_mmu.o \ + panthor_perf.o \ panthor_sched.o =20 obj-$(CONFIG_DRM_PANTHOR) +=3D panthor.o diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/pan= thor/panthor_device.h index 0e68f5a70d20..636542c1dcbd 100644 --- a/drivers/gpu/drm/panthor/panthor_device.h +++ b/drivers/gpu/drm/panthor/panthor_device.h @@ -119,6 +119,9 @@ struct panthor_device { /** @csif_info: Command stream interface information. */ struct drm_panthor_csif_info csif_info; =20 + /** @perf_info: Performance counter interface information. */ + struct drm_panthor_perf_info perf_info; + /** @gpu: GPU management data. */ struct panthor_gpu *gpu; =20 diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/pantho= r/panthor_drv.c index ad46a40ed9e1..e0ac3107c69e 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -175,7 +175,9 @@ panthor_get_uobj_array(const struct drm_panthor_obj_arr= ay *in, u32 min_stride, PANTHOR_UOBJ_DECL(struct drm_panthor_sync_op, timeline_value), \ PANTHOR_UOBJ_DECL(struct drm_panthor_queue_submit, syncs), \ PANTHOR_UOBJ_DECL(struct drm_panthor_queue_create, ringbuf_size), \ - PANTHOR_UOBJ_DECL(struct drm_panthor_vm_bind_op, syncs)) + PANTHOR_UOBJ_DECL(struct drm_panthor_vm_bind_op, syncs), \ + PANTHOR_UOBJ_DECL(struct drm_panthor_perf_info, shader_blocks)) + =20 /** * PANTHOR_UOBJ_SET() - Copy a kernel object to a user object. @@ -834,6 +836,10 @@ static int panthor_ioctl_dev_query(struct drm_device *= ddev, void *data, struct d args->size =3D sizeof(priorities_info); return 0; =20 + case DRM_PANTHOR_DEV_QUERY_PERF_INFO: + args->size =3D sizeof(ptdev->perf_info); + return 0; + default: return -EINVAL; } @@ -858,6 +864,9 @@ static int panthor_ioctl_dev_query(struct drm_device *d= dev, void *data, struct d panthor_query_group_priorities_info(file, &priorities_info); return PANTHOR_UOBJ_SET(args->pointer, args->size, priorities_info); =20 + case DRM_PANTHOR_DEV_QUERY_PERF_INFO: + return PANTHOR_UOBJ_SET(args->pointer, args->size, ptdev->perf_info); + default: return -EINVAL; } diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor= /panthor_fw.c index 4a2e36504fea..e9530d1d9781 100644 --- a/drivers/gpu/drm/panthor/panthor_fw.c +++ b/drivers/gpu/drm/panthor/panthor_fw.c @@ -21,6 +21,7 @@ #include "panthor_gem.h" #include "panthor_gpu.h" #include "panthor_mmu.h" +#include "panthor_perf.h" #include "panthor_regs.h" #include "panthor_sched.h" =20 @@ -1417,6 +1418,9 @@ int panthor_fw_init(struct panthor_device *ptdev) goto err_unplug_fw; =20 panthor_fw_init_global_iface(ptdev); + + panthor_perf_info_init(ptdev); + return 0; =20 err_unplug_fw: diff --git a/drivers/gpu/drm/panthor/panthor_fw.h b/drivers/gpu/drm/panthor= /panthor_fw.h index 22448abde992..db10358e24bb 100644 --- a/drivers/gpu/drm/panthor/panthor_fw.h +++ b/drivers/gpu/drm/panthor/panthor_fw.h @@ -5,6 +5,7 @@ #define __PANTHOR_MCU_H__ =20 #include +#include =20 struct panthor_device; struct panthor_kernel_bo; @@ -197,8 +198,11 @@ struct panthor_fw_global_control_iface { u32 output_va; u32 group_num; u32 group_stride; +#define GLB_PERFCNT_FW_SIZE(x) ((((x) >> 16) << 8)) u32 perfcnt_size; u32 instr_features; +#define PERFCNT_FEATURES_MD_SIZE(x) ((x) & GENMASK(3, 0)) + u32 perfcnt_features; }; =20 struct panthor_fw_global_input_iface { diff --git a/drivers/gpu/drm/panthor/panthor_perf.c b/drivers/gpu/drm/panth= or/panthor_perf.c new file mode 100644 index 000000000000..0e3d769c1805 --- /dev/null +++ b/drivers/gpu/drm/panthor/panthor_perf.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0 or MIT +/* Copyright 2023 Collabora Ltd */ +/* Copyright 2024 Arm ltd. */ + +#include +#include +#include +#include + +#include "panthor_device.h" +#include "panthor_fw.h" +#include "panthor_gpu.h" +#include "panthor_perf.h" +#include "panthor_regs.h" + +/** + * PANTHOR_PERF_COUNTERS_PER_BLOCK - On CSF architectures pre-11.x, the nu= mber of counters + * per block was hardcoded to be 64. Arch 11.0 onwards supports the PRFCNT= _FEATURES GPU register, + * which indicates the same information. + */ +#define PANTHOR_PERF_COUNTERS_PER_BLOCK (64) + +void panthor_perf_info_init(struct panthor_device *ptdev) +{ + struct panthor_fw_global_iface *glb_iface =3D panthor_fw_get_glb_iface(pt= dev); + struct drm_panthor_perf_info *const perf_info =3D &ptdev->perf_info; + + if (PERFCNT_FEATURES_MD_SIZE(glb_iface->control->perfcnt_features)) + perf_info->flags |=3D DRM_PANTHOR_PERF_BLOCK_STATES_SUPPORT; + + if (GPU_ARCH_MAJOR(ptdev->gpu_info.gpu_id) < 11) + perf_info->counters_per_block =3D PANTHOR_PERF_COUNTERS_PER_BLOCK; + + perf_info->sample_header_size =3D sizeof(struct drm_panthor_perf_sample_h= eader); + perf_info->block_header_size =3D sizeof(struct drm_panthor_perf_block_hea= der); + + if (GLB_PERFCNT_FW_SIZE(glb_iface->control->perfcnt_size)) { + perf_info->fw_blocks =3D 1; + perf_info->csg_blocks =3D glb_iface->control->group_num; + } + + perf_info->cshw_blocks =3D 1; + perf_info->tiler_blocks =3D 1; + perf_info->memsys_blocks =3D hweight64(ptdev->gpu_info.l2_present); + perf_info->shader_blocks =3D hweight64(ptdev->gpu_info.shader_present); +} + diff --git a/drivers/gpu/drm/panthor/panthor_perf.h b/drivers/gpu/drm/panth= or/panthor_perf.h new file mode 100644 index 000000000000..cff537a370c9 --- /dev/null +++ b/drivers/gpu/drm/panthor/panthor_perf.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 or MIT */ +/* Copyright 2024 Collabora Ltd */ +/* Copyright 2024 Arm ltd. */ + +#ifndef __PANTHOR_PERF_H__ +#define __PANTHOR_PERF_H__ + +struct panthor_device; + +void panthor_perf_info_init(struct panthor_device *ptdev); + +#endif /* __PANTHOR_PERF_H__ */ --=20 2.25.1 From nobody Sun Dec 14 13:49:49 2025 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2089.outbound.protection.outlook.com [40.107.20.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 571E81DDC3B for ; Wed, 11 Dec 2024 16:51:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.89 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935876; cv=fail; b=Sk9Igx7YJvuekHnVWGxK/WHOMEGxskj9afF29iOUt/mgrdZ6zyk+56pSzaLedIyVAIzEjll7zRqfsh0vtwJ93jTGtI551ry1jsY786BxT9woaMHtvUap4TxF6+sf47+kqyoxr4OZDYiwjAUr55Cuui7e7l332ID2iPLO6yIzN6s= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935876; c=relaxed/simple; bh=mH/z1bcjsA6H5jBdCOkm7ygmUJMhweIYTcjw4WeuznI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pCVzwjZhRBLygQLAdQVSKeLMq+HLC27iGhGSMrp7cW+HeVkIlTywjoWvXoqkXXN23Ucf37Nuq6MIRbc/SF12ZwUEEfVn9NRmO+Gq4nnqipBSBREQHk4AZ2c1NTPNpFCcxEOKU+1KrieM4CpzI9/qXXuKiT8c/efJoUU4Fx0GksI= ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Qj4CMfTS; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Qj4CMfTS; arc=fail smtp.client-ip=40.107.20.89 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Qj4CMfTS"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Qj4CMfTS" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=GqwfasLYvItlrL+2Ughcn8Dl11OHPjeHkPngLUBoaSMknoa8VTth8hxGX24DyNn34WbvQJUWNORHRj2L+ARvmWdx6RDs8J/+boZPd/ON1sVaCHA5i7wTQQOszO4xQrRd+Wx9d+/678UgAHT3K8J9gsJgE8LFa9g3Z7Knrm7Wfqsh807xpVhjR5k1bIdqbAMddJyswo5V+tOftRH3gZcM/innesW2yKwbRQh+TUoAb59xXgQ3dpxC2N97+qmK5kkW2Xq3qJQlNWyazU8pMJLzUQziREgturxNqf0AG3ARuGFXPbdx8pJd4WlYJ4AGbJLWF66vH3+aa9AST3kgho0xGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=HPFjvHzurYcGRDPl+eZz5UpIXNhjbNaySmNYBE0/D/4=; b=RMhNqR4G5L+fzI5KKwBSKxiCCM6y4kCgkQFOks4MUxQj8lLK3N7339RIpVnsIwBufiVa0YRrHZeuIvh5yi/zY4qsRGzu2C5r/8T2ygNQqB9ZdK9kfi8p1BZlvdrWL2GRXQeKhPL1tuj5q502zdkHftx8tgNtoN6M1E6YmnIlXD1GK7OO9/8QhtRbQt7juA5ENEnQYEsAdAJobBbJZ6aE6FIpt6LKX0jUbfk0I5FGy2NKERB8YDV2iIgCrXg1fizf1RYIMWjE8hUinMBmQxYbbsQV6FZCJhZv4kfR7usbbz7AeZX9uGgEVsedKSmKUnxbxeWtHH8THD/27Ap/Yd5gkA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HPFjvHzurYcGRDPl+eZz5UpIXNhjbNaySmNYBE0/D/4=; b=Qj4CMfTS+CWqpeVVkek4FwE7VYzXG1cNs8RSPHrQptRmLRDZrK0bAsMUGX5a7yAyeu3EZtaJWo87WrRx9kxb+rRR2egk07UKPyNFZSvIl0ud6D8aW7b07didUuInF3mYiZjq+zn52hiiMM4RpDMSQd8qKhCOh0RTN49Ivhkr+FU= Received: from DU2PR04CA0007.eurprd04.prod.outlook.com (2603:10a6:10:3b::12) by DB4PR08MB9261.eurprd08.prod.outlook.com (2603:10a6:10:3fa::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.18; Wed, 11 Dec 2024 16:51:06 +0000 Received: from DB5PEPF00014B98.eurprd02.prod.outlook.com (2603:10a6:10:3b:cafe::b4) by DU2PR04CA0007.outlook.office365.com (2603:10a6:10:3b::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:05 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5PEPF00014B98.mail.protection.outlook.com (10.167.8.165) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:05 +0000 Received: ("Tessian outbound 20d64b55c711:v524"); Wed, 11 Dec 2024 16:51:05 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d5046944b1377f70 X-TessianGatewayMetadata: lKDehNbMszKsgNrnshmMjwjqk/rb/dPNqPQwW1p/B414W0QqvtU8IAgqrZZ1mpQdjicC3M/53+/KRHu5if/qhnQkLZnBQNfa21aDzJom7vOU97jTHsXunXR+2kvI9Y2tmXNGp/k4feLqjsiKNg2+riZvRRW2i1wU16sGO7h0jKk= X-CR-MTA-TID: 64aa7808 Received: from L0461535056b5.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0E5C8FBF-BB58-4C81-8256-20ADBF4A650D.1; Wed, 11 Dec 2024 16:50:58 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id L0461535056b5.1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 11 Dec 2024 16:50:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jrP90VwBL4RMsJH2Tcsvxxv/PJdGMkVHiNSdcpOJFkOiBXoeCQvJhAfUYfPBpkFa6ueQFHI7OFcBIGeq/BYXE1xhkyGINMZ5hZxbgdUCuG/YaRu2Lrv8uwWowkz/QJZfouxA0tK0P8YTUtcDwjkBa98X5yQkwvtM62TT4FsSQwV5wxfQiTWsWyf72gCQGOFkN6gBIb6vf7geyyu0QePBUUo8WQwWyWUG7NVQPu6J2cms1Om/X8aH57AektMtIZwrYMSjVF3gk8PTCRqO87/LgcfgJVFS50vdDc7LB/fglB+DVGWPAmOdOUdylJdqtsFo7BetCj+tY+JZnSATzfqW+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=HPFjvHzurYcGRDPl+eZz5UpIXNhjbNaySmNYBE0/D/4=; b=guCIir2yg1Hp/FB6Sr7V2OE8fM9RHrQtz9L+Lo4ZlLHjHojWVLgkldWKLdKW6v/cYBdx51rDDk4mKEz0d/TBrKTpOiNasED/bo17LpOtbaqqJY7oRBSc/BmxvRif+QORFB+e7Sekf8e3CY/rYauCnIe5UYJ66j/W2udVZ5RH87GPC+nOw+7RY/Rxja+mC/skzcsvNAMJY+4bOURSQKdzMxlVcXKnZvoTvVRy6szbbt74Td6he/v6hP4FaC0iuFtQjBOP85cW5pFdcFBANFaD0x1n8r0e3Y6YT12dHFJn5jhDsvPc7cCV28rffztYKNyf0ac1CnXfLeClaS5yj541cQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HPFjvHzurYcGRDPl+eZz5UpIXNhjbNaySmNYBE0/D/4=; b=Qj4CMfTS+CWqpeVVkek4FwE7VYzXG1cNs8RSPHrQptRmLRDZrK0bAsMUGX5a7yAyeu3EZtaJWo87WrRx9kxb+rRR2egk07UKPyNFZSvIl0ud6D8aW7b07didUuInF3mYiZjq+zn52hiiMM4RpDMSQd8qKhCOh0RTN49Ivhkr+FU= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) by DU0PR08MB8422.eurprd08.prod.outlook.com (2603:10a6:10:406::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 16:50:56 +0000 Received: from AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897]) by AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897%7]) with mapi id 15.20.8230.016; Wed, 11 Dec 2024 16:50:56 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Mihail Atanassov , nd@arm.com, Lukas Zapolskas Subject: [RFC v2 3/8] drm/panthor: Add panthor_perf_init and panthor_perf_unplug Date: Wed, 11 Dec 2024 16:50:19 +0000 Message-Id: <20241211165024.490748-4-lukas.zapolskas@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241211165024.490748-1-lukas.zapolskas@arm.com> References: <20241211165024.490748-1-lukas.zapolskas@arm.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO2P265CA0069.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::33) To AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM6PR08MB3317:EE_|DU0PR08MB8422:EE_|DB5PEPF00014B98:EE_|DB4PR08MB9261:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a729c14-15d7-430f-3f4c-08dd1a04013d X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: =?us-ascii?Q?CZi/BeiXLDmTi6vumbQKSLWbyaJx6rpwHCSNpe9UMVZceNZryzuDTHKGTRqm?= =?us-ascii?Q?TmwTI5mVS8LoFjWCZ9u7lM9VUHNTxueWUZPzuQLQEoPftKOUXgrFVgdaMlU4?= =?us-ascii?Q?I8QfTujHQrdioXKvFbc/IPq1XlfBy4yVheOg94T/IV4FR03L3pJ7nQCoRPbL?= =?us-ascii?Q?dkIVNci92mUKqbewQwaEYEQdt3/CHrmOqX7UhmRa4sBWAnfBJ4byWnlIFm04?= =?us-ascii?Q?E9sH9i0xbHxESFr6KnVx6/Lt3Kmy2Q11oMGv8UCYU3H661dIc2aKnWfj4hyd?= =?us-ascii?Q?CPVADyMkMrZQRUPGXIkqWE3AGFO7igWmEbhU7UrJ1SAffbCg+9giToPr1iul?= =?us-ascii?Q?nKighefjvhTFcYK4U6I3nPWmVeI3E8I7c6wMG207Bj2IJJ4kvk1F6xGc4RdG?= =?us-ascii?Q?kiezcUZRwCGnGISUXCJE+HvGkjEqmJ0SsP1QMve905pQHEz67I0ODZib1rSF?= =?us-ascii?Q?ff5OW56iwQzQ/ALn98EGChiu90/jtLKkg2Mib5vC5ztEt980c3u/YS0yQwdN?= =?us-ascii?Q?xqOvvCHWdDxhK3XdL6gg/qBbjZNTDkIDnBBZgRAKmDF7F3cknltPb423aN4/?= =?us-ascii?Q?eYurTM0gxRUQhfBp1Z97kUDp5NnVok7H1gm7txpl4R9hIAEz0sWY89qSg3cK?= =?us-ascii?Q?DEegeVywcGpap50VveQpz3mF11dLcPtPEXVFNxBpZW49Dnf3feONQYspA3KH?= =?us-ascii?Q?qwEB/xxUkkrwjy9ABrt8Fa8rCzbnkZ+PseXEI89uhEjM91Yw+6wgeV3mvwYN?= =?us-ascii?Q?bkRcRJxTOAfuLTG4ZOc4xbsZlbDxST5IIw6376vM7mluAiHRgXTS6FNlI2QR?= =?us-ascii?Q?vkkaVka0WZf4lKf7PKtzPJKbYD8bpchG83rh2saLEkMoO33mwuqyhn56u4wg?= =?us-ascii?Q?Hw9o9si8hfVR5uabP5SuOUztaDjbE4BVQw4JvdSENbBCoR1MeYAeMofPf39s?= =?us-ascii?Q?d3cb9n+pkhpYMie4hXEUeiXBY3k7o43zMcpYZgqmXume/kiGrAnxE8xkCkFB?= =?us-ascii?Q?dY3FjFGTY5qaiESG2XrEukaQuEyactUQU/qaPWKQQRtgUqQiGO7cgEkbhLQ7?= =?us-ascii?Q?qVaX0rwHGqDQS/Mdv8wfbEMKNSVxuzUDWvaPNAvpfqRXXba4X67im5lmCVzF?= =?us-ascii?Q?2tXT3PHNFt7wVGC6HeE6clHl/bXVrlcRmtOVIuup0HIrZIFbLCObvpDWjayP?= =?us-ascii?Q?+w9GMUlJ65ourf7KYynnrUUXD1y+8MvF0zFQcV9M/cPHCNCGHtxsQHm+0syZ?= =?us-ascii?Q?xUmpVP0fOzANFkcIS59IUZ+yMRgXxKicqF7Tk/OwzoYwNasfM1MwrFQkgoDb?= =?us-ascii?Q?AjE8BmXMSTa2LA476+7IRcbaNKDmkWspSLn5FYwtgsYkQg=3D=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR08MB3317.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8422 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:209:42::28];domain=AM6PR08MB3317.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5PEPF00014B98.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c1d530cb-7b09-4c56-ca7e-08dd1a03fb80 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|14060799003|35042699022|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?4G/FcSOeJghJsqFcj9cDuwdOPyZavtz5wgfUHSL8EyTX4x7Ii5swgIouTskO?= =?us-ascii?Q?MDu9uY9sSNuSXF8pYmDFJTwmCSau2dGR1j0ebrBo3YJF/2l8hgWGk4NIm0sh?= =?us-ascii?Q?YbFbU3yEluKB50MQoys9CPGbmakhAxLNNHK4eOg9DX9g8DP7gjHzMmmxhuIL?= =?us-ascii?Q?6SShyGxwn7Qu6vSwokBgz/+2JndcjqIZqRSIvJjSvcSgVvymD2sluAw1UtDU?= =?us-ascii?Q?dY70xoo1D/GR07bdLHtiucw5ACoZuraxYRYJk8YmfnaNUsv04vtEye2KYoLP?= =?us-ascii?Q?34zrJXu/RnIDkgPTBzGfnZBM1zXg3PSQGU+BD3yKkFMha3UJNGiv4xgPCD1J?= =?us-ascii?Q?Q+JSkLunTO+S0uhlF6GJLzTdfUffvNq2F+90W6rAMv9jF5KjTldbzSoHUoeT?= =?us-ascii?Q?zSuOh5AcLbdJHR42bOAVOEL6jQcw2j+445hwxBRbmj0lrs8Dm76g+EcURyGh?= =?us-ascii?Q?cq5TxA+o8gUqxfcWobzGAbE8cPjWbndRMa5jYEvi6wvMpeSBG+oAZxVPYu/B?= =?us-ascii?Q?Rzcfxaa4LB4FmDA4b09A3nezXhAGh5j2dl2dRYKScoCKB+bmAM3UORVFYXyq?= =?us-ascii?Q?UYv/OtEYK/k1BSNRSYY3Dz37ZyqKw0VJS0NIN2AQsRvN4SJHUWxvz8V6H7PL?= =?us-ascii?Q?Sbq21+rQdsKQfYaFG6/DkI3LMIZd77W4it/QoESQ8M8oSRtEr9ZYvfVxJQfQ?= =?us-ascii?Q?6JQ8cxPtvD+1Hkk5JMTb6FMHAQcTH4ajiIRRD9xqs1Gso9WX8axDgXtbjYJL?= =?us-ascii?Q?DbE1Eezz7S0b4s3yweTOl5KYUcU5N1YTTDvmAXMxHFQpJ+uWNxyCHKH+bF9c?= =?us-ascii?Q?U3aJV7Lp4EeX7nTVsWgTurM4+8fRtkGjUW4Yw7TqrkPumFWldzbxQLlJo6gM?= =?us-ascii?Q?aUScUToIO5N5Lxmo10AL493awPbNJZ1Ee5KAL2rSfpBd+J7yKRiC7FwoEhau?= =?us-ascii?Q?W6K3dWWrL4J/ujD5B9q4+4T+3LuaIwB4d5+kx2L4RFUUnXCgMjJpWBXSHYD3?= =?us-ascii?Q?ZTQIELvywoCQeWq4lYutavxyZAbhVWW8ZijiyyAH6nFVtjOPMHa/cVDQDgDt?= =?us-ascii?Q?6TLcIu3ceIwE+VE+Q3pjxrIC0LPUw6beYFiAi1sMFksuaHYMN4MjQtX26AZ1?= =?us-ascii?Q?WSEwo0IESrVgZo9WOpEu/S4WyGoE9148o2AjevZbGW9lkcRx6WFdkygBNP10?= =?us-ascii?Q?H56JZC8UV2KiwxT3ftdGPMc6XZ76Kh/oZtuST0X8cRTRj5F2BvaEPMfBN+ZF?= =?us-ascii?Q?do2nCHv5IF6KjBe5/xZtroBP578XzcdVDJDoPqmjkvAtgKVjUJpA1UFY42WC?= =?us-ascii?Q?UQpXVmEak5+f1WELarX1yHlc+gwISrUFp02WrtSFOSYjLBTK6fjYCH4ulvj0?= =?us-ascii?Q?AlANHXlJFe+XFGQTtGWtFxmfgK8xz/9lMEcU0Fvef2ixoMJ+NoyetE9ew+c6?= =?us-ascii?Q?SM+u6DSU2YyEL8k+h7BaImKd5lr999lWyedQdKk7mgED297vHjfVdw=3D=3D?= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:64aa7808-outbound-1.mta.getcheckrecipient.com;CAT:NONE;SFS:(13230040)(376014)(82310400026)(14060799003)(35042699022)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 16:51:05.8992 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a729c14-15d7-430f-3f4c-08dd1a04013d X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB5PEPF00014B98.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB9261 Content-Type: text/plain; charset="utf-8" Added the panthor_perf system initialization and unplug code to allow for the handling of userspace sessions to be added in follow-up patches. Signed-off-by: Lukas Zapolskas --- drivers/gpu/drm/panthor/panthor_device.c | 7 +++ drivers/gpu/drm/panthor/panthor_device.h | 5 +- drivers/gpu/drm/panthor/panthor_perf.c | 77 ++++++++++++++++++++++++ drivers/gpu/drm/panthor/panthor_perf.h | 3 + 4 files changed, 91 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/pan= thor/panthor_device.c index 00f7b8ce935a..1a81a436143b 100644 --- a/drivers/gpu/drm/panthor/panthor_device.c +++ b/drivers/gpu/drm/panthor/panthor_device.c @@ -19,6 +19,7 @@ #include "panthor_fw.h" #include "panthor_gpu.h" #include "panthor_mmu.h" +#include "panthor_perf.h" #include "panthor_regs.h" #include "panthor_sched.h" =20 @@ -97,6 +98,7 @@ void panthor_device_unplug(struct panthor_device *ptdev) /* Now, try to cleanly shutdown the GPU before the device resources * get reclaimed. */ + panthor_perf_unplug(ptdev); panthor_sched_unplug(ptdev); panthor_fw_unplug(ptdev); panthor_mmu_unplug(ptdev); @@ -262,6 +264,10 @@ int panthor_device_init(struct panthor_device *ptdev) if (ret) goto err_unplug_fw; =20 + ret =3D panthor_perf_init(ptdev); + if (ret) + goto err_unplug_fw; + /* ~3 frames */ pm_runtime_set_autosuspend_delay(ptdev->base.dev, 50); pm_runtime_use_autosuspend(ptdev->base.dev); @@ -275,6 +281,7 @@ int panthor_device_init(struct panthor_device *ptdev) =20 err_disable_autosuspend: pm_runtime_dont_use_autosuspend(ptdev->base.dev); + panthor_perf_unplug(ptdev); panthor_sched_unplug(ptdev); =20 err_unplug_fw: diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/pan= thor/panthor_device.h index 636542c1dcbd..aca33d03036c 100644 --- a/drivers/gpu/drm/panthor/panthor_device.h +++ b/drivers/gpu/drm/panthor/panthor_device.h @@ -26,7 +26,7 @@ struct panthor_heap_pool; struct panthor_job; struct panthor_mmu; struct panthor_fw; -struct panthor_perfcnt; +struct panthor_perf; struct panthor_vm; struct panthor_vm_pool; =20 @@ -137,6 +137,9 @@ struct panthor_device { /** @devfreq: Device frequency scaling management data. */ struct panthor_devfreq *devfreq; =20 + /** @perf: Performance counter management data. */ + struct panthor_perf *perf; + /** @unplug: Device unplug related fields. */ struct { /** @lock: Lock used to serialize unplug operations. */ diff --git a/drivers/gpu/drm/panthor/panthor_perf.c b/drivers/gpu/drm/panth= or/panthor_perf.c index 0e3d769c1805..e0dc6c4b0cf1 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.c +++ b/drivers/gpu/drm/panthor/panthor_perf.c @@ -13,6 +13,24 @@ #include "panthor_perf.h" #include "panthor_regs.h" =20 +struct panthor_perf { + /** + * @block_set: The global counter set configured onto the HW. + */ + u8 block_set; + + /** @next_session: The ID of the next session. */ + u32 next_session; + + /** @session_range: The number of sessions supported at a time. */ + struct xa_limit session_range; + + /** + * @sessions: Global map of sessions, accessed by their ID. + */ + struct xarray sessions; +}; + /** * PANTHOR_PERF_COUNTERS_PER_BLOCK - On CSF architectures pre-11.x, the nu= mber of counters * per block was hardcoded to be 64. Arch 11.0 onwards supports the PRFCNT= _FEATURES GPU register, @@ -45,3 +63,62 @@ void panthor_perf_info_init(struct panthor_device *ptdev) perf_info->shader_blocks =3D hweight64(ptdev->gpu_info.shader_present); } =20 +/** + * panthor_perf_init - Initialize the performance counter subsystem. + * @ptdev: Panthor device + * + * The performance counters require the FW interface to be available to se= tup the + * sampling ringbuffers, so this must be called only after FW is initializ= ed. + * + * Return: 0 on success, negative error code on failure. + */ +int panthor_perf_init(struct panthor_device *ptdev) +{ + struct panthor_perf *perf; + + if (!ptdev) + return -EINVAL; + + perf =3D devm_kzalloc(ptdev->base.dev, sizeof(*perf), GFP_KERNEL); + if (ZERO_OR_NULL_PTR(perf)) + return -ENOMEM; + + xa_init_flags(&perf->sessions, XA_FLAGS_ALLOC); + + /* Currently, we only support a single session at a time. */ + perf->session_range =3D (struct xa_limit) { + .min =3D 0, + .max =3D 1, + }; + + drm_info(&ptdev->base, "Performance counter subsystem initialized"); + + ptdev->perf =3D perf; + + return 0; +} + +/** + * panthor_perf_unplug - Terminate the performance counter subsystem. + * @ptdev: Panthor device. + * + * This function will terminate the performance counter control structures= and any remaining + * sessions, after waiting for any pending interrupts. + */ +void panthor_perf_unplug(struct panthor_device *ptdev) +{ + struct panthor_perf *perf =3D ptdev->perf; + + if (!perf) + return; + + if (!xa_empty(&perf->sessions)) + drm_err(&ptdev->base, + "Performance counter sessions active when unplugging the driver!"); + + xa_destroy(&perf->sessions); + + devm_kfree(ptdev->base.dev, ptdev->perf); + + ptdev->perf =3D NULL; +} diff --git a/drivers/gpu/drm/panthor/panthor_perf.h b/drivers/gpu/drm/panth= or/panthor_perf.h index cff537a370c9..90af8b18358c 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.h +++ b/drivers/gpu/drm/panthor/panthor_perf.h @@ -9,4 +9,7 @@ struct panthor_device; =20 void panthor_perf_info_init(struct panthor_device *ptdev); =20 +int panthor_perf_init(struct panthor_device *ptdev); +void panthor_perf_unplug(struct panthor_device *ptdev); + #endif /* __PANTHOR_PERF_H__ */ --=20 2.25.1 From nobody Sun Dec 14 13:49:49 2025 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010058.outbound.protection.outlook.com [52.101.69.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16E071DE8A8 for ; Wed, 11 Dec 2024 16:51:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.58 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935883; cv=fail; b=WTlF3uiC5gsCJ7n2VIzXpKt4lLDq18RkhyXSjiVCRasDCBYtkXaFlTM8D2ydS2qkeufxHyxmrd9rBsXs7C9sX4wj8EuqwZ1FhsPYP2zpDiypJatKzTRvpXMpcfWa8Nd/7wjlb0p1xIDfnUcOwCLj5ihNDN5MkadBarMZz854FOQ= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935883; c=relaxed/simple; bh=avR96luLw6uHYAwvvla8yoa2JFMeyPDwZsR1vTzfDvo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=T+5NNHLYGuO/H9y9ka6bd4QHUGFFK1SP2zzPOWsHGlZjROUlvfOL+sqq8T2vsC3FuF3zzhvRVWq6mz1BEsOrbB6pVmvxDM6/+sbDjw+R+c0ejQRyswUlrzMU0UapHs6J2ga+3RubCOejQqemlscRuYJU/i0ydwyFR4snM7YDEJU= ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Qs4JS9hZ; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Qs4JS9hZ; arc=fail smtp.client-ip=52.101.69.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Qs4JS9hZ"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Qs4JS9hZ" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=QHSh8WK0e8rOX/oxAQgRaDy6QLXFwFZrw5AMfNdvd3cGubwgXiFTB3t0YEIU/mOaSxVEB+NVybIuV+OlbYyoyy9KQYZbUnar5voXp5tPesYfRBYJgHfjCvgzXXRSmhOv5EMJUpS+5FQm7ePUjtrR/PaY1z1ZnaLAEUyS0EnhblzmQz1yYHNsEKunC35xICd9DAT3rNOGZ9zhnucW67hGlawYrde4B9hpN2ablE8YZl6aalLaS3yZXeJgU/MELcFWgftWO2doPx2zlcG7/E96w6u9OD23qiG43WuSDm58rmkC8JRoGwv4kStj7FNmQI9fyp7Pzf65bpCK4ahQUPK8Yw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=0M0fqUueGrM75pIOTP2ln7I3QgIGIq/MIWBiNgamU48=; b=XxpUFTvglYvI6CfZazU8vfTY2N/tiv9VadoXgiyFwD4x3PCa5gFnf+D+HvBoXuPpoVTPzg/wGakXd4KMRFfN3IZeMcR5ri0pzMkJiaby+cqGRNfGhPRincI2peMp8unSAdCYkcg74jSuHCgekA9AEGrUbuSh2TP8JgQTgg6U8sdGWddz5DgvY5f1ASrpbt7Q9bLBrsBahWQiAtJHKcA0knTmqiT2GAI+mZEauX8WycE+nTuLE8HLmbKNITqczLcyBHhn/fLs3gTJGgKjl1TKds7tqEky2bYzX5QRV0IHsw+Xz1d5Y14Y7Amxvww76V1wfS4Zqyt/APlVTy1A1oMVeA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0M0fqUueGrM75pIOTP2ln7I3QgIGIq/MIWBiNgamU48=; b=Qs4JS9hZ8DViZdTg/dqt34zD/AeSsFgaAovdwYc8hRXf3rL49nrxECkkp3hUl59s67v2Unp7R80xYiTGP20yVudRhfZBVIITeP3in3HvotlAvBO03gf03QJ62heOurQPBVRvJilyj11toqN5Kf6yQnXh3d6VWrTrxOCvT2tSFr8= Received: from DUZPR01CA0224.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b4::20) by DU5PR08MB10552.eurprd08.prod.outlook.com (2603:10a6:10:526::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 16:51:13 +0000 Received: from DB3PEPF0000885B.eurprd02.prod.outlook.com (2603:10a6:10:4b4:cafe::2e) by DUZPR01CA0224.outlook.office365.com (2603:10a6:10:4b4::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.13 via Frontend Transport; Wed, 11 Dec 2024 16:51:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB3PEPF0000885B.mail.protection.outlook.com (10.167.242.6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:13 +0000 Received: ("Tessian outbound 2d228e31de9a:v524"); Wed, 11 Dec 2024 16:51:12 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 54ad7c95618afe61 X-TessianGatewayMetadata: QF7v0RaNDlZKgrjFIC/FrPbHsYltlmLl4KfRn77Vab8V52jP2Mkjx2h4AvC5H+JsHqdKUrCOrcPgCM+tBQIGHpEhp68njmIk1hD8z/tpElKAcv5uOh8tJFhZcJLPlfuj4WEIj685QnIix5JYLmYGxy89YHv0uliol+oFX/6Q7tw= X-CR-MTA-TID: 64aa7808 Received: from Lbbb948cb6fe8.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id AB1415DD-17FE-40B0-9681-68D3F8AF9154.1; Wed, 11 Dec 2024 16:51:00 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Lbbb948cb6fe8.1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 11 Dec 2024 16:51:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ogGGURi1gvbKuRz6fxhbmR7/Xk5sJnbmSk0uOwD9u5czeNGoLxelPPz3d16MgyUPiT67Z8saa3++1LBI+LVCEJKYR2rJWC9NGOLYVlV/2dhCXlyh7k75kwBjUMnuDmrjidfgxQ6kEJD6PS1sd6ugaPpF2lIotXi1GC/5cnY7RIkzAteN2hKUT4Qltb3+W4Vf7reLXJUK6H8wmzA9wMPYKcM41N7cCdENLKmrVGymEY+BUIq/uQoxMyDQ4gj9mHl6gT7tuvRlCjeZKdScTHZtIhrXoKsvy5pm1OFnx7OIwjkGGhZjGhAGvM8ffozRiq75lyqI96UDZtfNUZlvtkASvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=0M0fqUueGrM75pIOTP2ln7I3QgIGIq/MIWBiNgamU48=; b=KZYuRbAngRlGk8F4fhiV2wbuy0qVCYVX8cnMit0YGZtfaBoqt3uZchJj1GxU7gwWDFtfb2f5uyOeyEVWUCqtMeC6jZ0MdJZeS0Yh8DkXdsVoks8SgP9kcsXshg0KOexmnLzEsRCO3CQOtkLcMQdrs6OLGapHequVD0N0uzvzOnkSzTQxutJIHaXBEbjcoyoXSf0FF5zEiBGH+6jIt3R2NDNa3h6fR/70KgvWqYVoTDdqNEfF05vMyU4t4d8J1Pw9UABRUG70ltSMn6fGvXvXDCWqbdNj1o67ZWGUF7OZJyCsCj/2JyCWXuNux1PreCmecN0kigDL98N7yXPcj69paQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0M0fqUueGrM75pIOTP2ln7I3QgIGIq/MIWBiNgamU48=; b=Qs4JS9hZ8DViZdTg/dqt34zD/AeSsFgaAovdwYc8hRXf3rL49nrxECkkp3hUl59s67v2Unp7R80xYiTGP20yVudRhfZBVIITeP3in3HvotlAvBO03gf03QJ62heOurQPBVRvJilyj11toqN5Kf6yQnXh3d6VWrTrxOCvT2tSFr8= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) by DU0PR08MB8422.eurprd08.prod.outlook.com (2603:10a6:10:406::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 16:50:58 +0000 Received: from AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897]) by AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897%7]) with mapi id 15.20.8230.016; Wed, 11 Dec 2024 16:50:58 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Mihail Atanassov , nd@arm.com, Lukas Zapolskas Subject: [RFC v2 4/8] drm/panthor: Add panthor perf ioctls Date: Wed, 11 Dec 2024 16:50:20 +0000 Message-Id: <20241211165024.490748-5-lukas.zapolskas@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241211165024.490748-1-lukas.zapolskas@arm.com> References: <20241211165024.490748-1-lukas.zapolskas@arm.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO2P265CA0190.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::34) To AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM6PR08MB3317:EE_|DU0PR08MB8422:EE_|DB3PEPF0000885B:EE_|DU5PR08MB10552:EE_ X-MS-Office365-Filtering-Correlation-Id: bc4c3441-e169-430f-3f70-08dd1a040579 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: =?us-ascii?Q?fGtZtgayl8WlmUuylfDKId/jfjaCETC/P8yIADu9IbcAj7Iwxu4rvXwJznKO?= =?us-ascii?Q?NbIstCxxaVveZDzOIvcHKpnv8FE6I2EF1ng8/E2wrHbLuNuSOktw9C0Sj4zt?= =?us-ascii?Q?oclZehxWmd6qml23uV1gWSkZBUseJWQQoqBBQg4tvb/EvBJwFGpzj2dyZ9Sc?= =?us-ascii?Q?01XXuCQydmobe+7WHoHadi0Dpz2ZVFPGwyncKCVnQWft4tG8up/qAD6kP6GS?= =?us-ascii?Q?Wtkn4i7kcdV+SBC3ZA4EbK0Q6MwNMednCnjCJZesp59J3NStZvdh5cGfEmAR?= =?us-ascii?Q?3ixlFwUPh2+ucDKgQlcqcrG3qfWkBkDgdPco4nQIfUgskVUmJG/R3llx7qjm?= =?us-ascii?Q?mAhOhJb4JhbY7FCrfSzKQ+0fkvWHWnZpSnWjHy8DRx8s+xIviq51hni0zM01?= =?us-ascii?Q?T8xsVMC1hVrrsQlT79/sEzp/zR8HQ/331zVoV01j56SSHW/YCavRLzWNU96Y?= =?us-ascii?Q?sRyN3lRzgeTR+mMOAzVWjh1m599yQjZh8E9XgECpG0iZRDwWdg0hwuM4sDis?= =?us-ascii?Q?40oZAa6Q1sZDjsDuT29IJkvMgdmYm12KFxmpGPGuuwoscCBrkn1slet6ePV2?= =?us-ascii?Q?ANL9FroGEWc9+Jgf0YCCmZIkPT9CXPItiZwSvY41TCyRiMABnOCUGktKRN3A?= =?us-ascii?Q?lWiImG8abMQKUEAeZmdhH/ttgeHtYVBv1e15E4GcLJBi4VaKXeUHzHQouyZq?= =?us-ascii?Q?/VP5cqNDtB8ihYu06VlfXRqkz7huKKXxcx8IVoSHA30E7WhVRHaDD38KBWL8?= =?us-ascii?Q?04437bjwg2RvvUAEya4iVD5Y/eAhLCLuq3DVEZCrv92JaBsa4ZbZKjdLAH8Q?= =?us-ascii?Q?jwk6O9TXdKKdbsCaEM4oLgZPXVkcjjru5MeMnxYh0y/Hf1wQnsnZ8CHr5JAw?= =?us-ascii?Q?iOyQElzAsjnqmrHO2k/FlZfNcm1RsZdaw0LjVQ64UGPa52UayQ6AGdWRwR5y?= =?us-ascii?Q?cpRyVyDhaT2p5nzZ8uo0ic/3P29X3Znmio8GBhcsZBvD826rbq477DIhLQ1R?= =?us-ascii?Q?sYRkwpkvoxfzNCccTMw0olI7w7E8rjW0Ai+cwpLmydj40oxcFr/6fscVSqb1?= =?us-ascii?Q?65it/i3GBPlJPNictuax/N0prEPtCT0+Zm4rcqwQ6Qd2YzQ7nsJzxPDDZJ/6?= =?us-ascii?Q?eOCdRgsK5xtzGjMqWJdz2peosS4UFYo373WqyEtmlX8RBcaNCdIL+GU5NXs3?= =?us-ascii?Q?PNGMHc1kbrGLu+0lCSCPe1hi4XKdEnuCpZV6WsDA8ztqiq7JNY7MIILaRWoe?= =?us-ascii?Q?Gu8Ehd8pzcu0YyQFGkb2us2AUPMTFEg2wSvrwet5wnV0UL8o257kyxALGU7I?= =?us-ascii?Q?xmqSPDgFkbkacuHumcTRYejGbZydEqNv4ll/lGht7lrZtw=3D=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR08MB3317.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8422 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:209:42::28];domain=AM6PR08MB3317.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB3PEPF0000885B.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0e9f8942-a122-4540-9f39-08dd1a03fc67 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|35042699022|14060799003|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?gfLokhM/SXpAkr0e6bfp5ZY4bNcv2wVKdYM41puVbtdDYz+nwZ6e2bT2lWE4?= =?us-ascii?Q?qf1RKgU4xHSmjQEzCXgLgvmhFl30CoVN6nGQHKKRVGKN6KLdWUgW/uXtDiqi?= =?us-ascii?Q?yC6X5S9fUyiw2gFR+eqTVUbqUQgzy99wiuYpwIri8ctVxs27QjB/yVkl3hKU?= =?us-ascii?Q?O8GppVGleYPjLq0OjTUTt3H+QqoApBKGYhjKmltrYh/vXQSX5rag5bUyRWFn?= =?us-ascii?Q?p3BSZjzNGjuWV8OtKKqV+AZ5rwlRNhcd6gNz3cD/sRghI7YWzfR9Xd6yyjXv?= =?us-ascii?Q?IcrWmtcMmVptmT6tzCQlpVmJFDc5434Fkm64i+20NtsRY5O20YXD45VUcU1f?= =?us-ascii?Q?UP5irfJkVzjhsAAv8juG1Cw6gIahHt9EatFlhRxpvklBZJNsn/4Nsq/b+qIy?= =?us-ascii?Q?WCFj1wce+ppaEnCAaciNkCsoCHoKXDPvDdU37MpSkmmbdu/hacB6PA1YA2yv?= =?us-ascii?Q?FnyeHUN+zcHnBWjvl1GtdfqW/ywuHdt7bU5Twlb1yLqjVEnOcbxYH/3XuNOb?= =?us-ascii?Q?qUImoNFo51vr3TAeEU0wjb5lsp4svzAdNzVdD6O/CyRpg2V4jcLRKPzRvrpt?= =?us-ascii?Q?uKelJIb0z5B9870Ee8iBjs3gdoo0d2rY7vuxdXZW6E/hIFt/BrWLd0eq0Axl?= =?us-ascii?Q?sf9iOsdijCzDh+WFbYB+WDMRRLKfhbXM8RQt0+fHwuH+ObrX27HzUcRvXMCB?= =?us-ascii?Q?mUmfv+8HXKuTQAd7h6O3mgSshOJ+dDK/k8oDFOdOv2dHnjhaw2bwtqf3Od16?= =?us-ascii?Q?J+k6B91NpFZg9kZTuqD8E+z41TX5KHeeb76MA752yT0l3LlHx7/2rOeO606c?= =?us-ascii?Q?kpQ7W3z60ZqZhWaSQ1ySpDSDHvSJQI+c9TYoSkjrHEjPTj9WIQCnf6TtZdiL?= =?us-ascii?Q?ZKCcK/21MVoZL7KGv/NfBrxCkrgnAwqlH2WLwpBHOprNbz8h+cV9GlymQjY+?= =?us-ascii?Q?xj+Gh+KgM0+ZhBTh2hRi2/fHGkapJeEo8Z57cdcLe8hAZsVxIFgl13O/hRj/?= =?us-ascii?Q?Xo8BAU27Qmg1cpOm9pC8muXRoQjaKFAB26BkA7kL9Dq+qA6hErGiBqOkSL9Q?= =?us-ascii?Q?xEY6NyHHdUcbMa5CeW91Niv8tj27onS6FexJXdQP/sOh+ThXtreT8koGBBSk?= =?us-ascii?Q?xukSELLSnssXIu6YfqYiVFgwE3zqfhQbyeSsa7OCcVL2+hG9BgJFGr1kPhAX?= =?us-ascii?Q?VsTeQIzHN/X3sts/vpOK6iZo7SDbTgw4h/gGiK91sKYOT2eU85mAF7wf0aWf?= =?us-ascii?Q?gCFVyPzz4FVZZoGLLx9D5i3PLaFX/lqdJnK+Rj+EnvRmwKoqWItLadDXAfi5?= =?us-ascii?Q?/37V4aFLh//SfqfIlTbMxjUnX8Y/s/v+Ro/rIDtKjv36IaCsa2P3ZzNIYqQh?= =?us-ascii?Q?j7EDSVq1TS13dshzQkcCpTZztozUZKkT9fWcgWe0IxtfzLGDQSKy3h5XbYwb?= =?us-ascii?Q?4mV6OwGrjFznZMqeTeQfbymGuqF44q5dAYUL9bZ4pom6o0viyUm32A=3D=3D?= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:64aa7808-outbound-1.mta.getcheckrecipient.com;CAT:NONE;SFS:(13230040)(376014)(82310400026)(35042699022)(14060799003)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 16:51:13.0033 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bc4c3441-e169-430f-3f70-08dd1a040579 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DB3PEPF0000885B.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU5PR08MB10552 Content-Type: text/plain; charset="utf-8" This patch implements the PANTHOR_PERF_CONTROL ioctl series, and a PANTHOR_GET_UOBJ wrapper to deal with the backwards and forwards compatibility of the uAPI. Stub function definitions are added to ensure the patch builds on its own, and will be removed later in the series. Signed-off-by: Lukas Zapolskas --- drivers/gpu/drm/panthor/panthor_drv.c | 155 ++++++++++++++++++++++++- drivers/gpu/drm/panthor/panthor_perf.c | 34 ++++++ drivers/gpu/drm/panthor/panthor_perf.h | 19 +++ 3 files changed, 206 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/pantho= r/panthor_drv.c index e0ac3107c69e..458175f58b15 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -7,6 +7,7 @@ #include #endif =20 +#include #include #include #include @@ -31,6 +32,7 @@ #include "panthor_gpu.h" #include "panthor_heap.h" #include "panthor_mmu.h" +#include "panthor_perf.h" #include "panthor_regs.h" #include "panthor_sched.h" =20 @@ -73,6 +75,39 @@ panthor_set_uobj(u64 usr_ptr, u32 usr_size, u32 min_size= , u32 kern_size, const v return 0; } =20 +/** + * panthor_get_uobj() - Copy kernel object to user object. + * @usr_ptr: Users pointer. + * @usr_size: Size of the user object. + * @min_size: Minimum size for this object. + * + * Helper automating kernel -> user object copies. + * + * Don't use this function directly, use PANTHOR_UOBJ_GET() instead. + * + * Return: valid pointer on success, an encoded error code otherwise. + */ +static void* +panthor_get_uobj(u64 usr_ptr, u32 usr_size, u32 min_size) +{ + int ret; + void *out_alloc __free(kvfree) =3D NULL; + + /* User size shouldn't be smaller than the minimal object size. */ + if (usr_size < min_size) + return ERR_PTR(-EINVAL); + + out_alloc =3D kvmalloc(min_size, GFP_KERNEL); + if (!out_alloc) + return ERR_PTR(-ENOMEM); + + ret =3D copy_struct_from_user(out_alloc, min_size, u64_to_user_ptr(usr_pt= r), usr_size); + if (ret) + return ERR_PTR(ret); + + return_ptr(out_alloc); +} + /** * panthor_get_uobj_array() - Copy a user object array into a kernel acces= sible object array. * @in: The object array to copy. @@ -176,8 +211,11 @@ panthor_get_uobj_array(const struct drm_panthor_obj_ar= ray *in, u32 min_stride, PANTHOR_UOBJ_DECL(struct drm_panthor_queue_submit, syncs), \ PANTHOR_UOBJ_DECL(struct drm_panthor_queue_create, ringbuf_size), \ PANTHOR_UOBJ_DECL(struct drm_panthor_vm_bind_op, syncs), \ - PANTHOR_UOBJ_DECL(struct drm_panthor_perf_info, shader_blocks)) - + PANTHOR_UOBJ_DECL(struct drm_panthor_perf_info, shader_blocks), \ + PANTHOR_UOBJ_DECL(struct drm_panthor_perf_cmd_setup, shader_enable_mask= ), \ + PANTHOR_UOBJ_DECL(struct drm_panthor_perf_cmd_start, user_data), \ + PANTHOR_UOBJ_DECL(struct drm_panthor_perf_cmd_stop, user_data), \ + PANTHOR_UOBJ_DECL(struct drm_panthor_perf_cmd_sample, user_data)) =20 /** * PANTHOR_UOBJ_SET() - Copy a kernel object to a user object. @@ -192,6 +230,24 @@ panthor_get_uobj_array(const struct drm_panthor_obj_ar= ray *in, u32 min_stride, PANTHOR_UOBJ_MIN_SIZE(_src_obj), \ sizeof(_src_obj), &(_src_obj)) =20 +/** + * PANTHOR_UOBJ_GET() - Copies a user object from _usr_ptr to a kernel acc= essible _dest_ptr. + * @_dest_ptr: Local varialbe + * @_usr_size: Size of the user object. + * @_usr_ptr: The pointer of the object in userspace. + * + * Return: Error code. See panthor_get_uobj(). + */ +#define PANTHOR_UOBJ_GET(_dest_ptr, _usr_size, _usr_ptr) \ + ({ \ + typeof(_dest_ptr) _tmp; \ + _tmp =3D panthor_get_uobj(_usr_ptr, _usr_size, \ + PANTHOR_UOBJ_MIN_SIZE(_tmp[0])); \ + if (!IS_ERR(_tmp)) \ + _dest_ptr =3D _tmp; \ + PTR_ERR_OR_ZERO(_tmp); \ + }) + /** * PANTHOR_UOBJ_GET_ARRAY() - Copy a user object array to a kernel accessi= ble * object array. @@ -1339,6 +1395,99 @@ static int panthor_ioctl_vm_get_state(struct drm_dev= ice *ddev, void *data, return 0; } =20 +static int panthor_ioctl_perf_control(struct drm_device *ddev, void *data, + struct drm_file *file) +{ + struct panthor_device *ptdev =3D container_of(ddev, struct panthor_device= , base); + struct panthor_file *pfile =3D file->driver_priv; + struct drm_panthor_perf_control *args =3D data; + int ret; + + if (!args->pointer) { + switch (args->cmd) { + case DRM_PANTHOR_PERF_COMMAND_SETUP: + args->size =3D sizeof(struct drm_panthor_perf_cmd_setup); + return 0; + + case DRM_PANTHOR_PERF_COMMAND_TEARDOWN: + args->size =3D 0; + return 0; + + case DRM_PANTHOR_PERF_COMMAND_START: + args->size =3D sizeof(struct drm_panthor_perf_cmd_start); + return 0; + + case DRM_PANTHOR_PERF_COMMAND_STOP: + args->size =3D sizeof(struct drm_panthor_perf_cmd_stop); + return 0; + + case DRM_PANTHOR_PERF_COMMAND_SAMPLE: + args->size =3D sizeof(struct drm_panthor_perf_cmd_sample); + return 0; + + default: + return -EINVAL; + } + } + + switch (args->cmd) { + case DRM_PANTHOR_PERF_COMMAND_SETUP: + { + struct drm_panthor_perf_cmd_setup *setup_args __free(kvfree) =3D NULL; + + ret =3D PANTHOR_UOBJ_GET(setup_args, args->size, args->pointer); + if (ret) + return -EINVAL; + + if (setup_args->pad[0]) + return -EINVAL; + + ret =3D panthor_perf_session_setup(ptdev, ptdev->perf, setup_args, pfile= ); + + return ret; + } + case DRM_PANTHOR_PERF_COMMAND_TEARDOWN: + { + return panthor_perf_session_teardown(pfile, ptdev->perf, args->handle); + } + case DRM_PANTHOR_PERF_COMMAND_START: + { + struct drm_panthor_perf_cmd_start *start_args __free(kvfree) =3D NULL; + + ret =3D PANTHOR_UOBJ_GET(start_args, args->size, args->pointer); + if (ret) + return -EINVAL; + + return panthor_perf_session_start(pfile, ptdev->perf, args->handle, + start_args->user_data); + } + case DRM_PANTHOR_PERF_COMMAND_STOP: + { + struct drm_panthor_perf_cmd_stop *stop_args __free(kvfree) =3D NULL; + + ret =3D PANTHOR_UOBJ_GET(stop_args, args->size, args->pointer); + if (ret) + return -EINVAL; + + return panthor_perf_session_stop(pfile, ptdev->perf, args->handle, + stop_args->user_data); + } + case DRM_PANTHOR_PERF_COMMAND_SAMPLE: + { + struct drm_panthor_perf_cmd_sample *sample_args __free(kvfree) =3D NULL; + + ret =3D PANTHOR_UOBJ_GET(sample_args, args->size, args->pointer); + if (ret) + return -EINVAL; + + return panthor_perf_session_sample(pfile, ptdev->perf, args->handle, + sample_args->user_data); + } + default: + return -EINVAL; + } +} + static int panthor_open(struct drm_device *ddev, struct drm_file *file) { @@ -1386,6 +1535,7 @@ panthor_postclose(struct drm_device *ddev, struct drm= _file *file) =20 panthor_group_pool_destroy(pfile); panthor_vm_pool_destroy(pfile); + panthor_perf_session_destroy(pfile, pfile->ptdev->perf); =20 kfree(pfile); module_put(THIS_MODULE); @@ -1408,6 +1558,7 @@ static const struct drm_ioctl_desc panthor_drm_driver= _ioctls[] =3D { PANTHOR_IOCTL(TILER_HEAP_CREATE, tiler_heap_create, DRM_RENDER_ALLOW), PANTHOR_IOCTL(TILER_HEAP_DESTROY, tiler_heap_destroy, DRM_RENDER_ALLOW), PANTHOR_IOCTL(GROUP_SUBMIT, group_submit, DRM_RENDER_ALLOW), + PANTHOR_IOCTL(PERF_CONTROL, perf_control, DRM_RENDER_ALLOW), }; =20 static int panthor_mmap(struct file *filp, struct vm_area_struct *vma) diff --git a/drivers/gpu/drm/panthor/panthor_perf.c b/drivers/gpu/drm/panth= or/panthor_perf.c index e0dc6c4b0cf1..6498279ec036 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.c +++ b/drivers/gpu/drm/panthor/panthor_perf.c @@ -63,6 +63,40 @@ void panthor_perf_info_init(struct panthor_device *ptdev) perf_info->shader_blocks =3D hweight64(ptdev->gpu_info.shader_present); } =20 +int panthor_perf_session_setup(struct panthor_device *ptdev, struct pantho= r_perf *perf, + struct drm_panthor_perf_cmd_setup *setup_args, + struct panthor_file *pfile) +{ + return -EOPNOTSUPP; +} + +int panthor_perf_session_teardown(struct panthor_file *pfile, struct panth= or_perf *perf, + u32 sid) +{ + return -EOPNOTSUPP; +} + +int panthor_perf_session_start(struct panthor_file *pfile, struct panthor_= perf *perf, + u32 sid, u64 user_data) +{ + return -EOPNOTSUPP; +} + +int panthor_perf_session_stop(struct panthor_file *pfile, struct panthor_p= erf *perf, + u32 sid, u64 user_data) +{ + return -EOPNOTSUPP; +} + +int panthor_perf_session_sample(struct panthor_file *pfile, struct panthor= _perf *perf, + u32 sid, u64 user_data) +{ + return -EOPNOTSUPP; + +} + +void panthor_perf_session_destroy(struct panthor_file *pfile, struct panth= or_perf *perf) { } + /** * panthor_perf_init - Initialize the performance counter subsystem. * @ptdev: Panthor device diff --git a/drivers/gpu/drm/panthor/panthor_perf.h b/drivers/gpu/drm/panth= or/panthor_perf.h index 90af8b18358c..bfef8874068b 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.h +++ b/drivers/gpu/drm/panthor/panthor_perf.h @@ -5,11 +5,30 @@ #ifndef __PANTHOR_PERF_H__ #define __PANTHOR_PERF_H__ =20 +#include + +struct drm_gem_object; +struct drm_panthor_perf_cmd_setup; struct panthor_device; +struct panthor_file; +struct panthor_perf; =20 void panthor_perf_info_init(struct panthor_device *ptdev); =20 int panthor_perf_init(struct panthor_device *ptdev); void panthor_perf_unplug(struct panthor_device *ptdev); =20 +int panthor_perf_session_setup(struct panthor_device *ptdev, struct pantho= r_perf *perf, + struct drm_panthor_perf_cmd_setup *setup_args, + struct panthor_file *pfile); +int panthor_perf_session_teardown(struct panthor_file *pfile, struct panth= or_perf *perf, + u32 sid); +int panthor_perf_session_start(struct panthor_file *pfile, struct panthor_= perf *perf, + u32 sid, u64 user_data); +int panthor_perf_session_stop(struct panthor_file *pfile, struct panthor_p= erf *perf, + u32 sid, u64 user_data); +int panthor_perf_session_sample(struct panthor_file *pfile, struct panthor= _perf *perf, + u32 sid, u64 user_data); +void panthor_perf_session_destroy(struct panthor_file *pfile, struct panth= or_perf *perf); + #endif /* __PANTHOR_PERF_H__ */ --=20 2.25.1 From nobody Sun Dec 14 13:49:49 2025 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2057.outbound.protection.outlook.com [40.107.22.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E66221DE2DC for ; Wed, 11 Dec 2024 16:51:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.57 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935892; cv=fail; b=Yppa/JxTYBYjE562P7pA4fovoKCfxoaqkW+CQ9GOv9Eyl9JFHEFYcid1GSLp7e3mcyENdhucUkzpdoR/n6oDuCzOosv7tlWzosEtGi1/zWurThdQZIQk+zB7a/O+uX5NYgbYNImrrkpXwQy5PItydBy1hYpDF3IVEfN/sq32A/U= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935892; c=relaxed/simple; bh=uoBYEDWyV8YYKOOxKoi/gQ/6rlss2d4WbR/ckqd4q3w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mBTpj8tvXQ9jR3pTFMo1oO1YP9goA14l1R6jawCPsFJ6unbP8B/oWMdmVvowZD5GyvrI3pbm8C1yRIYIV0STN/znTFjCMcnjPRAn7bz6xh4azjgWjhpNVD/lBfEYZ+KcEJ9HqhlmbGkq5hCrWj+tHlWPE2G+elxwjA1AuO+Nmcc= ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Bb2evrXD; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Bb2evrXD; arc=fail smtp.client-ip=40.107.22.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Bb2evrXD"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Bb2evrXD" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=V/D2MdViu3kvDAwsmKkecVuAlS42f+pzhYhoAEkJYZ5/5iTA0SW0kPQXIiRZ4zuQKZV2PefkKOpY1Jhvg61M/bmMN0s8PACs2+7EjM2pXNNfMLXoNovm+0BkPayzbycD75mXPwBh/Z0LOMhzs62fXxyIGl3K17YH3SaiuboKITI8Sb2NLNlraJPo6XuO7MVoA3JUwd9MzhrXA0MFgEg8MZo9wEYo1vrAbuqqLyrmSkh844qekanG9hGFzrjID82xRly6kJsx0i0aNXALL1F3M88Kt8Hzu33oV7p2rMmfpuWNSOt3jVSBlwOBmsBhYq1Rm4YcmdCw7oyK2d6U4QemHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=jZuRX+eUV6aIwFRo4Jc2T3cXWMzxDhQduw5WQ3Mm9EU=; b=BSXaPmm4EQOTZvKiad/Upmb8aLGuVTRsdJUViX7X+sQEaInQlmRN384MpD5QpV7VqOj7MpfQdnu1P4dOtiS5pJ6k+WY8R5eqZZ+rcjojQRvDNn0d2AGj3G2P4o4jY5beYIy5TgXeF8o9JzX9MEFmViR4ocPN355xjOiyGwynHMFjrrTwNnazkeRBbpIC/S47OmLzB11sxABGyVVk6dsoSvtGwuJTTFvbthQjqwdDByMW+8MFUu1GwqC+AD3+ZyShMmzLQ3gf34OiInYbJJDz/05blvMmPm2YhV3knR6CAd11XbCcHT15XOKhk5SKFyyDrLTZeHdFhJf5zW7KmOCGIg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jZuRX+eUV6aIwFRo4Jc2T3cXWMzxDhQduw5WQ3Mm9EU=; b=Bb2evrXD1qw1DKeSRAzVITnWnKPAo2alR45Ollzkm5WmHhYxmrdFBFe2RcE8rpOgCp0haeJgObU6KftPh3j/p2pkJ34yn4xmcdzDYFjLqGWENC4gkTg6x+DDgMHNtr5MLbdTjif11Ovle/TIdAsBVSLKvf5D0uFW9IlV9eEcNYQ= Received: from DB3PR08CA0012.eurprd08.prod.outlook.com (2603:10a6:8::25) by GVXPR08MB10862.eurprd08.prod.outlook.com (2603:10a6:150:154::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 16:51:16 +0000 Received: from DU2PEPF00028D10.eurprd03.prod.outlook.com (2603:10a6:8:0:cafe::1a) by DB3PR08CA0012.outlook.office365.com (2603:10a6:8::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8230.13 via Frontend Transport; Wed, 11 Dec 2024 16:51:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DU2PEPF00028D10.mail.protection.outlook.com (10.167.242.24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:16 +0000 Received: ("Tessian outbound 2d228e31de9a:v524"); Wed, 11 Dec 2024 16:51:15 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7264bd6342dbc3ec X-TessianGatewayMetadata: /ZD/i4uMS2m2bTcn5403529Z8gtSYuYgnzwSa5tdkE3zoVyRw6wqn2PpzSmgZSzLdN53VmoHnjZepKb2xoKFWW51+nEYu3/hynctHZ6s1JBUsYAItHWtegQbbEcUUGdsNroC9n1n2fNor0MB6CHOnLFxKfQy/t2sG6AI27ejRGw= X-CR-MTA-TID: 64aa7808 Received: from Ld853ad558fcb.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4DAAD5A8-5FFB-40D0-B08C-B43E21D8230F.1; Wed, 11 Dec 2024 16:51:03 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Ld853ad558fcb.1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 11 Dec 2024 16:51:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=obj4/R5EUpv6AJzU77+HYKRrEmRzKcqQngfjHdGy42Tvmv6azrfFMwAPaJKxvmpgO/LCziPT0WfISUMJ+OT3SVlzl5snLgSVscK9E4j02Q/k2RsoM+ucPmTAEZmuJDj40kxwht79fFWLlqZkdb49Hy7j+YWYnxjuuAAlv5Z/YuW1WqZW670HlQAPrG1aAe+hwF2PlHC+aa9hdWbkVGP9ZOOJ0n6rvxbVxasxKt7oZEE4dGy6W0FKp/YSuTt2V8No9VecLjErg3pv2qvBzDHEEieebw56dK3w43RwF4scH5jMxmuR76VItsZy1Kwmuq6qcw+PHwhYQ17gf52Jt5E4Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=jZuRX+eUV6aIwFRo4Jc2T3cXWMzxDhQduw5WQ3Mm9EU=; b=n2nDHpPU/BAMKvVn0sQ3jAsz8BV14FQbzXjEU6mmD2V+bJOVshYicCKE3N7klDYPukGVCL+vi+MQPmSgdZjtrhQYpr2zwHRqXPShoBKrVFHLPGda8txdTEfSv6tfK8/Yd4J2heEcjFeAMshcMkdo02e2cbWJYX4qsM1I5SgFakwvHAg/nvKLkXPw0+OBx+vArOIrzr6KUznMSCJyDF71SCCXRUqJJTl3i4Oumy3DeP/tcr65Kk98KthJ1eQYo+zPzr8N/RVmDOZ6JHl+6dms2aVTmC6wnUnNPcoIL/kizsaYBDV+YKtBvlErHivojkj7O2/F9knGZAsdCFfU1H140Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jZuRX+eUV6aIwFRo4Jc2T3cXWMzxDhQduw5WQ3Mm9EU=; b=Bb2evrXD1qw1DKeSRAzVITnWnKPAo2alR45Ollzkm5WmHhYxmrdFBFe2RcE8rpOgCp0haeJgObU6KftPh3j/p2pkJ34yn4xmcdzDYFjLqGWENC4gkTg6x+DDgMHNtr5MLbdTjif11Ovle/TIdAsBVSLKvf5D0uFW9IlV9eEcNYQ= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) by DU0PR08MB8422.eurprd08.prod.outlook.com (2603:10a6:10:406::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 16:50:59 +0000 Received: from AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897]) by AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897%7]) with mapi id 15.20.8230.016; Wed, 11 Dec 2024 16:50:59 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Mihail Atanassov , nd@arm.com, Lukas Zapolskas Subject: [RFC v2 5/8] drm/panthor: Introduce sampling sessions to handle userspace clients Date: Wed, 11 Dec 2024 16:50:21 +0000 Message-Id: <20241211165024.490748-6-lukas.zapolskas@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241211165024.490748-1-lukas.zapolskas@arm.com> References: <20241211165024.490748-1-lukas.zapolskas@arm.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P265CA0082.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2bd::15) To AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM6PR08MB3317:EE_|DU0PR08MB8422:EE_|DU2PEPF00028D10:EE_|GVXPR08MB10862:EE_ X-MS-Office365-Filtering-Correlation-Id: 11d84b6c-08a2-487b-2a87-08dd1a040799 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: =?us-ascii?Q?iVueNGWKsox5QPfdG+byGGBOn8+YhLWd64zWCU19koXM4lRlUqN1xS+Z2/Nw?= =?us-ascii?Q?jSuqHqFwXvgck2+69wUzoWMXEYqJGorXGCpEZcdxxZ6MpLwt3z5nO7cNfq7p?= =?us-ascii?Q?zqqEGrnbhLiRWF9xFHB+BeVtGY+DDC5yuqmTCUWAnuRT2wNjw5GUjKPmCAz1?= =?us-ascii?Q?shbyXB3EGsH8gfY3b+pBplYSwrqN02ybF6m3UgXBBz/2AM0wcgjC54UScIYL?= =?us-ascii?Q?NtAbsMXIwjIMoPlxac6ARtuFDjKk5CL7Gy+5KwqHThihFNXmVGghM4TFCfIr?= =?us-ascii?Q?cdDAUxlbcZaVxoE0uyVReb9U77yCPDbGSbPCXtIRUU85iqo3i2fcaPtwI5GH?= =?us-ascii?Q?g5lWc/SuAeV28AYP6k4OF1pcP2giXaz/7AqLkpfnwjB8AkhvqwSolQ8AQJRC?= =?us-ascii?Q?+JFo54kCWp49VaEqfWO0s+3xkSBu8+ChE2vEC67gyS8aztvmQN99sT3pMbe0?= =?us-ascii?Q?QAXt2RllFVLcdo9cJrrGEo2iLPfyrQefpWNU5hOE54ably/3m0OWls+Jcsix?= =?us-ascii?Q?tYQ1hNd/kAHqxsBlb4G+Ppz5qbWNH/NhINycblo8QKEFFSbmplnwPrXCBanX?= =?us-ascii?Q?GQXO/PYvb6WpZA4/P/6P7PzkS00q3oBcfpTw2LzkX+zG+57p0tSAGYdWg2nd?= =?us-ascii?Q?h75e+qw3/r5piBgRaZ3mmofxJmPAz1yrUo6LiVrtLePwvHEY0vQtZkbKHkzu?= =?us-ascii?Q?+TKF0/Atrvsi7RRxWX2SNzx76TjVCfzO9IerQRkcEGhaKgcFLiEFAo3a4EKW?= =?us-ascii?Q?DMKd/iGS0pQ9+z18r2VRntYn5sTA+iqczfJFdm90bm5Z/AIIfxtXsrJRTXOv?= =?us-ascii?Q?2f1Njk9H2QRaOIxCtNnQSQwY5JQxl7bDwWFjvRbKHtnu7aqiiqUxASXjyqDi?= =?us-ascii?Q?fwMrL01TNEsEZ0J6TvCxW0g8ZtIwO/s5ldIr44Kb43vLS5wrgZcsuFk/PlNp?= =?us-ascii?Q?CntGT9E3JTq89QRrse19NY5vGqbolh/lL8cOQVmg1LYmoDBKfcizDEehSllO?= =?us-ascii?Q?yynJHfGNlg4Sjfl0btJSD5YfF7WIF8pppwoZaBODllQOa6/lpkEW/UUT44n3?= =?us-ascii?Q?h+jZX+PqyefQ0ULTFyI5IeQHQgBA31WYWLfvlXW/Gl46b01Co8boPmMNQtA7?= =?us-ascii?Q?6+uM1vkVU/JDPpPcWa2WoB7Vm9iubBxED+nii2sRPO9oan3zNoJRBDami17Y?= =?us-ascii?Q?xJPVXS6mfEgskwQ0EpyO4gIZlPp3BrJsjrli9zzbUSd5ojCtNq6vdCZjNko5?= =?us-ascii?Q?Pa70fN1YVqSXSrhIlwvwShsw2WRBJM5B1kT8uYE3U8qr+5oWUCsFpL6Up6rt?= =?us-ascii?Q?eI3rH1jhmdjIOe9zjtoPY9VPPH1bC3173CgxlEAF+k8uYg=3D=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR08MB3317.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8422 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:209:42::28];domain=AM6PR08MB3317.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU2PEPF00028D10.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2b8dc574-f29b-488f-3699-08dd1a03fd56 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|35042699022|14060799003|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?DC+lVzz+RgYPuOTkn0z0g6/JqG/OBABiMP6dqSqGJUDR4iBIak0YgRt0a0nE?= =?us-ascii?Q?y6+obWEZzQv1QvUP/gIOvccy9Mj7nCavEsylIhoJITgXGmYAnA0FzkftVM0I?= =?us-ascii?Q?1oFRLF2BgiBMRhuyDTBcTkvu2VOdHjNhxJ7cIVhFNkvWL5Ic0DicWN5YmhQQ?= =?us-ascii?Q?fSe1lAegybGO0TRKVzCv+kfPmOuRyJbWl+0W47ExxxzLAyK4d3o2+nIdcYvN?= =?us-ascii?Q?Wn/RVbx3vc6nBO0k+UuYRm+QqUfo5jVUr68RCsdqhbdCQX0vbMycWDfDlIi5?= =?us-ascii?Q?dvWZ/zXmEpV+dkHJmRCQMwvKwCPoaGm0DfSAwZeDFcr3a2FGPQIt+qEESiTr?= =?us-ascii?Q?TEAohOO0+0IUzl/4/0CEsslXBlPHKSbZ/CyXrWrlDOudlc5hJHCyf9bEpN4g?= =?us-ascii?Q?LZrlFeBtqC3M4sdjldnCuCxCrcjlptqqNon/fkUAiNKsrGUgD5cyaGnkyYcK?= =?us-ascii?Q?PaSa4M7jJGbaY07S4yaNzaPp8YiXui/UkUz8cb372Y6DBjw/PEhXq6fQUggW?= =?us-ascii?Q?5oIoj534o5DUgGc6Ddt5iphCUSYFxBgYAD4+xLFt89uaBsDO3W1Xel78Ev+A?= =?us-ascii?Q?ROW/l2iH6itc1ptiiRmPDfcvCZFP7ScmkFeZiNnhXkuC6CGfugOEJ1qeWro8?= =?us-ascii?Q?zTWWrpRAYojSfA2cG9YgnSJqUdIqHirK6ZOKeC+rXbk2e3SvPCRuNC9rZFuE?= =?us-ascii?Q?46fjpfKn1M61YGj35rpr3hc8oOymbMo+ZjiLoZLwGBZNKFrvIO0INXZAWrFb?= =?us-ascii?Q?YPuW1UCV7zSC98LGMksAbA60HW6Ynp3KruXhiBxl3s/PnWcfVXxflz2P4lU5?= =?us-ascii?Q?WNHScHCdJahPYTa1ztnyxUhpHiVNP1sbVPnlGbqrg3S84PNQNgab5r+p5zU1?= =?us-ascii?Q?Qxsn30S00ZJMAXfbFrZgAICGIaxDvYTEXynS4Gf+5lFbFAr5r2yA5miw8PK5?= =?us-ascii?Q?IwcIlKWCWGoV+8aUIDdJPURaxnslEBuzgPb7dBlUc6/Ygs3JXNMewYQpmHKU?= =?us-ascii?Q?TD0K+EyxYH3916AB8VGUD2uhc9nWfUzSoYU/fOQiyhDzW5vpLZWRZFCwGPvq?= =?us-ascii?Q?5LEXStXm8JMwPcjYRhcOgLilV54wyU4fGv3cMvSzKAgqijBD3+275OFiu9Kk?= =?us-ascii?Q?3jrML0lztjcqWYyoyjiqgtf2OZxZpjyhSEs0khQL6eMB9ydrTy0KcpiPBXQe?= =?us-ascii?Q?BvaAVUMbDqlf4qQTsqTEt7E5EvCa6BgZPObcJ2CfLNDgGIyihkHgLS5fKd4h?= =?us-ascii?Q?0PFTqbtOZ/fCPTq6kJsdv3b3BzYq8zFxdHPZu82t/mOU9RcmHTPRbcmrit8m?= =?us-ascii?Q?3OEhFofPuXZT06FZPr+EubsXZmK9Y+emlj2FdTKPB0sTVt5KsQ5tdfD36j6p?= =?us-ascii?Q?y4aqb0cQloI+FOFTTq6lyBtTgKEVW/OXpy+E6bFtO0rKUL9UG9GtmEUhUc+l?= =?us-ascii?Q?jj2gq/h+I2s/LAeEBL5CAmWOHnRavZhbLVDRWaobA6jvJGyG3e85vg=3D=3D?= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:64aa7808-outbound-1.mta.getcheckrecipient.com;CAT:NONE;SFS:(13230040)(376014)(82310400026)(35042699022)(14060799003)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 16:51:16.5366 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11d84b6c-08a2-487b-2a87-08dd1a040799 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DU2PEPF00028D10.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10862 Content-Type: text/plain; charset="utf-8" To allow for combining the requests from multiple userspace clients, an intermediary layer between the HW/FW interfaces and userspace is created, containing the information for the counter requests and tracking of insert and extract indices. Each session starts inactive and must be explicitly activated via PERF_CONTROL.START, and explicitly stopped via PERF_CONTROL.STOP. Userspace identifies a single client with its session ID and the panthor file it is associated with. The SAMPLE and STOP commands both produce a single sample when called, and these samples can be disambiguated via the opaque user data field passed in the PERF_CONTROL uAPI. If this functionality is not desired, these fields can be kept as zero, as the kernel copies this value into the corresponding sample without attempting to interpret it. Currently, only manual sampling sessions are supported, providing samples when userspace calls PERF_CONTROL.SAMPLE, and only a single session is allowed at a time. Multiple sessions and periodic sampling will be enabled in following patches. No protected is provided against the 32-bit hardware counter overflows, so for the moment it is up to userspace to ensure that the counters are sampled at a reasonable frequency. The counter set enum is added to the uapi to clarify the restrictions on calling the interface. Signed-off-by: Lukas Zapolskas --- drivers/gpu/drm/panthor/panthor_device.h | 3 + drivers/gpu/drm/panthor/panthor_drv.c | 1 + drivers/gpu/drm/panthor/panthor_perf.c | 697 ++++++++++++++++++++++- include/uapi/drm/panthor_drm.h | 50 +- 4 files changed, 732 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/pan= thor/panthor_device.h index aca33d03036c..9ed1e9aed521 100644 --- a/drivers/gpu/drm/panthor/panthor_device.h +++ b/drivers/gpu/drm/panthor/panthor_device.h @@ -210,6 +210,9 @@ struct panthor_file { /** @ptdev: Device attached to this file. */ struct panthor_device *ptdev; =20 + /** @drm_file: Corresponding drm_file */ + struct drm_file *drm_file; + /** @vms: VM pool attached to this file. */ struct panthor_vm_pool *vms; =20 diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/pantho= r/panthor_drv.c index 458175f58b15..2848ab442d10 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -1505,6 +1505,7 @@ panthor_open(struct drm_device *ddev, struct drm_file= *file) } =20 pfile->ptdev =3D ptdev; + pfile->drm_file =3D file; =20 ret =3D panthor_vm_pool_create(pfile); if (ret) diff --git a/drivers/gpu/drm/panthor/panthor_perf.c b/drivers/gpu/drm/panth= or/panthor_perf.c index 6498279ec036..42d8b6f8c45d 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.c +++ b/drivers/gpu/drm/panthor/panthor_perf.c @@ -3,16 +3,162 @@ /* Copyright 2024 Arm ltd. */ =20 #include +#include #include #include +#include #include =20 +#include +#include +#include + #include "panthor_device.h" #include "panthor_fw.h" #include "panthor_gpu.h" #include "panthor_perf.h" #include "panthor_regs.h" =20 +/** + * PANTHOR_PERF_EM_BITS - Number of bits in a user-facing enable mask. Thi= s must correspond + * to the maximum number of counters available for = selection on the newest + * Mali GPUs (128 as of the Mali-Gx15). + */ +#define PANTHOR_PERF_EM_BITS (BITS_PER_TYPE(u64) * 2) + +/** + * enum panthor_perf_session_state - Session state bits. + */ +enum panthor_perf_session_state { + /** @PANTHOR_PERF_SESSION_ACTIVE: The session is active and can be used f= or sampling. */ + PANTHOR_PERF_SESSION_ACTIVE =3D 0, + + /** + * @PANTHOR_PERF_SESSION_OVERFLOW: The session encountered an overflow in= one of the + * counters during the last sampling peri= od. This flag + * gets propagated as part of samples emi= tted for this + * session, to ensure the userspace clien= t can gracefully + * handle this data corruption. + */ + PANTHOR_PERF_SESSION_OVERFLOW, + + /** @PANTHOR_PERF_SESSION_MAX: Bits needed to represent the state. Must b= e last.*/ + PANTHOR_PERF_SESSION_MAX, +}; + +struct panthor_perf_enable_masks { + /** + * @link: List node used to keep track of the enable masks aggregated by = the sampler. + */ + struct list_head link; + + /** @refs: Number of references taken out on an instantiated enable mask.= */ + struct kref refs; + + /** + * @mask: Array of bitmasks indicating the counters userspace requested, = where + * one bit represents a single counter. Used to build the firmware= configuration + * and ensure that userspace clients obtain only the counters they= requested. + */ + DECLARE_BITMAP(mask, PANTHOR_PERF_EM_BITS)[DRM_PANTHOR_PERF_BLOCK_MAX]; +}; + +struct panthor_perf_counter_block { + struct drm_panthor_perf_block_header header; + u64 counters[]; +}; + +struct panthor_perf_session { + DECLARE_BITMAP(state, PANTHOR_PERF_SESSION_MAX); + + /** + * @user_sample_size: The size of a single sample as exposed to userspace= . For the sake of + * simplicity, the current implementation exposes the = same structure + * as provided by firmware, after annotating the sampl= e and the blocks, + * and zero-extending the counters themselves (to acco= unt for in-kernel + * accumulation). + * + * This may also allow further memory-optimizations of= compressing the + * sample to provide only requested blocks, if deemed = to be worth the + * additional complexity. + */ + size_t user_sample_size; + + /** + * @sample_freq_ns: Period between subsequent sample requests. Zero indic= ates that + * userspace will be responsible for requesting samples. + */ + u64 sample_freq_ns; + + /** @sample_start_ns: Sample request time, obtained from a monotonic raw = clock. */ + u64 sample_start_ns; + + /** + * @user_data: Opaque handle passed in when starting a session, requestin= g a sample (for + * manual sampling sessions only) and when stopping a session= . This handle + * allows the disambiguation of a sample in the ringbuffer. + */ + u64 user_data; + + /** + * @eventfd: Event file descriptor context used to signal userspace of a = new sample + * being emitted. + */ + struct eventfd_ctx *eventfd; + + /** + * @enabled_counters: This session's requested counters. Note that these = cannot change + * for the lifetime of the session. + */ + struct panthor_perf_enable_masks *enabled_counters; + + /** @ringbuf_slots: Slots in the user-facing ringbuffer. */ + size_t ringbuf_slots; + + /** @ring_buf: BO for the userspace ringbuffer. */ + struct drm_gem_object *ring_buf; + + /** + * @control_buf: BO for the insert and extract indices. + */ + struct drm_gem_object *control_buf; + + /** + * @extract_idx: The extract index is used by userspace to indicate the p= osition of the + * consumer in the ringbuffer. + */ + u32 *extract_idx; + + /** + * @insert_idx: The insert index is used by the kernel to indicate the po= sition of the + * latest sample exposed to userspace. + */ + u32 *insert_idx; + + /** @samples: The mapping of the @ring_buf into the kernel's VA space. */ + u8 *samples; + + /** + * @waiting: The list node used by the sampler to track the sessions wait= ing for a sample. + */ + struct list_head waiting; + + /** + * @pfile: The panthor file which was used to create a session, used for = the postclose + * handling and to prevent a misconfigured userspace from closing= unrelated + * sessions. + */ + struct panthor_file *pfile; + + /** + * @ref: Session reference count. The sample delivery to userspace is asy= nchronous, meaning + * the lifetime of the session must extend at least until the sampl= e is exposed to + * userspace. + */ + struct kref ref; +}; + + struct panthor_perf { /** * @block_set: The global counter set configured onto the HW. @@ -63,39 +209,154 @@ void panthor_perf_info_init(struct panthor_device *pt= dev) perf_info->shader_blocks =3D hweight64(ptdev->gpu_info.shader_present); } =20 -int panthor_perf_session_setup(struct panthor_device *ptdev, struct pantho= r_perf *perf, - struct drm_panthor_perf_cmd_setup *setup_args, - struct panthor_file *pfile) +static struct panthor_perf_enable_masks *panthor_perf_em_new(void) { - return -EOPNOTSUPP; + struct panthor_perf_enable_masks *em =3D kmalloc(sizeof(*em), GFP_KERNEL); + + if (!em) + return ERR_PTR(-ENOMEM); + + INIT_LIST_HEAD(&em->link); + + kref_init(&em->refs); + + return em; } =20 -int panthor_perf_session_teardown(struct panthor_file *pfile, struct panth= or_perf *perf, - u32 sid) +static struct panthor_perf_enable_masks *panthor_perf_create_em(struct drm= _panthor_perf_cmd_setup + *setup_args) { - return -EOPNOTSUPP; + struct panthor_perf_enable_masks *em =3D panthor_perf_em_new(); + + if (IS_ERR_OR_NULL(em)) + return em; + + bitmap_from_arr64(em->mask[DRM_PANTHOR_PERF_BLOCK_FW], + setup_args->fw_enable_mask, PANTHOR_PERF_EM_BITS); + bitmap_from_arr64(em->mask[DRM_PANTHOR_PERF_BLOCK_CSG], + setup_args->csg_enable_mask, PANTHOR_PERF_EM_BITS); + bitmap_from_arr64(em->mask[DRM_PANTHOR_PERF_BLOCK_CSHW], + setup_args->cshw_enable_mask, PANTHOR_PERF_EM_BITS); + bitmap_from_arr64(em->mask[DRM_PANTHOR_PERF_BLOCK_TILER], + setup_args->tiler_enable_mask, PANTHOR_PERF_EM_BITS); + bitmap_from_arr64(em->mask[DRM_PANTHOR_PERF_BLOCK_MEMSYS], + setup_args->memsys_enable_mask, PANTHOR_PERF_EM_BITS); + bitmap_from_arr64(em->mask[DRM_PANTHOR_PERF_BLOCK_SHADER], + setup_args->shader_enable_mask, PANTHOR_PERF_EM_BITS); + + return em; } =20 -int panthor_perf_session_start(struct panthor_file *pfile, struct panthor_= perf *perf, - u32 sid, u64 user_data) +static void panthor_perf_destroy_em_kref(struct kref *em_kref) { - return -EOPNOTSUPP; + struct panthor_perf_enable_masks *em =3D container_of(em_kref, typeof(*em= ), refs); + + if (!list_empty(&em->link)) + return; + + kfree(em); } =20 -int panthor_perf_session_stop(struct panthor_file *pfile, struct panthor_p= erf *perf, - u32 sid, u64 user_data) +static size_t get_annotated_block_size(size_t counters_per_block) { - return -EOPNOTSUPP; + return struct_size_t(struct panthor_perf_counter_block, counters, counter= s_per_block); } =20 -int panthor_perf_session_sample(struct panthor_file *pfile, struct panthor= _perf *perf, - u32 sid, u64 user_data) +static u32 session_read_extract_idx(struct panthor_perf_session *session) +{ + /* Userspace will update their own extract index to indicate that a sampl= e is consumed + * from the ringbuffer, and we must ensure we read the latest value. + */ + return smp_load_acquire(session->extract_idx); +} + +static u32 session_read_insert_idx(struct panthor_perf_session *session) +{ + return *session->insert_idx; +} + +static void session_get(struct panthor_perf_session *session) +{ + kref_get(&session->ref); +} + +static void session_free(struct kref *ref) +{ + struct panthor_perf_session *session =3D container_of(ref, typeof(*sessio= n), ref); + + if (session->samples) { + struct iosys_map map =3D IOSYS_MAP_INIT_VADDR(session->samples); + + drm_gem_vunmap_unlocked(session->ring_buf, &map); + drm_gem_object_put(session->ring_buf); + } + + if (session->insert_idx && session->extract_idx) { + struct iosys_map map =3D IOSYS_MAP_INIT_VADDR(session->extract_idx); + + drm_gem_vunmap_unlocked(session->control_buf, &map); + drm_gem_object_put(session->control_buf); + } + + kref_put(&session->enabled_counters->refs, panthor_perf_destroy_em_kref); + eventfd_ctx_put(session->eventfd); + + devm_kfree(session->pfile->ptdev->base.dev, session); +} + +static void session_put(struct panthor_perf_session *session) +{ + kref_put(&session->ref, session_free); +} + +/** + * session_find - Find a session associated with the given session ID and + * panthor_file. + * @pfile: Panthor file. + * @perf: Panthor perf. + * @sid: Session ID. + * + * The reference count of a valid session is increased to ensure it does n= ot disappear + * in the window between the XA lock being dropped and the internal sessio= n functions + * being called. + * + * Return: valid session pointer or an ERR_PTR. + */ +static struct panthor_perf_session *session_find(struct panthor_file *pfil= e, + struct panthor_perf *perf, u32 sid) { - return -EOPNOTSUPP; + struct panthor_perf_session *session; =20 + if (!perf) + return ERR_PTR(-EINVAL); + + xa_lock(&perf->sessions); + session =3D xa_load(&perf->sessions, sid); + + if (!session || xa_is_err(session)) { + xa_unlock(&perf->sessions); + return ERR_PTR(-EBADF); + } + + if (session->pfile !=3D pfile) { + xa_unlock(&perf->sessions); + return ERR_PTR(-EINVAL); + } + + session_get(session); + xa_unlock(&perf->sessions); + + return session; } =20 -void panthor_perf_session_destroy(struct panthor_file *pfile, struct panth= or_perf *perf) { } +static size_t session_get_max_sample_size(const struct drm_panthor_perf_in= fo *const info) +{ + const size_t block_size =3D get_annotated_block_size(info->counters_per_b= lock); + const size_t block_nr =3D info->cshw_blocks + info->csg_blocks + info->fw= _blocks + + info->tiler_blocks + info->memsys_blocks + info->shader_blocks; + + return sizeof(struct drm_panthor_perf_sample_header) + (block_size * bloc= k_nr); +} =20 /** * panthor_perf_init - Initialize the performance counter subsystem. @@ -130,6 +391,399 @@ int panthor_perf_init(struct panthor_device *ptdev) ptdev->perf =3D perf; =20 return 0; + +} + +static int session_validate_set(u8 set) +{ + if (set > DRM_PANTHOR_PERF_SET_TERTIARY) + return -EINVAL; + + if (set =3D=3D DRM_PANTHOR_PERF_SET_PRIMARY) + return 0; + + if (set > DRM_PANTHOR_PERF_SET_PRIMARY) + return capable(CAP_PERFMON) ? 0 : -EACCES; + + return -EINVAL; +} + +/** + * panthor_perf_session_setup - Create a user-visible session. + * + * @ptdev: Handle to the panthor device. + * @perf: Handle to the perf control structure. + * @setup_args: Setup arguments passed in via ioctl. + * @pfile: Panthor file associated with the request. + * + * Creates a new session associated with the session ID returned. When ini= tialized, the + * session must explicitly request sampling to start with a successive cal= l to PERF_CONTROL.START. + * + * Return: non-negative session identifier on success or negative error co= de on failure. + */ +int panthor_perf_session_setup(struct panthor_device *ptdev, struct pantho= r_perf *perf, + struct drm_panthor_perf_cmd_setup *setup_args, + struct panthor_file *pfile) +{ + struct panthor_perf_session *session; + struct drm_gem_object *ringbuffer; + struct drm_gem_object *control; + const size_t slots =3D setup_args->sample_slots; + struct panthor_perf_enable_masks *em; + struct iosys_map rb_map, ctrl_map; + size_t user_sample_size; + int session_id; + int ret; + + ret =3D session_validate_set(setup_args->block_set); + if (ret) + return ret; + + session =3D devm_kzalloc(ptdev->base.dev, sizeof(*session), GFP_KERNEL); + if (ZERO_OR_NULL_PTR(session)) + return -ENOMEM; + + ringbuffer =3D drm_gem_object_lookup(pfile->drm_file, setup_args->ringbuf= _handle); + if (!ringbuffer) { + ret =3D -EINVAL; + goto cleanup_session; + } + + control =3D drm_gem_object_lookup(pfile->drm_file, setup_args->control_ha= ndle); + if (!control) { + ret =3D -EINVAL; + goto cleanup_ringbuf; + } + + user_sample_size =3D session_get_max_sample_size(&ptdev->perf_info) * slo= ts; + + if (ringbuffer->size !=3D PFN_ALIGN(user_sample_size)) { + ret =3D -ENOMEM; + goto cleanup_control; + } + + ret =3D drm_gem_vmap_unlocked(ringbuffer, &rb_map); + if (ret) + goto cleanup_control; + + + ret =3D drm_gem_vmap_unlocked(control, &ctrl_map); + if (ret) + goto cleanup_ring_map; + + session->eventfd =3D eventfd_ctx_fdget(setup_args->fd); + if (IS_ERR_OR_NULL(session->eventfd)) { + ret =3D PTR_ERR_OR_ZERO(session->eventfd) ?: -EINVAL; + goto cleanup_control_map; + } + + em =3D panthor_perf_create_em(setup_args); + if (IS_ERR_OR_NULL(em)) { + ret =3D -ENOMEM; + goto cleanup_eventfd; + } + + INIT_LIST_HEAD(&session->waiting); + session->extract_idx =3D ctrl_map.vaddr; + *session->extract_idx =3D 0; + session->insert_idx =3D session->extract_idx + 1; + *session->insert_idx =3D 0; + + session->samples =3D rb_map.vaddr; + + /* TODO This will need validation when we support periodic sampling sessi= ons */ + if (setup_args->sample_freq_ns) { + ret =3D -EOPNOTSUPP; + goto cleanup_em; + } + + session->sample_freq_ns =3D setup_args->sample_freq_ns; + session->user_sample_size =3D user_sample_size; + session->enabled_counters =3D em; + session->ring_buf =3D ringbuffer; + session->control_buf =3D control; + session->pfile =3D pfile; + + ret =3D xa_alloc_cyclic(&perf->sessions, &session_id, session, perf->sess= ion_range, + &perf->next_session, GFP_KERNEL); + if (ret < 0) + goto cleanup_em; + + kref_init(&session->ref); + + return session_id; + +cleanup_em: + kref_put(&em->refs, panthor_perf_destroy_em_kref); + +cleanup_eventfd: + eventfd_ctx_put(session->eventfd); + +cleanup_control_map: + drm_gem_vunmap_unlocked(control, &ctrl_map); + +cleanup_ring_map: + drm_gem_vunmap_unlocked(ringbuffer, &rb_map); + +cleanup_control: + drm_gem_object_put(control); + +cleanup_ringbuf: + drm_gem_object_put(ringbuffer); + +cleanup_session: + devm_kfree(ptdev->base.dev, session); + + return ret; +} + +static int session_stop(struct panthor_perf *perf, struct panthor_perf_ses= sion *session, + u64 user_data) +{ + if (!test_bit(PANTHOR_PERF_SESSION_ACTIVE, session->state)) + return 0; + + const u32 extract_idx =3D session_read_extract_idx(session); + const u32 insert_idx =3D session_read_insert_idx(session); + + /* Must have at least one slot remaining in the ringbuffer to sample. */ + if (WARN_ON_ONCE(!CIRC_SPACE_TO_END(insert_idx, extract_idx, session->rin= gbuf_slots))) + return -EBUSY; + + session->user_data =3D user_data; + + clear_bit(PANTHOR_PERF_SESSION_ACTIVE, session->state); + + /* TODO Calls to the FW interface will go here in later patches. */ + return 0; +} + +static int session_start(struct panthor_perf *perf, struct panthor_perf_se= ssion *session, + u64 user_data) +{ + if (test_bit(PANTHOR_PERF_SESSION_ACTIVE, session->state)) + return 0; + + set_bit(PANTHOR_PERF_SESSION_ACTIVE, session->state); + + /* + * For manual sampling sessions, a start command does not correspond to a= sample, + * and so the user data gets discarded. + */ + if (session->sample_freq_ns) + session->user_data =3D user_data; + + /* TODO Calls to the FW interface will go here in later patches. */ + return 0; +} + +static int session_sample(struct panthor_perf *perf, struct panthor_perf_s= ession *session, + u64 user_data) +{ + if (!test_bit(PANTHOR_PERF_SESSION_ACTIVE, session->state)) + return -EACCES; + + const u32 extract_idx =3D session_read_extract_idx(session); + const u32 insert_idx =3D session_read_insert_idx(session); + + /* Manual sampling for periodic sessions is forbidden. */ + if (session->sample_freq_ns) + return -EINVAL; + + /* + * Must have at least two slots remaining in the ringbuffer to sample: on= e for + * the current sample, and one for a stop sample, since a stop command sh= ould + * always be acknowledged by taking a final sample and stopping the sessi= on. + */ + if (CIRC_SPACE_TO_END(insert_idx, extract_idx, session->ringbuf_slots) < = 2) + return -EBUSY; + + session->sample_start_ns =3D ktime_get_raw_ns(); + session->user_data =3D user_data; + + /* TODO Calls to the FW interface will go here in later patches. */ + return 0; +} + +static int session_destroy(struct panthor_perf *perf, struct panthor_perf_= session *session) +{ + session_put(session); + + return 0; +} + +static int session_teardown(struct panthor_perf *perf, struct panthor_perf= _session *session) +{ + if (test_bit(PANTHOR_PERF_SESSION_ACTIVE, session->state)) + return -EINVAL; + + if (!list_empty(&session->waiting)) + return -EBUSY; + + return session_destroy(perf, session); +} + +/** + * panthor_perf_session_teardown - Teardown the session associated with th= e @sid. + * @pfile: Open panthor file. + * @perf: Handle to the perf control structure. + * @sid: Session identifier. + * + * Destroys a stopped session where the last sample has been explicitly co= nsumed + * or discarded. Active sessions will be ignored. + * + * Return: 0 on success, negative error code on failure. + */ +int panthor_perf_session_teardown(struct panthor_file *pfile, struct panth= or_perf *perf, u32 sid) +{ + int err; + struct panthor_perf_session *session; + + xa_lock(&perf->sessions); + session =3D __xa_store(&perf->sessions, sid, NULL, GFP_KERNEL); + + if (xa_is_err(session)) { + err =3D xa_err(session); + goto restore; + } + + if (session->pfile !=3D pfile) { + err =3D -EINVAL; + goto restore; + } + + session_get(session); + xa_unlock(&perf->sessions); + + err =3D session_teardown(perf, session); + + session_put(session); + + return err; + +restore: + __xa_store(&perf->sessions, sid, session, GFP_KERNEL); + xa_unlock(&perf->sessions); + + return err; +} + +/** + * panthor_perf_session_start - Start sampling on a stopped session. + * @pfile: Open panthor file. + * @perf: Handle to the panthor perf control structure. + * @sid: Session identifier for the desired session. + * @user_data: An opaque value passed in from userspace. + * + * A session counts as stopped when it is created or when it is explicitly= stopped after being + * started. Starting an active session is treated as a no-op. + * + * The @user_data parameter will be associated with all subsequent samples= for a periodic + * sampling session and will be ignored for manual sampling ones in favor = of the user data + * passed in the PERF_CONTROL.SAMPLE ioctl call. + * + * Return: 0 on success, negative error code on failure. + */ +int panthor_perf_session_start(struct panthor_file *pfile, struct panthor_= perf *perf, + u32 sid, u64 user_data) +{ + struct panthor_perf_session *session =3D session_find(pfile, perf, sid); + int err; + + if (IS_ERR_OR_NULL(session)) + return IS_ERR(session) ? PTR_ERR(session) : -EINVAL; + + err =3D session_start(perf, session, user_data); + + session_put(session); + + return err; +} + +/** + * panthor_perf_session_stop - Stop sampling on an active session. + * @pfile: Open panthor file. + * @perf: Handle to the panthor perf control structure. + * @sid: Session identifier for the desired session. + * @user_data: An opaque value passed in from userspace. + * + * A session counts as active when it has been explicitly started via the = PERF_CONTROL.START + * ioctl. Stopping a stopped session is treated as a no-op. + * + * To ensure data is not lost when sampling is stopping, there must always= be at least one slot + * available for the final automatic sample, and the stop command will be = rejected if there is not. + * + * The @user_data will always be associated with the final sample. + * + * Return: 0 on success, negative error code on failure. + */ +int panthor_perf_session_stop(struct panthor_file *pfile, struct panthor_p= erf *perf, + u32 sid, u64 user_data) +{ + struct panthor_perf_session *session =3D session_find(pfile, perf, sid); + int err; + + if (IS_ERR_OR_NULL(session)) + return IS_ERR(session) ? PTR_ERR(session) : -EINVAL; + + err =3D session_stop(perf, session, user_data); + + session_put(session); + + return err; +} + +/** + * panthor_perf_session_sample - Request a sample on a manual sampling ses= sion. + * @pfile: Open panthor file. + * @perf: Handle to the panthor perf control structure. + * @sid: Session identifier for the desired session. + * @user_data: An opaque value passed in from userspace. + * + * Only an active manual sampler is permitted to request samples directly.= Failing to meet either + * of these conditions will cause the sampling request to be rejected. Req= uesting a manual sample + * with a full ringbuffer will see the request being rejected. + * + * The @user_data will always be unambiguously associated one-to-one with = the resultant sample. + * + * Return: 0 on success, negative error code on failure. + */ +int panthor_perf_session_sample(struct panthor_file *pfile, struct panthor= _perf *perf, + u32 sid, u64 user_data) +{ + struct panthor_perf_session *session =3D session_find(pfile, perf, sid); + int err; + + if (IS_ERR_OR_NULL(session)) + return IS_ERR(session) ? PTR_ERR(session) : -EINVAL; + + err =3D session_sample(perf, session, user_data); + + session_put(session); + + return err; +} + +/** + * panthor_perf_session_destroy - Destroy a sampling session associated wi= th the @pfile. + * @perf: Handle to the panthor perf control structure. + * @pfile: The file being closed. + * + * Must be called when the corresponding userspace process is destroyed an= d cannot close its + * own sessions. As such, we offer no guarantees about data delivery. + */ +void panthor_perf_session_destroy(struct panthor_file *pfile, struct panth= or_perf *perf) +{ + unsigned long sid; + struct panthor_perf_session *session; + + xa_for_each(&perf->sessions, sid, session) + { + if (session->pfile =3D=3D pfile) { + session_destroy(perf, session); + xa_erase(&perf->sessions, sid); + } + } } =20 /** @@ -146,10 +800,17 @@ void panthor_perf_unplug(struct panthor_device *ptdev) if (!perf) return; =20 - if (!xa_empty(&perf->sessions)) + if (!xa_empty(&perf->sessions)) { + unsigned long sid; + struct panthor_perf_session *session; + drm_err(&ptdev->base, "Performance counter sessions active when unplugging the driver!"); =20 + xa_for_each(&perf->sessions, sid, session) + session_destroy(perf, session); + } + xa_destroy(&perf->sessions); =20 devm_kfree(ptdev->base.dev, ptdev->perf); diff --git a/include/uapi/drm/panthor_drm.h b/include/uapi/drm/panthor_drm.h index 8a431431da6b..576d3ad46e6d 100644 --- a/include/uapi/drm/panthor_drm.h +++ b/include/uapi/drm/panthor_drm.h @@ -458,6 +458,12 @@ enum drm_panthor_perf_block_type { =20 /** @DRM_PANTHOR_PERF_BLOCK_SHADER: A shader core counter block. */ DRM_PANTHOR_PERF_BLOCK_SHADER, + + /** @DRM_PANTHOR_PERF_BLOCK_LAST: Internal use only. */ + DRM_PANTHOR_PERF_BLOCK_LAST =3D DRM_PANTHOR_PERF_BLOCK_SHADER, + + /** @DRM_PANTHOR_PERF_BLOCK_MAX: Internal use only. */ + DRM_PANTHOR_PERF_BLOCK_MAX =3D DRM_PANTHOR_PERF_BLOCK_LAST + 1, }; =20 /** @@ -1368,6 +1374,44 @@ struct drm_panthor_perf_control { __u64 pointer; }; =20 +/** + * enum drm_panthor_perf_counter_set - The counter set to be requested fro= m the hardware. + * + * The hardware supports a single performance counter set at a time, so re= questing any set other + * than the primary may fail if another process is sampling at the same ti= me. + * + * If in doubt, the primary counter set has the most commonly used counter= s and requires no + * additional permissions to open. + */ +enum drm_panthor_perf_counter_set { + /** + * @DRM_PANTHOR_PERF_SET_PRIMARY: The default set configured on the hardw= are. + * + * This is the only set for which all counters in all blocks are defined. + */ + DRM_PANTHOR_PERF_SET_PRIMARY, + + /** + * @DRM_PANTHOR_PERF_SET_SECONDARY: The secondary performance counter set. + * + * Some blocks may not have any defined counters for this set, and the bl= ock will + * have the UNAVAILABLE block state permanently set in the block header. + * + * Accessing this set requires the calling process to have the CAP_PERFMO= N capability. + */ + DRM_PANTHOR_PERF_SET_SECONDARY, + + /** + * @DRM_PANTHOR_PERF_SET_TERTIARY: The tertiary performance counter set. + * + * Some blocks may not have any defined counters for this set, and the bl= ock will have + * the UNAVAILABLE block state permanently set in the block header. Note = that the + * tertiary set has the fewest defined counter blocks. + * + * Accessing this set requires the calling process to have the CAP_PERFMO= N capability. + */ + DRM_PANTHOR_PERF_SET_TERTIARY, +}; =20 /** * struct drm_panthor_perf_cmd_setup - Arguments passed to DRM_PANTHOR_IOC= TL_PERF_CONTROL @@ -1375,13 +1419,17 @@ struct drm_panthor_perf_control { */ struct drm_panthor_perf_cmd_setup { /** - * @block_set: Set of performance counter blocks. + * @block_set: Set of performance counter blocks, member of + * enum drm_panthor_perf_block_set. * * This is a global configuration and only one set can be active at a tim= e. If * another client has already requested a counter set, any further reques= ts * for a different counter set will fail and return an -EBUSY. * * If the requested set does not exist, the request will fail and return = an -EINVAL. + * + * Some sets have additional requirements to be enabled, and the setup re= quest will + * fail with an -EACCES if these requirements are not satisfied. */ __u8 block_set; =20 --=20 2.25.1 From nobody Sun Dec 14 13:49:49 2025 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2077.outbound.protection.outlook.com [40.107.247.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E0C31DEFDC for ; Wed, 11 Dec 2024 16:51:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.77 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935892; cv=fail; b=le58rBuKvAr5bLfHnrLyO7g6TSU3t+L69MXgmF5lobZNbLcObXbcc7sg1+dQNPcAvdDHa9g5XK3Ihrhfii56Q8QeknLdoc32xLj6e/xT61HpKnWcd4t6GMMWHaQgTLnrXcQJkFVUEQ7vDXj7BTcyUkvURjgDDdQm1CXWLd3sNAE= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935892; c=relaxed/simple; bh=/QI/R6xet5hp5lIhRP+pMSe73gJy71lewLzW3pJ6akY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=iLdD4pUgNjfBlkfi7n/AleCOETH5gP0GjGnzpqVNz5y3uDGycz7YFcV4D7ofSpC6fDqHlYAaJiC0awRHcINncw3+G+c+/veaQxcL6ATYrhQBG47+pePk+qmVuSmOGeA1nxhzEiASzkIseKvk+osVpMadZMA2ZIqgeQBMDw9CiK4= ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=W29RHsa1; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=W29RHsa1; arc=fail smtp.client-ip=40.107.247.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="W29RHsa1"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="W29RHsa1" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=GZHSFW8hbSTIriGMD9+hge1Hg3d6ROAKrVkRwTveimOjLwjpDSWaecWjy+VoJsB3cM9bP3D6bQJ4CvcU0Na9xAJPawBTtF833s/RWokhP0jxDDpZutudcIPvbHT0E35ZzGTH0E19xtaWswm5w7xYsXmXZ5Bod0ViN01E80tGfH5JcX6/Ska2yKRLaVQieyEoBJtdsLBYw8hflbqImEeivU8mJ5zUIDj2bIqJZ2gSVx60evWoSryNxYh15dQjLcA8vrdn43KFVIPjoOlKm9pFKXJSRKOvihObOjNslhovCkjiPHPzeYz0sGbbskxuBBwm3qoXg0XGD1Ts/9dpk8Mi0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=xSnbtu7/4b0xcoVBcmxU4opQ6rHX/5VJgVS4QuzkGCY=; b=RndwGbBLiLBLk1yWSqbmcZU9t2Ci1V+B0N/YmQWpPZL3GYAmca4u8NSHFW1C6Whq5vPFUrzIoKIJlkmQYZY+/qndQusBntFw9DEAvuay+DV5LwrQgryiw8QStKAxPa1TDI9mCvn4zddDYUGwCku+COqounepUD7V/OYxlv4AnQXMeiO7tzDace7WkTHPb/YnGQWCu6stVVu0oGMmJbWy/oXUd5F9rk1r71Fuy28Ay9oRm546tRPbEX6w+ZVIn2c2D1Gf2ZsTH+Jt88CcnEbZzWcRyvsTuV19ua33lDYA58ZNklOpEDhP596j89IY1av5Op+6K5jxbDf2QLbgbMbRQQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xSnbtu7/4b0xcoVBcmxU4opQ6rHX/5VJgVS4QuzkGCY=; b=W29RHsa1JUnD8APJJU/Pkjdia1uxOQc7DwIFOYQAZKLBAUbQAQ9nd+8WeR4TY4/0f/h4Qk8E7eUjJbtLaEFmhsmtPRQHaEeLm19MWlo4dju9DOknENvoXCeLSejbVWNUMPmVO19KpN3HJFZofO0R6Q+VeIikGRrtugK2WmnwQ1k= Received: from AS9PR04CA0071.eurprd04.prod.outlook.com (2603:10a6:20b:48b::20) by PAXPR08MB6671.eurprd08.prod.outlook.com (2603:10a6:102:13b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 16:51:18 +0000 Received: from AM2PEPF0001C70C.eurprd05.prod.outlook.com (2603:10a6:20b:48b:cafe::21) by AS9PR04CA0071.outlook.office365.com (2603:10a6:20b:48b::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM2PEPF0001C70C.mail.protection.outlook.com (10.167.16.200) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:18 +0000 Received: ("Tessian outbound 9c6259131e4d:v524"); Wed, 11 Dec 2024 16:51:17 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0cf303c8a12e35c1 X-TessianGatewayMetadata: Erkx3mfIPFDV+UBvGmTwpPGEsBZElLkAyVxmVk9GCqp67IqFZhyBnl7nr7Wtd+KfLBh9wZo4x4WfJ0cQpcU6Y77lJAy9IK5R1sENjUs4CqyBCZKuODKNakRtilROawAPJjHyMJxJjMBpcuOrrWdHKx8ItqW0PQqG/mmdd+CNBzU= X-CR-MTA-TID: 64aa7808 Received: from L1c19647b0b3f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F35F1243-C2CA-471D-9E3B-B6656E8F2F07.1; Wed, 11 Dec 2024 16:51:06 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id L1c19647b0b3f.1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 11 Dec 2024 16:51:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jubFSn72R58paVuwGhmcbClcor13WMqYVkAg6jPoCa5ev0iT57hR2Hlvrtm0sm7MIBdlh57YHciHk/X+Uoe+S2OkMSdZsUFBd7Ywm6RDKQHmC+GugSmOIMSImeBVLQkEhDYnjwTaomQKyOEjPe5uWP9UalPLxWfR2ZiiGouK1q2MbXTWZRAwkF9tS0rNmJqTY8xTP49hmJDF2ztbir6iFWcryNdY8gTHvJAFHFtR73/gXnPbiBnoxjxswVcPV7LaLiLR7zhQjs2d6XIapbFo+b/qFbqWgRghkcZv+fh9wQSvXIAqH2yk6LVVRPeesUZ1tNwGFkJ+gDvUEJ+0YdVkVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=xSnbtu7/4b0xcoVBcmxU4opQ6rHX/5VJgVS4QuzkGCY=; b=lM0R+/7a/OHkHzncTpjM/bPYM3Hvfk7B7cwHWEziVJxb2W6lx5W+wYDm2ChO7Sg4cZSARmAuTnQheGyFmZ7ZX261ueWRNX5YMUyOMsvxkDbEwDNbnSDVC3JIj++uONd3cSnDpK4+Ar4pMghpmyEK3qtp4qCEM0LQasbin0hfO1PkUXfTxfkX896vuhSCqjikW9hsc94jN0YLKl/hIx3phoXZnmxjypSkwQw8ns46YGXz8hkzRnS8h0pKPdHNDLBzK0MgXoIXJG/rfEahREKMoBOV8kTg3wQnfcM0Me+P2TdogE1Rth9uIHXXlsFJoh4b5fS9ERiKMo68BmS22YdZiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xSnbtu7/4b0xcoVBcmxU4opQ6rHX/5VJgVS4QuzkGCY=; b=W29RHsa1JUnD8APJJU/Pkjdia1uxOQc7DwIFOYQAZKLBAUbQAQ9nd+8WeR4TY4/0f/h4Qk8E7eUjJbtLaEFmhsmtPRQHaEeLm19MWlo4dju9DOknENvoXCeLSejbVWNUMPmVO19KpN3HJFZofO0R6Q+VeIikGRrtugK2WmnwQ1k= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) by DU0PR08MB8422.eurprd08.prod.outlook.com (2603:10a6:10:406::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 16:51:02 +0000 Received: from AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897]) by AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897%7]) with mapi id 15.20.8230.016; Wed, 11 Dec 2024 16:51:02 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Mihail Atanassov , nd@arm.com, Lukas Zapolskas Subject: [RFC v2 6/8] drm/panthor: Implement the counter sampler and sample handling Date: Wed, 11 Dec 2024 16:50:22 +0000 Message-Id: <20241211165024.490748-7-lukas.zapolskas@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241211165024.490748-1-lukas.zapolskas@arm.com> References: <20241211165024.490748-1-lukas.zapolskas@arm.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO2P265CA0169.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::13) To AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM6PR08MB3317:EE_|DU0PR08MB8422:EE_|AM2PEPF0001C70C:EE_|PAXPR08MB6671:EE_ X-MS-Office365-Filtering-Correlation-Id: 4adae965-a6e6-4e92-7be5-08dd1a0408c7 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: =?utf-8?B?VGJYQnZZNE5ZY1FFZTN0Wm8vMnFDNDhmdUxPcllhMkFTdUNacVJVUUExNWJF?= =?utf-8?B?ZFNEbzYzMG5HTjVhaFRsc1Fyb1c5ZU9OSTJVZmE5b2RJb1VjZk9ZcVpBTDhJ?= =?utf-8?B?UTlPK1V6cjlxL2J3L2JwZlU3RlBRSDVHQ0tEbStXTWhjRzdPeDF4cG9xUDZn?= =?utf-8?B?RndsL0RwbHlDQ20vRnA4YmdQWDVEYzM3Y0dlWHFEUVVJYW1weGlNM0NsSElW?= =?utf-8?B?aTMvQTBxc1RpMnhkdWZxQ05ncERqYklqNG4yNytiOXRTaUVHdHlCeTVDdUZu?= =?utf-8?B?U3JxN0xMYm1XUHR6Q1l6bVBPenNianVlTnB6RWY2eVVCOGFGM1dKOG1RUC9K?= =?utf-8?B?MUdhRXR3a0Zhc0h6YytDMGx6ejdCeWJ3ZGtzQXZBVG1RQXppak9yWmlFN0ZL?= =?utf-8?B?VzY2VFNsN0xGOFkrcnZ4K1ppWnJsWkF3S3lPazBGcXFIV1MxVU1VZTRHK3VJ?= =?utf-8?B?LzZxL1REYkJOVHh5WVl6WlFMOW42aFlwMGNncldBWHdmZEhHcXdSRGpyNGFQ?= =?utf-8?B?VTh2UCtMdkpDK1JyUEJHRjdLS3V3YUtheDNTRkhBQ0xQaTYyZ0JtV2NhU1Nu?= =?utf-8?B?bFJ3LzhDTVNZT2RLU3pqcjNkT3IxaCtCVXlocHRxMkdYc2ZLQm5kRmY3V2xr?= =?utf-8?B?WG1VWDcxR3EzdVF4RW13U1lITWJGY1B6N01jMHo4QjhzQlhEd2h3SWtIdG10?= =?utf-8?B?MnVEL1ZjaGJZcEJJbGJhTGpJQUo2RGIvVGd1UFgxeWNrNitKRFQwaEViK3N5?= =?utf-8?B?OUl4SXhudUFCMDNXOFJsSDF5N1NQcVRYa2pEL1lpOTRvWkdHQTRYUWxPemtT?= =?utf-8?B?WTRDQVlzUVZTV3hsaXdGaVBRbnlEVm5CaHNpSXFpWUNrcUlzWlNKOUoxWFl4?= =?utf-8?B?dUwySHhZWEdyM3Rwb3pERnBid2FnVFIrS0xkMnM3aVEyNitMZDhDbG1IM2w0?= =?utf-8?B?V3BQY00xb1dkSkczTy9hN2hUR05vRVA5OXdGbjcrb0k4czJieXIxcmhISlhW?= =?utf-8?B?LzdLYWtGZGJxZ0dHdkdHWXJoSnlDZXVYSnJ3SXhwQ2xST2hXZk5KSi9OdGp0?= =?utf-8?B?TStjdlNzdG5VNERUOUZDYVZkRzF2MElDeHFyMWNleng4dlIwOUh4NXluaEN5?= =?utf-8?B?QkNsQ0ZDaEl2WHRNQmlPVWJ2end1blhOTVJzSVVvT2FIRlg2WW4ydnRJbVhL?= =?utf-8?B?djc3YVp1TFEvYU50L0hpeDdoTGRDL0h3UUlhQWQ0K3QzemN4MDE0dmc2With?= =?utf-8?B?cDJOdEZJNDFCcW9ma3FBVzQvS0hseDBhS21mOUg0dFJmZWJTaXhYUHV5aXI4?= =?utf-8?B?Y3laVmh5Mm1JeGZPbUZTTDN5by9Uc1FZTVIra1NpSzBxL3g1bGM5MFU0aEcx?= =?utf-8?B?dkYzUGZ0RlYyRzVoTFFReGlYRXRaR2dpaVZHOHVaY2dvSkZEWjBaaSs5TDVm?= =?utf-8?B?anVVaFpjemFBbUN0d0Z2YTBWV2VXVytpUzhqd095azQ2elFHWjFPVTBiSzE1?= =?utf-8?B?ZWNRTHpzSjhTLzIyWGx6c0NwSy8xaGtDWDFEbXBVcjdRdTZMbzBmb042c1pl?= =?utf-8?B?UVVGV1FJdU5nRUl2cGQxdXhmTXhKQ0tQTjl2U3NtNFN6RXBmVzlUZlQraVpp?= =?utf-8?B?RVRGY0Zaa3g0QjlrakJheHVId2hBcFBOMUpRc0dyTUlrNDBSS2MraG9FRWg4?= =?utf-8?B?RUVxbldiZVRYL0tkd01LT3B3MG56QUxXQmdESUF1V2kyL1UxaHU1bExZMnk1?= =?utf-8?B?WjF3RGFPVDh5cnhrR1J6czV4T0VqeEtvSzA3eTc3MjJTWGo2UnlGeDRBUWdl?= =?utf-8?B?cURteUY5SUhTdkZSR3hhUT09?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR08MB3317.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8422 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:209:42::28];domain=AM6PR08MB3317.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM2PEPF0001C70C.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7a7f4b6b-5fc6-4a01-43ff-08dd1a03ff01 X-Microsoft-Antispam: BCL:0;ARA:13230040|14060799003|376014|82310400026|35042699022|1800799024|36860700013; X-Microsoft-Antispam-Message-Info: =?utf-8?B?TlhTcmJSbHJNbzEvUXFZUnpjYVhVTmdWekx5Q0lYQ2JKWlduMHNaUjRrcjZ4?= =?utf-8?B?ajBLdmpFMzFEaDRQV3dwcE5NdnRvSlZjby8wZU9KOTFrOWJpQ3BQUGNLb2w2?= =?utf-8?B?YVFWZnQ3WDFvL2FiMDEwZmFvTjJYRGpSWW14YktLaVBEeUpzYUxLOFBZVENm?= =?utf-8?B?YTRURTliZ1JVMHU4NTZLQmwrbmJxeXV4RGVrQUgwVHNrZ0syNjJtMlllTjQ2?= =?utf-8?B?Y2VLdGNaVklsTWMvbmMyTmQxM2FnUFd4ZDREdHd4S2ErUlg5UzlFdWtCQWpP?= =?utf-8?B?T3JnVXVIUStkMjBwNFJBZUc4VE5DMHU3S0ROVlFGSHlzcDRPMVMvcDZCeXA3?= =?utf-8?B?SThTMVc4Y1F1cG44ekJ4bVlKeGxoU1RBcGYyVThYMGQyNks0VjVWYzNRVEVY?= =?utf-8?B?TGFOZkh5MEFtQWVNUGVDQ042a2NQTXdQTkN5M3Z2TGhFaFQ1QzUvY3U1WXpR?= =?utf-8?B?Rml2TzJKVzNVbEdvNC9URitoczhPYkpEMzQrRDlTWWJqa0w2RHpXNis2WTV1?= =?utf-8?B?OVBpUUdYQXc4ZGJxbkhYZlNERmhvZDF4QlRkUFVZNW5EOGZ4WVprc0JRb1JW?= =?utf-8?B?ZVorS3JFb3RYc2JWWXplNlBtTXhTYXpZUTdqZ2c4YWJ4N2pDaGlRK0lMY0tk?= =?utf-8?B?WW5GVmFGVVdBTVVmaUdyakJTZXZVQXdGMWg1dEhYVVQ2akE3cFpFcUxqNVRK?= =?utf-8?B?enkrV25RckZiMWo4SjE2ekNZK3gvRVBKeTFHZ2syMWpmdTlmQlE0MEc3Wkk4?= =?utf-8?B?Q043bG9lc0lYOHBlM2JYZWcxS3FDVG1Qbm0xY2F2S0gvZXV3NDQwVFZ3OGx6?= =?utf-8?B?QUhkek5aekpIOTlwaGFFWWEyZER0T0VzdCtoaXh2Y0RRS1RHelRueWxUcWJs?= =?utf-8?B?UVVZWWdMY2g1d3NyeU1GY05MNm0rNmwyOHlESzlKcFViWW9NUlE3RjFuaE1o?= =?utf-8?B?aXVkR3JLQ3BuU1JneFdXMFN1R2cvL1REY3dKbDNJUDVFMFhMRkZVM2dNc1dx?= =?utf-8?B?cCt5QWJsSWNHeDBqVFo1TWoyZVdMZVI3QU1pQlpVUVJBSGF1c25SQmdkb0x2?= =?utf-8?B?a1V1VEdHV2pqRjVIRG9vZ3p6RXR4bGNWUTJSMzJhdktKZE05eUQ5NXoybUhk?= =?utf-8?B?SG9uSWwyN1d3cTRXVEZLVmthd3lQbkZ0K2diSnJNdkhKR2xxZkZsbzBpU1hO?= =?utf-8?B?QkpycXd2cVJjRzU1WFJUcEpMbE1JTTZ6b3dORU9HaDdGRFJ2YndOaTBLMXN6?= =?utf-8?B?YU0yN2Y0ZnpEU09scXVtbFRvdUdrb3BYN09KM2Ztd29MNVZ6VXlxTk1qWGJS?= =?utf-8?B?SGxKK1Npc3BRbDdHQlZ6Tll5Yi84UllONVBLaTltL0hLc1ZOZUM4K2NaM2tk?= =?utf-8?B?M3QyOEtiUzR0VkRLMzZoTitBUkxuS09BSysvWTRRV3MrU0FsMWVldGNESjJZ?= =?utf-8?B?bkVFL2MxSFU2bUkvZGFZMHlDSHM1VkFsOXhsS2RDWGVMRjRCS0dCUmE1TTJy?= =?utf-8?B?MnB4WUxweGhqNkVIU1NLYk5Za1VsUWF1VGRlMDJvdWd0M0VDeGVDb1hmVWhx?= =?utf-8?B?WkFMR0p5QURxRGpnTXdqN2RGVVJ1Y0c1NDZsNlJWYStkaFg4QStaT0pWMzh3?= =?utf-8?B?UWlOSnMyU3dsY1haMXpiOERKcnBIY0tPSkJ0SC9iMzQ0L0xlL1NhSkExa0Fk?= =?utf-8?B?aVVpT1Z6QlNta3V0cU0reTFlNGRDZndtbW5DaVQvSnFlS2VFekE2Q0dqbVYy?= =?utf-8?B?VmgwZ0ZtVnJXaEtMOWJEZnhwbVRXRGpXMlZ0UGJhZ203RnZ1cUdOVlRXS2xQ?= =?utf-8?B?SHp3cHlBc29LSDMya0dpOWRwdjNsTUxWQ2xnSEZTYzdJSlpYOWJQenAwU2x0?= =?utf-8?B?M0ZHS3RQQ1h5bWpybXNJbVZJeDlBRXRXNFl5a1VBd2Y3M0dkb3p1VVpRWUo4?= =?utf-8?B?eFdJYzRBZTMxQjdtQjhPc2tsQjZFRUU3cmVscjYrb1Q5MThOY1ZPeGNHZFRn?= =?utf-8?B?Zjdsc25VcStRPT0=?= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:64aa7808-outbound-1.mta.getcheckrecipient.com;CAT:NONE;SFS:(13230040)(14060799003)(376014)(82310400026)(35042699022)(1800799024)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 16:51:18.5335 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4adae965-a6e6-4e92-7be5-08dd1a0408c7 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM2PEPF0001C70C.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6671 From: Adri=C3=A1n Larumbe The sampler aggregates counter and set requests coming from userspace and mediates interactions with the FW interface, to ensure that user sessions cannot override the global configuration. From the top-level interface, the sampler supports two different types of samples: clearing samples and regular samples. Clearing samples are a special sample type that allow for the creation of a sampling baseline, to ensure that a session does not obtain counter data from before its creation. Upon receipt of a relevant interrupt, corresponding to one of the three relevant bits of the GLB_ACK register, the sampler takes any samples that occurred, and, based on the insert and extract indices, accumulates them to an internal storage buffer after zero-extending the counters from the 32-bit counters emitted by the hardware to 64-bit counters for internal accumulation. When the performance counters are enabled, the FW ensures no counter data is lost when entering and leaving non-counting regions by producing automatic samples that do not correspond to a GLB_REQ.PRFCNT_SAMPLE request. Such regions may be per hardware unit, such as when a shader core powers down, or global. Most of these events do not directly correspond to session sample requests, so any intermediary counter data must be stored into a temporary accumulation buffer. If there are sessions waiting for a sample, this accumulated buffer will be taken, and emitted for each waiting client. During this phase, information like the timestamps of sample request and sample emission, type of the counter block and block index annotations are added to the sample header and block headers. If no sessions are waiting for a sample, this accumulation buffer is kept until the next time a sample is requested. Special handling is needed for the PRFCNT_OVERFLOW interrupt, which is an indication that the internal sample handling rate was insufficient. The sampler also maintains a buffer descriptor indicating the structure of a firmware sample, since neither the firmware nor the hardware give any indication of the sample structure, only that it is composed out of three parts: - the metadata is an optional initial counter block on supporting firmware versions that contains a single counter, indicating the reason a sample was taken when entering global non-counting regions. This is used to provide coarse-grained information about why a sample was taken to userspace, to help userspace interpret variations in counter magnitude. - the firmware component of the sample is composed out of a global firmware counter block on supporting firmware versions. - the hardware component is the most sizeable of the three and contains a block of counters for each of the underlying hardware resources. It has a fixed structure that is described in the architecture specification, and contains the command stream hardware block(s), the tiler block(s), the MMU and L2 blocks (collectively named the memsys blocks) and the shader core blocks, in that order. The structure of this buffer changes based on the firmware and hardware combination, but is constant on a single system. Signed-off-by: Adri=C3=A1n Larumbe Co-developed-by: Lukas Zapolskas Signed-off-by: Lukas Zapolskas --- drivers/gpu/drm/panthor/panthor_fw.c | 5 + drivers/gpu/drm/panthor/panthor_fw.h | 9 +- drivers/gpu/drm/panthor/panthor_perf.c | 882 ++++++++++++++++++++++++- drivers/gpu/drm/panthor/panthor_perf.h | 2 + include/uapi/drm/panthor_drm.h | 5 +- 5 files changed, 892 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor= /panthor_fw.c index e9530d1d9781..cd68870ced18 100644 --- a/drivers/gpu/drm/panthor/panthor_fw.c +++ b/drivers/gpu/drm/panthor/panthor_fw.c @@ -1000,9 +1000,12 @@ static void panthor_fw_init_global_iface(struct pant= hor_device *ptdev) =20 /* Enable interrupts we care about. */ glb_iface->input->ack_irq_mask =3D GLB_CFG_ALLOC_EN | + GLB_PERFCNT_SAMPLE | GLB_PING | GLB_CFG_PROGRESS_TIMER | GLB_CFG_POWEROFF_TIMER | + GLB_PERFCNT_THRESHOLD | + GLB_PERFCNT_OVERFLOW | GLB_IDLE_EN | GLB_IDLE; =20 @@ -1031,6 +1034,8 @@ static void panthor_job_irq_handler(struct panthor_de= vice *ptdev, u32 status) return; =20 panthor_sched_report_fw_events(ptdev, status); + + panthor_perf_report_irq(ptdev, status); } PANTHOR_IRQ_HANDLER(job, JOB, panthor_job_irq_handler); =20 diff --git a/drivers/gpu/drm/panthor/panthor_fw.h b/drivers/gpu/drm/panthor= /panthor_fw.h index db10358e24bb..7ed34d2de8b4 100644 --- a/drivers/gpu/drm/panthor/panthor_fw.h +++ b/drivers/gpu/drm/panthor/panthor_fw.h @@ -199,9 +199,10 @@ struct panthor_fw_global_control_iface { u32 group_num; u32 group_stride; #define GLB_PERFCNT_FW_SIZE(x) ((((x) >> 16) << 8)) +#define GLB_PERFCNT_HW_SIZE(x) (((x) & GENMASK(15, 0)) << 8) u32 perfcnt_size; u32 instr_features; -#define PERFCNT_FEATURES_MD_SIZE(x) ((x) & GENMASK(3, 0)) +#define PERFCNT_FEATURES_MD_SIZE(x) (((x) & GENMASK(3, 0)) << 8) u32 perfcnt_features; }; =20 @@ -211,7 +212,7 @@ struct panthor_fw_global_input_iface { #define GLB_CFG_ALLOC_EN BIT(2) #define GLB_CFG_POWEROFF_TIMER BIT(3) #define GLB_PROTM_ENTER BIT(4) -#define GLB_PERFCNT_EN BIT(5) +#define GLB_PERFCNT_ENABLE BIT(5) #define GLB_PERFCNT_SAMPLE BIT(6) #define GLB_COUNTER_EN BIT(7) #define GLB_PING BIT(8) @@ -234,7 +235,6 @@ struct panthor_fw_global_input_iface { u32 doorbell_req; u32 reserved1; u32 progress_timer; - #define GLB_TIMER_VAL(x) ((x) & GENMASK(30, 0)) #define GLB_TIMER_SOURCE_GPU_COUNTER BIT(31) u32 poweroff_timer; @@ -244,6 +244,9 @@ struct panthor_fw_global_input_iface { u64 perfcnt_base; u32 perfcnt_extract; u32 reserved3[3]; +#define GLB_PRFCNT_CONFIG_SIZE(x) ((x) & GENMASK(7, 0)) +#define GLB_PRFCNT_CONFIG_SET(x) (((x) & GENMASK(1, 0)) << 8) +#define GLB_PRFCNT_METADATA_ENABLE BIT(10) u32 perfcnt_config; u32 perfcnt_csg_select; u32 perfcnt_fw_enable; diff --git a/drivers/gpu/drm/panthor/panthor_perf.c b/drivers/gpu/drm/panth= or/panthor_perf.c index 42d8b6f8c45d..d62d97c448da 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.c +++ b/drivers/gpu/drm/panthor/panthor_perf.c @@ -15,7 +15,9 @@ =20 #include "panthor_device.h" #include "panthor_fw.h" +#include "panthor_gem.h" #include "panthor_gpu.h" +#include "panthor_mmu.h" #include "panthor_perf.h" #include "panthor_regs.h" =20 @@ -26,6 +28,41 @@ */ #define PANTHOR_PERF_EM_BITS (BITS_PER_TYPE(u64) * 2) =20 +/** + * PANTHOR_PERF_FW_RINGBUF_SLOTS - Number of slots allocated for individua= l samples when configuring + * the performance counter ring buffer to = firmware. This can be + * used to reduce memory consumption on lo= w memory systems. + */ +#define PANTHOR_PERF_FW_RINGBUF_SLOTS (32) + +/** + * PANTHOR_CTR_TIMESTAMP_LO - The first architecturally mandated counter o= f every block type + * contains the low 32-bits of the TIMESTAMP va= lue. + */ +#define PANTHOR_CTR_TIMESTAMP_LO (0) + +/** + * PANTHOR_CTR_TIMESTAMP_HI - The register offset containinig the high 32-= bits of the TIMESTAMP + * value. + */ +#define PANTHOR_CTR_TIMESTAMP_HI (1) + +/** + * PANTHOR_CTR_PRFCNT_EN - The register offset containing the enable mask = for the enabled counters + * that were written to memory. + */ +#define PANTHOR_CTR_PRFCNT_EN (2) + +/** + * PANTHOR_HEADER_COUNTERS - The first four counters of every block type a= re architecturally + * defined to be equivalent. The fourth counter = is always reserved, + * and should be zero and as such, does not have= a separate define. + * + * These are the only four counters that are the= same between different + * blocks and are consistent between different a= rchitectures. + */ +#define PANTHOR_HEADER_COUNTERS (4) + /** * enum panthor_perf_session_state - Session state bits. */ @@ -158,6 +195,135 @@ struct panthor_perf_session { struct kref ref; }; =20 +struct panthor_perf_buffer_descriptor { + /** + * @block_size: The size of a single block in the FW ring buffer, equal to + * sizeof(u32) * counters_per_block. + */ + size_t block_size; + + /** + * @buffer_size: The total size of the buffer, equal to (#hardware blocks= + + * #firmware blocks) * block_size. + */ + size_t buffer_size; + + /** + * @available_blocks: Bitmask indicating the blocks supported by the hard= ware and firmware + * combination. Note that this can also include blocks= that will not + * be exposed to the user. + */ + DECLARE_BITMAP(available_blocks, DRM_PANTHOR_PERF_BLOCK_MAX); + struct { + /** @offset: Starting offset of a block of type @type in the FW ringbuff= er. */ + size_t offset; + + /** @type: Type of the blocks between @blocks[i].offset and @blocks[i+1]= .offset. */ + enum drm_panthor_perf_block_type type; + + /** @block_count: Number of blocks of the given @type, starting at @offs= et. */ + size_t block_count; + } blocks[DRM_PANTHOR_PERF_BLOCK_MAX]; +}; + + +/** + * struct panthor_perf_sampler - Interface to de-multiplex firmware intera= ction and handle + * global interactions. + */ +struct panthor_perf_sampler { + /** @sample_requested: A sample has been requested. */ + bool sample_requested; + + /** + * @last_ack: Temporarily storing the last GLB_ACK status. Without storin= g this data, + * we do not know whether a toggle bit has been handled. + */ + u32 last_ack; + + /** + * @enabled_clients: The number of clients concurrently requesting sample= s. To ensure that + * one client cannot deny samples to another, we must e= nsure that clients + * are effectively reference counted. + */ + atomic_t enabled_clients; + + /** + * @sample_handled: Synchronization point between the interrupt bottom ha= lf and the + * main sampler interface. Must be re-armed solely on a = new request + * coming to the sampler. + */ + struct completion sample_handled; + + /** @rb: Kernel BO in the FW AS containing the sample ringbuffer. */ + struct panthor_kernel_bo *rb; + + /** + * @sample_size: The size of a single sample in the FW ringbuffer. This i= s computed using + * the hardware configuration according to the architecture= specification, + * and cross-validated against the sample size reported by = FW to ensure + * a consistent view of the buffer size. + */ + size_t sample_size; + + /** + * @sample_slots: Number of slots for samples in the FW ringbuffer. Could= be static, + * but may be useful to customize for low-memory devices. + */ + size_t sample_slots; + + /** + * @config_lock: Lock serializing changes to the global counter configura= tion, including + * requested counter set and the counters themselves. + */ + struct mutex config_lock; + + /** + * @ems: List of enable maps of the active sessions. When removing a sess= ion, the number + * of requested counters may decrease, and the union of enable mask= s from the multiple + * sessions does not provide sufficient information to reconstruct = the previous + * enable mask. + */ + struct list_head ems; + + /** @em: Combined enable mask for all of the active sessions. */ + struct panthor_perf_enable_masks *em; + + /** + * @desc: Buffer descriptor for a sample in the FW ringbuffer. Note that = this buffer + * at current time does some interesting things with the zeroth bl= ock type. On + * newer FW revisions, the first counter block of the sample is th= e METADATA block, + * which contains a single value indicating the reason the sample = was taken (if + * any). This block must not be exposed to userspace, as userspace= does not + * have sufficient context to interpret it. As such, this block ty= pe is not + * added to the uAPI, but we still use it in the kernel. + */ + struct panthor_perf_buffer_descriptor desc; + + /** + * @sample: Pointer to an upscaled and annotated sample that may be emitt= ed to userspace. + * This is used both as an intermediate buffer to do the zero-ex= tension of the + * 32-bit counters to 64-bits and as a storage buffer in case th= e sampler + * requests an additional sample that was not requested by any o= f the top-level + * sessions (for instance, when changing the enable masks). + */ + u8 *sample; + + /** @sampler_lock: Lock used to guard the list of sessions requesting sam= ples. */ + struct mutex sampler_lock; + + /** @sampler_list: List of sessions requesting samples. */ + struct list_head sampler_list; + + /** @set_config: The set that will be configured onto the hardware. */ + u8 set_config; + + /** + * @ptdev: Backpointer to the Panthor device, needed to ring the global d= oorbell and + * interface with FW. + */ + struct panthor_device *ptdev; +}; =20 struct panthor_perf { /** @@ -175,6 +341,9 @@ struct panthor_perf { * @sessions: Global map of sessions, accessed by their ID. */ struct xarray sessions; + + /** @sampler: FW control interface. */ + struct panthor_perf_sampler sampler; }; =20 /** @@ -247,6 +416,23 @@ static struct panthor_perf_enable_masks *panthor_perf_= create_em(struct drm_panth return em; } =20 +static void panthor_perf_em_add(struct panthor_perf_enable_masks *dst_em, + const struct panthor_perf_enable_masks *const src_em) +{ + size_t i =3D 0; + + for (i =3D DRM_PANTHOR_PERF_BLOCK_FW; i <=3D DRM_PANTHOR_PERF_BLOCK_LAST;= i++) + bitmap_or(dst_em->mask[i], dst_em->mask[i], src_em->mask[i], PANTHOR_PER= F_EM_BITS); +} + +static void panthor_perf_em_zero(struct panthor_perf_enable_masks *em) +{ + size_t i =3D 0; + + for (i =3D DRM_PANTHOR_PERF_BLOCK_FW; i <=3D DRM_PANTHOR_PERF_BLOCK_LAST;= i++) + bitmap_zero(em->mask[i], PANTHOR_PERF_EM_BITS); +} + static void panthor_perf_destroy_em_kref(struct kref *em_kref) { struct panthor_perf_enable_masks *em =3D container_of(em_kref, typeof(*em= ), refs); @@ -270,6 +456,12 @@ static u32 session_read_extract_idx(struct panthor_per= f_session *session) return smp_load_acquire(session->extract_idx); } =20 +static void session_write_insert_idx(struct panthor_perf_session *session,= u32 idx) +{ + /* Userspace needs the insert index to know where to look for the sample.= */ + smp_store_release(session->insert_idx, idx); +} + static u32 session_read_insert_idx(struct panthor_perf_session *session) { return *session->insert_idx; @@ -349,6 +541,70 @@ static struct panthor_perf_session *session_find(struc= t panthor_file *pfile, return session; } =20 +static u32 compress_enable_mask(unsigned long *const src) +{ + size_t i; + u32 result =3D 0; + unsigned long clump; + + for_each_set_clump8(i, clump, src, PANTHOR_PERF_EM_BITS) { + const unsigned long shift =3D div_u64(i, 4); + + result |=3D !!(clump & GENMASK(3, 0)) << shift; + result |=3D !!(clump & GENMASK(7, 4)) << (shift + 1); + } + + return result; +} + +static void expand_enable_mask(u32 em, unsigned long *const dst) +{ + size_t i; + DECLARE_BITMAP(emb, BITS_PER_TYPE(u32)); + + bitmap_from_arr32(emb, &em, BITS_PER_TYPE(u32)); + + for_each_set_bit(i, emb, BITS_PER_TYPE(u32)) + bitmap_set(dst, i * 4, 4); +} + +/** + * panthor_perf_block_data - Identify the block index and type based on th= e offset. + * + * @desc: FW buffer descriptor. + * @offset: The current offset being examined. + * @idx: Pointer to an output index. + * @type: Pointer to an output block type. + * + * To disambiguate different types of blocks as well as different blocks o= f the same type, + * the offset into the FW ringbuffer is used to uniquely identify the bloc= k being considered. + * + * In the future, this is a good time to identify whether a block will be = empty, + * allowing us to short-circuit its processing after emitting header infor= mation. + */ +static void panthor_perf_block_data(struct panthor_perf_buffer_descriptor = *const desc, + size_t offset, u32 *idx, enum drm_panthor_perf_block_type *type) +{ + unsigned long id; + + for_each_set_bit(id, desc->available_blocks, DRM_PANTHOR_PERF_BLOCK_LAST)= { + const size_t block_start =3D desc->blocks[id].offset; + const size_t block_count =3D desc->blocks[id].block_count; + const size_t block_end =3D desc->blocks[id].offset + + desc->block_size * block_count; + + if (!block_count) + continue; + + if ((offset >=3D block_start) && (offset < block_end)) { + *type =3D desc->blocks[id].type; + *idx =3D div_u64(offset - desc->blocks[id].offset, desc->block_size); + + return; + } + } +} + static size_t session_get_max_sample_size(const struct drm_panthor_perf_in= fo *const info) { const size_t block_size =3D get_annotated_block_size(info->counters_per_b= lock); @@ -358,6 +614,520 @@ static size_t session_get_max_sample_size(const struc= t drm_panthor_perf_info *co return sizeof(struct drm_panthor_perf_sample_header) + (block_size * bloc= k_nr); } =20 +static u32 panthor_perf_handle_sample(struct panthor_device *ptdev, u32 ex= tract_idx, u32 insert_idx) +{ + struct panthor_perf *perf =3D ptdev->perf; + struct panthor_perf_sampler *sampler =3D &ptdev->perf->sampler; + const size_t ann_block_size =3D + get_annotated_block_size(ptdev->perf_info.counters_per_block); + u32 i; + + for (i =3D extract_idx; i !=3D insert_idx; i =3D (i + 1) % sampler->sampl= e_slots) { + u8 *fw_sample =3D (u8 *)sampler->rb->kmap + i * sampler->sample_size; + + for (size_t fw_off =3D 0, ann_off =3D sizeof(struct drm_panthor_perf_sam= ple_header); + fw_off < sampler->desc.buffer_size; + fw_off +=3D sampler->desc.block_size) + + { + u32 idx; + enum drm_panthor_perf_block_type type; + DECLARE_BITMAP(expanded_em, PANTHOR_PERF_EM_BITS); + struct panthor_perf_counter_block *blk =3D + (typeof(blk))(perf->sampler.sample + ann_off); + const u32 prfcnt_en =3D blk->counters[PANTHOR_CTR_PRFCNT_EN]; + + panthor_perf_block_data(&sampler->desc, fw_off, &idx, &type); + + /** + * TODO Data from the metadata block must be used to populate the + * block state information. + */ + if (type =3D=3D DRM_PANTHOR_PERF_BLOCK_METADATA) + continue; + + expand_enable_mask(prfcnt_en, expanded_em); + + blk->header =3D (struct drm_panthor_perf_block_header) { + .clock =3D 0, + .block_idx =3D idx, + .block_type =3D type, + .block_states =3D DRM_PANTHOR_PERF_BLOCK_STATE_UNKNOWN + }; + bitmap_to_arr64(blk->header.enable_mask, expanded_em, PANTHOR_PERF_EM_B= ITS); + + u32 *block =3D (u32 *)(fw_sample + fw_off); + + /* + * The four header counters must be treated differently, because they a= re + * not additive. For the fourth, the assignment does not matter, as it + * is reserved and should be zero. + */ + blk->counters[PANTHOR_CTR_TIMESTAMP_LO] =3D block[PANTHOR_CTR_TIMESTAMP= _LO]; + blk->counters[PANTHOR_CTR_TIMESTAMP_HI] =3D block[PANTHOR_CTR_TIMESTAMP= _HI]; + blk->counters[PANTHOR_CTR_PRFCNT_EN] =3D block[PANTHOR_CTR_PRFCNT_EN]; + + for (size_t k =3D PANTHOR_HEADER_COUNTERS; + k < ptdev->perf_info.counters_per_block; + k++) + blk->counters[k] +=3D block[k]; + + ann_off +=3D ann_block_size; + } + } + + return i; +} + +static size_t panthor_perf_get_fw_reported_size(struct panthor_device *ptd= ev) +{ + struct panthor_fw_global_iface *glb_iface =3D panthor_fw_get_glb_iface(pt= dev); + + size_t fw_size =3D GLB_PERFCNT_FW_SIZE(glb_iface->control->perfcnt_size); + size_t hw_size =3D GLB_PERFCNT_HW_SIZE(glb_iface->control->perfcnt_size); + size_t md_size =3D PERFCNT_FEATURES_MD_SIZE(glb_iface->control->perfcnt_f= eatures); + + return md_size + fw_size + hw_size; +} + +#define PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, typ, blk_count, offset) \ + ({ \ + (desc)->blocks[(typ)].type =3D (typ); \ + (desc)->blocks[(typ)].offset =3D (offset); \ + (desc)->blocks[(typ)].block_count =3D (blk_count); \ + if ((blk_count)) \ + set_bit((typ), (desc)->available_blocks); \ + (offset) + ((desc)->block_size) * (blk_count); \ + }) + +static int panthor_perf_setup_fw_buffer_desc(struct panthor_device *ptdev, + struct panthor_perf_sampler *sampler) +{ + const struct drm_panthor_perf_info *const info =3D &ptdev->perf_info; + const size_t block_size =3D info->counters_per_block * sizeof(u32); + struct panthor_perf_buffer_descriptor *desc =3D &sampler->desc; + const size_t fw_sample_size =3D panthor_perf_get_fw_reported_size(ptdev); + size_t offset =3D 0; + + desc->block_size =3D block_size; + + for (enum drm_panthor_perf_block_type type =3D 0; type < DRM_PANTHOR_PERF= _BLOCK_MAX; type++) { + switch (type) { + case DRM_PANTHOR_PERF_BLOCK_METADATA: + if (info->flags & DRM_PANTHOR_PERF_BLOCK_STATES_SUPPORT) + offset =3D PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, + DRM_PANTHOR_PERF_BLOCK_METADATA, 1, offset); + break; + case DRM_PANTHOR_PERF_BLOCK_FW: + offset =3D PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, type, info->fw_blocks, + offset); + break; + case DRM_PANTHOR_PERF_BLOCK_CSG: + offset =3D PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, type, info->csg_block= s, + offset); + break; + case DRM_PANTHOR_PERF_BLOCK_CSHW: + offset =3D PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, type, info->cshw_bloc= ks, + offset); + break; + case DRM_PANTHOR_PERF_BLOCK_TILER: + offset =3D PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, type, info->tiler_blo= cks, + offset); + break; + case DRM_PANTHOR_PERF_BLOCK_MEMSYS: + offset =3D PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, type, info->memsys_bl= ocks, + offset); + break; + case DRM_PANTHOR_PERF_BLOCK_SHADER: + offset =3D PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, type, info->shader_bl= ocks, + offset); + break; + case DRM_PANTHOR_PERF_BLOCK_MAX: + drm_WARN_ON_ONCE(&ptdev->base, + "DRM_PANTHOR_PERF_BLOCK_MAX should be unreachable!"); + break; + } + } + + /* Computed size is not the same as the reported size, so we should not p= roceed in + * initializing the sampling session. + */ + if (offset !=3D fw_sample_size) + return -EINVAL; + + desc->buffer_size =3D offset; + + return 0; +} + +static int panthor_perf_fw_stop_sampling(struct panthor_device *ptdev) +{ + struct panthor_fw_global_iface *glb_iface =3D panthor_fw_get_glb_iface(pt= dev); + u32 acked; + int ret; + + if (~READ_ONCE(glb_iface->input->req) & GLB_PERFCNT_ENABLE) + return 0; + + panthor_fw_update_reqs(glb_iface, req, 0, GLB_PERFCNT_ENABLE); + gpu_write(ptdev, CSF_DOORBELL(CSF_GLB_DOORBELL_ID), 1); + ret =3D panthor_fw_glb_wait_acks(ptdev, GLB_PERFCNT_ENABLE, &acked, 100); + if (ret) + drm_warn(&ptdev->base, "Could not disable performance counters"); + + return ret; +} + +static int panthor_perf_fw_start_sampling(struct panthor_device *ptdev) +{ + struct panthor_fw_global_iface *glb_iface =3D panthor_fw_get_glb_iface(pt= dev); + u32 acked; + int ret; + + if (READ_ONCE(glb_iface->input->req) & GLB_PERFCNT_ENABLE) + return 0; + + panthor_fw_update_reqs(glb_iface, req, GLB_PERFCNT_ENABLE, GLB_PERFCNT_EN= ABLE); + gpu_write(ptdev, CSF_DOORBELL(CSF_GLB_DOORBELL_ID), 1); + ret =3D panthor_fw_glb_wait_acks(ptdev, GLB_PERFCNT_ENABLE, &acked, 100); + if (ret) + drm_warn(&ptdev->base, "Could not enable performance counters"); + + return ret; +} + +static void panthor_perf_fw_write_em(struct panthor_perf_sampler *sampler, + struct panthor_perf_enable_masks *em) +{ + struct panthor_fw_global_iface *glb_iface =3D panthor_fw_get_glb_iface(sa= mpler->ptdev); + u32 perfcnt_config; + + glb_iface->input->perfcnt_csf_enable =3D + compress_enable_mask(em->mask[DRM_PANTHOR_PERF_BLOCK_CSHW]); + glb_iface->input->perfcnt_shader_enable =3D + compress_enable_mask(em->mask[DRM_PANTHOR_PERF_BLOCK_SHADER]); + glb_iface->input->perfcnt_mmu_l2_enable =3D + compress_enable_mask(em->mask[DRM_PANTHOR_PERF_BLOCK_MEMSYS]); + glb_iface->input->perfcnt_tiler_enable =3D + compress_enable_mask(em->mask[DRM_PANTHOR_PERF_BLOCK_TILER]); + glb_iface->input->perfcnt_fw_enable =3D + compress_enable_mask(em->mask[DRM_PANTHOR_PERF_BLOCK_FW]); + glb_iface->input->perfcnt_csg_enable =3D + compress_enable_mask(em->mask[DRM_PANTHOR_PERF_BLOCK_CSG]); + + perfcnt_config =3D GLB_PRFCNT_CONFIG_SIZE(PANTHOR_PERF_FW_RINGBUF_SLOTS); + perfcnt_config |=3D GLB_PRFCNT_CONFIG_SET(sampler->set_config); + glb_iface->input->perfcnt_config =3D perfcnt_config; + + /** + * The spec mandates that the host zero the PRFCNT_EXTRACT register befor= e an enable + * operation, and each (re-)enable will require an enable-disable pair to= program + * the new changes onto the FW interface. + */ + WRITE_ONCE(glb_iface->input->perfcnt_extract, 0); +} + +static void session_populate_sample_header(struct panthor_perf_session *se= ssion, + struct drm_panthor_perf_sample_header *hdr) +{ + hdr->block_set =3D 0; + hdr->user_data =3D session->user_data; + hdr->timestamp_start_ns =3D session->sample_start_ns; + /** + * TODO This should be changed to use the GPU clocks and the TIMESTAMP re= gister, + * when support is added. + */ + hdr->timestamp_end_ns =3D ktime_get_raw_ns(); +} + +/** + * session_patch_sample - Update the PRFCNT_EN header counter and the coun= ters exposed to the + * userspace client to only contain requested count= ers. + * + * @ptdev: Panthor device + * @session: Perf session + * @sample: Starting offset of the sample in the userspace mapping. + * + * The hardware supports counter selection at the granularity of 1 bit per= 4 counters, and there + * is a single global FW frontend to program the counter requests from mul= tiple sessions. This may + * lead to a large disparity between the requested and provided counters f= or an individual client. + * To remove this cross-talk, we patch out the counters that have not been= requested by this + * session and update the PRFCNT_EN, the header counter containing a bitma= sk of enabled counters, + * accordingly. + */ +static void session_patch_sample(struct panthor_device *ptdev, + struct panthor_perf_session *session, u8 *sample) +{ + const struct drm_panthor_perf_info *const perf_info =3D &ptdev->perf_info; + + const size_t block_size =3D get_annotated_block_size(perf_info->counters_= per_block); + const size_t sample_size =3D session_get_max_sample_size(perf_info); + + for (size_t i =3D 0; i < sample_size; i +=3D block_size) { + size_t ctr_idx; + DECLARE_BITMAP(em_diff, PANTHOR_PERF_EM_BITS); + struct panthor_perf_counter_block *blk =3D (typeof(blk))(sample + block_= size); + enum drm_panthor_perf_block_type type =3D blk->header.block_type; + unsigned long *blk_em =3D session->enabled_counters->mask[type]; + + bitmap_from_arr64(em_diff, blk->header.enable_mask, PANTHOR_PERF_EM_BITS= ); + + bitmap_andnot(em_diff, em_diff, blk_em, PANTHOR_PERF_EM_BITS); + + for_each_set_bit(ctr_idx, em_diff, PANTHOR_PERF_EM_BITS) + blk->counters[ctr_idx] =3D 0; + + bitmap_to_arr64(blk->header.enable_mask, blk_em, PANTHOR_PERF_EM_BITS); + } +} + +static int session_copy_sample(struct panthor_device *ptdev, + struct panthor_perf_session *session) +{ + struct panthor_perf *perf =3D ptdev->perf; + const size_t sample_size =3D session_get_max_sample_size(&ptdev->perf_inf= o); + const u32 insert_idx =3D session_read_insert_idx(session); + const u32 extract_idx =3D session_read_extract_idx(session); + u8 *new_sample; + + if (!CIRC_SPACE_TO_END(insert_idx, extract_idx, session->ringbuf_slots)) + return -ENOSPC; + + new_sample =3D session->samples + extract_idx * sample_size; + + memcpy(new_sample, perf->sampler.sample, sample_size); + + session_populate_sample_header(session, + (struct drm_panthor_perf_sample_header *)new_sample); + + session_patch_sample(ptdev, session, new_sample + + sizeof(struct drm_panthor_perf_sample_header)); + + session_write_insert_idx(session, (insert_idx + 1) % session->ringbuf_slo= ts); + + /* Since we are about to notify userspace, we must ensure that all change= s to memory + * are visible. + */ + wmb(); + + eventfd_signal(session->eventfd); + + return 0; +} + +#define PERFCNT_IRQS (GLB_PERFCNT_OVERFLOW | GLB_PERFCNT_SAMPLE | GLB_PERF= CNT_THRESHOLD) + +void panthor_perf_report_irq(struct panthor_device *ptdev, u32 status) +{ + struct panthor_perf *const perf =3D ptdev->perf; + struct panthor_perf_sampler *sampler; + struct panthor_fw_global_iface *glb_iface =3D panthor_fw_get_glb_iface(pt= dev); + + if (!(status & JOB_INT_GLOBAL_IF)) + return; + + if (!perf) + return; + + sampler =3D &perf->sampler; + + /* TODO This needs locking. */ + const u32 ack =3D READ_ONCE(glb_iface->output->ack); + const u32 fw_events =3D sampler->last_ack ^ ack; + + sampler->last_ack =3D ack; + + if (!(fw_events & PERFCNT_IRQS)) + return; + + /* TODO Fix up the error handling for overflow. */ + if (fw_events & GLB_PERFCNT_OVERFLOW) + return; + + if (fw_events & (GLB_PERFCNT_SAMPLE | GLB_PERFCNT_THRESHOLD)) { + const u32 extract_idx =3D READ_ONCE(glb_iface->input->perfcnt_extract); + const u32 insert_idx =3D READ_ONCE(glb_iface->output->perfcnt_insert); + + WRITE_ONCE(glb_iface->input->perfcnt_extract, + panthor_perf_handle_sample(ptdev, extract_idx, insert_idx)); + } + + scoped_guard(mutex, &sampler->sampler_lock) + { + struct list_head *pos, *temp; + + list_for_each_safe(pos, temp, &sampler->sampler_list) { + struct panthor_perf_session *session =3D list_entry(pos, + struct panthor_perf_session, waiting); + + session_copy_sample(ptdev, session); + list_del_init(pos); + + session_put(session); + } + } + + memset(sampler->sample, 0, session_get_max_sample_size(&ptdev->perf_info)= ); + sampler->sample_requested =3D false; + complete(&sampler->sample_handled); +} + + +static int panthor_perf_sampler_init(struct panthor_perf_sampler *sampler, + struct panthor_device *ptdev) +{ + struct panthor_fw_global_iface *glb_iface =3D panthor_fw_get_glb_iface(pt= dev); + struct panthor_kernel_bo *bo; + u8 *sample; + int ret; + + ret =3D panthor_perf_setup_fw_buffer_desc(ptdev, sampler); + if (ret) { + drm_err(&ptdev->base, + "Failed to setup descriptor for FW ring buffer, err =3D %d", ret); + return ret; + } + + bo =3D panthor_kernel_bo_create(ptdev, panthor_fw_vm(ptdev), + sampler->desc.buffer_size * PANTHOR_PERF_FW_RINGBUF_SLOTS, + DRM_PANTHOR_BO_NO_MMAP, + DRM_PANTHOR_VM_BIND_OP_MAP_NOEXEC | DRM_PANTHOR_VM_BIND_OP_MAP_UNCACHED, + PANTHOR_VM_KERNEL_AUTO_VA); + + if (IS_ERR_OR_NULL(bo)) + return IS_ERR(bo) ? PTR_ERR(bo) : -ENOMEM; + + ret =3D panthor_kernel_bo_vmap(bo); + if (ret) + goto cleanup_bo; + + sample =3D devm_kzalloc(ptdev->base.dev, + session_get_max_sample_size(&ptdev->perf_info), GFP_KERNEL); + if (ZERO_OR_NULL_PTR(sample)) { + ret =3D -ENOMEM; + goto cleanup_vmap; + } + + glb_iface->input->perfcnt_as =3D panthor_vm_as(panthor_fw_vm(ptdev)); + glb_iface->input->perfcnt_base =3D panthor_kernel_bo_gpuva(bo); + glb_iface->input->perfcnt_extract =3D 0; + glb_iface->input->perfcnt_csg_select =3D GENMASK(glb_iface->control->grou= p_num, 0); + + sampler->rb =3D bo; + sampler->sample =3D sample; + sampler->sample_slots =3D PANTHOR_PERF_FW_RINGBUF_SLOTS; + + sampler->em =3D panthor_perf_em_new(); + + mutex_init(&sampler->sampler_lock); + mutex_init(&sampler->config_lock); + INIT_LIST_HEAD(&sampler->sampler_list); + INIT_LIST_HEAD(&sampler->ems); + init_completion(&sampler->sample_handled); + + sampler->ptdev =3D ptdev; + + return 0; + +cleanup_vmap: + panthor_kernel_bo_vunmap(bo); + +cleanup_bo: + panthor_kernel_bo_destroy(bo); + + return ret; +} + +static void panthor_perf_sampler_term(struct panthor_perf_sampler *sampler) +{ + int ret; + + if (sampler->sample_requested) + wait_for_completion_killable(&sampler->sample_handled); + + panthor_perf_fw_write_em(sampler, &(struct panthor_perf_enable_masks) {}); + + ret =3D panthor_perf_fw_stop_sampling(sampler->ptdev); + if (ret) + drm_warn_once(&sampler->ptdev->base, "Sampler termination failed, ret = =3D %d", ret); + + devm_kfree(sampler->ptdev->base.dev, sampler->sample); + + panthor_kernel_bo_destroy(sampler->rb); +} + +static int panthor_perf_sampler_add(struct panthor_perf_sampler *sampler, + struct panthor_perf_enable_masks *const new_em, + u8 set) +{ + int ret =3D 0; + + guard(mutex)(&sampler->config_lock); + + /* Early check for whether a new set can be configured. */ + if (!atomic_read(&sampler->enabled_clients)) + sampler->set_config =3D set; + else + if (sampler->set_config !=3D set) + return -EBUSY; + + kref_get(&new_em->refs); + list_add_tail(&sampler->ems, &new_em->link); + + panthor_perf_em_add(sampler->em, new_em); + pm_runtime_get_sync(sampler->ptdev->base.dev); + + if (atomic_read(&sampler->enabled_clients)) { + ret =3D panthor_perf_fw_stop_sampling(sampler->ptdev); + if (ret) + return ret; + } + + panthor_perf_fw_write_em(sampler, sampler->em); + + ret =3D panthor_perf_fw_start_sampling(sampler->ptdev); + if (ret) + return ret; + + atomic_inc(&sampler->enabled_clients); + + return 0; +} + +static int panthor_perf_sampler_remove(struct panthor_perf_sampler *sample= r, + struct panthor_perf_enable_masks *session_em) +{ + int ret; + struct list_head *em_node; + + guard(mutex)(&sampler->config_lock); + + list_del_init(&session_em->link); + kref_put(&session_em->refs, panthor_perf_destroy_em_kref); + + panthor_perf_em_zero(sampler->em); + list_for_each(em_node, &sampler->ems) + { + struct panthor_perf_enable_masks *curr_em =3D + container_of(em_node, typeof(*curr_em), link); + + panthor_perf_em_add(sampler->em, curr_em); + } + + ret =3D panthor_perf_fw_stop_sampling(sampler->ptdev); + if (ret) + return ret; + + atomic_dec(&sampler->enabled_clients); + pm_runtime_put_sync(sampler->ptdev->base.dev); + + panthor_perf_fw_write_em(sampler, sampler->em); + + if (atomic_read(&sampler->enabled_clients)) + return panthor_perf_fw_start_sampling(sampler->ptdev); + return 0; +} + /** * panthor_perf_init - Initialize the performance counter subsystem. * @ptdev: Panthor device @@ -370,6 +1140,7 @@ static size_t session_get_max_sample_size(const struct= drm_panthor_perf_info *co int panthor_perf_init(struct panthor_device *ptdev) { struct panthor_perf *perf; + int ret; =20 if (!ptdev) return -EINVAL; @@ -386,12 +1157,93 @@ int panthor_perf_init(struct panthor_device *ptdev) .max =3D 1, }; =20 + ret =3D panthor_perf_sampler_init(&perf->sampler, ptdev); + if (ret) + goto cleanup_perf; + drm_info(&ptdev->base, "Performance counter subsystem initialized"); =20 ptdev->perf =3D perf; =20 - return 0; + return ret; + +cleanup_perf: + devm_kfree(ptdev->base.dev, perf); + + return ret; +} + + +static void panthor_perf_fw_request_sample(struct panthor_perf_sampler *sa= mpler) +{ + struct panthor_fw_global_iface *glb_iface =3D panthor_fw_get_glb_iface(sa= mpler->ptdev); + + panthor_fw_toggle_reqs(glb_iface, req, ack, GLB_PERFCNT_SAMPLE); + gpu_write(sampler->ptdev, CSF_DOORBELL(CSF_GLB_DOORBELL_ID), 1); +} + +/** + * panthor_perf_sampler_request_clearing - Request a clearing sample. + * @sampler: Panthor sampler + * + * Perform a synchronous sample that gets immediately discarded. This sets= a baseline at the point + * of time a new session is started, to avoid having counters from before = the session. + * + */ +static int panthor_perf_sampler_request_clearing(struct panthor_perf_sampl= er *sampler) +{ + scoped_guard(mutex, &sampler->sampler_lock) { + if (!sampler->sample_requested) { + panthor_perf_fw_request_sample(sampler); + sampler->sample_requested =3D true; + } + } + + return wait_for_completion_timeout(&sampler->sample_handled, + msecs_to_jiffies(1000)); +} + +/** + * panthor_perf_sampler_request_sample - Request a counter sample for the = userspace client. + * @sampler: Panthor sampler + * @session: Target session + * + * A session that has already requested a sample cannot request another on= e until the previous + * sample has been delivered. + * + * Return: + * * %0 - The sample has been requested successfully. + * * %-EBUSY - The target session has already requested a sample and has = not received it yet. + */ +static int panthor_perf_sampler_request_sample(struct panthor_perf_sampler= *sampler, + struct panthor_perf_session *session) +{ + struct list_head *head; + + reinit_completion(&sampler->sample_handled); + + guard(mutex)(&sampler->sampler_lock); + + /* + * If a previous sample has not been handled yet, the session cannot requ= est another + * sample. If this happens too often, the requested sample rate is too hi= gh. + */ + list_for_each(head, &sampler->sampler_list) { + struct panthor_perf_session *cur_session =3D list_entry(head, + typeof(*cur_session), waiting); + + if (session =3D=3D cur_session) + return -EBUSY; + } + + if (list_empty(&sampler->sampler_list) && !sampler->sample_requested) + panthor_perf_fw_request_sample(sampler); =20 + sampler->sample_requested =3D true; + list_add_tail(&session->waiting, &sampler->sampler_list); + session_get(session); + + return 0; } =20 static int session_validate_set(u8 set) @@ -483,7 +1335,12 @@ int panthor_perf_session_setup(struct panthor_device = *ptdev, struct panthor_perf goto cleanup_eventfd; } =20 + ret =3D panthor_perf_sampler_add(&perf->sampler, em, setup_args->block_se= t); + if (ret) + goto cleanup_em; + INIT_LIST_HEAD(&session->waiting); + session->extract_idx =3D ctrl_map.vaddr; *session->extract_idx =3D 0; session->insert_idx =3D session->extract_idx + 1; @@ -507,12 +1364,15 @@ int panthor_perf_session_setup(struct panthor_device= *ptdev, struct panthor_perf ret =3D xa_alloc_cyclic(&perf->sessions, &session_id, session, perf->sess= ion_range, &perf->next_session, GFP_KERNEL); if (ret < 0) - goto cleanup_em; + goto cleanup_sampler_add; =20 kref_init(&session->ref); =20 return session_id; =20 +cleanup_sampler_add: + panthor_perf_sampler_remove(&perf->sampler, em); + cleanup_em: kref_put(&em->refs, panthor_perf_destroy_em_kref); =20 @@ -540,6 +1400,8 @@ int panthor_perf_session_setup(struct panthor_device *= ptdev, struct panthor_perf static int session_stop(struct panthor_perf *perf, struct panthor_perf_ses= sion *session, u64 user_data) { + int ret; + if (!test_bit(PANTHOR_PERF_SESSION_ACTIVE, session->state)) return 0; =20 @@ -552,6 +1414,10 @@ static int session_stop(struct panthor_perf *perf, st= ruct panthor_perf_session * =20 session->user_data =3D user_data; =20 + ret =3D panthor_perf_sampler_request_sample(&perf->sampler, session); + if (ret) + return ret; + clear_bit(PANTHOR_PERF_SESSION_ACTIVE, session->state); =20 /* TODO Calls to the FW interface will go here in later patches. */ @@ -573,8 +1439,7 @@ static int session_start(struct panthor_perf *perf, st= ruct panthor_perf_session if (session->sample_freq_ns) session->user_data =3D user_data; =20 - /* TODO Calls to the FW interface will go here in later patches. */ - return 0; + return panthor_perf_sampler_request_clearing(&perf->sampler); } =20 static int session_sample(struct panthor_perf *perf, struct panthor_perf_s= ession *session, @@ -601,15 +1466,16 @@ static int session_sample(struct panthor_perf *perf,= struct panthor_perf_session session->sample_start_ns =3D ktime_get_raw_ns(); session->user_data =3D user_data; =20 - /* TODO Calls to the FW interface will go here in later patches. */ - return 0; + return panthor_perf_sampler_request_sample(&perf->sampler, session); } =20 static int session_destroy(struct panthor_perf *perf, struct panthor_perf_= session *session) { + int ret =3D panthor_perf_sampler_remove(&perf->sampler, session->enabled_= counters); + session_put(session); =20 - return 0; + return ret; } =20 static int session_teardown(struct panthor_perf *perf, struct panthor_perf= _session *session) @@ -813,6 +1679,8 @@ void panthor_perf_unplug(struct panthor_device *ptdev) =20 xa_destroy(&perf->sessions); =20 + panthor_perf_sampler_term(&perf->sampler); + devm_kfree(ptdev->base.dev, ptdev->perf); =20 ptdev->perf =3D NULL; diff --git a/drivers/gpu/drm/panthor/panthor_perf.h b/drivers/gpu/drm/panth= or/panthor_perf.h index bfef8874068b..3485e4a55e15 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.h +++ b/drivers/gpu/drm/panthor/panthor_perf.h @@ -31,4 +31,6 @@ int panthor_perf_session_sample(struct panthor_file *pfil= e, struct panthor_perf u32 sid, u64 user_data); void panthor_perf_session_destroy(struct panthor_file *pfile, struct panth= or_perf *perf); =20 +void panthor_perf_report_irq(struct panthor_device *ptdev, u32 status); + #endif /* __PANTHOR_PERF_H__ */ diff --git a/include/uapi/drm/panthor_drm.h b/include/uapi/drm/panthor_drm.h index 576d3ad46e6d..a29b755d6556 100644 --- a/include/uapi/drm/panthor_drm.h +++ b/include/uapi/drm/panthor_drm.h @@ -441,8 +441,11 @@ enum drm_panthor_perf_feat_flags { * enum drm_panthor_perf_block_type - Performance counter supported block = types. */ enum drm_panthor_perf_block_type { + /** DRM_PANTHOR_PERF_BLOCK_METADATA: Internal use only. */ + DRM_PANTHOR_PERF_BLOCK_METADATA =3D 0, + /** @DRM_PANTHOR_PERF_BLOCK_FW: The FW counter block. */ - DRM_PANTHOR_PERF_BLOCK_FW =3D 1, + DRM_PANTHOR_PERF_BLOCK_FW, =20 /** @DRM_PANTHOR_PERF_BLOCK_CSG: A CSG counter block. */ DRM_PANTHOR_PERF_BLOCK_CSG, --=20 2.25.1 From nobody Sun Dec 14 13:49:49 2025 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2058.outbound.protection.outlook.com [40.107.22.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEE321DE8BA for ; Wed, 11 Dec 2024 16:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.58 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935885; cv=fail; b=t1JCEXUq4IR0xPdWyGDMEDlf9DvVxd7jOTHIuuOjygvB+UmT1EhZQ0pDq15Yhdgn/ycd+AyZ2vd0XbWLKQFVKUjAS9mZkcAu44Ruli6y+iU4qWJWIyHi1SyQ9yDDT0X9QweIxpdudNz/7VvmP91Bcy23mIThjhMbYosxjdQaHmE= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935885; c=relaxed/simple; bh=etIDknxbtc1S0vQu+Jn/sK87Lkmm7aDS0DY3eZEGYn4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=COqAE9KICpVPo5bzOUviNt+h1qo2I/TBLDOdesGdJ0HY3IR9YI3NWaQ4ySIY3ys/iJUmGudJM21orCbL8JSjHsNRSA7wiWC7fYmHe3EBIxF2oy5TDsoeY4CoOGDifWdipPHQ/jNruKAtl9UCbz4FbeDIwokxhi6syhoTHFJJczs= ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=f/lRgIB3; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=f/lRgIB3; arc=fail smtp.client-ip=40.107.22.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="f/lRgIB3"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="f/lRgIB3" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=Z4MML9G8sEh/97nAOSF69MHnJ8p58fBo/LFTndrFXBljvnIv8SL0g442z31K8mBMa+E7EtLjtUpYQzgaI7rO4ADEU0pm3mhpg5or1DMnNCINNPtCNZZKR/obQJlaEw1Abura4/gCrIs6gvcSb5LPVmpE6u7VFbtUS9hYB6Nc9KVCITk6xW/GTbgPvAtUyrAmjknQUF6pD4KhowAo+wFpJh1UTqGNmvii2nm+2UWch4LK8dA9YrM7GY/KnOq78eJRkgUC8cF3u7u1d0RNSaDoWAfYhfHgCVnWUQcn2RS++9p6fcp2Qsssz66+SUPh+3zDD1Hi3x2aS6kx4gdIgvkCMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=bKg/67rYZmh6NYjhU9gjQ53VEeK6A3Xe2GXQM/vg0RA=; b=mI17xF+CrgDTW3nH2n4GEFeU6GSqZj6cPFWxjiH1uOzShBOok01pNZRR922HlOmk9qlon2jFNsBujBOFKEunXMpSlYkJRKVUYRfg1uxsni/dxfLl3TIKtaS/TkQRGQkBIK+HEuCGXMi8thc6aOw8ndcle5wBLwK9fdNWgDD+z5V2ZqHm4WoGY7jN3ZHWNQYLp/OpairMrxBCopwQtZ84FAzAl03dN3a7PyWtcPACphVjmpQsBsmoXv/SYzeo2bgJ/x5w+fPdEjdCXDM81rtjgHoI92wp3uc8VfVDGbirglmnR2IqYKRo36YMVsFZ3Ro2jlM2igDujM6v+JpEywa2hQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bKg/67rYZmh6NYjhU9gjQ53VEeK6A3Xe2GXQM/vg0RA=; b=f/lRgIB3WwsDA92oUJsLaYiFWDCc3Lmk4rMMtmnJwRl08lIZme1i1/i5O8UgbOF/gSQQDvpkcIfQJZyJTkE6MnyApG206yASckrBpfgPiJfnzeglB6oeci5zUCxMDQaodsMOi5S4ahdO7nWlYc1d0TAXV0KahF9SnUwhyRvGRL0= Received: from AS9PR0301CA0019.eurprd03.prod.outlook.com (2603:10a6:20b:468::29) by GV2PR08MB8677.eurprd08.prod.outlook.com (2603:10a6:150:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Wed, 11 Dec 2024 16:51:15 +0000 Received: from AMS1EPF0000004B.eurprd04.prod.outlook.com (2603:10a6:20b:468:cafe::d6) by AS9PR0301CA0019.outlook.office365.com (2603:10a6:20b:468::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AMS1EPF0000004B.mail.protection.outlook.com (10.167.16.136) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:14 +0000 Received: ("Tessian outbound 2d228e31de9a:v524"); Wed, 11 Dec 2024 16:51:14 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e164a7827162b85c X-TessianGatewayMetadata: wxMRNHlx9L39bHspbKxLxr3AW2TQwIOmcja+JkZbt6ndO7KrG6k7fbFn9JAVIFINwvb34QoJWgMk0+f77oTF0BCt/g562l/FRzjcvr95SyoAxnFTloAhkO29/FYta8QOeKVapRv/IPWKjaj6s25sXFY2/PQenyogqGHc+MkZSXw= X-CR-MTA-TID: 64aa7808 Received: from Lf4c2a157c311.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 213540C7-8374-4E74-9716-3B02186A3045.1; Wed, 11 Dec 2024 16:51:08 +0000 Received: from EUR02-AM0-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Lf4c2a157c311.2 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 11 Dec 2024 16:51:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yF9QsjirKIV4mkm8N0xCPNHQzMBC4X35fdg1bEpzQARAW++4jBiXwkMCdIX0aYHOGmiFLGY6bNwVY4LJ+DBfqfyStLLt1MF9/i58wsfP/aZgaTya7saUDkoVB14DsYgR+dWyTG0Pw973H2waq76bceTa7ztw7JsnPz9nvq4F3f8lzYAEIrIbublMlMCTl4aEI2Pw3Y6oo82F9YDQqEU+ViHTbTi2SYiiFkaDAQw5M2frAmtxXYrPZajaqXxgMKs8nAX+mQ/w8OvM2msuixIcNazB7uCOyTDWhWm17wTTz+FJtS8P8I4/Kg3x4cTknnLds7SdOOn6IrkJ2begyhyKcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=bKg/67rYZmh6NYjhU9gjQ53VEeK6A3Xe2GXQM/vg0RA=; b=rrY0Ptvf4H2LzMAIEExGZjXFrBbTk3RFGID0Bha3+olL+MOBnhNStUIvP21r5rhMiU7aH6Aj1n9vQ296B+hMso8thTV2GpA+3tAByp7wbWFv36/GSRKajOjJGBrFyNH6oGEXfrDa5D36pTMoXFPVf85wBRSA8Culfy6B9SDzCvO4KEQo1WPdbKg7dLGc+ojMjgYVxIz+fhDoZp99ce9mLVr8UqsN0UYuA68ooIni3tyMoMVUCdgqmPigGbWfAUlnispVtriQZrSz/uWFK7uTsZ9UfPN2JRlSx/IM0FBV6jwX7o8HS9Fd3ytmD0IyLvLn62KBiy77yNTj1nNfXESCug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bKg/67rYZmh6NYjhU9gjQ53VEeK6A3Xe2GXQM/vg0RA=; b=f/lRgIB3WwsDA92oUJsLaYiFWDCc3Lmk4rMMtmnJwRl08lIZme1i1/i5O8UgbOF/gSQQDvpkcIfQJZyJTkE6MnyApG206yASckrBpfgPiJfnzeglB6oeci5zUCxMDQaodsMOi5S4ahdO7nWlYc1d0TAXV0KahF9SnUwhyRvGRL0= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) by DU0PR08MB8493.eurprd08.prod.outlook.com (2603:10a6:10:406::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.19; Wed, 11 Dec 2024 16:51:04 +0000 Received: from AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897]) by AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897%7]) with mapi id 15.20.8230.016; Wed, 11 Dec 2024 16:51:04 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Mihail Atanassov , nd@arm.com, Lukas Zapolskas Subject: [RFC v2 7/8] drm/panthor: Add suspend/resume handling for the performance counters Date: Wed, 11 Dec 2024 16:50:23 +0000 Message-Id: <20241211165024.490748-8-lukas.zapolskas@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241211165024.490748-1-lukas.zapolskas@arm.com> References: <20241211165024.490748-1-lukas.zapolskas@arm.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P265CA0218.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:33a::19) To AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM6PR08MB3317:EE_|DU0PR08MB8493:EE_|AMS1EPF0000004B:EE_|GV2PR08MB8677:EE_ X-MS-Office365-Filtering-Correlation-Id: 05174565-27f9-4219-1b05-08dd1a04068b X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: =?us-ascii?Q?Q4MaBE183tweZDq/aeTaI4GBfoVDzQYgCcL6URYthgYr9aJdUtHpxI2NXw8/?= =?us-ascii?Q?ST7wYEQGv3GQ4y6izI7a1OxBzRLLctAJnApYuyMGQRtNmMtLpaq8JvGReL0Y?= =?us-ascii?Q?9EzbTLTDjNI78wvxFQ+E/dKTwZLLSUQ2yrhDSCVa3U6DgJ9Iw10rpGOkv8YP?= =?us-ascii?Q?1WKwowaYoazePZ3S2d/DfEcAZ+6IuX6MtF//je9USC2GhW5ScvdXsXww9NQv?= =?us-ascii?Q?RrzDJ/Rc/UbTrOro/Q5HMVGJ51ksMsoJ6NhnT6d8mdG+T636ap4N+J/ucuWf?= =?us-ascii?Q?ZVCVwdUxn3QyV0Xh7LnlZz5aqcFEycQLkwAQYmFwfSZPTiRZUC88dn4xRu8U?= =?us-ascii?Q?4eGaN2Rmy+G66WgaksB7v2K3VMd9BrcSwJJCvXBnARMJ4ymVqHc333HLJxEU?= =?us-ascii?Q?nlF0IVkPMCuBfo663b5RGCPFbaeqvDywN2b8EMMrNl0NMY6Af9e853v0D9GV?= =?us-ascii?Q?wl3486c+9vfxPZJm79SXn8KNv3S/71ZCOcZy0a0XIW0BC14mbBSmkpG7Nw0R?= =?us-ascii?Q?QJYUYqDctkwzdye1NIiXCXWMNwt54vhWxAwBOQshDehF69qUXy1It9rAoIjA?= =?us-ascii?Q?5VjLr83sFohuWPNnC//yUAcX66bkxyU9HjAPfN+3qJOE3Q9UYUtjxk3tIRvz?= =?us-ascii?Q?hPenQJz555Aqsv10P+Hn+1309GAu8VEuFUI5+SkSaT3hy8P9OMgp06N2StFG?= =?us-ascii?Q?h81q+IoEuV+E/ITzCntayMKBmOh4dg4VZLTGTqgcXJnRLACoesVfwWuWscu1?= =?us-ascii?Q?9CcsFdqaGbKILvnoDIDYk2oW4RjX5DoOJcH58IjRVkPh4+gj8qvZEH+6ibdh?= =?us-ascii?Q?Lmi7juAt1IG1nHZyQeMgfwNCmzEo6NbKnsBCth107EmUu/CZ4wXweT89y1Og?= =?us-ascii?Q?blooTyT2sk7VePS9aXjsbY8owj1dxnntcV0d84Q65lQnU0Xf3hzUwT5g52xC?= =?us-ascii?Q?88L3l0WQ2sY/6vuspOArhHsIqERKJznmYVKLLFRH7D7F3ZM9qRoqR8JSbUfv?= =?us-ascii?Q?iy4+eD7iApGtk/Lp/OLUAZQ3S78wGniitHx2YQVr4J5C66wRXwXiYEmKP5Dh?= =?us-ascii?Q?ujIRQc23ln5ddgP50BiGGIzoQ5e0gHDFmBK0oDb1qFp8+EwkMJ0wWCA9WmTw?= =?us-ascii?Q?6pMM6lpgoCCyaSoWU4g9wRp/hMJY8OxiyH32eH07y/SaL4aw091JWxg2JAvT?= =?us-ascii?Q?iN67f6kUMYDakQW+pRldQgRCOufThLnYunI1WtTLtKB/911x1pb7iJ5BHnQ3?= =?us-ascii?Q?Bsrl1Lc4YqhverYR0fdJxPcAsWGWk9xJ7J/EpUXTnSnuEidswqmpTevk3gnj?= =?us-ascii?Q?uNM3iqv/o2AvZN/9M3qTHp8asy4+w+XUp8cVPoNn6glwjQ=3D=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR08MB3317.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8493 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:209:42::28];domain=AM6PR08MB3317.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS1EPF0000004B.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 9f9ca443-e79e-4f73-1fd8-08dd1a040060 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|14060799003|35042699022|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?bMmBkJAgvXj9B3wCEc0BTmCXJVKRfsNIaS8aPAcNZ5ewnsrjnQYBK92Y8of6?= =?us-ascii?Q?t0mMoo55iLRZRzZ0qTtHH7EKd7x/NvI12WBpcCxydRDrGIiyk5xRZtST53Ng?= =?us-ascii?Q?oQ8Yi39lt1kfXeyUxvwyT7reQFMPNzu8lPZqJnp55tMPJwx8Xu5wu+4VpVUZ?= =?us-ascii?Q?WF7jYsQxtaPuY6yvrtpfQ19PYHSZJ6dLu6QGuT5JOQtSR948tZCsOQuQcUEu?= =?us-ascii?Q?SBxlwkpc6Ju28NwrRISivDF5S/JOGCgZ/fh5zEQV4+7QIiJEZet/vVr2fCCJ?= =?us-ascii?Q?UpIvDFVKfM0VgaMj5fMEOXBLd1gnA583F/nw9cGdvgDnciGIMvFMT9kLB+hL?= =?us-ascii?Q?3pgHA8Hh/h5vULzEeqCTlNqhLJu11ks830MYFpaiV1IQbp3CgZyICHMCnsKo?= =?us-ascii?Q?TAPSFfQR1nuDL3AXpPkhxeRgJsgUYBrCWSuOZ34ePWbbuY+xW0Th+BG1tR0A?= =?us-ascii?Q?BbnGm4Gf/RAJ1q+1EdKPNQePehZn/Y9+ElaCw50HhnM8HxiuzVx6YmMERz2H?= =?us-ascii?Q?kz3R2Vbct5hP5L8PK/WUpvVWqB4MydL3N7t97BVcHwhGouWe7+kZJkOxFdHk?= =?us-ascii?Q?7/DofKxlmzvBZhgZSIYmG+AP2SlTcXdgXG1EXlI+WqG6vyCgoYoU74yjeN4g?= =?us-ascii?Q?2MKgq7fYDnj2ldKVLsMZeJ54HuVu6xo85LXqqAM2/IyVxqnJw+HLcdUcjKU6?= =?us-ascii?Q?MsKem9bucjmz2VEQX8FeEDBn6wJ31QG9qWJdbsonvjjRGYpYzkN0K8Be1tgH?= =?us-ascii?Q?yGyNjlR4ZJtojGk4hPPFZjiM7efYctHLTYsoSAOUyV4mdGkb+Q6cNpjW6NK/?= =?us-ascii?Q?bDEkNNHPpZ5zAJnatSG1wTAB0HrQ3KEQd3O+XfJ0bSHnRmDsU027KR0s6/UF?= =?us-ascii?Q?tZxHBPZyy06Sr8oaVify/ZzDzk6ZiLtCq2agGGEojCJXU1i/3OzfjrrNo0mf?= =?us-ascii?Q?BpqDQkTr3iLqGIJKz5MYSvfq+H+fXIFBw929GDKb2REPoWh6Z/I3NuvzhSeJ?= =?us-ascii?Q?QWdsiWua9hcFaFHOrULTbr/E/HEEkvF2BjtHSsH88v1UxlRvSfKucpeTRotU?= =?us-ascii?Q?KETvgkx+PXyMYiJrQDzKh3DXHJxoy8kMASdFWcaGd5/kA9ihf0VDFEUHjGEE?= =?us-ascii?Q?LzHjID7GRwM4WuR0rG+pWdsULXvzG6u1ZweW+kFNiKb5SiDNaZeRi+dAdate?= =?us-ascii?Q?um590uGh8xaiS2Er9ZOAx9PHIrgv1SCEzP880mbIdrllnGPIMgLFYjkgN+0F?= =?us-ascii?Q?qKQ7oX5M/FzgeZngkfbtT+jLq3Y5aj+9zOisNoZpDyiJEYDrVoppZwpo/tQt?= =?us-ascii?Q?9BRz+PEB9rmdyRfVYWZ3nDBzMZozsf8JajW8RQXgo4DBzLOre1hRh/SO4bnv?= =?us-ascii?Q?AoZKUZWX4WgWdeeVF9Vkl+DwxJZRZuXpQXoD0E0WdKkKcy5OCNWF05hsAKdZ?= =?us-ascii?Q?mRjll0TU39JcEYrDm8/eRT4NuHg3GSoEoYnE88ZnCpGtV7NO5T7WSg=3D=3D?= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:64aa7808-outbound-1.mta.getcheckrecipient.com;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(14060799003)(35042699022)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 16:51:14.7668 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 05174565-27f9-4219-1b05-08dd1a04068b X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AMS1EPF0000004B.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8677 Content-Type: text/plain; charset="utf-8" Signed-off-by: Lukas Zapolskas --- drivers/gpu/drm/panthor/panthor_device.c | 3 + drivers/gpu/drm/panthor/panthor_perf.c | 86 ++++++++++++++++++++++++ drivers/gpu/drm/panthor/panthor_perf.h | 2 + 3 files changed, 91 insertions(+) diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/pan= thor/panthor_device.c index 1a81a436143b..69536fbdb5ef 100644 --- a/drivers/gpu/drm/panthor/panthor_device.c +++ b/drivers/gpu/drm/panthor/panthor_device.c @@ -475,6 +475,7 @@ int panthor_device_resume(struct device *dev) ret =3D drm_WARN_ON(&ptdev->base, panthor_fw_resume(ptdev)); if (!ret) { panthor_sched_resume(ptdev); + panthor_perf_resume(ptdev); } else { panthor_mmu_suspend(ptdev); panthor_gpu_suspend(ptdev); @@ -543,6 +544,7 @@ int panthor_device_suspend(struct device *dev) drm_dev_enter(&ptdev->base, &cookie)) { cancel_work_sync(&ptdev->reset.work); =20 + panthor_perf_suspend(ptdev); /* We prepare everything as if we were resetting the GPU. * The end of the reset will happen in the resume path though. */ @@ -561,6 +563,7 @@ int panthor_device_suspend(struct device *dev) panthor_mmu_resume(ptdev); drm_WARN_ON(&ptdev->base, panthor_fw_resume(ptdev)); panthor_sched_resume(ptdev); + panthor_perf_resume(ptdev); drm_dev_exit(cookie); } =20 diff --git a/drivers/gpu/drm/panthor/panthor_perf.c b/drivers/gpu/drm/panth= or/panthor_perf.c index d62d97c448da..727e66074eab 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.c +++ b/drivers/gpu/drm/panthor/panthor_perf.c @@ -433,6 +433,17 @@ static void panthor_perf_em_zero(struct panthor_perf_e= nable_masks *em) bitmap_zero(em->mask[i], PANTHOR_PERF_EM_BITS); } =20 +static bool panthor_perf_em_empty(const struct panthor_perf_enable_masks *= const em) +{ + bool empty =3D true; + size_t i =3D 0; + + for (i =3D DRM_PANTHOR_PERF_BLOCK_FW; i <=3D DRM_PANTHOR_PERF_BLOCK_LAST;= i++) + empty &=3D bitmap_empty(em->mask[i], PANTHOR_PERF_EM_BITS); + + return empty; +} + static void panthor_perf_destroy_em_kref(struct kref *em_kref) { struct panthor_perf_enable_masks *em =3D container_of(em_kref, typeof(*em= ), refs); @@ -1652,6 +1663,81 @@ void panthor_perf_session_destroy(struct panthor_fil= e *pfile, struct panthor_per } } =20 +static int panthor_perf_sampler_resume(struct panthor_perf_sampler *sample= r) +{ + int ret; + + if (!atomic_read(&sampler->enabled_clients)) + return 0; + + if (!panthor_perf_em_empty(sampler->em)) { + guard(mutex)(&sampler->config_lock); + panthor_perf_fw_write_em(sampler, sampler->em); + } + + ret =3D panthor_perf_fw_start_sampling(sampler->ptdev); + if (ret) + return ret; + + return 0; +} + +static int panthor_perf_sampler_suspend(struct panthor_perf_sampler *sampl= er) +{ + int ret; + + if (!atomic_read(&sampler->enabled_clients)) + return 0; + + ret =3D panthor_perf_fw_stop_sampling(sampler->ptdev); + if (ret) + return ret; + + return 0; +} + +/** + * panthor_perf_suspend - Prepare the performance counter subsystem for sy= stem suspend. + * @ptdev: Panthor device. + * + * Indicate to the performance counters that the system is suspending. + * + * This function must not be used to handle MCU power state transitions: j= ust before MCU goes + * from on to any inactive state, an automatic sample will be performed by= the firmware, and + * the performance counter firmware state will be restored on warm boot. + * + * Return: 0 on success, negative error code on failure. + */ +int panthor_perf_suspend(struct panthor_device *ptdev) +{ + struct panthor_perf *perf =3D ptdev->perf; + + if (!perf) + return 0; + + return panthor_perf_sampler_suspend(&perf->sampler); +} + +/** + * panthor_perf_resume - Resume the performance counter subsystem after sy= stem resumption. + * @ptdev: Panthor device. + * + * Indicate to the performance counters that the system has resumed. This = must not be used + * to handle MCU state transitions, for the same reasons as detailed in th= e kerneldoc for + * @panthor_perf_suspend. + * + * Return: 0 on success, negative error code on failure. + */ +int panthor_perf_resume(struct panthor_device *ptdev) +{ + struct panthor_perf *perf =3D ptdev->perf; + + if (!perf) + return 0; + + return panthor_perf_sampler_resume(&perf->sampler); +} + /** * panthor_perf_unplug - Terminate the performance counter subsystem. * @ptdev: Panthor device. diff --git a/drivers/gpu/drm/panthor/panthor_perf.h b/drivers/gpu/drm/panth= or/panthor_perf.h index 3485e4a55e15..a22a511a0809 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.h +++ b/drivers/gpu/drm/panthor/panthor_perf.h @@ -16,6 +16,8 @@ struct panthor_perf; void panthor_perf_info_init(struct panthor_device *ptdev); =20 int panthor_perf_init(struct panthor_device *ptdev); +int panthor_perf_suspend(struct panthor_device *ptdev); +int panthor_perf_resume(struct panthor_device *ptdev); void panthor_perf_unplug(struct panthor_device *ptdev); =20 int panthor_perf_session_setup(struct panthor_device *ptdev, struct pantho= r_perf *perf, --=20 2.25.1 From nobody Sun Dec 14 13:49:49 2025 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011048.outbound.protection.outlook.com [52.101.70.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E89A91DE884 for ; Wed, 11 Dec 2024 16:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.48 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935885; cv=fail; b=Hyyj49e2l03O+dMR/ewiSflzihMxF/45hriidhU0wndYnOA+UzaxUIkgd2NeNjUNKF70KC6uPEm6eEP1yKAeysnB5sUn8aq3/ni7w30k2pZYYh9d0nD51qdU2Nn6eHs7BwE+oGckUmJar2rZ6tqyY20aW8HKLiFI9WrjD+0AT80= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733935885; c=relaxed/simple; bh=Zn4RCl/AIGzC7PJ9cB3X4Z1HxysGGmtlJ6WvvSrXrXM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Bgr+z5P8X9YziJebmMd6iJyabCjcZYt5VSIGe6YM8bi6wiJ4VFsUMzw3Zwl63NB5Hiz6nYEUfchBm7EPa0N4oZn8wbprR8Pd6gZAAet+2Pky52mS+jBdaanJNusvhjf4MxTjBN+fs93skCT8oNwjlq1fhoFjWbv/V6ib5dT27rw= ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=c544+nLq; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=c544+nLq; arc=fail smtp.client-ip=52.101.70.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="c544+nLq"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="c544+nLq" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=cI3PpuuNFt9cRZDBfpCbX1BZhaHdn4KU9Ydrx7CMaAFGBAf5JHuozOjpmCdafLKD1KjVGluvMx4miGeyREnu4HBW+LAPUkXGnXqc0hS8w89VV6KKgMWe84p784p1qa7V7slEyDk9PfnWKjUnfjo2/9lFDHSW5+THR+j8g/sM1LFfJeDJy26g3XzB0drfoG3YEcnq392eBd4Uv40hnrXwWf2nVYli+9HVi5hn+YNOWHAErxfhat6ONm57+MT2EJ5+lyBhwxDSVwR/ivHnncK2m/GwFWm/fFtP6yU9Hsms5hFQITtGQQUanps8g3injg6ODxiATCHxFCJye//JTa7RrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Ah54vksIAL1XBn9oTvm0ntr07MfGjKJQMzj3zX/uYF8=; b=epLDHZoABz3E+Hx9vB0NBKQ2Q8Qnt4lGE5LgUJBiFk77fDvsORO8jCsq0Fn2mrcJTVvfgVhjq3VC83taQtVvXcim2aAVibiABRNcSgP6mlamTvmGakXTO0rWcmiguQMHjMmHY/22YZi5N2igU7iX/JFiAIKaaTPlPaDjsJkIvz9Zvntftm1+s4eBkDEqhtKkQLwYQBwgoqC9AA0vvFIxYpyi6HyvJexkd4VZa7EYlRpcHlHkJH37V+TiczixVpjtBGlMmkjP99qPT1NSe+MhDxufHORkFIqJDSHm4P0wq0dG6Yn5PBZXeMMhi+MTCUXE0GZF9vaOFY1Dlws+kYEwiw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ah54vksIAL1XBn9oTvm0ntr07MfGjKJQMzj3zX/uYF8=; b=c544+nLqQdNQRuBgKSvafcV/FzYJa/mPg6CJAKhOrBTQLVYg4S7ELKX4aADWQ5QW1EnUti1gU34pf3dgyAImpFY73pvgPilAJXQWsdcDuzVPI9M5e2ue0d2PFgNmWjown+/wrT5SzfIAyM2qq4S0MFxRfqylOFTDguzZmIQRTHo= Received: from PA7P264CA0271.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:373::13) by AS8PR08MB5976.eurprd08.prod.outlook.com (2603:10a6:20b:299::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 16:51:16 +0000 Received: from AMS1EPF0000004A.eurprd04.prod.outlook.com (2603:10a6:102:373:cafe::57) by PA7P264CA0271.outlook.office365.com (2603:10a6:102:373::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AMS1EPF0000004A.mail.protection.outlook.com (10.167.16.134) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8251.15 via Frontend Transport; Wed, 11 Dec 2024 16:51:16 +0000 Received: ("Tessian outbound 20d64b55c711:v524"); Wed, 11 Dec 2024 16:51:15 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: acce7723b911880f X-TessianGatewayMetadata: gHELJN3cN6pU0hGP3jWmJfHP7jS32iiWXC7SQbWHErBrkbyhDQUaAxNG+ObV0k+E5VGSBtnD3dx+TRk/eJr0lbMbtoC21D2A9Aiyjyj9wQke1gDNHQi83KbNWkB+xWngwjgEmefBu5C7FkV5o7qkaph6CAygRawItYSvCjebde8= X-CR-MTA-TID: 64aa7808 Received: from Lf4c2a157c311.3 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 16F5E391-AB5C-4C79-90BB-E28DF4A0E328.1; Wed, 11 Dec 2024 16:51:08 +0000 Received: from EUR02-AM0-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Lf4c2a157c311.3 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 11 Dec 2024 16:51:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Va+LKlxVo3A8doHLFCSpQHiFfpReW/9y/m8p+f0mGiADR0C1menkgqjE2eIL2o2td9gBfmLu7zLb7D4GPmDXt+UqQuB6f4/CancC9NZCxOWh/MgZrRNf+DsB10LLXkyzE7ignBhGPVjvFePymHrzApwSgKGG6ToRbeggMKIpeoj2BFz4aAKr7v3VJT9YIFt1+JCYkKMte7JGl411Sd6f7uZDq/pIipR4MeypJvNesC3JiLGiubn6opm0bmasWCb94qIehk3VZ939wmxGXYOMRpbJG1tlrsa65YiIsMWrq4j4tdqkelDbd3fIwwVZ13LGB/AOBcu/K5GLtFw287XDsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Ah54vksIAL1XBn9oTvm0ntr07MfGjKJQMzj3zX/uYF8=; b=kv42CKYaH7yNRZBAepTwVMQqH4L3swOk1JEQwun6wNCNl4ZXy54K4F1GX7U9NoZ4KcaHbd2Njlbz2bTke7eysUmSc71/R+l/MAZZzY54/YjpXuN4MnNe38IrTqr5kpylq+QahGL3lJZ4idr3eGYTv1pQW4SyXI3zGyH+nVEQV88+wsMyc/UCorSG9Uh5vQghQ0huOL/ZkxJBkX6Ay7csqPsqX9dl1do03tlTFa0u0oqQsdSpAFNe8uKh5Z4LGZ6VZHcyP01qduleAbv3VjHugiGaq/pKOK9RuOXPSJlSRuEz1aLbNM+uCqPTigWCLtp7Kat2igTaxTvBwyS/6U54aA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ah54vksIAL1XBn9oTvm0ntr07MfGjKJQMzj3zX/uYF8=; b=c544+nLqQdNQRuBgKSvafcV/FzYJa/mPg6CJAKhOrBTQLVYg4S7ELKX4aADWQ5QW1EnUti1gU34pf3dgyAImpFY73pvgPilAJXQWsdcDuzVPI9M5e2ue0d2PFgNmWjown+/wrT5SzfIAyM2qq4S0MFxRfqylOFTDguzZmIQRTHo= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) by DU0PR08MB8493.eurprd08.prod.outlook.com (2603:10a6:10:406::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.19; Wed, 11 Dec 2024 16:51:06 +0000 Received: from AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897]) by AM6PR08MB3317.eurprd08.prod.outlook.com ([fe80::e42a:494c:6581:1897%7]) with mapi id 15.20.8230.016; Wed, 11 Dec 2024 16:51:06 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , =?UTF-8?q?Adri=C3=A1n=20Larumbe?= Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Mihail Atanassov , nd@arm.com, Lukas Zapolskas Subject: [RFC v2 8/8] drm/panthor: Expose the panthor perf ioctls Date: Wed, 11 Dec 2024 16:50:24 +0000 Message-Id: <20241211165024.490748-9-lukas.zapolskas@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241211165024.490748-1-lukas.zapolskas@arm.com> References: <20241211165024.490748-1-lukas.zapolskas@arm.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO2P265CA0102.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:c::18) To AM6PR08MB3317.eurprd08.prod.outlook.com (2603:10a6:209:42::28) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM6PR08MB3317:EE_|DU0PR08MB8493:EE_|AMS1EPF0000004A:EE_|AS8PR08MB5976:EE_ X-MS-Office365-Filtering-Correlation-Id: 19e16346-55e6-41f7-14cc-08dd1a040774 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: =?us-ascii?Q?2bMmBzCdjC4e/Gtqup0QtTlUnqdJve+Y5D0hUmlfJTITQYD8DIlgN93Ik70N?= =?us-ascii?Q?aFAfnq/er5Tw7NVem+FXS//AeZbQpoSKbcTyI9wJE8/bZmi25FL4pQML5f+f?= =?us-ascii?Q?BS0LsX2770tlFVKM0xCeUNUL/syaHKqHfUVKXTtiWsUyZa/Upjawsv8KQ/Br?= =?us-ascii?Q?gDBObnGc6UCPJt1un4RDJAFTDmmqQRpY8mQ4EP2YDC4zVfu1pYl+RNwu3Wdn?= =?us-ascii?Q?6OBmW6D9vQdb6bCbZreY9VXXpWft/4xDAzNXbtHTDrlkN03aygw2v8BSqb2X?= =?us-ascii?Q?1S7l4tkgxxOjvRAeUSDwkewW4h/5uJLflN3L/oTydb8CluGH0QfpVgRQ9hhx?= =?us-ascii?Q?2665Xj/XMpfjyIcfR5D/7dkQeRECbP96IRyon/9JpdpevyL6CNXOPMAjEMDj?= =?us-ascii?Q?2KPemz9SiES3mNiLBXbFJvCTKdbfj8zQ8Tzw0+PsVNCdIeLvCPukfUqhHQB+?= =?us-ascii?Q?NBwKSNHRSGJfNzVHzjub53biRgTQBdip/86z+7/dwzXcg5XnD/av07SzjnlO?= =?us-ascii?Q?K2By0VGeAAOO6VCIBRH51ZxoWdWmJghSm/uwsa5OfyMH+dCv2wB2gpf1cDrj?= =?us-ascii?Q?BQMbBrS5152/tvufnhOf/22vQ48scXLjxDEOkcw88b9kN+OkCz72WkkRVirt?= =?us-ascii?Q?2Vq7o76g4oEVeyX7xSFuvgB75Km7ZBe6oMnPYkBqyjqkHXaa2dLVX5cirCAa?= =?us-ascii?Q?QNc2jBW7knjjrakodRALw1b1gvWpqpD/deNQK2YGsLHRMbfstuCnmB3qtHcx?= =?us-ascii?Q?R2t94OhJQNlveweJLpFwhk9aHEzw2XNuJBr0BsTkHfwnlLMAghfXsMFhyNnl?= =?us-ascii?Q?PcTcUgZ16c9TS6+gsTaPbLq71saY4OUMoJKKeDZBzb3ZEFbZn4FjXXsBF705?= =?us-ascii?Q?cQE+PP+6tsZq+t7V1U4OGfkrrbFZh3A7usSJdhjS+E7hyuygt47NmEfQi85G?= =?us-ascii?Q?835KRyA4EifMpih3pPTblbhu2Ies8k8afo/gtzLPByaCl21O8LW8TL4T8By7?= =?us-ascii?Q?8WAoi/LQc4cvOKnOzrNihvy9BqrqbWd7sH6BW9Soc8RlhumWFTb5Lans+A6/?= =?us-ascii?Q?Y30UxBQFS7Xo4YI2EvuWmpL3j7GrgSm5YlLbkwdW56w7CcRP6J2UaCPRyjLs?= =?us-ascii?Q?UODMy7WCJ9f0aZTSz6kI6UQ88y+LpN9cIy4p8zn/jY8bXKl8sEgscNxBSXAn?= =?us-ascii?Q?KbqQZWBXVbB9NHJjNVofyhoMmBHA6gON+pE4HFnLg/kTIfzuMf6qicUh58bh?= =?us-ascii?Q?XfGPpTg7OSfDWrtlsRar7EJO9QMJYYqKIeeVBkaGKIgadfYWHKFCzKU38dwW?= =?us-ascii?Q?Y9zybyOhCxW2DK0pLXkA5qFGOlaaEodHMox6UgzTRXi8kQ=3D=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR08MB3317.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8493 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-SkipListedInternetSender: ip=[2603:10a6:209:42::28];domain=AM6PR08MB3317.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS1EPF0000004A.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 24195952-0700-41d8-e43c-08dd1a040165 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|82310400026|35042699022|1800799024|14060799003|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?CmsPMh3iS3iLgpPLnJnEM8Cc4s14HuEmR/ZEUMecQHtTSK9QLxwD/9/mXhJv?= =?us-ascii?Q?mbSkdryxBtTI/BfamROQmMJqWxk1I2Q+q8ofDrVeUtQqhjoNEdQH2U6pL0tf?= =?us-ascii?Q?YDe84W4drW1YafdhqQV2QuW1dpdiwIFPurkme+kIVFOvKPLzi/8de9FPtR2V?= =?us-ascii?Q?8g3186NgCf7eIUqmqoPK2ZyXtlorLCsDj7ka1XBaHDwK0ouyw8XKb0l3Yy7E?= =?us-ascii?Q?FUBU9Irxej2p/0v8CVPr3u36NdlyQPi9Oq3G+AD7wtB12hNvGJaQvr3TuOcZ?= =?us-ascii?Q?UQFKhpFyyHH3O70VkR/5nkRsEkaHzJCbFvhUPcQc6++Pv9mDXrxeMQuMZp4c?= =?us-ascii?Q?VeKYg1+yxw9hz9XFo9FFK0kDGTqd4hwicAvaJI3XNA0q1W9Q0/a+wwtqsjvk?= =?us-ascii?Q?oHOxpQAtfgwpvvGgODSZt19LA/SbrBAt32eAiZJmCgqjjV2U8iGeiYBnpasO?= =?us-ascii?Q?cUMYcqX2Toj3xDdH1UifY7SDxlHHFQK2R5PXgjzQwlbLVoeuYYmbcnnTbA2E?= =?us-ascii?Q?/Ri2TMD4y/g3TBzEo9LF3MsKJVFFzVSmRxXsFAbhyCZsc3WEwtdCPQPfKPpm?= =?us-ascii?Q?xgoxAKd6SQEcHlTTWWt3BEFJT9M8crTCqXMQq22gIzivJnHa9lGUB3mVpYy4?= =?us-ascii?Q?S/2ATlAuUyp6E+ydze0lCnR7apljkpyWD6Kl+f+TmVyeEy/caXQfw6cMz6rY?= =?us-ascii?Q?yyFzybFsL7y4kwDdSUUlRm6IsJK0/oGZXE/Df15JpWpyKkc04szEUH+2mT6l?= =?us-ascii?Q?gxJzrNpZoLnEqJ69c7CI/pPR4PLlE5wWNS3OG6HH6uiI6FzYSl6BkBHZ6DI4?= =?us-ascii?Q?Vq0m/agr7x4LMab0O7hhsAmKFFHk9Uz2NQEyy9Gs6VIArTZ2M7Gihpz+9Loa?= =?us-ascii?Q?WrFc5sZU+SL9cxRoJfQ/KGjt44M4U0svKsaFempV8/XENlmxZrx2cACvYdlw?= =?us-ascii?Q?WTTeU0tjiyiScIQmVFxH22qDMqKrXGpHIw/cEQaLbii2XxnUjnaTAfXL+c0m?= =?us-ascii?Q?2J55U3VH2mggUGaCzbjSdUqqHss/cTqLgwz7/4nBD6VfQKHjhrKeQNJ4p3zS?= =?us-ascii?Q?7uYM3P62rhjb42qNiec3SJCmad9a0sN6Z9mcP4DoNiXQVXDPgavnKN5qp7TS?= =?us-ascii?Q?J2EHSqkygY6rw80yhUBJ3DpW2JRWGhuhbtSr5ppiWCtHexNezidvqF8SX4/7?= =?us-ascii?Q?ifX0iNwZet5I+192HVosn+tSGZIU2Lw3Nqy0eUb7OqF3t8GgxBId2+0zYCw3?= =?us-ascii?Q?7QNsZ1KCGCGD3VPm+ASs0TyggB03PQaHldAoeentK24R9g/HK0qgRan2B3T4?= =?us-ascii?Q?K4VNOrMgyjwvW15TXFAygmwTfFhAXJYUXMkugWZMrCEfKaO5rfPf2fh5csmA?= =?us-ascii?Q?5G8Pa+agZ+eXyG+Ff6e1nwz+4Nf6lqRYgNd7iTyD8hJM9DGFKzVEwbN98p4t?= =?us-ascii?Q?yiPQrf5K1F/6/xIW/8dyNV3nC6HPNdumXcYmm1GF8qdA/2xI0GjTiA=3D=3D?= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:64aa7808-outbound-1.mta.getcheckrecipient.com;CAT:NONE;SFS:(13230040)(376014)(82310400026)(35042699022)(1800799024)(14060799003)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 16:51:16.2624 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 19e16346-55e6-41f7-14cc-08dd1a040774 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AMS1EPF0000004A.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB5976 Content-Type: text/plain; charset="utf-8" Signed-off-by: Lukas Zapolskas Reviewed-by: Adri=C3=A1n Larumbe --- drivers/gpu/drm/panthor/panthor_drv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/pantho= r/panthor_drv.c index 2848ab442d10..ef081a383fa9 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -1654,6 +1654,8 @@ static void panthor_debugfs_init(struct drm_minor *mi= nor) * - 1.1 - adds DEV_QUERY_TIMESTAMP_INFO query * - 1.2 - adds DEV_QUERY_GROUP_PRIORITIES_INFO query * - adds PANTHOR_GROUP_PRIORITY_REALTIME priority + * - 1.3 - adds DEV_QUERY_PERF_INFO query + * adds PERF_CONTROL ioctl */ static const struct drm_driver panthor_drm_driver =3D { .driver_features =3D DRIVER_RENDER | DRIVER_GEM | DRIVER_SYNCOBJ | @@ -1667,7 +1669,7 @@ static const struct drm_driver panthor_drm_driver =3D= { .name =3D "panthor", .desc =3D "Panthor DRM driver", .major =3D 1, - .minor =3D 2, + .minor =3D 3, =20 .gem_create_object =3D panthor_gem_create_object, .gem_prime_import_sg_table =3D drm_gem_shmem_prime_import_sg_table, --=20 2.25.1