From nobody Thu Apr 10 17:52:21 2025 Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2077.outbound.protection.outlook.com [40.107.249.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 8E13F20C465 for ; Tue, 1 Apr 2025 15:48:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.249.77 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522541; cv=fail; b=Ms2HlT5RbNK3cByg7wX6tHT7KfbDoSJU4WcWvYPRQPkoikSA8hf20JNFQrg6nYy3T8cyoEmf3N26b/CkLXZKNkbWsIebliEQYrYmjJjPtIkpqVXb5aNxPsAc/CqXDbiFNikispf1X3R86JJ8rT7C0UI7ftek3wLLn+WXXlftuUk= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522541; c=relaxed/simple; bh=rE2SR9z8/wuLhWSs/kCQvs1djDvqH7odxO1ji0EbrTk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=KzYQcYWsH9JHvK9wW2GrdGlVXEbCyE98d5qpfyy3mk9+QfcQqf8pAh1qDkwT08T22o1PZ6bNVcUXTpvMXFWIQDyhX2ftURYs9P1e25dgbZSMRVyc/zwvzkCVIq55+w/zWCu74IwEtCm/n+YR23ccu2AqToRfgMC3zPPekw7YMHA= 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=kVTLMgsU; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=kVTLMgsU; arc=fail smtp.client-ip=40.107.249.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="kVTLMgsU"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="kVTLMgsU" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=o+X/ZpjdUmI4Ksid8K2nYqq4Jh0VZbKGfdH3n3m08is9XYQHdwFl57PiDW6R4RvKh3/1gObVWENKO+Fh49SQY/t5z1YmHM4RUySXT86sRR2OUZbYlvQRwEgWFMYjH8L9z1KLlcxyh6TV4NRbSxXZiitzO9fR6IFHlPnbim/ss8Izwy0N37XbCz1xpnIBM7BDA6VGMwSUHDqgYxIzZafzdvP2tLd5HpJNXdy4PNT2t6V/YX5tPG+BExlzi8tsD611muHzliFLO9A/YkiUWFI7tch3YAopcR7GukZoj1KYCiDBwIbRIefC+ilU0rOP8xRZELItBlKcmPegEzB8KPZXqA== 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=hK8eaAo11ZlCQ6I373AuHMwGQk0vWIuFjiv6aQ2KXCs=; b=x818jzSkmMJAio+4hZ+WJu16o4mRU2IYXFc29vh1BAavPTN+Q93h4tEhARzzji0qaUaol4ZHMnH8mOMy9NJ3Zc/KVpDt7LqWk+iTl26CrnpSIP+w1qvOfjqu0H1Q2q8vcP+i+J+/tVHt34iI4iThjpvH1ELSMHbEXZIxg3iKwk44OzN2JRGGwPkahN8248S2qaAPEWti1lTj3tDLqN5TcvtKTQZRdNRSvVu+Yh8jdHRcQvPVJNVNrKul8xznAULiN9xBR2/zOi5x6QNXJl3xrkeR7SpPweQJ2cdwjWWrvEaOUD+jaN0mmHRdNOfhxdoLqoTPu1lS/Wz27gaNWFG3AA== 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=hK8eaAo11ZlCQ6I373AuHMwGQk0vWIuFjiv6aQ2KXCs=; b=kVTLMgsUDqjRCcyUDL3yq/hwvGTyItJEyohR6zy4VvnOUqhvoRVg6wCa1Ys7wsbIbQhItdLUzkIogPsIw/ToRgyztwq+NWE2Bw2P60+TCMBfloyuf/cA7RXbnB722f9kut3d6pngID9flPFEwlu8C9+5UCR2WE6ZUa+XP2XUjQI= Received: from DU6P191CA0069.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:53e::22) by PAVPR08MB9355.eurprd08.prod.outlook.com (2603:10a6:102:300::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.49; Tue, 1 Apr 2025 15:48:51 +0000 Received: from DU2PEPF0001E9C5.eurprd03.prod.outlook.com (2603:10a6:10:53e:cafe::4b) by DU6P191CA0069.outlook.office365.com (2603:10a6:10:53e::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.54 via Frontend Transport; Tue, 1 Apr 2025 15:48:51 +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 DU2PEPF0001E9C5.mail.protection.outlook.com (10.167.8.74) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.22 via Frontend Transport; Tue, 1 Apr 2025 15:48:51 +0000 Received: ("Tessian outbound 93207444acda:v604"); Tue, 01 Apr 2025 15:48:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8d6888ad6b27e5a1 X-TessianGatewayMetadata: 2wo16KCqSDmdAK4BxtRuODu094DohDQl4RJmO2wMXxuhd8qhYHT0enbWsXNfAvtGMzPU9RQ+bT4HID+QOegpgI5ra2Mwn8dy/e9qvNkZpH2G0NrAEnJQm9Ev0XaSy1g8ZXMQl/jefyO/8Hrkvxju8q9lFJK2n9KcFYKgzPD7YMmE4BhrfDdFhBg7VNE68KjLu92R3Q8YYus6pT+iK1WKhA== X-CR-MTA-TID: 64aa7808 Received: from Ldf56ed5f71a0.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id ABABF5FE-650C-4DDE-993E-C438ED48AB1A.1; Tue, 01 Apr 2025 15:48:38 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Ldf56ed5f71a0.1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 01 Apr 2025 15:48:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YLEJKUZxqhEJOY/l97PMyPp7GoKB21SKkvGR0uovsgRev0OKU//fFoNmssFP6rgWYvPUu0Hv2BX7J2ltAvZfo9SX329T7Eu+vTWK0LIad76jYG6GozdhzCuFVv+DJ5e7CPpWsZRfC0mGkgXkAfsZMUZDX7EZCEcM5wx5n6hrgjtnVaANfB1E87SZympX2h/1zOuqbSyV/0jE6JTu+Oo6rKwrIJ2bn3Q7ghxaGOuU7UQ4OHjeQjKrI4jfJc9aEivk1h7uoG7k69OPGPIly9FAuqedTlEmXuruKFOajKcLlBQ1lu+WnxhRAsbaOtFr5hgDJuSljuXhja69cTiGps5OkQ== 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=hK8eaAo11ZlCQ6I373AuHMwGQk0vWIuFjiv6aQ2KXCs=; b=kcSDBWcfWGwr7zriUZ4KX2pkA2SfFiJFoyrMCUH04z1HoU6nRpDw5WM4cfgOFN4KsMywoic0gA3xSDCjG8ftuOrVXODiUUBq7/j8eIXYJlI+Dz6qQHoRelF594NEm1vyssQFlfzVbSh7sx8BE7k7hr+Q+/PDBaD0sIgVbr632wawKL6eOG6a3rskQsodW7KzUvrd0ZB+/SvSDbnGb8GG9SsQJyiaFWlAl+jbFgYzXvWBOo/WtVaplqRLqUj0jAGbGOeDL1RhHlOYwPmY0APsF5yAdoQ5djPQk142dR/smJWnzzCFyYC8gPtsvw+S9Ub447L+kjrGG1P41T3v3jQdXA== 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=hK8eaAo11ZlCQ6I373AuHMwGQk0vWIuFjiv6aQ2KXCs=; b=kVTLMgsUDqjRCcyUDL3yq/hwvGTyItJEyohR6zy4VvnOUqhvoRVg6wCa1Ys7wsbIbQhItdLUzkIogPsIw/ToRgyztwq+NWE2Bw2P60+TCMBfloyuf/cA7RXbnB722f9kut3d6pngID9flPFEwlu8C9+5UCR2WE6ZUa+XP2XUjQI= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) by DU0PR08MB8279.eurprd08.prod.outlook.com (2603:10a6:10:40d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Tue, 1 Apr 2025 15:48:36 +0000 Received: from AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc]) by AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc%6]) with mapi id 15.20.8534.048; Tue, 1 Apr 2025 15:48:36 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= , Lukas Zapolskas , Mihail Atanassov Subject: [PATCH v3 1/7] drm/panthor: Add performance counter uAPI Date: Tue, 1 Apr 2025 16:48:16 +0100 Message-Id: <45c1f1a99427800ee154f22070648c41e0d3dfe9.1743517880.git.lukas.zapolskas@arm.com> X-Mailer: git-send-email 2.33.0.dirty In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P123CA0040.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:152::9) To AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM0PR08MB3315:EE_|DU0PR08MB8279:EE_|DU2PEPF0001E9C5:EE_|PAVPR08MB9355:EE_ X-MS-Office365-Filtering-Correlation-Id: 328adc6c-dd4c-4419-e1e0-08dd7134b338 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|1800799024|366016|376014|921020; X-Microsoft-Antispam-Message-Info-Original: =?us-ascii?Q?QODcco8NbBjoAuOdspfzkcZ/rYW6TCvVee2El16Jp+ToOni7V2JyaeUqTBLn?= =?us-ascii?Q?SldLRc1FzJcNm8rb9u74BtsnCcs5nKV/oZboiY+czM2YMh3kG92u/6ueIovI?= =?us-ascii?Q?LRUk2n8dCA6M7++sBDL3jKJNa2rhVoaTVyBLShVF/YDI64q4/dDBMBJrRZL2?= =?us-ascii?Q?ZMEdCqLwlwpujSynoNcvVSs1ij0SVY2e21zFKjHy9oNYcz8hHtccetIrak5J?= =?us-ascii?Q?bMRMdTQcWnWLMS5pIE8ThmNXbISNYAbUHUoHnF3vz8KrxIvbHcJoYGCfpUDu?= =?us-ascii?Q?FC3Q9fOPLM8gsg1Gvkock8KtUP0L8JXozb+El9T0TtXKPXaTBM1Qs42KuZZw?= =?us-ascii?Q?MQFRlAITHz5LGU2Rh/7hqvg4OtaGNvEatB5XS+lROuEYfnjyN6ixCmq87Ii7?= =?us-ascii?Q?4yexOdnmoFPFzfnMMeEweXcD42fIZmSwnnzCAOoShQovtbXo1b+CGVOEFW3W?= =?us-ascii?Q?hxaTt5UsosJFir4dCBkfH1JBPwtGrokOJOiqkFV4OUPiylHNrALtsOK4gg5d?= =?us-ascii?Q?Qe6LZupP9nMaXyHj2fNoFzqikd8rpXqYPhwT+ikBZ5FH2Q1qT58H8YkIe5wA?= =?us-ascii?Q?DWvIKKgoGQ4ud2spuWKgBpzOnkdxP/uK44W5PValpaKF+2fvS955RuhMdS2b?= =?us-ascii?Q?ne1T8dfw2sFPL0eFBCCZuwYTRDV5DqtZr0/eHXLzUL36p3MCTe0ng8J7IhLJ?= =?us-ascii?Q?9LKQr5VxDMvMI/U5Hrh1Zq0z4e7N6TnnMWiOPJwIikKnVHYeceZshM4m7Xux?= =?us-ascii?Q?QWUNZVv1HeZZ0qk05zI45lMW8wVMSX3k+iejipm+xHdxovtZCe0WQ/J6G1u0?= =?us-ascii?Q?uT+HPQ1wxTaYxFqHBhPvHYEdIUbqBjhzWXZm5j9BTwY7Ifm3MpHRej7zBb6h?= =?us-ascii?Q?zwoi9XvGM6NvBkuSoYCQ6rurJ5JTo9x7sp6/7/tp3nbQZY0wqDN9lmjJgTX4?= =?us-ascii?Q?iWQ9YSfBQzpNik30Yxs37lLRCeyIyTHkH9RTKDd6kpNvHUQlMwKKpmBa6RjY?= =?us-ascii?Q?vG1mjOwvbnQHAnz01OzHLhtq+Txqtml3UfhMz7YleRenMd1mAeehEegkldSL?= =?us-ascii?Q?ojdPu5acPARxa222ba+rSHnVCI6hp6OfLDZSw0UoyoQqftHB3YOprWSrvTPp?= =?us-ascii?Q?ZsnKimYHo0AafqZWp/nu2cuD0TGLrQlEZTUic0a0FUewciKD0zp0Ts+EP8lC?= =?us-ascii?Q?esL+dw9JnicBti+5i0UryFA/dB1vSXRQnX8oqWITbJhI7UP1K414XeMjviOU?= =?us-ascii?Q?gftzsq9eKojQR28UJp1TM0fEpI2ygS092l8Jg3uYatVBgOAhTNy/W9rAuCKp?= =?us-ascii?Q?SwqmrDWuE+bwLoucwLRg0ZJCLOr6rxomjF5Bf3696I83TyQaKrndi50eTEvC?= =?us-ascii?Q?z7nDjlK7VgmMRHanYsywTbWR9t6tDii3UC2UjJPEan/oAezZJRDH538iLwn9?= =?us-ascii?Q?lykzZuvFA/0=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR08MB3315.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8279 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:208:5c::16];domain=AM0PR08MB3315.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU2PEPF0001E9C5.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2f36e349-6b82-475c-f756-08dd7134a9e9 X-Microsoft-Antispam: BCL:0;ARA:13230040|35042699022|82310400026|1800799024|14060799003|36860700013|376014|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?AGhCZdq4ylnjblD5rKwArx7u5KFGNygiTXOji05AlsyVHZBa7t3TyphlcMeN?= =?us-ascii?Q?mM4aRm6a5Uvw0EA+0PNyB/a70oT6gm3ZZM0rfEgh0I7MZNAyWz74nq0kBmH8?= =?us-ascii?Q?qml13nUv9SU8xd7P8zu0bdOfjQ5wBE/uXA0illWza2wLv5ciZ982nazmrOVL?= =?us-ascii?Q?t9j/iuXjFjaIiMzXuBSSCnMCaaerXfGR1K3szpsv8K3/CqqEmzHVfJCwQuD0?= =?us-ascii?Q?fNUur7fLu1bQrAsif8GctPY5hL6QS8XFAXhuamfDB999guxv8AHWaZvPedHh?= =?us-ascii?Q?XNY+b0XYm5fwY8mFSCxtfqfB7I9BcIa4jrusg1TOg7oJUlbkf6wiw1EdjmBf?= =?us-ascii?Q?7cN4mJJVo3PN291N1tHJ856Nnz1tgNAq0+dLD6JGWdaWm501hay+RP1p9hkC?= =?us-ascii?Q?Lv/3R19xFpo8frY4DmDcui0YQnTuHjzVzxs9XWWvMBCDMjq8M/l+zaiI09me?= =?us-ascii?Q?mguQgTs/ko9o/UmyUizyTZZu0T1Zu8ep0aGihSAwpwGIbrOmeOiZqZiT0Qmq?= =?us-ascii?Q?Sp2A2poFQT0ns3K5LnvtsYrYdgpFjb9eXyD3W+KBbP+M0hXdnO53u2g6kvnh?= =?us-ascii?Q?9wYb/+uQ26Ut1r0LiNScBO7FXKkNvfOWCVabTzADfHi4VtZ3yBILBguhVIcu?= =?us-ascii?Q?GG23Vee2i4CLovivPc4X13koGsDdxAKrnZUoW87+uOMxt2AZ8LUFs3IWuTuW?= =?us-ascii?Q?11bULg9q8HHrsclfTZVSCdTQk9C/wYUjkUEzDtrYq3kT8TIIOcc9nHq9x17L?= =?us-ascii?Q?dkAH+m1rvrRLTbHbfceasBicVmSOQ8U95H1/s4SMoX4LWaFHi75HI0QHmTVg?= =?us-ascii?Q?eOjEHQaV+pJhYChbMvTOG+USWX9DB3/7aqdee3ynmC7CKufis8WRLJp7vbTw?= =?us-ascii?Q?KVL0+HjFksEh06pwXEZio0Xfk3X1rbI+tjHDgf9OvDtQquCyOn9TQnYkwfLd?= =?us-ascii?Q?wFuxxCm1ZR6cTeMr0lag4aZSo+1VU0IK/dmE7x87hCEumdfHMla91BUnzzp2?= =?us-ascii?Q?G2ngMP3lFiCjAq/cKP7N9Fpi6d4bei+VWePICwcZuVwrP/uHWhgESKoKOSwM?= =?us-ascii?Q?Fgu7nKscz6SzvXwiTT74IEysLHcFjzlXMtuaenUBPSdY48yF/oARYd+oXwNF?= =?us-ascii?Q?jYN4umuq+VsjRY/CEMLmDe0KRzm6l4O41yhI1zzEdhdxyXhdo/hwCwHfBtAg?= =?us-ascii?Q?4cJH+YOKf7NKtdRlrkfOt3SWwM0rM41d2L/YozZse2ZJmKkQApF0IBpKubXB?= =?us-ascii?Q?SOWEezHz15TYHZnlDn7fogwn7yH1YYV/oOw5BGoETYrbDGBRNZABny0vG7qX?= =?us-ascii?Q?mXJ0KcOemM59Hhbj9jVzl9pW4q1B2QOsznuYhkP3opL863TWAL9HZ31XkIYs?= =?us-ascii?Q?P0adKm00OC35P6T26RD4lpTssXUd7tIaCdUPwc4MpLuajJh8asP/e2B2JxZr?= =?us-ascii?Q?pDar6J2zDmMlNKZU2wmJCCU/IL9RmNluPAMvFL7c4rNqyQPRTc4ynFDYIuI5?= =?us-ascii?Q?SDXJiI4TfKaGzDHc+PKr/co49CvqIlOwOd0y?= 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)(35042699022)(82310400026)(1800799024)(14060799003)(36860700013)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2025 15:48:51.5566 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 328adc6c-dd4c-4419-e1e0-08dd7134b338 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: DU2PEPF0001E9C5.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9355 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 | 545 +++++++++++++++++++++++++++++++++ 1 file changed, 545 insertions(+) diff --git a/include/uapi/drm/panthor_drm.h b/include/uapi/drm/panthor_drm.h index 97e2c4510e69..c63cbdddde76 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 /** @@ -226,6 +229,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 /** @@ -379,6 +385,123 @@ 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_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, + + /** @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, + + /** @DRM_PANTHOR_PERF_BLOCK_FIRST: Internal use only. */ + DRM_PANTHOR_PERF_BLOCK_FIRST =3D DRM_PANTHOR_PERF_BLOCK_FW, + + /** @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, +}; + +/** + * 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; + + /** @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; +}; + /** * struct drm_panthor_dev_query - Arguments passed to DRM_PANTHOR_IOCTL_DE= V_QUERY */ @@ -977,6 +1100,426 @@ 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; +}; + +/** + * 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, +}; + +/** + * struct drm_panthor_perf_ringbuf_control - Struct used to map in the rin= g buffer control indices + * into memory shared between us= er and kernel. + * + */ +struct drm_panthor_perf_ringbuf_control { + /** + * @extract_idx: The index of the latest sample that was processed by use= rspace. Only + * modifiable by userspace. + */ + __u64 extract_idx; + + /** + * @insert_idx: The index of the latest sample emitted by the kernel. Onl= y modiable by + * modifiable by the kernel. + */ + __u64 insert_idx; +}; + +/** + * 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, 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; + + /** @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]; + + /** + * @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; +}; + /** * DRM_IOCTL_PANTHOR() - Build a Panthor IOCTL number * @__access: Access type. Must be R, W or RW. @@ -1019,6 +1562,8 @@ enum { DRM_IOCTL_PANTHOR(WR, TILER_HEAP_CREATE, tiler_heap_create), DRM_IOCTL_PANTHOR_TILER_HEAP_DESTROY =3D DRM_IOCTL_PANTHOR(WR, TILER_HEAP_DESTROY, tiler_heap_destroy), + DRM_IOCTL_PANTHOR_PERF_CONTROL =3D + DRM_IOCTL_PANTHOR(WR, PERF_CONTROL, perf_control) }; =20 #if defined(__cplusplus) --=20 2.33.0.dirty From nobody Thu Apr 10 17:52:21 2025 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011018.outbound.protection.outlook.com [52.101.70.18]) (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 984637DA93 for ; Tue, 1 Apr 2025 15:48:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.18 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522537; cv=fail; b=o17DvAuf2eVAqifoQpRVtBFNG/tc59VpibR7XeolGQU/BXf/bO4XJ5Cul2czNL0S/pXLoeeJSrJwE+9Vbk4fjAhOPzUVyCvXEhttO4T1+BD0KaYCbuRgds9d8tUHHHbIIiNitXZ5wtx077LWz8nTQZ9oPKbC43DMfQD19Fe5EIo= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522537; c=relaxed/simple; bh=gqPiVdwTBUEZ5TcRPUL3d78twDD+RZc4ZivDsA7/rOM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=EWsa7yLNTstvwgMUK95IOlL+JMQFfBcOYfxKzy1EbwGRjotDePz6MeD6FCrsK0C3q+7uYmH83LE0/xhf8YsNIc84RrldGESzw3qMNO6Pd1C7Hmt1zl0aSuRaU68cEMOSIW4G93zwuyWkw9vuJ1+Sr37frqQqfzhkBAQguzyeVOs= 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=ZB4XxlhL; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=ZB4XxlhL; arc=fail smtp.client-ip=52.101.70.18 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="ZB4XxlhL"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="ZB4XxlhL" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=ngSzfymkucHOmyFNk4PUKeALvIKHzcKHmcYe577sg95/FyV6T8rPxx96DnHDcZg08FPbVGV7W610077Ets49t6x58bbJs7tBKgIxkPMvlpfThfIHo7bupClY8/SoyHM2yFXxw6eWXBCNKRI8TjDq9zx0lyqtKyFZJ7T4MdRWwpqiTFy04FlRYgg0lOK1Hbcp8ktDY7IMYJm41y/Nr5Y++12nBdToizO4M0dUuXs2DHv6PaJwUFzHeIAgfZ3krQ+BPAOAUuMXOo+Z7hMZubojzAOxrGy8scfwLNZLeZOoj7qMF97r7nCpd2lnAPlFKfm2kEAqKEkhi8QD9+G3T8IOjg== 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=RKToYnsnhK/atjtQcUyS+m3lGaKZADzK4Xhkt3mZuVo=; b=PoQUD+RTTPvyMnQXMD60GpLSxTMpE+8tuHE2Oc70wu+f0t01tZfszp+38lOtbY+P9iY5FT5kT5ODGo97ysMF+jAh2NK8HMTPw7Gl4Wp9nKzBo9DUYILnY1qbqvX5cALSInxE95WkKa4C0HXKTTom4mZeHTbWmPY0eclFvV4utf1ujrwRw+enSZOKTq+zjObEke8HdTwxXWkcoiR1APmNFdFaDv6Wf7AQmCu89v6plgbp61YmzJzDhulvcz9cLTGw+vKf3h7eoqgCMrFDjBbvPvxQPbEoB09qTHeghemwiJrquDKnajgCk0w3RjPuODxWB5ASbCj6Pe38lPp9/adn8Q== 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=RKToYnsnhK/atjtQcUyS+m3lGaKZADzK4Xhkt3mZuVo=; b=ZB4XxlhLBJzUytrgYqaEHiYB5nHTNaTFSoJ1iZh/P0dCn7o4B/4W7EWXOTr9tz/Sh7pkXFeT6GeM4Cqmj6eL0mLJfAB2eagtTFuVsHlaeCh+1DZwHaBlWCOZJTKaTgD2qwylGPn9OR+LwQWJCM03w/NAbCvGKFl/fNHlUbsjIps= Received: from PA7P264CA0166.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:36f::17) by DB4PR08MB9191.eurprd08.prod.outlook.com (2603:10a6:10:3fc::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Tue, 1 Apr 2025 15:48:48 +0000 Received: from AMS0EPF0000019B.eurprd05.prod.outlook.com (2603:10a6:102:36f:cafe::4) by PA7P264CA0166.outlook.office365.com (2603:10a6:102:36f::17) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.54 via Frontend Transport; Tue, 1 Apr 2025 15:48:48 +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 AMS0EPF0000019B.mail.protection.outlook.com (10.167.16.247) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.22 via Frontend Transport; Tue, 1 Apr 2025 15:48:46 +0000 Received: ("Tessian outbound d933a9851b56:v604"); Tue, 01 Apr 2025 15:48:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 3fdee01f070c5258 X-TessianGatewayMetadata: zdau7lNxuKT/PBcDwz3JCS2lj63ukJ2jrJIWxTaUjM4J6d/6vgGv2Uba6bRv7oVwjPrFR7AVbtJd2w2lXo0EC7ypRf38cXS0EBPE8gRernDiHiVlJ4Fv6w5eUk61eC8BtMmtjqw2Kz7GPm42uGpB0DedA5fQQA6MXUpJUpWUmae+F/l/q0nIP+VWkx+pkSzP3TzAnnKjhnU+Noi4B2eyuw== X-CR-MTA-TID: 64aa7808 Received: from L12314321001d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A8011DF0-7E90-4AE2-B5FE-6DADAC91EE5E.1; Tue, 01 Apr 2025 15:48:39 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id L12314321001d.1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 01 Apr 2025 15:48:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gSx1CPoRt16r07GY7pWLzthTJMdFmrhOJY53q3dMq4FHZahsLE8CoEey/1+bpyGDgEVMTdTnqPjegb/wT/XPXeUMyoywCEazb2t7wVJMvSfaO2inGYQ79K1IU6e+O4e1Q5Gy5KAjKlYj4eEZ+sGaXLxlQN7f//vJ/Nx71srbCNj7z+U2druhY/VUOk/+Su0IE+W/5y/yChHlwEvq7HhL1FwwD+Atj4JSVLoV2hTzwAw4A+UWh4M0csElGJUbSXAYNTBmfSzd563jETc1hNHj9tF+7L1Ow+nTeiXgX8zQQWJ+/wJg+uzXrFqIvlyvbxtHvlTNSIeqmY+KPk+WCZM6rQ== 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=RKToYnsnhK/atjtQcUyS+m3lGaKZADzK4Xhkt3mZuVo=; b=IQJHJzMawE3owv7ibm8XZ5HwRvxl5ZHCzxPXJWWTvgk5o6v+ra7w319dnhnzfxG+JaiuolZ9Ps0qS5AgWzWDUH/xSl+OGMMj2lquNpaKRof+01mjMyoggF5Bzbd0v8y/FcJJ+oxnJ6IGxCypgbGQjY0CSQyGRCfn+C+SrRFS9RaiWDOukNXR3ZQycdW20Bsvt4QqLMrj6ZfF712POI3BTON0Xz9S83SwY7jWSrje8IzGVtdgzSd1UyvhVaK+TyIP3FuzJG9z0MfOoVY7yusTlrfUPvS6A5SJVxTKE2BGVIrBz3uh3FCpXZ9YiCHlK7jkm+aUWcDZMpd1bNmUIUNXtQ== 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=RKToYnsnhK/atjtQcUyS+m3lGaKZADzK4Xhkt3mZuVo=; b=ZB4XxlhLBJzUytrgYqaEHiYB5nHTNaTFSoJ1iZh/P0dCn7o4B/4W7EWXOTr9tz/Sh7pkXFeT6GeM4Cqmj6eL0mLJfAB2eagtTFuVsHlaeCh+1DZwHaBlWCOZJTKaTgD2qwylGPn9OR+LwQWJCM03w/NAbCvGKFl/fNHlUbsjIps= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) by DU0PR08MB8279.eurprd08.prod.outlook.com (2603:10a6:10:40d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Tue, 1 Apr 2025 15:48:38 +0000 Received: from AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc]) by AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc%6]) with mapi id 15.20.8534.048; Tue, 1 Apr 2025 15:48:38 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= , Lukas Zapolskas Subject: [PATCH v3 2/7] drm/panthor: Add DEV_QUERY.PERF_INFO handling for Gx10 Date: Tue, 1 Apr 2025 16:48:17 +0100 Message-Id: <203e6c8f7e82068fd570896a4302757247980c09.1743517880.git.lukas.zapolskas@arm.com> X-Mailer: git-send-email 2.33.0.dirty In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO6P123CA0047.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:310::16) To AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM0PR08MB3315:EE_|DU0PR08MB8279:EE_|AMS0EPF0000019B:EE_|DB4PR08MB9191:EE_ X-MS-Office365-Filtering-Correlation-Id: df9c3118-7195-4984-87a2-08dd7134b070 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|1800799024|366016|376014|921020; X-Microsoft-Antispam-Message-Info-Original: =?utf-8?B?T25hd2lVMkV4dFcvNnU0eGZVd0Z3Tnc0UUxYelRCY2wxY2FPOEpkSVNETm91?= =?utf-8?B?NExsaGhmT0RtRXVqbXk0RDFGU2JjNVkvTDJ5L2laSTFicno2ZWwyeERPN2Vm?= =?utf-8?B?N1p4UWN0VzYybXdoSGUwZlpoS1BJMnB6ZEQ2RTdjWFBYNnZndjYxbW9XZjg4?= =?utf-8?B?NFZNYUEvZlpCajg5Y1BnYzZtUUxKVSsvREM1YmxrTU9lTlZGR2dqeTFPVGlL?= =?utf-8?B?L3NnNkJjd2tHVGp5dUtDc2UvampvVjRrNUFtWnVZRWMzOU5KUkpNd3JiVDVE?= =?utf-8?B?Qzh4d3RZcndkTTZJTVJJQ29zditwVzdrV1J5WUNyUVdkM201eldqd3AyRjEy?= =?utf-8?B?bE13c2Z5cGc4NW1rS1ZBZExVam96KzI3SGNseWJ5SEhGcW51cGNSeVROVGQx?= =?utf-8?B?ZmR0NW01OEFDRlk3cVErOUJFT25ETmNYUkl6RGozZkZuSXVubkhBVktqNC9Z?= =?utf-8?B?VlNiLzNqdS9HcTcvSDJaV1FWZjR2ZWJFOS8yODBVdnhYeUFlUWNIRWczQmJn?= =?utf-8?B?MW1ZMXhNS0JZbGpGTWJkSnhRYWQ4WGFDZnNGMlV0TVZIVDhKSHJvcU5MWVdP?= =?utf-8?B?KzlqcEgyZVNxS1RjT2ROSEZpUE8wRmtFMms5RXQ1aXlvWnZjSWNZVC9jVUUx?= =?utf-8?B?c0wrdXViZ0ZmckF3T1g2V2lrYjE1aGUvWGdsWTY1cXErNW1DN0RtUzRBbjcv?= =?utf-8?B?VHViQ0NxZXJXaFQyVTgzRU5pbmVZSkE4L0VXaU8rUzNqTmR0dUNHYzhBSDJs?= =?utf-8?B?VnpsbVZ5VWJPNmdNQzdIVmp1ZVZNZDkzVUpHUFpRRkNsWjZOZVJabFVaZlMw?= =?utf-8?B?ajR5a2JrVUtZNHVxRnRia3p0YmllMWJaZjhPbEt3NnhXamFaZXo1ZXN6SzVT?= =?utf-8?B?eHUxSFFNS0lwL0tiRmdscUhRK3hBeHVVdDhCWGgxcGIwUzJxNUNaVVluZXBU?= =?utf-8?B?UlVqNDM4eUhlQzArYUVQSDd3RnRJZWJwNjFLbDFERi9memxVTmNQQlpIdDdT?= =?utf-8?B?N3dvUlBzVVBFOVlPUFVrYVIzSE9RRytOZHdWRWxMM1BpVnNlLzRWYzNmdk1F?= =?utf-8?B?bllMMkdhVUdQbzhLQ0RDLzFIUitGQndEdWFoRUhVQmNObHNhTnB1VUhKVGFP?= =?utf-8?B?YXMxQUVDeHNPdFdKWXpCTnBBZjRrSGtORmUzNFM5YkdtY3FIMXZsRFBNQkxu?= =?utf-8?B?UEk5ZkJuM2IwWllGUGZYdjRrSkFmZG5TVmpjdzNMbS9IUEhZcy9HRHJwMWZr?= =?utf-8?B?a0RsLzNNRUVFV2FaR3MzcVE3cmNqeHZ3ZkFEdUdPc1ZiQ25ta0hzb1NQckFo?= =?utf-8?B?MCtBazFyczVyb1lyYXhrOHEyZ0lhTUhZSXJXUWdPUjRxRWxLYUtaVklnK3R3?= =?utf-8?B?NUZiaS9pTk90NDFicVdydkJUbzNqL2o2QjRWWmxnQ1dJNll4Nnd1WlJmM2I4?= =?utf-8?B?OC9ibmQxZzc1c0hGbHc3cWpVVnBiUjlvVzhseGEzS1NZSVVjaDI0S3I0L3lS?= =?utf-8?B?YXFtYnB5V1pYMlRIalpsYWwrSXlleXlsL2wzRFhJOWFtYkloUEFCTzZXbzBW?= =?utf-8?B?T2t4ajFVT2VXNyswYW5qcHFTbElzaWdzaUhDdG5PUnA3TWlsQzdTaktZT1Bu?= =?utf-8?B?UCtmYnh6UFBkb1B3T2owTU54cXptbDhpYm5WSVBVT3p3b2p0eHpWNWx2NEY3?= =?utf-8?B?K1M3R3ZPTUpSdTZ5ZWhOMDBDTk1IMndxbjJPeTc3SDlOMG1xQTkrQ0FrVW9w?= =?utf-8?B?T3RTWURwdVFMbzI0bE15T1JyVmN5dFBCMU9tMXhCTnFNbkF5Q1Q2ZW1NMU51?= =?utf-8?B?RjhnUlpVaWpWWWN5L1krUEcrQXVEbUtuVzFRUkVwV2lxL0ZXV3FwYWxGT3VV?= =?utf-8?B?NGhDb1poQy9TbEs1QjczZVgzdzlKNEd5cFdWWE1wbVVCSDJIdTZWVm0vb2FN?= =?utf-8?Q?+SEC48H7oXA=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR08MB3315.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8279 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:208:5c::16];domain=AM0PR08MB3315.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS0EPF0000019B.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 22075fad-1163-4046-218e-08dd7134ab1e X-Microsoft-Antispam: BCL:0;ARA:13230040|14060799003|82310400026|36860700013|35042699022|1800799024|376014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?B?dndBSHFjOXFHcWNiWTRodHFSRTUzOTFrOEh1ZFpISTNPMCtmNFRTUTdjTmRM?= =?utf-8?B?RzBRQXB2MmVWTzdYZ1BvandyamVDemhKYlRwbzZjK3k5UXZvTUFqU29aeDFM?= =?utf-8?B?U29MYndnVzM2Mjg3NWNaTmdZV2lXUzZ1WVFmREFjRlEvek9vdU1SaWtpcGJO?= =?utf-8?B?UkxpTzVMY0U4RjcveFVoeldMell6RTYwTmx1N01HS1FDdVhBNmVDcFFOQXZ0?= =?utf-8?B?WFVoVkhIWVR3NEpPMkNhMHovZWlvU3lBYTQ2eVVXWjNqZDRqRmdpK2J6Rmpr?= =?utf-8?B?cTlzbU1Ka2NKN2pqcVQzbjJ3MEpJU3RnWUVmR1ptWmhMcjVrV0lzUTFmcXVk?= =?utf-8?B?d3lySC9nbWJMVTBZblVyRmxNTmhSTWlkVWJCOVRNZjdwQTR3bnYxdVpYRkFm?= =?utf-8?B?L1BCWVYyVVJieC8zNkd0cG5kRVhINzFXZWRuYVBQUVU2U2ZIV0F2TXVjOFZH?= =?utf-8?B?aC92SG50dXdVODJYOUY0c1l0VkJFVEhuclJhZXFlaUtwbVBjbkRPOXNhSzdS?= =?utf-8?B?M0w2NlM5RktBdFBqK0F6dStQc1VnQTRSRWo3UDljVmxLNUx4QjEwL1RTckxs?= =?utf-8?B?Y2NsNG5vYnI0cDJydGlTZ3Zsa3BBMXBlbDAxSWg0dFRwMmtxQStxMEI2WmFz?= =?utf-8?B?YXRpdTBSYVNGN3RXaWxOTnY3OVFraGphcExzYzN4WlpwZm5PRzVIRFIyYThp?= =?utf-8?B?NHl1bjNiZXpueTVKUmo4U0xlZnJXMnJyQzFUK0VVSERqdVNrSm5OMGQ4VG9w?= =?utf-8?B?Ymg5bjNsaGxqak4vOHJ2V2VyeThPU3VwVGtldmxScmYwa3Urd1QvSWN4VUpF?= =?utf-8?B?TWMycFZGZlVwaWdoaFpSRXpwaFdIUDYzY2s5Q1I1Q1QvcDhvNzFZMUY0ZUxV?= =?utf-8?B?UUZMdWtzbTBQbzJaUzRBbWpkUnZyL2lFaEMrcHhGTVZKaDdwMWZjMnJCMzND?= =?utf-8?B?SEJhN21Xa0FxVUFyRzZMRWtHY0xJZjBrbUpaVnp0aVVXUEkzTCt1VHZUUlFE?= =?utf-8?B?TGFkR3VrK1BTelY2VHo3NjgzZERNR0dlbSs1ZVNqdGFaSzlhYXBrTkFKNVpP?= =?utf-8?B?VUtDem5ZTmF4eGRaTkVUK3AwV3RCOUF4NFNFT3NscDY2My8yb01qZHJkSGtr?= =?utf-8?B?OXlSa2dkN3N5NHd4Tkg3VW1mYlU2bXBlTUY4b3JOZTlCMTNVVTZPTjFJQnhU?= =?utf-8?B?U0JIcXN0K0xhK3hPVU9tb3dOMmIzYXl2enVMUVFGQXJzeStEb1lSdXhYUGFG?= =?utf-8?B?Ui9nMHd3eDFXd3BSRk9heDZ3VkhFNUpoMThOeHdsVUx4aVFmeU5PQTNZUk9P?= =?utf-8?B?ajJLSUJMSHFXcDgvZHpSVmlxNGRteis2dDVlRmJKZUxHUklSTS9ieXdleGlh?= =?utf-8?B?Rit5SnhVWCtyYjltNjFHOWdrTDhzQm5nQW9UZlEvZlNsblQzQUFUSnYzQ2Nm?= =?utf-8?B?ZEpBK3BNK3pMWWhJVzcwa1RUSUs5VWRPOWd1eUs0bTB4KzMvOUtLbU1jbG0y?= =?utf-8?B?QWdKeXZwS1dYZTJuZTdHdGIwTmIySWszTVBodWVYRzlxckVBbnNxbk9yYk9U?= =?utf-8?B?ZDhRSklRb0c5LzdqektwRFFqZnVFZG84L0RxL0JOcDdsTWVLdmhxZkxxdWFM?= =?utf-8?B?NTAyaExCL2tsNUw2Z0V3TWZhY3lnc3RnbUp2Z1lXM3hQbmprcU1sTmZhVkkr?= =?utf-8?B?WlpRbUF5T09VcWhKYXRPTWVCT0ZqOG41c2RZSGdDOU05VC80OWg1aVhMVncx?= =?utf-8?B?N2pNTm8xMXFNekhCZVEvUGE0aUhNWVZGZWpzWmdzbEtFWC9JL0piTzVVTC9s?= =?utf-8?B?RmhjZ1VNVzBITHNXb3hCZzZFckJvdGQxUW1obFhzVzBJM2RTY1o4MVdmUWUx?= =?utf-8?B?S1h2VkZZbVNPYkxEOGYxZkJVUVJFTXExUWZzMnVlYjlMaXYwR3lKaGxIb2tx?= =?utf-8?B?SzFjM0kvak51N2o2M2VFTm1DeHlFVkx5dWZnQ2pBdHR4c05RR3BLcTltR08v?= =?utf-8?Q?gzdZfS7s570knEwKRhqd8mkNWuP47Q=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)(82310400026)(36860700013)(35042699022)(1800799024)(376014)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2025 15:48:46.8256 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df9c3118-7195-4984-87a2-08dd7134b070 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: AMS0EPF0000019B.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB9191 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. Signed-off-by: Lukas Zapolskas Reviewed-by: Adri=C3=A1n Larumbe --- drivers/gpu/drm/panthor/Makefile | 1 + drivers/gpu/drm/panthor/panthor_device.c | 5 +++ drivers/gpu/drm/panthor/panthor_device.h | 3 ++ drivers/gpu/drm/panthor/panthor_drv.c | 10 ++++- drivers/gpu/drm/panthor/panthor_fw.h | 3 ++ drivers/gpu/drm/panthor/panthor_perf.c | 55 ++++++++++++++++++++++++ drivers/gpu/drm/panthor/panthor_perf.h | 15 +++++++ include/uapi/drm/panthor_drm.h | 1 + 8 files changed, 92 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.c b/drivers/gpu/drm/pan= thor/panthor_device.c index a9da1d1eeb70..76b4cf3dc391 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 @@ -259,6 +260,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); diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/pan= thor/panthor_device.h index da6574021664..657ccc39568c 100644 --- a/drivers/gpu/drm/panthor/panthor_device.h +++ b/drivers/gpu/drm/panthor/panthor_device.h @@ -120,6 +120,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 06fe46e32073..9d2b716cca45 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -175,7 +175,8 @@ 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. @@ -835,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; } @@ -859,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.h b/drivers/gpu/drm/panthor= /panthor_fw.h index 6598d96c6d2a..8bcb933fa790 100644 --- a/drivers/gpu/drm/panthor/panthor_fw.h +++ b/drivers/gpu/drm/panthor/panthor_fw.h @@ -197,8 +197,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)) << 8) + 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..b0a6f3fca8a9 --- /dev/null +++ b/drivers/gpu/drm/panthor/panthor_perf.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 or MIT +/* Copyright 2023 Collabora Ltd */ +/* Copyright 2025 Arm ltd. */ + +#include +#include + +#include "panthor_device.h" +#include "panthor_fw.h" +#include "panthor_perf.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) + +static 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; + + 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->cshw_blocks =3D 1; + perf_info->tiler_blocks =3D 1; + perf_info->memsys_blocks =3D DRM_PANTHOR_L2_SLICES(ptdev->gpu_info.mem_fe= atures); + perf_info->shader_blocks =3D hweight64(ptdev->gpu_info.shader_present); +} + +/** + * panthor_perf_init - Initialize the performance counter subsystem. + * @ptdev: Panthor device + * + * Return: 0 on success, negative error code on failure. + */ +int panthor_perf_init(struct panthor_device *ptdev) +{ + if (!ptdev) + return -EINVAL; + + panthor_perf_info_init(ptdev); + + return 0; +} 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..3c32c24c164c --- /dev/null +++ b/drivers/gpu/drm/panthor/panthor_perf.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 or MIT */ +/* Copyright 2025 Collabora Ltd */ +/* Copyright 2025 Arm ltd. */ + +#ifndef __PANTHOR_PERF_H__ +#define __PANTHOR_PERF_H__ + +#include + +struct panthor_device; + +int panthor_perf_init(struct panthor_device *ptdev); + +#endif /* __PANTHOR_PERF_H__ */ + diff --git a/include/uapi/drm/panthor_drm.h b/include/uapi/drm/panthor_drm.h index c63cbdddde76..4d352008dffa 100644 --- a/include/uapi/drm/panthor_drm.h +++ b/include/uapi/drm/panthor_drm.h @@ -270,6 +270,7 @@ struct drm_panthor_gpu_info { =20 /** @mem_features: Memory features. */ __u32 mem_features; +#define DRM_PANTHOR_L2_SLICES(x) ((((x) >> 8) & 0xf) + 1) =20 /** @mmu_features: MMU features. */ __u32 mmu_features; --=20 2.33.0.dirty From nobody Thu Apr 10 17:52:21 2025 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2067.outbound.protection.outlook.com [40.107.21.67]) (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 BC01120CCCC for ; Tue, 1 Apr 2025 15:49:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.67 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522543; cv=fail; b=N0owf6wZotho+5Z4VifLPvTDb5XW+bEYw0DlBxLVo6J51Uc7mMBgAYjh86yqyxwSPKblerGjP/G/zPfYRF26XNhuTW0NtS5aOUdbsED7O6/MfVkdWmznKnEL6TgPalY9LTeXZ0Ajt42S8P94eMrQRfGcVivfQgPHlOrmHlrpF94= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522543; c=relaxed/simple; bh=WkhCTufnnIpGsVl6KMi9zZUee8znNwJiqdYqaDd4N/U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=M7foRYBVt1pzTDZt2vuIgnAarRhXW4AtGQIkpjtqUqOD/Yem1BAbaoks6WPHUE5dXz79OmpBOJKlm213Zo0cswhZEoA2mFT5hQ+argAGjgZPeMfJNqP5nqZ80ckeLb9YMOQB9QMdhht8h10sTcg8XLBRrbgMHvGWzzpe99Kq1yo= 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=LEFBTRoK; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=LEFBTRoK; arc=fail smtp.client-ip=40.107.21.67 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="LEFBTRoK"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="LEFBTRoK" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=ZR/3VHgvQkhVXwkpaWUBamc3f7IMbF19vzDckVEVCcgK4BH2duEvj7fwmct8eXxEVMq1VBJHuSLthUoZiOV0bN0JpkbiwyJFfjVC+qO/vPUSFzchKTWszkD1AxI3Hqxx/XyJUCoVmALmBKdjoZ6pYmqPV9bab3bDwMiL5hZKSnbxybzCPB6y/QupqM0ucrU+nrzsARYcBdXvgA1sIDVokceopV9jxyEGAJsHk0lQNjINS7ACy0/wN5aU6SS1Z4TLWYuPnJ1Au4ZDm2vn8/kmRO/SRX8nLQ5vnIHYgsAqhp4giDjBkOFq6FW3Pl5CHr9va1QlA3IMaEBhP6p6m41+ZQ== 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=PsrSlE0RqRhNatSH9PeOhP26l7gL422INcqlFJXpfVQ=; b=XSClfnWO/rByDtGbEbL3mBRzfV98FcMLfmQQNFoZb5yfn7U6OxpOo3dMYzcHcFJMDzJxpXBgyPNOWXUskn8TR8ftfkxxKJtvUHN+MRB4IkgciARScL23BsYuQdbnxey/rV6SrMxNkZ71GL2Do8jr8pVNlsuDTrIZ3CunxtaauDCCl+Wu1LnEOGhUkYvh/q9R9mOONg9BbDGVQrWZblqX6pr/dJlthuznhjLnuIslxgwHbZ/U/iP6buEjKrJtHmfpS8fu7nxUr7cF6Z+cHWy4aXakx6FELRxfU2JLurb73E9ZWFRQOFszb/jxb3HwgD3l+sPE5wsB4PPohxyGufwyrg== 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=PsrSlE0RqRhNatSH9PeOhP26l7gL422INcqlFJXpfVQ=; b=LEFBTRoKe4aIML4F9vw8qQ7+DiS0eJjCvj7YRZ5att2d24TKSk016jOOXoVyOTbUfRzDaaOiUsA0YVrOkoVvN37a+WYyQeorB9A/Quyr6C4EUeryV/qx6mq3s+F7it4MBPD+JjtxlHX9k3Pm8YX4gwcpo/0FbzC5ScCE7hVF0Eo= Received: from DBBPR09CA0023.eurprd09.prod.outlook.com (2603:10a6:10:c0::35) by DB9PR08MB7584.eurprd08.prod.outlook.com (2603:10a6:10:308::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.54; Tue, 1 Apr 2025 15:48:54 +0000 Received: from DB3PEPF0000885A.eurprd02.prod.outlook.com (2603:10a6:10:c0:cafe::48) by DBBPR09CA0023.outlook.office365.com (2603:10a6:10:c0::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.54 via Frontend Transport; Tue, 1 Apr 2025 15:48:54 +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 DB3PEPF0000885A.mail.protection.outlook.com (10.167.242.5) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.22 via Frontend Transport; Tue, 1 Apr 2025 15:48:54 +0000 Received: ("Tessian outbound 850a7d29d40b:v604"); Tue, 01 Apr 2025 15:48:54 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 83949acd2e2dcaaa X-TessianGatewayMetadata: rfQJ/Gaud4ugcxZyXp+QDj0MytGyn36N+5BjuUKERINkjFOQ8zzPzcQ4fBM2zs8AX/ajOfPJLpPGd81oOENp1svXjsTtHWqLl0xtG2sFdvdlRcN70ldKF8f3cjLKvoPsa5LIx2DpKiJpkzMVwX6UkA+bhm99tf3lOOF15e0FvkhHJgOjXezZEzNsPVnBjN+jV8XZ7GpMeF680dMPYQJ4vA== X-CR-MTA-TID: 64aa7808 Received: from Ld0ef08db9166.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5A01BB6B-016A-4F12-95BB-49E0B76FC9FA.1; Tue, 01 Apr 2025 15:48:43 +0000 Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Ld0ef08db9166.2 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 01 Apr 2025 15:48:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lza470LosDgCpCWP1rvHvaEL1Bm4ZogG2ru9yfsZ1VRStntac+l7Sy3nLptPwazVOGwolDsNDvQyvMww7TpEWcNp+ypAVer2Fd9IBfuTV3ITonwruKQXy/Lj0/oDEzU4+mBmH5owrpU3ChtAtfDwqjSarxER+oQQRKCe40jhEjCS8miCpou4jOWPnO8pIP79rbwxyfy0H2ffG342tEKC1VCTjnoETyhcwiFcSIpw8K0BpoSZ+vKS95WMZcxHuqAgVxuIvOuNKbeH9M0yAhIvSo2RbCL/S2ZBCk/yQyYKbZKnw3IYy655ZywUUY1wB56w1eYhN1CxLS7GgO5xL+VnlQ== 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=PsrSlE0RqRhNatSH9PeOhP26l7gL422INcqlFJXpfVQ=; b=H/VXOnQ2YAVF/dEYglPY7ZdGFNd33SVxlO1FVHV1j6eiKDZDdwuR9QA/KS0t5XmXL0oyGtQ3VNBbt3FD71UtzJEd5bXfNER2MySmQgPkj7yYGrkB+c36RVGJOT+A48kZsdFoAd91p1HXiG+LENfsxztd/27fqXxZef+BsgpNKsV6Oa4Xh+xqwe3YraPgUBDPxqgDqYzUSIRo98WSYYXcqBGFLwy9dUv0kJiaDI8Q5t3rLLy5DPOin4HV3wsM5SOoj8x+XVr2uzsZrs9t6dAqS/9rHWhrVwfvfS0pqdm5x/iUJT89xcoqZ6qPKOAPQiaF8jH6gSdsY/+VYQY1cUwJew== 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=PsrSlE0RqRhNatSH9PeOhP26l7gL422INcqlFJXpfVQ=; b=LEFBTRoKe4aIML4F9vw8qQ7+DiS0eJjCvj7YRZ5att2d24TKSk016jOOXoVyOTbUfRzDaaOiUsA0YVrOkoVvN37a+WYyQeorB9A/Quyr6C4EUeryV/qx6mq3s+F7it4MBPD+JjtxlHX9k3Pm8YX4gwcpo/0FbzC5ScCE7hVF0Eo= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) by DU0PR08MB8279.eurprd08.prod.outlook.com (2603:10a6:10:40d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Tue, 1 Apr 2025 15:48:41 +0000 Received: from AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc]) by AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc%6]) with mapi id 15.20.8534.048; Tue, 1 Apr 2025 15:48:41 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= , Lukas Zapolskas Subject: [PATCH v3 3/7] drm/panthor: Add panthor perf initialization and termination Date: Tue, 1 Apr 2025 16:48:18 +0100 Message-Id: X-Mailer: git-send-email 2.33.0.dirty In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO2P265CA0136.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9f::28) To AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM0PR08MB3315:EE_|DU0PR08MB8279:EE_|DB3PEPF0000885A:EE_|DB9PR08MB7584:EE_ X-MS-Office365-Filtering-Correlation-Id: 351f56e3-20b8-4a1f-80e2-08dd7134b531 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|1800799024|366016|376014|921020; X-Microsoft-Antispam-Message-Info-Original: =?us-ascii?Q?x07Ldoz5JTaEzlT1VGNG27ynOJQMfMCwG1v6+9oaWjGBWinotKq1wgujzzjH?= =?us-ascii?Q?KgDYrinGamGkBsnNTqCSjk3+9w1riOz/Yfa24iwCXEaCIc0+I/+ak2EYBUGA?= =?us-ascii?Q?oWOr4Wu4PHGRLG23bE7ABB1wKY/VkAr5vXhGJomnUZxPyPZGtIHLzhrdZ4UC?= =?us-ascii?Q?IQsPI/gfTguOO64qAkwpR/ssD6Z+iFiGqP5sJkBd3u2wi3vn+xhWLZCjixqt?= =?us-ascii?Q?Xl2jFMAj4aRqiYEYe8B3Xas0HFs7AOppuh8PrwFgytmRNgs7s6ydbv1F9aDj?= =?us-ascii?Q?yZ4b9WyYnNQxolz5gUXFi6Ru7XHSIiKs+xig9doouYXg6FtmQRqMcB1R8U2b?= =?us-ascii?Q?NgkihFtgjqnEJT9ndikZ29I6G6xIfzZ3WiM2wq+oUs6xHDpGeWraHPOpnoTR?= =?us-ascii?Q?IdGy9XOdoH8Dt0TTJUt+zozjijUpfAzFytIHG7L2UTvUec25PNbnldvlpSLQ?= =?us-ascii?Q?vH/d4J3fLqlpo5B8zqU60VaEUDNct5AsbX/Z7bbmtiynTBIhPV+J/PQ+E7dl?= =?us-ascii?Q?gLf7p36OKXW8AjVfcBuPkQuIUuhAKT5FrE7ztFg4Uly1mlNRA7zjneZucKEG?= =?us-ascii?Q?nTlURytp4RVbX4rdM69+bVcgOAyi5rVQ/HihH6w9Ya+5ZuOwFTLiEBidd//H?= =?us-ascii?Q?MDERUv09ihkRTb0CyRBcLCgwfws3DvibgmolX7FMCXPAMChuz9mTSaLGIDW2?= =?us-ascii?Q?dMQVjqzR1dOixJWEpCfjwRxr/d7WgQpwJaIo68jiJz9mo3D87eoXnQ5qJJhx?= =?us-ascii?Q?+37O/IsP27UwyTONzUAuDbHhULh0LNnAHCa3JduRuuEKeJwK/FilqyqMjAxC?= =?us-ascii?Q?Gm/DMrKAV+jpyD0WgZef7wfdgiK0eV/03dw1YKhTLvRCTmhOSWy4dPxJWN8s?= =?us-ascii?Q?AmwTz/qN7jrXsjjZt1pj6iCLgvRKv8vghKpcAYA/k+T3DE/VYKjg7tmHSeVY?= =?us-ascii?Q?eFQEG7BEQjswv6WZKRRo6natL0wTK97mutRQTbnAioVM5Kplh+rfe9I05gF5?= =?us-ascii?Q?iepAV8uLm2vNOaXUqAR8RVSAPG9CFdD3fCnIYrEBvrQaRgelSRKVkV9L01zD?= =?us-ascii?Q?WuVgDefHDSY71mMFWDBNYdSedyrc0A3SxqIbYrnYhud7bf61GTuTXEGLM6bu?= =?us-ascii?Q?mcz8pqnA+VJkeo9DlJTveg6VZfuT22vIIT15bk2eOutSK+Jo5uBJh+u+LDXb?= =?us-ascii?Q?bEDPjWZigBd1TE5AFOk5fePz1s/Irk4vSc/OOptA6SZVwppMySg9+HHFFmx5?= =?us-ascii?Q?otY/jhI6ptcsQ0YTWSJnvItKs5lD+PCrJxKQ6+eELxGf84UuPliS+sP5dcbG?= =?us-ascii?Q?XWhACpXwmaZHEjyb5LGt2OtFYrWQhiqBhhQLpCEWLIdZLX1bD+e0hw37++aV?= =?us-ascii?Q?9h8jNLCMHqI2vxIHXwGMKUrhMubIEPhWOd0vRotW3R4luoxoi307ypSTASrl?= =?us-ascii?Q?3I6oNpFdfMo=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR08MB3315.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8279 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:208:5c::16];domain=AM0PR08MB3315.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB3PEPF0000885A.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4e8c7f37-02f1-421c-9781-08dd7134ad49 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|376014|14060799003|36860700013|35042699022|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?oNrltFpRX/xyxIHx5y7piUXLDr4GbaENSQ2VwPqS43N34siMf5PDK8KdfB/J?= =?us-ascii?Q?2YNgbi5Tiffjd08xpAP1YT5iXKyDn7PAUvKfp4Id3V6tfxthbWNXQxO2UlSz?= =?us-ascii?Q?HKkDObK32oOTP5yn1eQU95BsPGekPLjol2tIcqzJ0mu/RKZLkQOZ5PFS0IVa?= =?us-ascii?Q?FnwYzPVtJCtAkJ19uwnIWKP1iMM0EtzcdpkXbjztrnyXA8jsJWPIrN4XR2Xl?= =?us-ascii?Q?NxDHmpz1j09SXuk6qXz1rci795VlHk/LJT5wseDq42JJAnQz8Jl+o3cj4FEg?= =?us-ascii?Q?GTsGAR2r06tu3FqHFfPsut4s45mg0TsoGnmE7SfJPljDiyW3xNMT1OuiAFtj?= =?us-ascii?Q?BO0ZnLs/GIEMFxfgOsjpFJwKgcYNQ/HkjQHceuSY83p/VvosiGHQLH4zFXQ5?= =?us-ascii?Q?Sw9jYJGTRBQQQekX7uNiqU612N+d+KvyZpn/sr8R+UiFhoTEvgCcBvBdTV21?= =?us-ascii?Q?vKqfxtqzqMH3LQ2uKuRUB7FWG+ix8wonm9LaFY3D2q7tuCKav/PER6utCPlo?= =?us-ascii?Q?y9UVPr1LpsNB2TxWf0fWm4tF+8dYwHHU2W55dVvPssVqalTwCXgf+qs5aLjO?= =?us-ascii?Q?NBfBq3QKu4VSg8vK3wRkU5Yl9Z7WuiBDYmCWdcr8TrNzc1zPVUsR3EGzLZtQ?= =?us-ascii?Q?FWqJ9OfyKSV6xSXll8nw5Gdm1abvG519+Pjj49xxis+CKqLMgAcpGR4CTEuc?= =?us-ascii?Q?VwMkXUIjCCnBHvffPcUAP3r5m6FoEmUwEfUXLHli2X61lz5ow5bfSJrpVNrW?= =?us-ascii?Q?JNAojzXShgE70tnGrjRgJE7FhGI9gDifUrV8C7B3/onUyEhzRzkzzUFcXrl7?= =?us-ascii?Q?+wGvnwzecQduTCO+O6BaYXTws843E9Dn69mH1Y/9LenhowADyiO5EyJ+8dZz?= =?us-ascii?Q?8F8FhVZfo2O7VnlPTTbyHdjlbm91LNRQxvDQncu69Xs8exBFoYaI006g/BJv?= =?us-ascii?Q?Rs9O/UDLukVeQTvhl9/9FKlyZArXvZjk+hzDrYxHmsyqVSMt2i8mHKw/yi9W?= =?us-ascii?Q?mUMvWJO6m8EJxWtuK3xTMsIckh5WuFx6C3N+e5a8Z/mWogN47an6VUbrshug?= =?us-ascii?Q?PBVkliynGPI5KeGaJvpUXzixIYfQ7FFTMb7I7z1LMe68m5JnGyx+LB81h+lh?= =?us-ascii?Q?BrOfqLln1EzULB5vAknaTY1aG3bous+O7CR3Zl4sQWGdNGbRH88awIG+rInE?= =?us-ascii?Q?7wejk/nD/2cHGW1JpaeBEV1aAzaIy0KcDz/kG21GTYYsAAVtQm1vWw1kKXwB?= =?us-ascii?Q?bOGp40UD4dngYTL7LumgbkTUE2KBoQpuiUjJzl4XagkV2dQzbyZiY/JVRfdU?= =?us-ascii?Q?UEyO7EW8Y9qsvu09kbOOM8QVY5EXE4z6g7Ix2MLfHXVdTrBCp/lVsDn7s62S?= =?us-ascii?Q?cDx9UHB3KL56HLk3jG7AIt1C3eyT8CsRJMxuURsjOY8tPFNtFKnjvqAB+I1Y?= =?us-ascii?Q?V11ztfJRY2ilZaCYCs041FliWM1BHlc6EisqwXI9b0K2HYABHajI8WJbc+gS?= =?us-ascii?Q?28+1VTP/BVdhkPA1WRwm10fQT5TtrCv3f9aw3jKtj7XQ6R2uRgOXhiVHMw?= =?us-ascii?Q?=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)(82310400026)(376014)(14060799003)(36860700013)(35042699022)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2025 15:48:54.8636 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 351f56e3-20b8-4a1f-80e2-08dd7134b531 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: DB3PEPF0000885A.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7584 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 | 2 + drivers/gpu/drm/panthor/panthor_device.h | 5 +- drivers/gpu/drm/panthor/panthor_perf.c | 62 +++++++++++++++++++++++- drivers/gpu/drm/panthor/panthor_perf.h | 1 + 4 files changed, 68 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/pan= thor/panthor_device.c index 76b4cf3dc391..7ac985d44655 100644 --- a/drivers/gpu/drm/panthor/panthor_device.c +++ b/drivers/gpu/drm/panthor/panthor_device.c @@ -98,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); @@ -277,6 +278,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 657ccc39568c..818c4d96d448 100644 --- a/drivers/gpu/drm/panthor/panthor_device.h +++ b/drivers/gpu/drm/panthor/panthor_device.h @@ -27,7 +27,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 @@ -138,6 +138,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 b0a6f3fca8a9..7c59c8642b7c 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.c +++ b/drivers/gpu/drm/panthor/panthor_perf.c @@ -9,6 +9,19 @@ #include "panthor_fw.h" #include "panthor_perf.h" =20 +struct panthor_perf { + /** @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, @@ -42,14 +55,61 @@ static void panthor_perf_info_init(struct panthor_devic= e *ptdev) * 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 __free(kfree) =3D NULL; + int ret =3D 0; + if (!ptdev) return -EINVAL; =20 panthor_perf_info_init(ptdev); =20 - return 0; + perf =3D kzalloc(sizeof(*perf), GFP_KERNEL); + if (ZERO_OR_NULL_PTR(perf)) + return -ENOMEM; + + xa_init_flags(&perf->sessions, XA_FLAGS_ALLOC); + + perf->session_range =3D (struct xa_limit) { + .min =3D 0, + .max =3D 1, + }; + + drm_info(&ptdev->base, "Performance counter subsystem initialized"); + + ptdev->perf =3D no_free_ptr(perf); + + return ret; +} + +/** + * 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); + + kfree(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 3c32c24c164c..e4805727b9e7 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.h +++ b/drivers/gpu/drm/panthor/panthor_perf.h @@ -10,6 +10,7 @@ struct panthor_device; =20 int panthor_perf_init(struct panthor_device *ptdev); +void panthor_perf_unplug(struct panthor_device *ptdev); =20 #endif /* __PANTHOR_PERF_H__ */ =20 --=20 2.33.0.dirty From nobody Thu Apr 10 17:52:21 2025 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2052.outbound.protection.outlook.com [40.107.247.52]) (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 371DD20D51A for ; Tue, 1 Apr 2025 15:49:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.52 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522550; cv=fail; b=P8jfQ97mw18/TFP+kODLI7tmcVC+iSoBWgc5DikcWtsT1g+tRU+/UXq9YMhGWArg/QLyhHAzAl2RMQJ99zqb7wcWZtTjU+cqU065e4EUu5Zbl248CWE88m8L0hkfSAUYTOmlv3vWWXopHA40UbdXtp471Mi/J+gayWltcQ7xKJU= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522550; c=relaxed/simple; bh=/oe8DAHU4O6LGkg+JEJFSvhqBKIc9ocOeZmKV1xmm5I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=u9NY+AAgoyDmpNJJGk6dyin4+tujxbQT4k0UCXkhDCJ546NJmGGg2yMrn53vfnw0zqr/CxLvC8Up8V9TUUSbI0DRilsv88rr3I2alm6+Pvx5lbKfDhhe/9BnwpC3pRg5kpUahineY2QyddXnw5at1Nme/9Uu0e44y88JczCsfVk= 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=OnZAAlld; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=OnZAAlld; arc=fail smtp.client-ip=40.107.247.52 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="OnZAAlld"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="OnZAAlld" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=NPBaZ1SL+DTePJFf4uYuQYY15MN8YeSWj20GVBp2Z9Oo5gfbkM6DmWj+bAu36uYfwbga+5YS0rbW73geBEqgJbAbHC5pqLIbIIZaBjSAGc0+3juDKYz8oigsEFANjapz9L8i3W1MJC9RrZ/un6ZeMSA9UVg13VKYBXwLfD3nsim00QDN3WP64CWsxxIwTM5ZoOf+KvRu+mGtusIh+IDMjuWg/5hvNG3FCIb8bikTjI8+VqkUpEcb0DEIq5VP14LkT/jGjUxG3k1TAL2c6011Kw4r8TwvuYj3NkekyQoX+nOFZolOdLMi/VLrfdfdEnxkEHHX2i8RTqTOQw4ib1dTBQ== 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=RvTmlLFGFBXELu+Vla4RX6T96PC61Jm/CYBH+45OSJ8=; b=Px7PjkXLLFK5DPkqzR+2ZnaxGPZJaPq8406xxG1+WRgHPz3trfQetBZjd01Ekugjkk8fXK5s9gk3nwFUkM48rjPO4cK/t8tRyv70TkxdmHLSenlZhYirfep4FSxph04BzinwHsNogGFCucCYW71AVcZaeVxq5bYWnSSlycxwHG7n4G48rMY9SL+9K4ENi7Ni9xjH9peSYhqCJvkv9yHymI63+JefGJ51WDiYokHqSL0UqcKzKQR5SlZSTguyJMXsQAfoicWbBGy/dMgnTywRaZt6rMSy109VRO2Y2cAJ2f2mzqdTzJP7idug70TDQKB9j2ox9Ijw0etNmVdlwFT9lg== 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=RvTmlLFGFBXELu+Vla4RX6T96PC61Jm/CYBH+45OSJ8=; b=OnZAAlld4PaDEkZ21jBCUrZQjfj0kwJv9A6j+NGRxw1oB0pNTigEVnzQMpbhJvm1Y4s4d3tT3+FlIFdg+NdGLD5Pc1JSnP7ZKhvlZXk6dk3CsuI3790unu902l2NJkhGKZOdun2LOZ2i2Urb4ylcwn2f11FYNCEVCZW5yd09SVA= Received: from DU6P191CA0057.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:53e::15) by DBBPR08MB10531.eurprd08.prod.outlook.com (2603:10a6:10:53d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.47; Tue, 1 Apr 2025 15:48:58 +0000 Received: from DU2PEPF0001E9C5.eurprd03.prod.outlook.com (2603:10a6:10:53e:cafe::c3) by DU6P191CA0057.outlook.office365.com (2603:10a6:10:53e::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.54 via Frontend Transport; Tue, 1 Apr 2025 15:48:58 +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 DU2PEPF0001E9C5.mail.protection.outlook.com (10.167.8.74) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.22 via Frontend Transport; Tue, 1 Apr 2025 15:48:58 +0000 Received: ("Tessian outbound eb3c789b7dfa:v604"); Tue, 01 Apr 2025 15:48:58 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7dd1ecdedb246179 X-TessianGatewayMetadata: vFCsPqN8ugEg4uIN2s7M04GkcpuDo58kKuxLYsoxecjnElJym7hcZgqwrBRW2jb7Xvi8x+cqg0MgEZsHZyIiEVNbmzFSxpXWsmYefZW0y3xrsXf3Je7YI5hHRFOYEIthCHALQv0Bd4bkqFGgFDqfU5WrcAe9deRF8aUOwZ/f3DNjAZjIt+LBFJjVpb0DT0JnEEIris8aC1SZ/VwqLdx77Q== X-CR-MTA-TID: 64aa7808 Received: from L44f6bdaecad9.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A5567325-4CDA-4DC1-884E-CCA9F47B57B7.1; Tue, 01 Apr 2025 15:48:47 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id L44f6bdaecad9.2 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 01 Apr 2025 15:48:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g3uuO3iObpV4ajbskJjGj3eiI5BU1cgqsngr+OQwV8vDnxsS8YzMIbog9NoJa+GNlQYiuQruplmzy0L/mXY10c4sOrYh8T5Z1tuo3xiSapMmCjehiWbF2NCaCnuoAHxUoU3LI43cepKgTLexqP0IlTTo4wPK1u/2S0XLXSTpdPRx4y+3WpvoqrMh0IxIKak6NJmTxrIIURzj7yHctuvXR0oyTgn5pnwIEVTUJ/6o31twIJqt0IwJZhPQZvQHazNOaXTwgFrGpLwHVKLEow+vO7OSRONNrPqK0FRcsBTxVpjyx6f1NH5tVLyZrzge9Wiq4GNeRlYYUNfH4To7DUZGRQ== 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=RvTmlLFGFBXELu+Vla4RX6T96PC61Jm/CYBH+45OSJ8=; b=r9Qtcn1da33oRYyOsamYGf9OQSvAtoe9JohuuwBhzbzZAdmPYMz02uqW4LYV+TZh2LsqTKIeuFnxwzan/U6oP6BNEp9mj8422t7/PZY3Bsw1pRks8olkBCyN+gzc8lhBDNpRQqxaintpvB5wX84NVX6r0nHqVpmnWou/n0D2BIUwiNc1I9lWkToZUo1fCj615dAYNB6Srnsf5K9hbxiBENko1DqUqvOvxZLqbCU2JatLmYSBVx4PG6qG2PifQ6tjanxTlSVx3QxkBeQoI4dmqlQtwT/TsnOqjCWuOFzjvrsBzgwbeNXQGluMwUFJ9zkglgshpbiJxrL+jxZAQ1rFaw== 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=RvTmlLFGFBXELu+Vla4RX6T96PC61Jm/CYBH+45OSJ8=; b=OnZAAlld4PaDEkZ21jBCUrZQjfj0kwJv9A6j+NGRxw1oB0pNTigEVnzQMpbhJvm1Y4s4d3tT3+FlIFdg+NdGLD5Pc1JSnP7ZKhvlZXk6dk3CsuI3790unu902l2NJkhGKZOdun2LOZ2i2Urb4ylcwn2f11FYNCEVCZW5yd09SVA= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) by DU0PR08MB8279.eurprd08.prod.outlook.com (2603:10a6:10:40d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Tue, 1 Apr 2025 15:48:43 +0000 Received: from AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc]) by AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc%6]) with mapi id 15.20.8534.048; Tue, 1 Apr 2025 15:48:43 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= , Lukas Zapolskas Subject: [PATCH v3 4/7] drm/panthor: Introduce sampling sessions to handle userspace clients Date: Tue, 1 Apr 2025 16:48:19 +0100 Message-Id: X-Mailer: git-send-email 2.33.0.dirty In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P265CA0250.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:350::12) To AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM0PR08MB3315:EE_|DU0PR08MB8279:EE_|DU2PEPF0001E9C5:EE_|DBBPR08MB10531:EE_ X-MS-Office365-Filtering-Correlation-Id: affdd35d-0171-4b77-e95e-08dd7134b78f 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|1800799024|366016|376014|921020; X-Microsoft-Antispam-Message-Info-Original: =?us-ascii?Q?M711jmkWrXT8bukkSTbeg0kq4ymEQE7zaCWlmryt6R9vbVWthn64zCIuahlr?= =?us-ascii?Q?m/eVjwGhOM0rrMnEFlYO21tGbuC4uasUOTF+UbC6FmyG32Jrzd2FczmUdOO6?= =?us-ascii?Q?67II59tiuHpmWg6h/0J7enQ6XdnGMbPhFH49al5+zjt2ErGPGu0KMiqN7drt?= =?us-ascii?Q?hn37wtXIdfS0R2L7LjZpSFO/tfYlDVNhfwqOF7Lr3mo/GgZKdcDax3nlZmOh?= =?us-ascii?Q?Uwe1zk4wOyu9zcFgdzc+hVbJC5XMUxdur2MmFbd2hjvnnz6S0wHrcaEfWgU7?= =?us-ascii?Q?gaGDRyBuEyrA1wESIXweD4PvoS443XA/iQyorxPT6hssVeARmKY8Erz3jKYJ?= =?us-ascii?Q?wmYostB6wfesa2IxQbBgnGpaIoG3+NdVce7IHq5W7nsFUqc4rB60cOsUpHCX?= =?us-ascii?Q?1NngGFNH2pax3I1krzwjSNVNQN0VO8oBf4POS37CziW9Lzd2LxXoa28RNAV9?= =?us-ascii?Q?vyzVy5o2qPJGRIIZRgn3L+3e7d0dGR1z7hAylKqCNB7uNd1iWIy5h+3oMsKR?= =?us-ascii?Q?jWLsKSaLNkuPfAOk/ArfgmL1rgzq7v/OqJC2laMW7qzXEeRgm5D145LW1TWc?= =?us-ascii?Q?lh/iPV7+GgsUjc96Rukys6PLgW3R5ZxywbQiooM+UThQDrzIPIWkt9CeOtdZ?= =?us-ascii?Q?84u9bGplYjDHAOPyJvuyE60SSIIwSEWO320WMqKrOq6tLq966gZht4bPV3kE?= =?us-ascii?Q?pQoe25W8Ws5WWOo4+wiSf5g1upIQPeopfElbvJ0TMZrtvDVQtVrhBOGI0khW?= =?us-ascii?Q?8W+6qHKzxJtP+HmwgpY4F7B3mf1KvpZ0Jy+WH5/PyfjeAkGesODkgodbXAxa?= =?us-ascii?Q?U5V6Ox0hblytnCrDrtsON8SYRQUdS/hSH70VBO+4Dsmml0A2IH5v4yNjZcmn?= =?us-ascii?Q?cx/bn3vE2ecMPcIgMNHsqLLn87c2ylm7wmZcTi4v5hYIEimd/aYvwyYeGVvO?= =?us-ascii?Q?WwANauLrwiA/TJThLjo6sfIPy2t2s7qrbC1H1BeTVM5k0vB7TyN60x5yvtUy?= =?us-ascii?Q?V2Ng1yVyZRrdhGDPFkcuwG6g9edm84i7UJIv+QxazV1tkAcbbLSH0+Ek80hY?= =?us-ascii?Q?He31QUT1d+RGez/ewo5qynCyrpWYP0tOCYLHGFBdQqfFvhRavqvtfIBQFVAv?= =?us-ascii?Q?LFJmwmNx0cQknL+JoeFnwaoPdjKEg+3LgKmtEIbIIMbMGCp+aSoGpLWeRAHH?= =?us-ascii?Q?6FscFy/KAgGQtkaGn31deuKOt2n5ySBx8nsQgWyUmRDOHdDtKB6B6PBHkI96?= =?us-ascii?Q?M9aaE4VH8CWB+Lmq97oWE63JjeVY9ecuXITrx43tGY8o6+1LXTnIbPyRkjZF?= =?us-ascii?Q?g6txPeOeHM3Mu8nnppdxlMnJVo9N2cA/cC5NfJn/vHjqnG0+l0MnowF3AQhE?= =?us-ascii?Q?pSkcM7clVbZZ0KOuQb4S+NJVlBsCZkVXy2ay+ALIgnSO0Mc1odRLJnlOVOqZ?= =?us-ascii?Q?jVau4TzRgrM=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR08MB3315.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8279 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:208:5c::16];domain=AM0PR08MB3315.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU2PEPF0001E9C5.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 01a195a9-cef7-4837-7423-08dd7134ae8f X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|1800799024|14060799003|35042699022|376014|36860700013|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?diDt4Vy05hLbRVnivPI9aWrvYyA4+BAP/FjH2PY56bxqe4KBkwJN//j/dNRi?= =?us-ascii?Q?aLsRa1ygFHIExPKuTNXdQ5SjXwSA456mMs/rlsMg9McT8nYu6hwq/eVy8z8g?= =?us-ascii?Q?kdz+AdXkCFbinwLGFmj3m1MtLcfsLV1NUqQXYkS5FNTwvCLe/TkBGd/H3GAl?= =?us-ascii?Q?GIhy0Oyy2e3SC+OG21BWd52BfggcUnFPJaC4iXPigrSRi6OCKqfVb+TXUJSA?= =?us-ascii?Q?I0lyUNvgyvMXWcW73i0Q0ILDJLvSKU27CR7vKf0wJ6YVp72wApna++tKS6bL?= =?us-ascii?Q?UcuzyyCg+SdftV8v+FR1GRvxgOcrK0eln/VYP+8/tAtJxzZpqbbeYoDxVcml?= =?us-ascii?Q?elIXy4oi7c2R7alxmG3LUfK7d+qLOnfN4KSC06d9J3LbCuCHzKavjkNInqF6?= =?us-ascii?Q?vNgrYa1DtDtvEJfSe6aVZUtenXGTcd5VtUy4eeIi95k6TkVSt1rHJTEtizWG?= =?us-ascii?Q?GVG64UXLDxSNn9pRvIFs8O7BoSGQApPa/DY5wjwmSauWz9Gzxt7MI/Yz80rf?= =?us-ascii?Q?sLCSWkmU+NyL6GBU8EV/u7/XqJtDBzYofj4fbFltSjQpbIoK0i35XpjB7bTJ?= =?us-ascii?Q?a5SGRcBDJEhtdRGs3Fg1ucI4ICyAYANrzVTMsKuaWXweZXCK0o+TOXLmkaq2?= =?us-ascii?Q?wJG9jh9v1WU8Z1DVfKj6gAK/BWAzCFCvYOTRkwhG9GRA3QyfcH+lFfXy9oZl?= =?us-ascii?Q?/zwCbsLYygEpVavo5tUaLXna3l9nE9U0BBNeKgetFfNKL5O9YEyxQy+ght+0?= =?us-ascii?Q?WyysBImkgRJ4bo3OfB871b2D7m+3rJUVh2jiHIRd3Ov6hJ441vVIB3CFG0GU?= =?us-ascii?Q?97oI6UzHRa++wgLjzlgNM/jC3xOYu3a2BgbqNhQSOHiJyN4JylXyVPmrM1fU?= =?us-ascii?Q?fwQHcWNHSzd+DlUXu3y2NpAapon4jJNyN7f+6wm4h1ZXUrXvjX5d9MCtiqqp?= =?us-ascii?Q?cTcACZI9gW1Wp1eWlcc9N1vfjshrka9XZE9v4VL75h3MW5U9veoSTMhyk9nY?= =?us-ascii?Q?6hFc2bGWfT/sDUYdn3w+dxahnBDrMCWA2Hap5GKQM8ult1u+D5TNVwXAR+2K?= =?us-ascii?Q?Eo13ZGdjbOR89LFZaig5VsuH3TuM6ROwDKYvQrjRjhqkggGpkIre6hHUsjSo?= =?us-ascii?Q?wYRUyeJEqNhAz9HKJb4GZe33Qa2/0Gd+zPV89w3i0y+gWMec6oCy83uKttkr?= =?us-ascii?Q?jntaOJPWtVos6bxE4DUDLG6gAWGvVia8mvqrva2LyZBRZ5XSUZTgS3FLR9N8?= =?us-ascii?Q?k0dRnlscnaQhdSHKwOiJVYuXPre3J46bH+jz6qSeIxY2sj44vC5wEHax0uS8?= =?us-ascii?Q?uzi9F70fY03f01dhCaCqqD32erKHIqtdACPmulEjka48Ie6Z2pJIXw863+jl?= =?us-ascii?Q?c1TrqGUFGwzJ9M5Ljbhlu03LXVOzkXFFb/sCEX2u/KpTWMD6bq55vgPtB7vH?= =?us-ascii?Q?kQLk/5Il/RMZndoqimA2HJgFqCPdlV3hsTIzWx54Hi8cuuO8qBrKdJBFyuBZ?= =?us-ascii?Q?DFVZZsRw8ZywCiN4QO58XrWF4oknfSdolWeJ?= 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)(82310400026)(1800799024)(14060799003)(35042699022)(376014)(36860700013)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2025 15:48:58.8222 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: affdd35d-0171-4b77-e95e-08dd7134b78f 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: DU2PEPF0001E9C5.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB10531 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 protection 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 | 699 ++++++++++++++++++++++- drivers/gpu/drm/panthor/panthor_perf.h | 16 + 4 files changed, 718 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/pan= thor/panthor_device.h index 818c4d96d448..3fa0882fe81b 100644 --- a/drivers/gpu/drm/panthor/panthor_device.h +++ b/drivers/gpu/drm/panthor/panthor_device.h @@ -225,6 +225,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 9d2b716cca45..4c1381320859 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -1356,6 +1356,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 7c59c8642b7c..62c27be4ca8b 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.c +++ b/drivers/gpu/drm/panthor/panthor_perf.c @@ -2,13 +2,177 @@ /* Copyright 2023 Collabora Ltd */ /* Copyright 2025 Arm ltd. */ =20 -#include +#include #include +#include +#include =20 #include "panthor_device.h" #include "panthor_fw.h" #include "panthor_perf.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 { + /** @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, + + /* Must be last */ + PANTHOR_PERF_SESSION_MAX, +}; + +struct panthor_perf_enable_masks { + /** + * @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. + */ + unsigned long mask[DRM_PANTHOR_PERF_BLOCK_MAX][BITS_TO_LONGS(PANTHOR_PERF= _EM_BITS)]; +}; + +struct panthor_perf_counter_block { + struct drm_panthor_perf_block_header header; + u64 counters[]; +}; + +/** + * enum session_sample_type - Enum of the types of samples a session can r= equest. + */ +enum session_sample_type { + /** @SAMPLE_TYPE_NONE: A sample has not been requested by this session. */ + SAMPLE_TYPE_NONE, + + /** @SAMPLE_TYPE_INITIAL: An initial sample has been requested by this se= ssion. */ + SAMPLE_TYPE_INITIAL, + + /** @SAMPLE_TYPE_REGULAR: A regular sample has been requested by this ses= sion. */ + SAMPLE_TYPE_REGULAR, +}; + +struct panthor_perf_session { + DECLARE_BITMAP(state, PANTHOR_PERF_SESSION_MAX); + + /** + * @pending_sample_request: The type of sample request that is currently = pending: + * - when a sample is not requested, the data sh= ould be accumulated + * into the next slot of its ring buffer, but = the extract index + * should not be updated, and the user-space s= ession must + * not be signaled. + * - when an initial sample is requested, the da= ta must not be + * emitted into the target ring buffer and the= userspace client + * must not be notified. + * - when a regular sample is requested, the dat= a must be emitted + * into the target ring buffer, and the usersp= ace client must + * be signalled. + */ + enum session_sample_type pending_sample_request; + + /** + * @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; + + /** + * @accum_idx: The last insert index indicates whether the current sample + * needs zeroing before accumulation. This is used to d= isambiguate + * between accumulating into an intermediate slot in th= e user ring buffer + * and zero-ing the buffer before copying data over. + */ + u32 accum_idx; + + /** + * @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; + + /** @control: The mapped insert and extract indices. */ + struct drm_panthor_perf_ringbuf_control *control; + + /** @samples: The mapping of the @ring_buf into the kernel's VA space. */ + u8 *samples; + + /** + * @pending: The list node used by the sampler to track the sessions that= have not yet + * received a sample. + */ + struct list_head pending; + + /** + * @sessions: The list node used by the sampler to track the sessions wai= ting for a sample. + */ + struct list_head sessions; + + /** + * @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 { /** @next_session: The ID of the next session. */ u32 next_session; @@ -51,6 +215,118 @@ static void panthor_perf_info_init(struct panthor_devi= ce *ptdev) perf_info->shader_blocks =3D hweight64(ptdev->gpu_info.shader_present); } =20 +static struct panthor_perf_enable_masks *panthor_perf_create_em(struct drm= _panthor_perf_cmd_setup + *setup_args) +{ + struct panthor_perf_enable_masks *em =3D kmalloc(sizeof(*em), GFP_KERNEL); + 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_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; +} + +static size_t get_annotated_block_size(size_t counters_per_block) +{ + return struct_size_t(struct panthor_perf_counter_block, counters, counter= s_per_block); +} + +static u64 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->control->extract_idx); +} + +static u64 session_read_insert_idx(struct panthor_perf_session *session) +{ + return session->control->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 && session->ring_buf) { + 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->control && session->control_buf) { + struct iosys_map map =3D IOSYS_MAP_INIT_VADDR(session->control); + + drm_gem_vunmap_unlocked(session->control_buf, &map); + drm_gem_object_put(session->control_buf); + } + + eventfd_ctx_put(session->eventfd); + + kfree(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) +{ + struct panthor_perf_session *session; + + 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; +} + /** * panthor_perf_init - Initialize the performance counter subsystem. * @ptdev: Panthor device @@ -88,6 +364,421 @@ int panthor_perf_init(struct panthor_device *ptdev) return ret; } =20 +static size_t session_get_user_sample_size(const struct drm_panthor_perf_i= nfo *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->fw_blocks + + info->tiler_blocks + info->memsys_blocks + info->shader_blocks; + + return sizeof(struct drm_panthor_perf_sample_header) + (block_size * bloc= k_nr); +} + +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) { + drm_err(&ptdev->base, "Did not meet requirements for set %d\n", + setup_args->block_set); + return ret; + } + + session =3D kzalloc(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) { + drm_err(&ptdev->base, "Could not find handle %d!\n", setup_args->ringbuf= _handle); + ret =3D -EINVAL; + goto cleanup_session; + } + + control =3D drm_gem_object_lookup(pfile->drm_file, setup_args->control_ha= ndle); + if (!control) { + drm_err(&ptdev->base, "Could not find handle %d!\n", setup_args->control= _handle); + ret =3D -EINVAL; + goto cleanup_ringbuf; + } + + user_sample_size =3D session_get_user_sample_size(&ptdev->perf_info) * sl= ots; + + if (ringbuffer->size !=3D PFN_ALIGN(user_sample_size)) { + drm_err(&ptdev->base, "Incorrect ringbuffer size from userspace: user %z= u vs kernel %lu\n", + ringbuffer->size, 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(session->eventfd)) { + drm_err(&ptdev->base, "Invalid eventfd %d!\n", setup_args->fd); + 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->sessions); + INIT_LIST_HEAD(&session->pending); + + session->control =3D ctrl_map.vaddr; + *session->control =3D (struct drm_panthor_perf_ringbuf_control) { 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; + } + + ret =3D xa_alloc_cyclic(&perf->sessions, &session_id, session, perf->sess= ion_range, + &perf->next_session, GFP_KERNEL); + if (ret < 0) { + drm_err(&ptdev->base, "System session limit exceeded.\n"); + ret =3D -EBUSY; + goto cleanup_em; + } + + kref_init(&session->ref); + session->enabled_counters =3D em; + + session->sample_freq_ns =3D setup_args->sample_freq_ns; + session->user_sample_size =3D user_sample_size; + session->ring_buf =3D ringbuffer; + session->ringbuf_slots =3D slots; + session->control_buf =3D control; + session->pfile =3D pfile; + session->accum_idx =3D U32_MAX; + + return session_id; + +cleanup_em: + kfree(em); + +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: + kfree(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 0; + + 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; + + 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 (READ_ONCE(session->pending_sample_request) =3D=3D SAMPLE_TYPE_NONE) + 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; + + if (!pfile || !perf) + return; + + xa_for_each(&perf->sessions, sid, session) + { + if (session->pfile =3D=3D pfile) { + session_destroy(perf, session); + xa_erase(&perf->sessions, sid); + } + } +} + /** * panthor_perf_unplug - Terminate the performance counter subsystem. * @ptdev: Panthor device. @@ -103,8 +794,14 @@ void panthor_perf_unplug(struct panthor_device *ptdev) return; =20 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!"); + + xa_for_each(&perf->sessions, sid, session) + session_destroy(perf, session); } =20 xa_destroy(&perf->sessions); diff --git a/drivers/gpu/drm/panthor/panthor_perf.h b/drivers/gpu/drm/panth= or/panthor_perf.h index e4805727b9e7..89d61cd1f017 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.h +++ b/drivers/gpu/drm/panthor/panthor_perf.h @@ -7,10 +7,26 @@ =20 #include =20 +struct drm_panthor_perf_cmd_setup; struct panthor_device; +struct panthor_file; +struct panthor_perf; =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 --=20 2.33.0.dirty From nobody Thu Apr 10 17:52:21 2025 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2079.outbound.protection.outlook.com [40.107.103.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 3625820C01C for ; Tue, 1 Apr 2025 15:49:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.79 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522545; cv=fail; b=EiVghTXxx0hhb3QLUT+vrWptgJdxlJSiJmkkIFLIoz8MuHUYNmV1IutOjqQT68qLEKvOuzaw5T3eZZ0IAZUFQ7gGyKcnEt/yMB2mJH7/dwdSkq9IDuhmkkIlCPyrHEreUGUnBOwCbQQeqBByjlXOe9M0qAoZRMN4CxjLkTyzW0I= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522545; c=relaxed/simple; bh=WiGnc/oHVHo3rh+RTwPN264cefsv3c3kmh90bR6TsKQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Ut2MHFH/gAKGflO/5SAFBdW2DkgI3LENOwPKTykm8+Ng/FVCLWToLKKYtDwkHid68G8UjQS9DbeEHCUwOAr8OBcyQnW3N6BDPfxZjtLvMgM33Wuo1n99Zz35UR6xZ+AxFxwYgreVOkjgN6RxbBRog4wVPCqRwnAhJxqmAf28JRI= 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=gzWnZxrv; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=gzWnZxrv; arc=fail smtp.client-ip=40.107.103.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="gzWnZxrv"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="gzWnZxrv" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=QutHqiQK7IEH9vHRsy32xlTPvfNWft7EzFq8EVRauIPD83l3no1Fn46MOyQsxfGER2dpDNmbFmbQcwGwXHQM7AuC+yMa1+T0PRbVkqtjl9guKx4deB7/SBtfuAKg7gDcpPN1+Zg7/cAOEJAXaIZmynAJUkz7gJxLSCSTE8gZBXp5cwmZN7V7puz5urYnU4jkA///O33wOeWwK9bkPKI90hwHVPAa5iyhJmbSGdHEcaoSCVXwiEc/GlwHLyl4l8TQLjDt0QZmA47Gz04j9IYdUro56d8wStAVz6teu2hsChEnaoMwuhbnUFhK/SpLys6gMfJn67MZkor7v0gjCYhQxQ== 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=vVw6zSBmuroZtDsYPtebpCt1IHkaWMqXjpRGigkASfg=; b=ooZj/IktceNZuKM5LDx8RlNFTnzXXF5UdU4uZwXcKudbX/irFgG2euapDbI6oaWVyyyp4adGQUC5n0t6XIDBErtJRKhn+uEhgQs/InleqhlcesQe4v61QcfT7+fKYBSyDUvS8sjxQ9kzr1EMxGTTLH1UNPg/6Po4exA4cYxhdfcoRY9ZlD1R0qm2WJf3vRDNywMPxiH1fofvtLC0Gvq/iooG5awqtCaaWdbjn7ggTZuvUy4BxcMa7AE1UB+U2AKrnnB4zCDvAxzfKbWAvusm7gC5M7I8pHLWPKXnJGMJ9OgCLKJIPtWtwGbVkbnv92bPHqPef0q3S54RVdhdvPRDZQ== 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=vVw6zSBmuroZtDsYPtebpCt1IHkaWMqXjpRGigkASfg=; b=gzWnZxrvGXf03WV5+b7VXmqrlomxbOqNKcOeRYT0rOCAC8tThUKE+EZ302drBygySd0wD5LQD7k6FjR+U3kNahsaA8wnWRDWlyFW2VGa24oNtvTgB3XtExqRwybIhQwk8ie3DvOsh7QBHyisy7MofPjOFT5z0ZxhDs5llfFDWlU= Received: from DUZP191CA0052.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:4fa::15) by DB9PR08MB6347.eurprd08.prod.outlook.com (2603:10a6:10:253::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.47; Tue, 1 Apr 2025 15:48:56 +0000 Received: from DU6PEPF0000B620.eurprd02.prod.outlook.com (2603:10a6:10:4fa:cafe::fa) by DUZP191CA0052.outlook.office365.com (2603:10a6:10:4fa::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.54 via Frontend Transport; Tue, 1 Apr 2025 15:48:56 +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 DU6PEPF0000B620.mail.protection.outlook.com (10.167.8.136) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.22 via Frontend Transport; Tue, 1 Apr 2025 15:48:55 +0000 Received: ("Tessian outbound 5d826d745fa9:v604"); Tue, 01 Apr 2025 15:48:54 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 00ed9207f3ca2475 X-TessianGatewayMetadata: kPPU1iEXddXGzvDPQKXA/isw97cw37KURDumgYaN+wNFBqXoA/t01+KxbcuP1YAodhNzlevWHDXVtqfuWnk6WYA1LL98V+wXkVBW/k6vWQUffTLNSsv/c0HU+Cpt4S7sTSY8QYZOaIfx5nHUAKQeFWbjD/wzf3iuio/dArGCIbnN4YITq/Lc0yVzhygUfQ7h+pPPMHW7P1SJWZIooL0J7A== X-CR-MTA-TID: 64aa7808 Received: from L30764a9a19e4.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 674FE753-E8AA-4FA8-A706-EC228DB0FE3C.1; Tue, 01 Apr 2025 15:48:47 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id L30764a9a19e4.2 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 01 Apr 2025 15:48:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hPq6/pcA7lIvVlfIeMhqrna3pOLHC9zPhdui1/0gNtP3WrcnFi6B7tzhAAUbKhKuwOPhLV/NwaDZP1Qs7BWHjQ4zW7OEmXVvTsw1ygeYXYwlILqBSXxG/h4fsehUGWN56/Oi110C62NC3bXzIjdajwc4HFLi51sxCBo5JuXj6KvfrvvZfjopFP8Bz0QjGSMknWODolBVVtS1rqdtCy3iH/hxRBZUM9BkxuCjyZAfDkphMt3LzYGZxJj9sIJq/iwJ2wmspk1/uCLP4CdSsMbHrKSpnQpaXDLdEr9OrGsUry22hdoWPSQ4XRy4bGnjnt4Gg8ghLiCQI/AJ0lD1+3kJHQ== 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=vVw6zSBmuroZtDsYPtebpCt1IHkaWMqXjpRGigkASfg=; b=sE4wQ5H5TjHKCWYgNERcza9IfEeFAhvMUai3Bcbjsg50vv8YkTGHzj5QssYeoiJhzFmo25coGGeILh7/PG7fMOhvWVr6r7tHJil2JKFz0F6ytwepC71UhARVDbOdc+29ikSaFVGLP02brGMvdtpl0j6ymVUQ96EZ52fhnm5CDW/gpG0QRs5hmPeyn7K0UG+i+uNcYejozT71vLVo9VeJJHeTNmLk+fy/cA2vUzfPgT9LtM0I4vRCztzxrqST/rMG/73XM7GLTIOJ2KQYmYfsufo/aUFIv4wbSpl2gTuAtSh+TouPFDFDiHDUlMbIBmeFdS2EX0qFmiS8IEBBfnpznA== 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=vVw6zSBmuroZtDsYPtebpCt1IHkaWMqXjpRGigkASfg=; b=gzWnZxrvGXf03WV5+b7VXmqrlomxbOqNKcOeRYT0rOCAC8tThUKE+EZ302drBygySd0wD5LQD7k6FjR+U3kNahsaA8wnWRDWlyFW2VGa24oNtvTgB3XtExqRwybIhQwk8ie3DvOsh7QBHyisy7MofPjOFT5z0ZxhDs5llfFDWlU= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) by DU0PR08MB8279.eurprd08.prod.outlook.com (2603:10a6:10:40d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Tue, 1 Apr 2025 15:48:45 +0000 Received: from AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc]) by AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc%6]) with mapi id 15.20.8534.048; Tue, 1 Apr 2025 15:48:45 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= , Lukas Zapolskas Subject: [PATCH v3 5/7] drm/panthor: Implement the counter sampler and sample handling Date: Tue, 1 Apr 2025 16:48:20 +0100 Message-Id: X-Mailer: git-send-email 2.33.0.dirty In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P123CA0583.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:276::13) To AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM0PR08MB3315:EE_|DU0PR08MB8279:EE_|DU6PEPF0000B620:EE_|DB9PR08MB6347:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fcd1be7-ef72-4831-c86e-08dd7134b589 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|1800799024|366016|376014|921020; X-Microsoft-Antispam-Message-Info-Original: =?utf-8?B?bnJpY0t1bG1ha2dMZ2NvYzF2SzFVd1F0N2pCQm9xYUNoZkpQaGV0SFU1dmdJ?= =?utf-8?B?SjdjcWhoTUsvZ2tVMG42SXRkQzY0SGc3MkREdGZ5RmhLVUVlVjlodWtvTEhN?= =?utf-8?B?ZDE0SkZieHJHZng0blczYUVUa0dNSkttTm1JOGZESU94cGZHaGZsYllhVlZP?= =?utf-8?B?eU1aYS9sVWdYY0YzV2dRYkJlQWdaTnhxSytwNGVBeVc2UTlzMElveVArL3Iw?= =?utf-8?B?MG1BbFl2ZFNHUDY3alVNZk11ektZMUJyRS9lTDVxRWxIa2dtVkFwcDk3RWJu?= =?utf-8?B?WWRya0F1R3dmanl1S1NwUnc2OUo3RHc4RDlObjBGcVpEeVZXak05NS9hd0Vi?= =?utf-8?B?clZZRVpHMC84L1JVcEoxVFRuUTgzTXFGNit6UGZ3ME5zK094V1IzemYzWFhG?= =?utf-8?B?K3VSTmxONGNUaVhVaW0vYi9NM1hjdUJ6YVNlVVEzVGdoMDV1bGxSNmppbjJw?= =?utf-8?B?NmcyMWNNNm5rdEx6OHZhWjRvWkZrZmJPd0IzeEFZSjhwUEl3UXpYTjBBaUVw?= =?utf-8?B?MVFXYjhCN0x2VkxOUTF1dkxxK0YyclBtQ2RxaWJUMk1qNDBNRi96TFZUbXRk?= =?utf-8?B?b0lKc2xKN3RQMFVMMGpFSjNCREoyZjVzYisyMWErNWFSS3AxOFJ2TitmWW9i?= =?utf-8?B?ZXFORHdkdlZOeHFTd3NTU21Ma3JxWUtFMDdUQ05QdlFLMmNvdXpTRll3UXA5?= =?utf-8?B?VGVqWklBbjVUNHVOakk3eVpqZmN0VUMxOXkvbTRYU1hRa2FJWGdQaldzOXY1?= =?utf-8?B?OXpVa25xbDZSNzgyQ0o5YkR1eEFsZEViSkN4aGhDWVQ0RGdxSjRWVFFzdjJ5?= =?utf-8?B?azBOSW5IVkJBZHlOS050SW1PWERTMnAxUGpOTzJqYmVvL2JWSGk5V0hsSEFQ?= =?utf-8?B?VnhGWmt5N0pmcHVHbGkzbDJFRS9Rb2JldHdPTnRvN3RIbXR2S2RMc3hVOTFT?= =?utf-8?B?d1M2UERaUEhPU1ZGQ0tLNG12VzRhQTBKdUxHalZlc0pKV0NOMzB5Vk1JNVM4?= =?utf-8?B?VVkyNm9Jb3ZuVUdNcFdDQ3N0V0F4QjJUcDFGT1BnRHc0eXNkU2UwQkdNZllT?= =?utf-8?B?bGZNZjRoS21qY0ZrbUV4VE55UG8xTzNaV2ZVbEFIQytqbERyZUFua092NkJH?= =?utf-8?B?OWdqVXdIMGd1YTJBWGI4V0xBa1FwNGNEaVAwWXd1QWNmcitlRlFNUEdTRzMy?= =?utf-8?B?YngrZmFqSy9JTG9lWk94bUp6cVN6aDdKNnU0MU44dnlQa3lmNVoySEUrQlk3?= =?utf-8?B?WEUzMG44WGlHVUpyQWs2aklzaXVjckcwZy96ZXY3SFllODRFL0JmZHRCL21u?= =?utf-8?B?YlZoblpDM2VMdytmSXp4NzZlNitxQ1ZaMjFueFJUNTM5eXl6ZVNnNFY0cVZU?= =?utf-8?B?MlBnWE5XN2oyMnFSVlBSY2tWaG5UTlVIYTJzK3F3RDlWOHVnbzFxTGVQelZ5?= =?utf-8?B?RnQxYTdPOTQ2aXpjbnpFZ003Rkt2OTNuZ1dhZC9TR3U3NE9GU0RnWXVXbmln?= =?utf-8?B?ay9TNGFrUklvbzdSSjV2TWRBalJLQUdIeUgvbXEra1pXL2szMXhnQ2N4OFVr?= =?utf-8?B?WGJlcFhwN3ZRQlp3TWFhR0Z3djJ3b09zK2ZUNWtKYkVzaDB0VXZOWVVkWUdE?= =?utf-8?B?Vlhla2IwZnh6Q05BYTNES1lNeTBGMHlkRTdqYjVzVDRnSVZBSGpZVEF5ZXFp?= =?utf-8?B?aTRKdWFUQ1JZUWxUaks1aUJkdlptWGhKRGVkaXI3ai9ib25TaXBjRVJUdjN2?= =?utf-8?B?dENGVS8zY1VpOUdocnJpNnNHSUxRNjVudlNXbUo1RmNEV2F1M2lodk1JK3Fl?= =?utf-8?B?UStrcC9jT2w3QjFKb0cxYlJIdmdyZ3FLQXRncWdrcnBURk5Ma3FYMldlUDEv?= =?utf-8?B?dDRmNnkvR3JMMTl5dHB4SUtubm1zbE9rMTRZWVoxb25tN3MyUVhIZ1Y5dlc2?= =?utf-8?Q?ESLvEM9d4sA=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR08MB3315.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8279 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:208:5c::16];domain=AM0PR08MB3315.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU6PEPF0000B620.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 0760bd2f-bc63-42b4-6978-08dd7134afbc X-Microsoft-Antispam: BCL:0;ARA:13230040|35042699022|82310400026|14060799003|36860700013|376014|1800799024|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?B?RFVyR0N6Z0U0UDhMaW10NE44MFZSc2NxU3JrY1ZHa0VCUVVIb0E1WnloTysw?= =?utf-8?B?UVc3SklQNFQ4TnBxaXhEY2FJWUJYV0ttM0pCdVJnc2xoYzA5UzErbFVmMmUw?= =?utf-8?B?UFhaUVZua25xVFlaeWlTQ1h0QmNHUUs2UVpzWTZrSlZHaE1PZ2ZzM2tLVUpm?= =?utf-8?B?d2NBMjdYSVlXU0F3MWNPY2MzekxKdnhmSFJUcGVVcWFoeXBDV2VJMmhTRGZn?= =?utf-8?B?SHhvQkJtbWJRbUErM1Q1aVlPMmxReURyQWxQSE5FdWoyeHd1K05jejJhSHdP?= =?utf-8?B?aE8yVXNDb3drWTQvS1MxZDYyWjlrVm43R2ltRjlNUmpvYkxPeUxEcjNmVU1C?= =?utf-8?B?YVdsbExuR1NEUTZwT2JkYW8vUXJ5dzA5WG9jWnZScFIyTE5EdVBSNmVpd1lC?= =?utf-8?B?NTU1bHVtV2h5VVlCT1hKajUxR0szNEw5a3ltam81VXJtVXM4dVJVUXlRUjNX?= =?utf-8?B?dlJCbFZRc1hwMmVTd3RJSlEvdXc1M2t6azk5RXRxQkZLMXFmU1EyekNybXBZ?= =?utf-8?B?QURsZzByU1BmTXNKb2xDem1QcGpkS0daS29FdEVMZ3paTC9lenV2RnZ3UHNS?= =?utf-8?B?RlRwa05kTnBXaXdMdzNuNlByL0QyQ0piTy83S25HeEJOOVlGMWNVTU01em81?= =?utf-8?B?U0MrMFBxdXdxZk1sRXkzQ0paTTlZeXdMVnByYVV6dzVQMUJycUNwOTNTVGk0?= =?utf-8?B?QVFCdnpEVUxURHljazVtQ3hKT3E3bThRU3ZDN3pJTzdLY3I1TG9NZ0pqaVc5?= =?utf-8?B?RXBuQ3h2aDNpaWpZRGFqakdYOVFQTUdHUGFBUng1WmFJbmtMNmV3MzVFVlJz?= =?utf-8?B?Szk3dDVibS8wcCs0RFVrTkppUzVsb05NdGVhUVRucFFnWGxFaGRmT2dIekFz?= =?utf-8?B?Tm1vVnhaOXMvUDUxMmprcStzTWVUbUV0QTRveHpwMDgzVVNXY1JLSXMzTlhC?= =?utf-8?B?amw3YUEvQVljdXdKci9RRWR6VnNDbUtudzhIV09kU0RsMEp6Mnd1SFVuY2tI?= =?utf-8?B?NTdUYnQrbURYbVFIVFpHcjZVemRtR1oxYmIrVGE1YTRKTnFFS3Q4NHUrUGRO?= =?utf-8?B?UjRERW5kSUxaK2JKbEFUZU83RjNEZVZZT2RXNXIvSWo3MmxqNEVuN2RWbFFP?= =?utf-8?B?c29oYjNDc0NyTWVKeFBYQ3BMZUJ6WDFncDVGbWg2aTlKSnJIZG4rZk1yY3lE?= =?utf-8?B?M3duMEdYT3h0ckdyNlBMY2xUTzdybkVvaFZYWkcvVGdQOVd3dFl2MGE2WjZm?= =?utf-8?B?ZmM3TWo4bDJIRmQ4RGdCTmxaNS80R1BHVHZyTFRsUEExQmRXNUhqNmN6NjVP?= =?utf-8?B?cisrcCtDZ1V3T216NWFpc2duK3k4c0ZWL2hPcXZDYzlJbGczaU44WmtHNFBm?= =?utf-8?B?b3h6RmdIUk9PZnZpblR1OVJ4c0N4NFhJSU0xbm9wcVpGRklxeWt4ZlNrQ29w?= =?utf-8?B?aUpRdHRjNEptUGtJNkllR3lSZkt2Tkw5ZFhjQkpacTNGQ3FwbzNjNVhOTVAv?= =?utf-8?B?dElROWNoMFpYd0k4d3RYd2ZxZGd6Q1gxQ0w1WEdHdm5CeG4vZSttZklzd1RQ?= =?utf-8?B?cXVUcVJodDN2NTRWZ1Uxb2NpY255ZGgwVkZObkZSd2FlZXhtc1hxT0YxSzhR?= =?utf-8?B?elhsL1NRRmJIaWRjdXFiWS84bzJ3MmgrZ1NONWFGYVV1d3A4STVkTlgvZzZh?= =?utf-8?B?czgwVkM1bHZDVnJNMTBDZE1zQzRnMkFicTRucnZuYVZtVTdNVSsrbGZDMGZm?= =?utf-8?B?NkVHd0k2TGV3UVh4dlZVYmcvRitNdXFoWk1GSTdmWmJmUWx0R2Z2T2VGSTBJ?= =?utf-8?B?THpqaCt4R1FPNEVjUDJBU3AyNjg5VGd6YmZmTlY3VzltWGl1QkU0b1AxVjNJ?= =?utf-8?B?a2xSZkc1eTVKNnZnV0gxQmRaNkJYcHJ1QlZUQlhwdWovVzhnb1VUNkRwUjFh?= =?utf-8?B?a1VoL3E5WmlaOEI4TWRVNmtDdUx6QUt3NDlZejlCUFhzV0hzaEMzY0ZQU0M4?= =?utf-8?B?MWZtS1Z5akRTbHdBSE1XRzRld1kyK0I3WG0ybHR3SzdLbzcra01taENiaWFV?= =?utf-8?Q?GJtlgU?= 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)(35042699022)(82310400026)(14060799003)(36860700013)(376014)(1800799024)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2025 15:48:55.4266 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fcd1be7-ef72-4831-c86e-08dd7134b589 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: DU6PEPF0000B620.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6347 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. This buffer descriptor also handles the sparseness of the shader cores, wherein the physical core mask contains holes, but the memory allocated for it is done based on the position of the most significant bit. In cases with highly sparse core masks, this means that a lot of shader counter blocks are empty, and must be skipped. The number of ring buffer slots is configurable through module param to allow for a lower memory footprint on memory constrained systems. Signed-off-by: Adri=C3=A1n Larumbe Co-developed-by: Lukas Zapolskas Signed-off-by: Lukas Zapolskas --- drivers/gpu/drm/panthor/panthor_fw.c | 6 + drivers/gpu/drm/panthor/panthor_fw.h | 6 +- drivers/gpu/drm/panthor/panthor_perf.c | 1066 +++++++++++++++++++++++- drivers/gpu/drm/panthor/panthor_perf.h | 2 + 4 files changed, 1059 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor= /panthor_fw.c index 0f52766a3120..e3948354daa4 100644 --- a/drivers/gpu/drm/panthor/panthor_fw.c +++ b/drivers/gpu/drm/panthor/panthor_fw.c @@ -22,6 +22,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 @@ -987,9 +988,12 @@ static void panthor_fw_init_global_iface(struct pantho= r_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 @@ -1018,6 +1022,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 8bcb933fa790..5a561e72e88b 100644 --- a/drivers/gpu/drm/panthor/panthor_fw.h +++ b/drivers/gpu/drm/panthor/panthor_fw.h @@ -198,6 +198,7 @@ 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)) << 8) @@ -210,7 +211,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) @@ -243,6 +244,9 @@ struct panthor_fw_global_input_iface { u64 perfcnt_base; u32 perfcnt_extract; u32 reserved3[3]; +#define GLB_PERFCNT_CONFIG_SIZE(x) ((x) & GENMASK(7, 0)) +#define GLB_PERFCNT_CONFIG_SET(x) (((x) & GENMASK(1, 0)) << 8) +#define GLB_PERFCNT_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 62c27be4ca8b..3cb79b999886 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.c +++ b/drivers/gpu/drm/panthor/panthor_perf.c @@ -9,7 +9,11 @@ =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 /** * PANTHOR_PERF_EM_BITS - Number of bits in a user-facing enable mask. Thi= s must correspond @@ -18,6 +22,81 @@ */ #define PANTHOR_PERF_EM_BITS (BITS_PER_TYPE(u64) * 2) =20 +/** + * 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) + +/** + * PANTHOR_CTR_SAMPLE_REASON - The metadata block has a single value in po= sition three which + * indicates the reason a sample was taken. + */ +#define PANTHOR_CTR_SAMPLE_REASON (3) + +/** + * PANTHOR_HW_COUNTER_SIZE - The size of a hardware counter in the FW ring= buffer. + */ +#define PANTHOR_HW_COUNTER_SIZE (sizeof(u32)) + +/** + * PANTHOR_PERF_RINGBUF_SLOTS_MIN - The minimum permitted number of slots = in the Panthor perf + * ring buffer. + */ +#define PANTHOR_PERF_RINGBUF_SLOTS_MIN (16) + +/** + * PANTHOR_PERF_RINGBUF_SLOTS_MAX - The maximum permitted number of slots = in the Panthor perf + * ring buffer. + */ +#define PANTHOR_PERF_RINGBUF_SLOTS_MAX (256) + +static unsigned int perf_ringbuf_slots =3D 32; + +static int perf_ringbuf_slots_set(const char *val, const struct kernel_par= am *kp) +{ + unsigned int slots; + int ret =3D kstrtouint(val, 0, &slots); + + if (ret) + return ret; + + if (!is_power_of_2(slots)) + return -EINVAL; + + return param_set_uint_minmax(val, kp, 16, 256); +} + +static const struct kernel_param_ops perf_ringbuf_ops =3D { + .set =3D perf_ringbuf_slots_set, + .get =3D param_get_uint, +}; +module_param_cb(perf_ringbuf_slots, &perf_ringbuf_ops, &perf_ringbuf_slots= , 0400); +MODULE_PARM_DESC(perf_ringbuf_slots, + "Power of two slots allocated for the Panthor perf kernel-FW ringbuffer= "); + 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, @@ -63,6 +142,122 @@ enum session_sample_type { SAMPLE_TYPE_REGULAR, }; =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; + + /** @block_count: Number of blocks of the given @type, starting at @offs= et. */ + size_t block_count; + + /** @phys_mask: Bitmask of the physically available blocks. */ + u64 phys_mask; + } 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 { + /** + * @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_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; + + /** @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 and the sampler= configuration. + * In particular, it guards the @session_list and the @em. + */ + struct mutex sampler_lock; + + /** @session_list: List of all sessions. */ + struct list_head session_list; + + /** @pend_lock: Lock used to guard the list of sessions with pending samp= les. */ + spinlock_t pend_lock; + + /** @pending_samples: List of sessions requesting samples. */ + struct list_head pending_samples; + + /** @sample_requested: A sample has been requested. */ + bool sample_requested; + + /** @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; +}; + struct panthor_perf_session { DECLARE_BITMAP(state, PANTHOR_PERF_SESSION_MAX); =20 @@ -184,6 +379,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 /** @@ -216,7 +414,7 @@ static void panthor_perf_info_init(struct panthor_devic= e *ptdev) } =20 static struct panthor_perf_enable_masks *panthor_perf_create_em(struct drm= _panthor_perf_cmd_setup - *setup_args) + *setup_args) { struct panthor_perf_enable_masks *em =3D kmalloc(sizeof(*em), GFP_KERNEL); if (IS_ERR_OR_NULL(em)) @@ -236,6 +434,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_FIRST; i <=3D DRM_PANTHOR_PERF_BLOCK_LA= ST; 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_FIRST; i <=3D DRM_PANTHOR_PERF_BLOCK_LA= ST; i++) + bitmap_zero(em->mask[i], PANTHOR_PERF_EM_BITS); +} + static size_t get_annotated_block_size(size_t counters_per_block) { return struct_size_t(struct panthor_perf_counter_block, counters, counter= s_per_block); @@ -249,6 +464,12 @@ static u64 session_read_extract_idx(struct panthor_per= f_session *session) return smp_load_acquire(&session->control->extract_idx); } =20 +static void session_write_insert_idx(struct panthor_perf_session *session,= u64 idx) +{ + /* Userspace needs the insert index to know where to look for the sample.= */ + smp_store_release(&session->control->insert_idx, idx); +} + static u64 session_read_insert_idx(struct panthor_perf_session *session) { return session->control->insert_idx; @@ -301,7 +522,7 @@ static void session_put(struct panthor_perf_session *se= ssion) * 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) + struct panthor_perf *perf, u32 sid) { struct panthor_perf_session *session; =20 @@ -327,6 +548,738 @@ static struct panthor_perf_session *session_find(stru= ct 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. + * + * Return: True if the current block is available, false otherwise. + */ +static bool 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)) { + const unsigned long phys_mask[] =3D { + BITMAP_FROM_U64(desc->blocks[id].phys_mask), + }; + const size_t pos =3D + div_u64(offset - desc->blocks[id].offset, desc->block_size); + + *type =3D id; + + if (test_bit(pos, phys_mask)) { + const u64 mask =3D GENMASK_ULL(pos, 0); + const u64 zeroes =3D ~desc->blocks[id].phys_mask & mask; + + *idx =3D pos - hweight64(zeroes); + return true; + } + return false; + } + } + + return false; +} + +static size_t session_get_user_sample_size(const struct drm_panthor_perf_i= nfo *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->fw_blocks + + info->tiler_blocks + info->memsys_blocks + info->shader_blocks; + + return sizeof(struct drm_panthor_perf_sample_header) + (block_size * bloc= k_nr); +} + +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->desc.buffer_siz= e; + + 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 =3D 0; + enum drm_panthor_perf_block_type type =3D 0; + DECLARE_BITMAP(expanded_em, PANTHOR_PERF_EM_BITS); + struct panthor_perf_counter_block *blk =3D + (typeof(blk))(perf->sampler.sample + ann_off); + u32 *const block =3D (u32 *)(fw_sample + fw_off); + const u32 prfcnt_en =3D block[PANTHOR_CTR_PRFCNT_EN]; + + if (!panthor_perf_block_data(&sampler->desc, fw_off, &idx, &type)) + continue; + + /** + * TODO Data from the metadata block must be used to populate the + * block state information. + */ + if (type =3D=3D DRM_PANTHOR_PERF_BLOCK_METADATA) { + /* + * The host must clear the SAMPLE_REASON to acknowledge it has + * consumed the sample. + */ + block[PANTHOR_CTR_SAMPLE_REASON] =3D 0; + 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); + + /* + * 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]; + + /* + * The host must clear PRFCNT_EN to acknowledge it has consumed the sam= ple. + */ + block[PANTHOR_CTR_PRFCNT_EN] =3D 0; + + 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, __type, __blk_count, __ph= ys_mask, __offset) \ + ({ \ + (__desc)->blocks[(__type)].offset =3D (__offset); \ + (__desc)->blocks[(__type)].block_count =3D (__blk_count); \ + (__desc)->blocks[(__type)].phys_mask =3D (__phys_mask); \ + if ((__blk_count)) \ + set_bit((__type), (__desc)->available_blocks); \ + (__offset) + ((__desc)->block_size) * (__blk_count); \ + }) + +static size_t get_reserved_shader_core_blocks(struct panthor_device *ptdev) +{ + const u64 sc_mask =3D ptdev->gpu_info.shader_present; + + return fls64(sc_mask); +} + +#define BLK_MASK(x) GENMASK_ULL((x) - 1, 0) + +static u64 get_shader_core_mask(struct panthor_device *ptdev) +{ + const u64 sc_mask =3D ptdev->gpu_info.shader_present; + + return BLK_MASK(hweight64(sc_mask)); +} + +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 * PANTHOR_HW_COUNTER= _SIZE; + 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, type, 1, + BLK_MASK(1), offset); + break; + case DRM_PANTHOR_PERF_BLOCK_FW: + offset =3D PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, type, info->fw_blocks, + BLK_MASK(info->fw_blocks), + offset); + break; + case DRM_PANTHOR_PERF_BLOCK_CSHW: + offset =3D PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, type, info->cshw_bloc= ks, + BLK_MASK(info->cshw_blocks), + offset); + break; + case DRM_PANTHOR_PERF_BLOCK_TILER: + offset =3D PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, type, info->tiler_blo= cks, + BLK_MASK(info->tiler_blocks), + offset); + break; + case DRM_PANTHOR_PERF_BLOCK_MEMSYS: + offset =3D PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, type, info->memsys_bl= ocks, + BLK_MASK(info->memsys_blocks), + offset); + break; + case DRM_PANTHOR_PERF_BLOCK_SHADER: + offset =3D PANTHOR_PERF_SET_BLOCK_DESC_DATA(desc, type, + get_reserved_shader_core_blocks(ptdev), + get_shader_core_mask(ptdev), + 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_config(struct panthor_perf_sampler *samp= ler, + 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]); + + WRITE_ONCE(glb_iface->input->perfcnt_as, panthor_vm_as(panthor_fw_vm(samp= ler->ptdev))); + WRITE_ONCE(glb_iface->input->perfcnt_base, panthor_kernel_bo_gpuva(sample= r->rb)); + + perfcnt_config =3D GLB_PERFCNT_CONFIG_SIZE(perf_ringbuf_slots); + perfcnt_config |=3D GLB_PERFCNT_CONFIG_SET(sampler->set_config); + if (sampler->ptdev->perf_info.flags & DRM_PANTHOR_PERF_BLOCK_STATES_SUPPO= RT) + perfcnt_config |=3D GLB_PERFCNT_METADATA_ENABLE; + + WRITE_ONCE(glb_iface->input->perfcnt_config, 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 panthor_perf_fw_write_sampler_config(struct panthor_perf_sampl= er *sampler) +{ + panthor_perf_fw_write_config(sampler, sampler->em); +} + +static void session_populate_sample_header(struct panthor_perf_session *se= ssion, + struct drm_panthor_perf_sample_header *hdr, u8 set) +{ + *hdr =3D (struct drm_panthor_perf_sample_header) { + .block_set =3D set, + .user_data =3D session->user_data, + .timestamp_start_ns =3D session->sample_start_ns, + /** + * TODO This should be changed to use the GPU clocks and the TIMESTAMP r= egister, + * when support is added. + */ + .timestamp_end_ns =3D ktime_get_raw_ns(), + }; +} + +/** + * session_accumulate_sample - Accumulate the counters that are requested = by the session + * into the target buffer. + * + * @ptdev: Panthor device + * @session: Perf session + * @session_sample: Starting offset of the sample in the userspace mapping. + * @sampler_sample: Starting offset of the sample in the sampler intermedi= ate buffer. + * + * 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_accumulate_sample(struct panthor_device *ptdev, + struct panthor_perf_session *session, + u8 *session_sample, u8 *sampler_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_user_sample_size(perf_info); + const size_t sample_header_size =3D sizeof(struct drm_panthor_perf_sample= _header); + const size_t data_size =3D sample_size - sample_header_size; + struct drm_panthor_perf_sample_header *hdr =3D (typeof(hdr))session_sampl= e; + + hdr->timestamp_end_ns =3D ktime_get_raw_ns(); + + session_sample +=3D sample_header_size; + + for (size_t i =3D 0; i < data_size; i +=3D block_size) { + size_t ctr_idx; + DECLARE_BITMAP(enabled_ctrs, PANTHOR_PERF_EM_BITS); + struct panthor_perf_counter_block *dst_blk =3D (typeof(dst_blk))(session= _sample + i); + struct panthor_perf_counter_block *src_blk =3D (typeof(src_blk))(sampler= _sample + i); + + bitmap_from_arr64(enabled_ctrs, dst_blk->header.enable_mask, PANTHOR_PER= F_EM_BITS); + bitmap_clear(enabled_ctrs, 0, 4); + + dst_blk->counters[PANTHOR_CTR_TIMESTAMP_HI] =3D + src_blk->counters[PANTHOR_CTR_TIMESTAMP_HI]; + dst_blk->counters[PANTHOR_CTR_TIMESTAMP_LO] =3D + src_blk->counters[PANTHOR_CTR_TIMESTAMP_LO]; + + for_each_set_bit(ctr_idx, enabled_ctrs, PANTHOR_PERF_EM_BITS) + dst_blk->counters[ctr_idx] +=3D src_blk->counters[ctr_idx]; + } +} + +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); +} + +/** + * session_populate_sample - Write out a new sample into a previously popu= lated slot in the user + * ringbuffer and update both the header of the = block and the PRFCNT_EN + * counter to contain only the selected subset o= f counters for that block. + * + * @ptdev: Panthor device + * @session: Perf session + * @session_sample: Pointer aligned to the start of the data section of th= e sample in the targeted + * slot. + * @sampler_sample: Pointer aligned to the start of the data section of th= e intermediate sampler + * buffer. + * + * When a new sample slot is targeted, it must be cleared of the data alre= ady existing there, + * enabling a direct copy from the intermediate buffer and then zeroing ou= t any counters + * that are not required for the current session. + */ +static void session_populate_sample(struct panthor_device *ptdev, + struct panthor_perf_session *session, u8 *session_sample, + u8 *sampler_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_user_sample_size(perf_info); + const size_t sample_header_size =3D sizeof(struct drm_panthor_perf_sample= _header); + const size_t data_size =3D sample_size - sample_header_size; + + memcpy(session_sample, sampler_sample, sample_size); + + session_populate_sample_header(session, + (struct drm_panthor_perf_sample_header *)session_sample, + ptdev->perf->sampler.set_config); + + session_sample +=3D sample_header_size; + + for (size_t i =3D 0; i < data_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))(session_sample = + i); + 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); + bitmap_clear(em_diff, 0, 4); + + blk->counters[PANTHOR_CTR_PRFCNT_EN] =3D compress_enable_mask(blk_em); + + 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 pantho= r_perf_session *session) +{ + struct panthor_perf *perf =3D ptdev->perf; + const size_t sample_size =3D session_get_user_sample_size(&ptdev->perf_in= fo); + 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; + + if (READ_ONCE(session->pending_sample_request) =3D=3D SAMPLE_TYPE_INITIAL) + return 0; + + new_sample =3D session->samples + insert_idx * sample_size; + + if (session->accum_idx !=3D insert_idx) + session_populate_sample(ptdev, session, new_sample, perf->sampler.sample= ); + else + session_accumulate_sample(ptdev, session, new_sample, perf->sampler.samp= le); + + return 0; +} + +static void session_emit_sample(struct panthor_perf_session *session) +{ + const u32 insert_idx =3D session_read_insert_idx(session); + const enum session_sample_type type =3D READ_ONCE(session->pending_sample= _request); + + if (type =3D=3D SAMPLE_TYPE_INITIAL || type =3D=3D SAMPLE_TYPE_NONE) + goto reset_sample_request; + + session->accum_idx =3D insert_idx; + 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); + +reset_sample_request: + WRITE_ONCE(session->pending_sample_request, SAMPLE_TYPE_NONE); +} + +#define PRFCNT_IRQS (GLB_PERFCNT_OVERFLOW | GLB_PERFCNT_SAMPLE | GLB_PERFC= NT_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 & PRFCNT_IRQS)) + return; + + /* TODO Fix up the error handling for overflow. */ + if (drm_WARN_ON_ONCE(&ptdev->base, 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; + + list_for_each(pos, &sampler->session_list) { + struct panthor_perf_session *session =3D list_entry(pos, + struct panthor_perf_session, sessions); + + session_copy_sample(ptdev, session); + } + } + + scoped_guard(spinlock_irqsave, &sampler->pend_lock) { + struct list_head *pos, *tmp; + + list_for_each_safe(pos, tmp, &sampler->pending_samples) { + struct panthor_perf_session *session =3D list_entry(pos, + struct panthor_perf_session, pending); + + session_emit_sample(session); + list_del(pos); + session_put(session); + } + } + + memset(sampler->sample, 0, session_get_user_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_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 * perf_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 kzalloc(session_get_user_sample_size(&ptdev->perf_info), GFP_K= ERNEL); + if (ZERO_OR_NULL_PTR(sample)) { + ret =3D -ENOMEM; + goto cleanup_vmap; + } + + sampler->rb =3D bo; + sampler->sample =3D sample; + sampler->sample_slots =3D perf_ringbuf_slots; + sampler->em =3D kzalloc(sizeof(*sampler->em), GFP_KERNEL); + + mutex_init(&sampler->sampler_lock); + spin_lock_init(&sampler->pend_lock); + INIT_LIST_HEAD(&sampler->session_list); + INIT_LIST_HEAD(&sampler->pending_samples); + 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_config(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); + + kfree(sampler->sample); + + panthor_kernel_bo_destroy(sampler->rb); +} + +static int panthor_perf_sampler_add(struct panthor_perf_sampler *sampler, + struct panthor_perf_session *session, u8 set) +{ + int ret =3D 0; + struct panthor_perf_enable_masks *session_em =3D session->enabled_counter= s; + + guard(mutex)(&sampler->sampler_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; + + panthor_perf_em_add(sampler->em, session_em); + ret =3D pm_runtime_resume_and_get(sampler->ptdev->base.dev); + if (ret) + return ret; + + if (atomic_read(&sampler->enabled_clients)) { + ret =3D panthor_perf_fw_stop_sampling(sampler->ptdev); + if (ret) + return ret; + } + + panthor_perf_fw_write_sampler_config(sampler); + + ret =3D panthor_perf_fw_start_sampling(sampler->ptdev); + if (ret) + return ret; + + session_get(session); + list_add_tail(&session->sessions, &sampler->session_list); + atomic_inc(&sampler->enabled_clients); + + return 0; +} + +static int panthor_perf_sampler_remove_session(struct panthor_perf_sampler= *sampler, + struct panthor_perf_session *session) +{ + int ret; + struct list_head *snode; + + guard(mutex)(&sampler->sampler_lock); + + list_del_init(&session->sessions); + session_put(session); + + panthor_perf_em_zero(sampler->em); + list_for_each(snode, &sampler->session_list) + { + struct panthor_perf_session *session =3D + container_of(snode, typeof(*session), sessions); + + panthor_perf_em_add(sampler->em, session->enabled_counters); + } + + 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_sampler_config(sampler); + + 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 @@ -357,6 +1310,10 @@ int panthor_perf_init(struct panthor_device *ptdev) .max =3D 1, }; =20 + ret =3D panthor_perf_sampler_init(&perf->sampler, ptdev); + if (ret) + return ret; + drm_info(&ptdev->base, "Performance counter subsystem initialized"); =20 ptdev->perf =3D no_free_ptr(perf); @@ -364,13 +1321,67 @@ int panthor_perf_init(struct panthor_device *ptdev) return ret; } =20 -static size_t session_get_user_sample_size(const struct drm_panthor_perf_i= nfo *const info) +static int sampler_request(struct panthor_perf_sampler *sampler, + struct panthor_perf_session *session, enum session_sample_type type) { - 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->fw_blocks + - info->tiler_blocks + info->memsys_blocks + info->shader_blocks; + guard(spinlock_irqsave)(&sampler->pend_lock); =20 - return sizeof(struct drm_panthor_perf_sample_header) + (block_size * bloc= k_nr); + /* + * 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. + */ + if (READ_ONCE(session->pending_sample_request) !=3D SAMPLE_TYPE_NONE) + return -EBUSY; + + WRITE_ONCE(session->pending_sample_request, type); + session_get(session); + list_add_tail(&session->pending, &sampler->pending_samples); + + if (!sampler->sample_requested) { + reinit_completion(&sampler->sample_handled); + sampler->sample_requested =3D true; + panthor_perf_fw_request_sample(sampler); + } + + return 0; +} + +/** + * panthor_perf_sampler_request_initial - Request an initial sample. + * @sampler: Panthor sampler + * @session: Target session + * + * 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_initial(struct panthor_perf_sample= r *sampler, + struct panthor_perf_session *session) +{ + int ret =3D sampler_request(sampler, session, SAMPLE_TYPE_INITIAL); + + if (ret) + return ret; + + 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) +{ + return sampler_request(sampler, session, SAMPLE_TYPE_REGULAR); } =20 static int session_validate_set(u8 set) @@ -401,8 +1412,8 @@ static int session_validate_set(u8 set) * 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 drm_panthor_perf_cmd_setup *setup_args, + struct panthor_file *pfile) { struct panthor_perf_session *session; struct drm_gem_object *ringbuffer; @@ -494,6 +1505,10 @@ int panthor_perf_session_setup(struct panthor_device = *ptdev, struct panthor_perf kref_init(&session->ref); session->enabled_counters =3D em; =20 + ret =3D panthor_perf_sampler_add(&perf->sampler, session, setup_args->blo= ck_set); + if (ret) + goto cleanup_xa_alloc; + session->sample_freq_ns =3D setup_args->sample_freq_ns; session->user_sample_size =3D user_sample_size; session->ring_buf =3D ringbuffer; @@ -504,6 +1519,9 @@ int panthor_perf_session_setup(struct panthor_device *= ptdev, struct panthor_perf =20 return session_id; =20 +cleanup_xa_alloc: + xa_store(&perf->sessions, session_id, NULL, GFP_KERNEL); + cleanup_em: kfree(em); =20 @@ -529,8 +1547,10 @@ int panthor_perf_session_setup(struct panthor_device = *ptdev, struct panthor_perf } =20 static int session_stop(struct panthor_perf *perf, struct panthor_perf_ses= sion *session, - u64 user_data) + u64 user_data) { + int ret; + if (!test_bit(PANTHOR_PERF_SESSION_ACTIVE, session->state)) return 0; =20 @@ -543,14 +1563,17 @@ static int session_stop(struct panthor_perf *perf, s= truct 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. */ return 0; } =20 static int session_start(struct panthor_perf *perf, struct panthor_perf_se= ssion *session, - u64 user_data) + u64 user_data) { if (test_bit(PANTHOR_PERF_SESSION_ACTIVE, session->state)) return 0; @@ -564,12 +1587,11 @@ static int session_start(struct panthor_perf *perf, = struct 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_initial(&perf->sampler, session); } =20 static int session_sample(struct panthor_perf *perf, struct panthor_perf_s= ession *session, - u64 user_data) + u64 user_data) { if (!test_bit(PANTHOR_PERF_SESSION_ACTIVE, session->state)) return 0; @@ -592,14 +1614,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 - 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_session(&perf->sampler, session); + session_put(session); =20 - return 0; + return ret; } =20 static int session_teardown(struct panthor_perf *perf, struct panthor_perf= _session *session) @@ -675,7 +1699,7 @@ int panthor_perf_session_teardown(struct panthor_file = *pfile, struct panthor_per * 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) + u32 sid, u64 user_data) { struct panthor_perf_session *session =3D session_find(pfile, perf, sid); int err; @@ -708,7 +1732,7 @@ int panthor_perf_session_start(struct panthor_file *pf= ile, struct panthor_perf * * 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) + u32 sid, u64 user_data) { struct panthor_perf_session *session =3D session_find(pfile, perf, sid); int err; @@ -739,7 +1763,7 @@ int panthor_perf_session_stop(struct panthor_file *pfi= le, struct panthor_perf *p * 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) + u32 sid, u64 user_data) { struct panthor_perf_session *session =3D session_find(pfile, perf, sid); int err; @@ -806,6 +1830,8 @@ void panthor_perf_unplug(struct panthor_device *ptdev) =20 xa_destroy(&perf->sessions); =20 + panthor_perf_sampler_term(&perf->sampler); + kfree(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 89d61cd1f017..c482198b6fbd 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.h +++ b/drivers/gpu/drm/panthor/panthor_perf.h @@ -28,5 +28,7 @@ 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__ */ =20 --=20 2.33.0.dirty From nobody Thu Apr 10 17:52:21 2025 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2053.outbound.protection.outlook.com [40.107.241.53]) (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 3683B20CCE5 for ; Tue, 1 Apr 2025 15:49:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.53 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522544; cv=fail; b=fRwJ+lD20YhhGLJPeXftvEkqje+USlQRHP8BRWOQmK43ubXEzLDN0slD3C9zXCA5sSn/UIOhtKaCubjpTt1Ho8tqWitT9d/3LVmmDcLLh2TQjZDy43ieICfVqgh2wdsf4UwL3RNCP13keKlhiTKZ4Q57jmq0QeBAdqL7J0x0Wxg= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522544; c=relaxed/simple; bh=vw17WZ/KoHZhanWzmSq5u445Z8IkTvYsDsFP9E2TLnA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Poc1h//bIH/BbQSSwq5W/tLBl+ml/ymArQdXTfaw/9UuEmoEpEQAhrMcLoHuegdEKe1tm7NFpmwtRVdijkFoDlso2sC6bCyBDYC0O5xMLR4TUjj/+ovZ/cqCwEqPafBEVxCug4sV9SdXGI/ZkYiapqZ/JC9+ldgrJhBCRqRYt8c= 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=Psr0hmAn; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Psr0hmAn; arc=fail smtp.client-ip=40.107.241.53 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="Psr0hmAn"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Psr0hmAn" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=Bt416+ix0NkstJxHw9wZ5xIMPc2IFPmPjp+slA7FBkZ4Ryik7+SWiNoE/IIGR7kK0NRsQ5ec8UOaq86h9k9CxNKL/3ZHMxjwDhrl53Tja4EM5O/GdzktWpDtjI0MI+mjS5fx1ffvEe1o84DbExCHrYWV3GHFNCX/m5v1XBY1nkYdzUqpUsfNrY8uT0VT493w8i6iIvZWpYcjrUrYt/nmiU9UpOrGY6FhgQGQST9qWES4D0++mqw1UZ8oH4OdpbXKQMZSiF9I8lYZpBNWqRjIBuvVK6huvGTxYHgQk3E1abHtRcgHirqTUh7QraN+ReV0pcNWD50pWlZVlTxQSRBHHw== 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=73aJ/NgW4EkLrd1krm3aj73AkSedo8cBOtOcevIJ3xI=; b=KEE7lfm34mVnLgnMfE1K9tCASDA972IZIJJtnfKXWTi7YeDf43QlHv6oK4s94Vq49vhx/HyRK8ASo9MQLH9Iz4oi1O1z9anrXLDHz6MmUPBPVbx2A8CGrhupwGrVDl35DQNTl2Djbkg6+59wi8/VMfaIC+Ze7rgS6QiqOaJdzD2pwdi4cdBgMREYZVd7rJWVrgkATJ5u3Ul8pR/k3CFseCF9PEMfxA7Skbx5iuHvOR9m4dNjr91K82f7KNlXeazS56JpLxTVg6EIT+jhv32a12r6TtR0bygR8kDfi9Im/TEX4uF7zp872Zws6iNRNmmTOAPqM6+SkAUdzJ6d2EN8hA== 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=73aJ/NgW4EkLrd1krm3aj73AkSedo8cBOtOcevIJ3xI=; b=Psr0hmAnnMUxJ63tm3LV2koB6DVi/itVyHWIY4kPjVeL0Uq/iv84l/mOr3kjfe5XdmQI9gKl6I3xDx9gUGMhkPd+dR0qrNW0b2yTi1YZvonYyaSQRWa/5D5w6SNwLqPaIo8FHEJBgUOxPuBY0nojOYkwMVBAooRpE/176SiIfhs= Received: from AM0PR10CA0108.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::25) by PA4PR08MB7593.eurprd08.prod.outlook.com (2603:10a6:102:26f::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.54; Tue, 1 Apr 2025 15:48:56 +0000 Received: from AMS1EPF00000049.eurprd04.prod.outlook.com (2603:10a6:208:e6:cafe::fa) by AM0PR10CA0108.outlook.office365.com (2603:10a6:208:e6::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8583.39 via Frontend Transport; Tue, 1 Apr 2025 15:48:56 +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 AMS1EPF00000049.mail.protection.outlook.com (10.167.16.133) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.22 via Frontend Transport; Tue, 1 Apr 2025 15:48:56 +0000 Received: ("Tessian outbound 8df300e92501:v604"); Tue, 01 Apr 2025 15:48:55 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f877ce8a26a71364 X-TessianGatewayMetadata: oHNERHLLSIuK45Qn4WjcaR8YD+44SIV0c5uhxWi/9qc6kjsQR/FSkxNF9NHjyATuzEYO3ztuWTkzNT7avEtgqMjSiv0id4Y4OXo1JODvoBzsKvl6XJNcVJc1GBfAdKJ4xPup6NuGkO/tETr1ZZus1wihxKkVvhi9kGcs+KBuZJT8PeSBiLkC1ZKX6hHVFjnilHeMoM2mXSofbsJu1vRi/w== X-CR-MTA-TID: 64aa7808 Received: from L037f915c84da.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0A66C371-A3FD-4516-8548-5403BDA98438.1; Tue, 01 Apr 2025 15:48:49 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id L037f915c84da.2 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 01 Apr 2025 15:48:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=auyrbq0jYWdHp1I81vnBt+HDZO/Ah2/Z5KBln9Nd8CE0vRWcR1Q7HnYMvNIYYdOzaZZxQWrKN6E0EyF/hsaCnqzi9bejR/rCTdPseqDGi1mDdXc8UCw/55vT0iVIjTLNsje4sRJI6Y9uqXLwO1vHtL5990s4CFY5rHPgOly+/xqMdGjXf1LtFpRL7PDrYFa1gEpNhuIEz1fVlXSYgXFbTWWBNC3GJwH1gR5XpTWg+IgCeOhAz7IKXYXijKkldrmlN+dMy2z3JQ17+lTDazLKnr+gaAKY/EJcZT986+DLuMQ7KjDahumxKV2gNIuzzNs6jUcIrlYR9JOYiId/dsThPg== 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=73aJ/NgW4EkLrd1krm3aj73AkSedo8cBOtOcevIJ3xI=; b=QS2juvUtvvWlJF1ik2mdd/Rz1U+naA7hCITEqLgaaYgQYx0WwHf2UjkquMQ6hhxJtg8ZeAv4j/ncxk5fMRQoRjBBNu9+Z4fFcOkkAsT0aGGSjo/1uZW07vu/1GHX9Kzz2BQFBxFD7fwMmQypKcAtpO/A8hOAP1FukU0NGu7Hw696xOh1DyL24rV+7JpFqYNnIncBoMclfW/SuuZnvvkiIpW6GVpJulRuihnwk4HG5Nn5MbCtsuaWyZDYic19OR2oG7LBsj+nAmzy6doXma4jZcP/mt3F7Tj0hP/wcTerL9gFKPlglhfSCHAMnLIXCR/zUsHyLAx7tHiMNrPbWqXwGA== 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=73aJ/NgW4EkLrd1krm3aj73AkSedo8cBOtOcevIJ3xI=; b=Psr0hmAnnMUxJ63tm3LV2koB6DVi/itVyHWIY4kPjVeL0Uq/iv84l/mOr3kjfe5XdmQI9gKl6I3xDx9gUGMhkPd+dR0qrNW0b2yTi1YZvonYyaSQRWa/5D5w6SNwLqPaIo8FHEJBgUOxPuBY0nojOYkwMVBAooRpE/176SiIfhs= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) by DU0PR08MB8279.eurprd08.prod.outlook.com (2603:10a6:10:40d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Tue, 1 Apr 2025 15:48:47 +0000 Received: from AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc]) by AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc%6]) with mapi id 15.20.8534.048; Tue, 1 Apr 2025 15:48:47 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= , Lukas Zapolskas Subject: [PATCH v3 6/7] drm/panthor: Add suspend, resume and reset handling Date: Tue, 1 Apr 2025 16:48:21 +0100 Message-Id: <55457330ddeaa95ad389076b7ad01be452836ae2.1743517880.git.lukas.zapolskas@arm.com> X-Mailer: git-send-email 2.33.0.dirty In-Reply-To: References: Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO0P123CA0009.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:354::14) To AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM0PR08MB3315:EE_|DU0PR08MB8279:EE_|AMS1EPF00000049:EE_|PA4PR08MB7593:EE_ X-MS-Office365-Filtering-Correlation-Id: c4e8fccc-4f3a-409e-cc65-08dd7134b62c 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|1800799024|366016|376014|921020; X-Microsoft-Antispam-Message-Info-Original: =?us-ascii?Q?79tkHEDLbsA/NyQjgbBLjF5+7u/szp7v0JekKkjHgqkYRURNsjcq4STDLNrL?= =?us-ascii?Q?4XwuPp17bmvrXr/GW0YE8+eS59322mp7zY6x/MDB7zOrKc6Y7TW49IK58nOp?= =?us-ascii?Q?3YazQL8fz6dFhADYkuaacxSxIqADLIpntx+utA+P5jZl/ZHxc+K9PcOAKIVV?= =?us-ascii?Q?Psq3cAZ4qxJXg6pRG4/Xx7+o7IyQcPSMceXEJyE92IMvc49ugKzQkq9rB9pk?= =?us-ascii?Q?zQbyeJDr/VdG+29LUwSOTj8yQ6B8VlUMaIrzedh51A+CJzCVvXpRTUyLBGMn?= =?us-ascii?Q?cbtSzFsUcCoVNUcXl3cnVRWIMaTmkziZ/EfBHZvyommA+87U0eiltSQnPO9m?= =?us-ascii?Q?L1FQEtDkQYZIMi+MQG7y4vv/ugnws0ywOyFCEtBVqOapWhQZmAh9gD8gjtGp?= =?us-ascii?Q?tqCJLynLEM40MeaiNZkXn1n1zyjfDop70gfF0l8IH0lmS51tTvv0LAErIvnt?= =?us-ascii?Q?ynzUAezRI/wnGPQ3mvj/hcGGNlv6uIZLGKmV3nNoue3+s54R4uwMYwIW8FDT?= =?us-ascii?Q?nIQnZciHPCivmFa22oVd+4/D9Zfp2NaDuqG5fW/yBTIyp+7NsISBd8ULEkpq?= =?us-ascii?Q?yqrTQYnnsIWPkFURX6M/ONwjOSIlbCPRYccxndpMji6slAfR7P4M7jYgo+3j?= =?us-ascii?Q?uAgELKhwOTydfGFuXcqk4Pyh0GZ614e3c3cuLOFIEY8pZ2jabhWG5RepZeU7?= =?us-ascii?Q?vzPFqnIoCtT4G7SpCO67euZoCy5leD+MEeLzbk9Tq6P66bP6GXqclxLK8d6C?= =?us-ascii?Q?H32pAXxW78cF48fKz0MT2sSah7+wgVM3EAS90WmYmtJBLUoT1LvoHmDV/LsN?= =?us-ascii?Q?XnjQH8k5Yil6b+VG6b/Ykv342hcUwk8H4KQ0BLVdQbJZtEDCTuRzqOx4yo/d?= =?us-ascii?Q?mHkwthkZ0sBtKt3Dr9qz7nyOkLf1uNBspYVutJM7xs4ML3thYJ75PDeCoFN2?= =?us-ascii?Q?NyOnCAV51iPrMTA+bJ+QcGT7Zf2lWXKjL7ZGlBzY1ZwgEZN6shbTWcbXuX+U?= =?us-ascii?Q?XujWct7oMWnqaJNo9+yj1CNiPc4rand8H9V9AfrE6yskBBxVqe6OzrRUaje7?= =?us-ascii?Q?7fT4IiTBSSbI03CXHzIx8hlTOFu21bL4rkAav6gIVhgv7fFQcu8bqU/rwm+V?= =?us-ascii?Q?BLuf9SXFesPQca9n2q744JHrccVjpVlh05mIGc5kaPe0JQZz5h/FhSI0Xcyc?= =?us-ascii?Q?1DVeJ7S4JdY2ZAyYgaAVNQBxbSJb9KePcBNpR8KIJndkGOAzgXoSW4rJ2/It?= =?us-ascii?Q?KJZpESy3MMal27/+qTs6zTgxsVVjEWb+VnAS4qaApiJ4XoM9jXnK7aAmxnhR?= =?us-ascii?Q?Rbamgx5DYGKre7b2qHSJqMkTdFqrVLhSa2Bjk/6QobPC9T/ALUchDIkeryx6?= =?us-ascii?Q?bO+P9bbrWREf9dknVACECOA+qf86bePMRAjK3xpOJ6X68ckNJeeOWkQppoCL?= =?us-ascii?Q?OLRJVpwqtr4=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR08MB3315.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8279 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:208:5c::16];domain=AM0PR08MB3315.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS1EPF00000049.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c457a5ca-72c1-41cd-6aaa-08dd7134b0ec X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|1800799024|14060799003|376014|35042699022|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?YOpmY8eJ4pyKTqN2tjzItE4wOl3tbVHhmX8hkHlvrl1lLWzybmk2jhsYg+v3?= =?us-ascii?Q?DfuOKtw7MCAbK1Ya0u/2SMY3NkuHBnfzJl6hvnRipWu3SUnDqRbjjK6ZPRsI?= =?us-ascii?Q?rEEhrjqsFtDiHeQ8DyckO/nmdBJdArr52GmvqfcRwGieFXRBYHWbt4sxNBwV?= =?us-ascii?Q?R7mZ08asW+ZshtHfKVk0wZ5XeRf8393o+hsGCHLhc7UYhB3twSiWUhz6vMqs?= =?us-ascii?Q?sq4KYw9G2in/Jy/9c9ungtTG64ORTDhtlvCr71QmeljcT2O+HFGxmhRC9GkN?= =?us-ascii?Q?qGlUn766ZoDzgZgAujhhmS6tvf5Yzsg988VeoRuEy+5NmaxgWyPVQp8a/3hV?= =?us-ascii?Q?5O/Fd0cgPvPktpHkDx9af5Yx34AkgRj3cXfW6PuXalWZbpYN4UgK+TRhB0As?= =?us-ascii?Q?RBjRIuuqoIQdhogwerOIFq2ky1nlapyxIhzGFezHbhWhOosguXOtf5Ge1ccD?= =?us-ascii?Q?h61pKQnjOAxyHgV6nj9VrWQyuiHFR5+PSzVNb8fP+SJ85DixTAIoqTSVos/J?= =?us-ascii?Q?EaIH/BAdaNLjusWHHyAvXb86s8I5ybYGS6HrzDXTXow9k517sxYbL7PVy93S?= =?us-ascii?Q?NJcquCgiM0h718ajUdgsnKlB792yumauxFXRfJ9vuwNeI/TNeSv2mMqc101+?= =?us-ascii?Q?IDf0wVnWrhXz0gy1gjaidcVWaYyryf2Lob47WtH7d3NMtRVoPYsy6uEtXWgv?= =?us-ascii?Q?hVtRgszpM52ZeLwYVZu7vCuMAJ75v1lGsE5eDmBjTfONmHGCTzUHVPULF8No?= =?us-ascii?Q?PasUm/m5LS5+1YEGtWyok3kteITB+yxfIQZ1/iRFUdtVj7ss5x4QMORKVtqC?= =?us-ascii?Q?nYbcpxrzn38YgH/QVU2JNLsL8/+M33DAliTkvYfDbFrekFqybRbHwz8lW0t7?= =?us-ascii?Q?vUJDIT7QtIbHqN/pp4UcmW6QKYFl7AAYled6E5/FYzpVLJHWx4qhQpR/vMBz?= =?us-ascii?Q?GrLy9lBcR2sVtQbInvOYI8wgYQs9RC4gHOd+mul0QP6ZFfVsAYKIOsWMWzTi?= =?us-ascii?Q?Gjx9y71bBclccMKDHX/f/L6nPYhu405du6XsOAxjYMJ7k5cFRvIrsrvfim6q?= =?us-ascii?Q?LhJTtjXadkrk8RR+ZR05Y4U5NGtmLlBPsyMUA9g1SUfvIZn+zdITgXCoFwOe?= =?us-ascii?Q?v0Kfve810c9N/hR4FHL45qmSDnq/9EiLu62+Pia9es5klrCjl9fq+MNhVcjZ?= =?us-ascii?Q?6M2pVkbJF/1ntO24k/upiajgbgReuX/U5gDBmztKRzUGpV1XHi+vIUY8ovRX?= =?us-ascii?Q?01wttl8tAabyZRSSPQJd31/540esRxAdGeq7dsBzwXsJ/MejfawFSVDI7VSK?= =?us-ascii?Q?vTR8gmw/6SPfrKby2GfyBoFzlHtfeR7Kf1sH/zDmK+0cFaAjYJYVHEqOvPmO?= =?us-ascii?Q?VYairxEXNdMWD+YxYRFcveqYaLnPMZy3mZ6U97dfHZcJZQ/J6dJIR6RJ4YaG?= =?us-ascii?Q?U237hAd2Ioi23CMc0GEMuXY6rocAAZ62W/507+UIlJbsXlwZklxgRv0lgJOa?= =?us-ascii?Q?1aon07LOPBP0zQU=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)(36860700013)(1800799024)(14060799003)(376014)(35042699022)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2025 15:48:56.4324 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4e8fccc-4f3a-409e-cc65-08dd7134b62c 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: AMS1EPF00000049.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB7593 Content-Type: text/plain; charset="utf-8" The sampler must disable and re-enable counter sampling around suspends, and must re-program the FW interface after a reset to avoid losing data. Signed-off-by: Lukas Zapolskas --- drivers/gpu/drm/panthor/panthor_device.c | 7 +- drivers/gpu/drm/panthor/panthor_perf.c | 102 +++++++++++++++++++++++ drivers/gpu/drm/panthor/panthor_perf.h | 6 ++ 3 files changed, 114 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/pan= thor/panthor_device.c index 7ac985d44655..92624a8717c5 100644 --- a/drivers/gpu/drm/panthor/panthor_device.c +++ b/drivers/gpu/drm/panthor/panthor_device.c @@ -139,6 +139,7 @@ static void panthor_device_reset_work(struct work_struc= t *work) if (!drm_dev_enter(&ptdev->base, &cookie)) return; =20 + panthor_perf_pre_reset(ptdev); panthor_sched_pre_reset(ptdev); panthor_fw_pre_reset(ptdev, true); panthor_mmu_pre_reset(ptdev); @@ -148,6 +149,7 @@ static void panthor_device_reset_work(struct work_struc= t *work) ret =3D panthor_fw_post_reset(ptdev); atomic_set(&ptdev->reset.pending, 0); panthor_sched_post_reset(ptdev, ret !=3D 0); + panthor_perf_post_reset(ptdev); drm_dev_exit(cookie); =20 if (ret) { @@ -496,8 +498,10 @@ int panthor_device_resume(struct device *dev) ret =3D panthor_device_resume_hw_components(ptdev); } =20 - if (!ret) + if (!ret) { panthor_sched_resume(ptdev); + panthor_perf_resume(ptdev); + } =20 drm_dev_exit(cookie); =20 @@ -561,6 +565,7 @@ int panthor_device_suspend(struct device *dev) /* We prepare everything as if we were resetting the GPU. * The end of the reset will happen in the resume path though. */ + panthor_perf_suspend(ptdev); panthor_sched_suspend(ptdev); panthor_fw_suspend(ptdev); panthor_mmu_suspend(ptdev); diff --git a/drivers/gpu/drm/panthor/panthor_perf.c b/drivers/gpu/drm/panth= or/panthor_perf.c index 3cb79b999886..753c65294745 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.c +++ b/drivers/gpu/drm/panthor/panthor_perf.c @@ -1803,6 +1803,76 @@ 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; + + 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. @@ -1836,3 +1906,35 @@ void panthor_perf_unplug(struct panthor_device *ptde= v) =20 ptdev->perf =3D NULL; } + +void panthor_perf_pre_reset(struct panthor_device *ptdev) +{ + struct panthor_perf_sampler *sampler; + + if (!ptdev || !ptdev->perf) + return; + + sampler =3D &ptdev->perf->sampler; + + if (!atomic_read(&sampler->enabled_clients)) + return; + + panthor_perf_fw_stop_sampling(sampler->ptdev); +} + +void panthor_perf_post_reset(struct panthor_device *ptdev) +{ + struct panthor_perf_sampler *sampler; + + if (!ptdev || !ptdev->perf) + return; + + sampler =3D &ptdev->perf->sampler; + + if (!atomic_read(&sampler->enabled_clients)) + return; + + panthor_perf_fw_write_sampler_config(sampler); + + panthor_perf_fw_start_sampling(sampler->ptdev); +} diff --git a/drivers/gpu/drm/panthor/panthor_perf.h b/drivers/gpu/drm/panth= or/panthor_perf.h index c482198b6fbd..fc08a5440a35 100644 --- a/drivers/gpu/drm/panthor/panthor_perf.h +++ b/drivers/gpu/drm/panthor/panthor_perf.h @@ -13,6 +13,8 @@ struct panthor_file; struct panthor_perf; =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, @@ -30,5 +32,9 @@ void panthor_perf_session_destroy(struct panthor_file *pf= ile, struct panthor_per =20 void panthor_perf_report_irq(struct panthor_device *ptdev, u32 status); =20 +void panthor_perf_pre_reset(struct panthor_device *ptdev); + +void panthor_perf_post_reset(struct panthor_device *ptdev); + #endif /* __PANTHOR_PERF_H__ */ =20 --=20 2.33.0.dirty From nobody Thu Apr 10 17:52:21 2025 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2055.outbound.protection.outlook.com [40.107.103.55]) (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 744D020E03F for ; Tue, 1 Apr 2025 15:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.55 ARC-Seal: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522552; cv=fail; b=AsyvpylzNjM6uw/6AQmOUCBJ7vqiHVFykRLIBEsHRQ884PcA3ivtOz473mhZXhqq+CO7SStIkuCsj4Dgz+A7aYsahAaPNUPFdhLUeQeA5VQuPCV96/zCq/b4RlxOXLUWmp9/yXM6Sy2a29i4MpvfGAmF94HmdhdExF6LN3xpsuQ= ARC-Message-Signature: i=3; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743522552; c=relaxed/simple; bh=/8o3cFgnnrgWoQjy9f42CHMAGgoGSsKkTA+lJgfF2v8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=VAvnbb/XiXVSC7h9Rn5XGjidvKkfTUT/yByCQwR/4jms6W2Wn3AbITudlfr2vrgTj3kiUpFDUjY2lyDotyFgltrSz+La/hrW7559RALAsv5vq4NRVaw54X3N2h1G4lH0gqPyjQLpeTmJvqleK0BvBpyCkQ9uJdhXlreHy7EmRLc= 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=Brc2ZYea; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=Brc2ZYea; arc=fail smtp.client-ip=40.107.103.55 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="Brc2ZYea"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="Brc2ZYea" ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=NTyPPSEI3e8fuCneML29ou6AnWRDjIByIAs0ezUSTRuLYMoj5pERcVbjDSmbw0xq7yGC5uc9qsKYUcYGoHYChNST0uehUofkFmnK2OXhc8IHXa52Y0q0IDPP66gj7YxQ3uvAhg9g0o90W8hiPJOuGrAYNbSDNgKo/jQZP/NftQggBF4JEyXChTMVchxhuYXei7oZ34EI/Jy9uaZEe1Yyoy2JATZ2CWouBDyPXgH/DoUwhyQavXBIvFkcqsEyNoIPp6igTl8kAdG3OIgBk5TW8Xa1w6je9RalhK7U4p8bfDfRO1uaCUprguPaLXAo4WTgJ8kj7KZqNgUUHM2G47Nxtw== 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=FZotHG/NiHZdV7jEQZVPj2JqaAhiLixdocbppNgllw8=; b=Wk8IUMfYXSF6xzlO4cqR//mbthzvuWmI/zifl9xddDg3D/mcBXPg77TVlVCNllTJaBIm3x+vFV71P7HA5AZ0q/etWvpqxiMMeD6r+WX+SFBOwRuOs2Mf9AEr+RrlcBiG1kPui/rOMzgd12g32o1/VtVlFPA63RJzlMVqwckJ3CtEAeQp7vPUz+18sohp03uw1rCioIoYDHj0oe5/cjf2biwUD0q8rwWINvCqrbm8PV/wO7XJF1gdmIj7OfWUvXU3iy9GxgtchBDKmDVZZJGYcMzTVoTkENmOXekkECqHzVj0i/96l7tBlnVI+enxgSpmqGNFKLknhAUtPHZLdLeqVA== 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=FZotHG/NiHZdV7jEQZVPj2JqaAhiLixdocbppNgllw8=; b=Brc2ZYeawqTOE4b0ZRYihd13CtrWN9bW953r+DXsJJ1nCFK/dcN/rAfPwV9/0dqcDqb4sB7XdhHXD9694xtsucPybid+YeQ2VaGDurMSw/yIoKocZzAjfOHZowKPULk2mFKs9UdpRLMNVCKnKzNGJQh/FnXc8ISFUWE9O3zI3gw= Received: from DU6P191CA0050.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:53e::13) by AM8PR08MB5780.eurprd08.prod.outlook.com (2603:10a6:20b:1c4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.47; Tue, 1 Apr 2025 15:49:03 +0000 Received: from DU6PEPF0000B61D.eurprd02.prod.outlook.com (2603:10a6:10:53e:cafe::c3) by DU6P191CA0050.outlook.office365.com (2603:10a6:10:53e::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8534.54 via Frontend Transport; Tue, 1 Apr 2025 15:49:03 +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 DU6PEPF0000B61D.mail.protection.outlook.com (10.167.8.137) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8606.22 via Frontend Transport; Tue, 1 Apr 2025 15:49:03 +0000 Received: ("Tessian outbound eb3c789b7dfa:v604"); Tue, 01 Apr 2025 15:49:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 054820aff8357f30 X-TessianGatewayMetadata: V9GQzal8YZ2Ke0O9w0rhnllqJQWy0U0aVPUNZ/GoNGOHAeXOg2xgPreGwImCkDXf2Bgx65yR9Tyo0bB2GoesCYCzE7bSgsRb/bynKuu+DdaO/TJnUFUv9avSuWu+76DvvbEjMY06N2qYsHMfJMxyIhf/qDJ73fGFwFaPZKvwsm+8UxEEsxMpQOHMutL+Iuz/sq/oDgZdHyt6Dol/n0GL5w== X-CR-MTA-TID: 64aa7808 Received: from L09bc3a1ed403.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id FF6A9144-F857-42B2-841E-E4C600CA087C.1; Tue, 01 Apr 2025 15:48:52 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id L09bc3a1ed403.2 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 01 Apr 2025 15:48:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NyAB7QIyXG61lgi9Xaz0bX++huN4J08+PIyBPl3ZIm6WIjAxzz9j0xtnIhotRGaZoOtYRfBAqzng2o2PJueKD3fhid8AK6MK+wKrNBmLfoBEJulgJyLNqoC5tTtKLWiYUvp5VATUss0W7aKQgqikHdW0utogjqf4xoMIITbxnOtVK+KSbOvggVfyyo+VPkNRdlOMYzOHlEsBVem3sPmSVpqFNX18TYGnkh1aMV7ld6EW4ARSHReFGgkHxaDxGCdKHy5o8d2HApIuJt+rzR5v770mBaLg2oWf7+Nn1lgkULt2Cv+LbLCmM7nQ+tMw/y5u+3NyLnLRKphUg51g30IhWA== 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=FZotHG/NiHZdV7jEQZVPj2JqaAhiLixdocbppNgllw8=; b=ftUvpiqY9W5jR4nV5qVcwagxv0jCXX3EliNqmORytGAFfbNbDhgj5LhDEevkME7gERxc9S/mWHyVZFF9V0HA4BU1xBmpF6UEf1+3YjW+W/NFOirrpCeUgoJR+f2Krfd658HmXXNqg2P1K4+z0d3G3U2zBT5UT0gqK3ZaFtaDVQ8Pgw/7cmYRPXEGQ3nRAlR9/AhFQS2NNazfCk1eGw0IA8Kbco/gsbJ/MBYIxA2KypmChmD0bBi/3N6TMEqA3uVPsKcqs34obZelEvtluhiw4mEIfRWMpUpYi9pQRtwEwgV/ljUeNGd7RfJHlpktjYjFPUAVntjix24aHssOY0LPGg== 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=FZotHG/NiHZdV7jEQZVPj2JqaAhiLixdocbppNgllw8=; b=Brc2ZYeawqTOE4b0ZRYihd13CtrWN9bW953r+DXsJJ1nCFK/dcN/rAfPwV9/0dqcDqb4sB7XdhHXD9694xtsucPybid+YeQ2VaGDurMSw/yIoKocZzAjfOHZowKPULk2mFKs9UdpRLMNVCKnKzNGJQh/FnXc8ISFUWE9O3zI3gw= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) by DU0PR08MB8279.eurprd08.prod.outlook.com (2603:10a6:10:40d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8534.44; Tue, 1 Apr 2025 15:48:49 +0000 Received: from AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc]) by AM0PR08MB3315.eurprd08.prod.outlook.com ([fe80::42a0:1b6e:cf98:d8fc%6]) with mapi id 15.20.8534.048; Tue, 1 Apr 2025 15:48:49 +0000 From: Lukas Zapolskas To: Boris Brezillon , Steven Price , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= , Lukas Zapolskas Subject: [PATCH v3 7/7] drm/panthor: Expose the panthor perf ioctls Date: Tue, 1 Apr 2025 16:48:22 +0100 Message-Id: <1db5077232173ec63bb16e953422c55efcd41e69.1743517880.git.lukas.zapolskas@arm.com> X-Mailer: git-send-email 2.33.0.dirty In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: LO4P123CA0584.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:276::15) To AM0PR08MB3315.eurprd08.prod.outlook.com (2603:10a6:208:5c::16) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AM0PR08MB3315:EE_|DU0PR08MB8279:EE_|DU6PEPF0000B61D:EE_|AM8PR08MB5780:EE_ X-MS-Office365-Filtering-Correlation-Id: 9cf1e56d-d877-481d-8f7b-08dd7134ba79 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|1800799024|366016|376014|921020; X-Microsoft-Antispam-Message-Info-Original: =?utf-8?B?dVZ5VlRWS2F2bVQ0RW5PMEprKzFOY0g0eCt5eGFQdENhMW1MQlArcnJGclI4?= =?utf-8?B?a3BqNGFrNWZpeDVqdWFhV2lnbUlnbmZ0clJOT0JxVGhRd3JmTWRjMUpsK1h4?= =?utf-8?B?aURqTDYrZDk3NGtzWitVVlJXeU1vT0JZdndsZWp0S3F4UnNtekR3Y0JDc0xY?= =?utf-8?B?akxCR3VRWmgrVk04UG4yb2xOenp0U0dJR1gvOURZTmI2RmYrdVRhVElqejhv?= =?utf-8?B?N2p3aXRxenJjN2xUdVo1Yi9oWGRaRGhuZWFTYlJiaGtIK1AvNXhrenZkRlRs?= =?utf-8?B?cUR6ektCWHlVTjNHYWYwQjlESERZS2t6bVdxaXh4TS8xWlFFYldCdCtJaEky?= =?utf-8?B?UTJHdmpKQnB2OFFUR0d3bnBBTlA0bmVaNW1tTzBXMGtVNEhJdFY1OVphdm9x?= =?utf-8?B?R3NzcWtDeFVlYUx1N00zM05ESUlmUTR1YS9jZ25IMGw5QWNla2xGVmxKQ3ZX?= =?utf-8?B?WFhxdnBQSFF1WkFMK2h3aEJrbmw2NEg0N2V3cDN1dmNLUm5CNGYrV1A1bnpF?= =?utf-8?B?a2kzbDFuSXFEK0FKLzNFS0o5ZkJVYWhheW1xbDkxbGVFVHFVeHBHaU5GU0F4?= =?utf-8?B?OGlxWldaMkNjbE1xc2szTVByajdWbEJlNVBJM0dUNmJYZ1lhVC9mblN2bytF?= =?utf-8?B?bG56SDJmRUdLSXRWVVozYnJRb0IzaVlld3pNa3RrOHRSdXJTZFNQU2JhalZN?= =?utf-8?B?bU1xL0NVWVZiNFJ4cGtVR0RLeHJRYTk5NUhsZ2hpbFR0MVZKTWVyWUg0QTNh?= =?utf-8?B?c3kzeElocTU3YzRKbHhxK0tqSUNrRFBnY3pUa2RBdDIxUSs0QW5Pd1ZSV24w?= =?utf-8?B?QXRadWZnNlhXYVQ0VUlmVU9OMmVsSldCOG5RWkZIcmp2YktoUHF5d1grOWVt?= =?utf-8?B?MnozVG5KVDlVcXpPRkZVU3BKTnhpS25vSEg2NGplNW13REx1cnB0cnJIZXpM?= =?utf-8?B?aGRPRHBwSWl2NUhBU1VmYVZadVRpS3dPK2NScG9pblkwcEwzaXFLK3hDcWt3?= =?utf-8?B?Umg3RDIrWWcrZ1dLRmdnRVlYTkVUa08rNEEzWmZXQ3ZHNm8rZGxMNDdkc0Y2?= =?utf-8?B?R21IS2R6eUw1ZFJ2bTdyR3RnTUV3alMvL1JEbzN2S3BtK256UktyS0txeHFF?= =?utf-8?B?VEVqZFcydDBuamZYSkN2YmhqelllaE03NTZIZjIxS3FMZlliRnhqR0pjeGhM?= =?utf-8?B?a3dTbU1FSktIRUkyVW9NT3hjRGpiaVdDV1BoZVBDVC9uZzhiQjZDZHNoeFBO?= =?utf-8?B?MWoyMm5PK3Vsdy9CalpWSENFWmRMK0FkVlptMWRyUWZXTjlBbEhzSXB1RS9j?= =?utf-8?B?R0IxbktrMC9oV25MVHNsVFVNK3BVRzIrSFMwdnVRcllRUTdzdEtqeTBzaDBa?= =?utf-8?B?cDF4WVpvcURBSy9xT3h6SmcrR05uVXgxZ0tUZllMcm1lUEN6ZmVpL1BRRkJI?= =?utf-8?B?UENVNWRZbTIrbUxCTS9pL0FxaHl1ajhjV0ROZFB1Ujg0OVRxNEFZbjhtNEZk?= =?utf-8?B?Y25rcmNtSG5xVTJsR252aUNFbDAzell1amExeCtrdWhWZHZ3Y2ZPckNtdVhv?= =?utf-8?B?WVI5bVA0ZmFtMUJEK2NqTmVQOTNyeHJ4a2c0ckZzM3RPT0ZoVkYwS0c4a0hL?= =?utf-8?B?cWpQUVJ0V3VmZmcvODd6ZDlxV01VZ21JRWRkZHZYd1QxVEJpNnVFUExMejhv?= =?utf-8?B?K2c3cDJRV0dJM0hja3FsRUlkOEFTaVczVFlkdnhBejgrZ0cybXNjTnpHdCta?= =?utf-8?B?b0hHVUdwbU4zZ2dScjlXTS9oNS9lSytpTSszR21Qc0w5bmJ4M2pCbTB1L3Nz?= =?utf-8?B?NlVNV2F6T1MrZHB4cFpwdUd1RU9Pa2tIaG9NS002L1RzMnh5MTg2ODVWVkdC?= =?utf-8?B?ck1Edk9pclk1Qkd5dWp5am5WMWZDT0tNeDBsQTE1VFowWk1lZXpzUXQ4UFR3?= =?utf-8?Q?UeHQ81MNJEg=3D?= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR08MB3315.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(376014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8279 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:208:5c::16];domain=AM0PR08MB3315.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU6PEPF0000B61D.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 73bd0a7d-bf87-41c5-2a3e-08dd7134b21d X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|376014|1800799024|35042699022|14060799003|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?B?c3JyVnF0NEpIKzg4M1dGN05lQ0IvdmZXbzJmclUvN1h5RE13ZVc2aXhERERG?= =?utf-8?B?WlR5UkJ3R2JiWFd4V0RXcTV1eEpqZDR1TnYyZnl1R2JGUndEbUh2cGs4TVJv?= =?utf-8?B?NWhMelM2UWlOY0cxR0JkamlQNGs1RzlwaGxiYkhSUlM4d1pZMFFodXo1QTdG?= =?utf-8?B?UnNNRW9IWExINGgzbTJINEVxQkpCMk5NQWVaTWM3TFBydnF3T25tT0YrNVZh?= =?utf-8?B?K1p5eEJaOWc3SFFGMEN6Zy9vQVdOMmNaSlg0L2lmS3VCczBWVWp5VXhxN0RI?= =?utf-8?B?cURDdDYzMlp0Y2JqRnVHcysvZkFNd1NDbVFDaGhoQmlkbCtpYnZIR2tSaGtW?= =?utf-8?B?aU96UTFUMHBkN1dsSXRrR1dPS2Rnb01ldVY5NWZvYzhVWk9EQVdTU1FZSlht?= =?utf-8?B?Y2VMRTFXU0RrRE5Qc3VoQ2ZTTGxzaTBUdnhwMFNCdUk4dmtjM0hwcGdhV01s?= =?utf-8?B?c1NhSzg1eWZLT0NXVEJFZStPNGpqVVd2MVYrN0hHWW1PaEVQN0NJVU5teFhN?= =?utf-8?B?VGJ0UC9lQmVvUnBRYW03OTBwblFUVkNFN3hxd0ltOGRVQ0ZlL0dFdE1IUVVN?= =?utf-8?B?eFZMOUljaE1ZajBjZzFXNG91WDdJenFkdUFkNW1lVEsrWStVRkhZQWtiVXZ5?= =?utf-8?B?YXduSGpVeUFjVEdpYnNWbzBsVjNCeDdpajdHY1ZvVGVVL3JKdEVneHdLVTdJ?= =?utf-8?B?czlCdlZLeHFRb0hicW5DVno5azY4bkVHcXJSQ2FyRElqS1JBazJ2dE1yZ0to?= =?utf-8?B?cVhsT2pKMVNiTmd2NnBNaXZROGZJRnJRMmZkZXpVT2VWVEtSdW5LR1hxemU5?= =?utf-8?B?blBCVTU1Ritmck8wMFk4cXRobnVzdzU3TGFZd2FOQURPdGk4SzVidnM4b3lL?= =?utf-8?B?TkJQZU9ob2tSZ3EvZDB0c1BBaGxIMEtaN2ZjZlNsOU9qSmpQUGpGQ3lIaFZv?= =?utf-8?B?eWErZG9SL3k4c1hQTVRUUm9VOXM3aTVUb084d2VaOW55cXhtS0VoZHU5eGkx?= =?utf-8?B?blVKV1JQbFJLcFZkVWFqVnRkNVFSNTFsTmtYM2pJK2RLOEtZOTFtbGYvMTRW?= =?utf-8?B?dVpIMmhONkJMcmkxK3NFVWs4T24xZUNtZXNsMkVSUW53cjVmRGtmRHFBWlFP?= =?utf-8?B?WlR6M1BNS2hLYktxV2ljR1F5RUFVMi9Sa2lQVDhlMTNidklUS3RqS3hTd2o1?= =?utf-8?B?OUNpUkFxRkVHTDJDajZKM01ScEJjcExualhlQndzL2thbnFmRHdsbTZkaXE1?= =?utf-8?B?dzhpZktHUTJoR3RKQlZiZHhDOUxFYVpKUjM1OW1NRUxWUWVjWW8wMnp1ZkxY?= =?utf-8?B?Mm1wODdEamNpSVQ5c0JIcENXMW9IdzNjYzBUNW5kTEo0STYyMS92aEVPQ1R0?= =?utf-8?B?Wm1ieFBYcWF5RWlQZFkrOHBUcGd4eWRsYmRDWnQvbWxmSStDVVFZSm5maHNu?= =?utf-8?B?TURaa2QzNjBhbWMxQWJGTkJjQWhNNW9pay95dUJSa0lwZm9mc2NBOXB2UFp5?= =?utf-8?B?QUM4K3duRGhXM1pwRENoTkhQMWFFSmtIeFFJaFo0N2IxNk1hdUpud0h5VDlv?= =?utf-8?B?TVBpRzhWM1B5aU5yM2oyOFkwYWR1dGhueTZqUkN3bUZ5TFUvNnhTWkRYUUM4?= =?utf-8?B?ZXl6dzJhRC9rNE1hcHNyN3Bqend1bFkxWlZkbGdoQWhWeUZZUG1YZ2lCOE02?= =?utf-8?B?YkpvbnE1M2dsSk1GcWNVK3pqSjV3NkZ1T0tLWFlFeXBwaGNMRzhwYXhHM1Mv?= =?utf-8?B?dmJOcmk1U2lUYjluT041WC9wdENneUlsL2ZhbjFuMXNVY3g0ekVJZE5MZ3p0?= =?utf-8?B?ZndncnV1SVJVS0ZNUVovc0lqSmVqUk94bGtaM2pMTUxaTnBOZzYvZFZHNzhN?= =?utf-8?B?TXRVcTQrTW13cnd3SWY1RWs4NHY3RzNWY3ZEV1VBT0FKOExaWVE5M3RHS05t?= =?utf-8?B?Q3ErQ0Qzbmg3aGNMclcvbkVuZkJLcGUrSlVXeERqVG01dVVwV2VIZEJSeFBv?= =?utf-8?B?cWdFVFhLVDlDRVpnQVh6RmM1emszKzhpdVdYUG01Q0JDQ2REeUR3cENSUEJz?= =?utf-8?Q?zv2dQ5?= 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)(36860700013)(376014)(1800799024)(35042699022)(14060799003)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Apr 2025 15:49:03.6620 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9cf1e56d-d877-481d-8f7b-08dd7134ba79 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: DU6PEPF0000B61D.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5780 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. The minor version is bumped to indicate that the feature is now supported. Signed-off-by: Lukas Zapolskas Reviewed-by: Adri=C3=A1n Larumbe --- drivers/gpu/drm/panthor/panthor_drv.c | 141 +++++++++++++++++++++++++- 1 file changed, 139 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/pantho= r/panthor_drv.c index 4c1381320859..850a894fe91b 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -31,6 +31,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 +74,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,7 +210,12 @@ 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. @@ -191,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 variable + * @_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 +1396,83 @@ static int panthor_ioctl_vm_get_state(struct drm_dev= ice *ddev, void *data, return 0; } =20 +#define perf_cmd(command) \ + ({ \ + struct drm_panthor_perf_cmd_##command *command##_args __free(kvfree) =3D= NULL; \ + int _ret =3D PANTHOR_UOBJ_GET(command##_args, args->size, args->pointer)= ; \ + if (_ret) \ + return _ret; \ + return panthor_perf_session_##command(pfile, ptdev->perf, args->handle, \ + command##_args->user_data); \ + }) + +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; + + return panthor_perf_session_setup(ptdev, ptdev->perf, setup_args, pfile); + } + case DRM_PANTHOR_PERF_COMMAND_TEARDOWN: + { + return panthor_perf_session_teardown(pfile, ptdev->perf, args->handle); + } + case DRM_PANTHOR_PERF_COMMAND_START: + { + perf_cmd(start); + } + case DRM_PANTHOR_PERF_COMMAND_STOP: + { + perf_cmd(stop); + } + case DRM_PANTHOR_PERF_COMMAND_SAMPLE: + { + perf_cmd(sample); + } + default: + return -EINVAL; + } +} + static int panthor_open(struct drm_device *ddev, struct drm_file *file) { @@ -1409,6 +1543,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) @@ -1518,6 +1653,8 @@ static void panthor_debugfs_init(struct drm_minor *mi= nor) * - 1.2 - adds DEV_QUERY_GROUP_PRIORITIES_INFO query * - adds PANTHOR_GROUP_PRIORITY_REALTIME priority * - 1.3 - adds DRM_PANTHOR_GROUP_STATE_INNOCENT flag + * - 1.4 - 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 | @@ -1531,7 +1668,7 @@ static const struct drm_driver panthor_drm_driver =3D= { .name =3D "panthor", .desc =3D "Panthor DRM driver", .major =3D 1, - .minor =3D 3, + .minor =3D 4, =20 .gem_create_object =3D panthor_gem_create_object, .gem_prime_import_sg_table =3D drm_gem_shmem_prime_import_sg_table, --=20 2.33.0.dirty