From patchwork Wed Aug 28 17:25:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 13781611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 941D7C636ED for ; Wed, 28 Aug 2024 17:26:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1A47110E30C; Wed, 28 Aug 2024 17:26:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.b="EIvqehKM"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="EIvqehKM"; dkim-atps=neutral Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2047.outbound.protection.outlook.com [40.107.105.47]) by gabe.freedesktop.org (Postfix) with ESMTPS id BB04210E30C for ; Wed, 28 Aug 2024 17:26:39 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=CP+6dLbIlK9DjdOjXUkRCAJlfVeA/Xi8x2p/4wI2t4hhDv9Lern0mP3tG4vMA54ix/FtEXr9iNKzx2YS6Q+KBfc0Lie8fSXeQ4d7VsV5FtWW7HLsCve1BHp7rWMtFNHLDVhRixuw/f571KtpUuAh6ai3idRVLMGPqo5+WfVF+dtG6Z4So2aVen6p1FWfWh7zzypJtB5zUaZtuwsuzvJl21o24Ckxp5Bla/rlDwYtUd7t7vjC6VMRavOHoejj6Lubv862uz3nlp8Pi+txbTJI5gRa3jytEGx59aHcsL2PkwB83wSi9JHNVs7gVckmxj15SnIR0GgklkaQ4h3oAcgxTQ== 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=5m7hf/25ORVUBhUoMY/OJ1lZUWDEtBtLgjWn3WpUW2w=; b=FZ8FutZ2o3Y/amul7rMMfn9tcFXYxJyjm0ulMD5a/9i7sRWdbsDY031Nul3rka5Y2tY1F6FXkIYNPs8EQ6oj6HCMLRyTtvvvk8f+fWUXVqR2N8nIHXpPkpD3AonSCsOm26bEfdVF7MhwCuNJJRs9ll5T/kMGFi+9AQwCCqddr+x9RWL7T/XCHE4j5vLzjXHl/rqAZ+BykG3xu7snNA6RwGBr1caNuh676ewYMfW/ypBjJLqQLj+BTqYRl9bxQ0ktt8KnlyqIJAFpO7hurI+ZxtXsYHUYjFFlKLoOHWYz2lg6WhVnjOT7xY302d48pOTRC8y+QWWJ6flDafd4B/A4yA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.freedesktop.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=5m7hf/25ORVUBhUoMY/OJ1lZUWDEtBtLgjWn3WpUW2w=; b=EIvqehKMEo15SqV552K7PAvjSQenaRqryK/wVdHC/eJMoxIhZAao1vMzJmriBg4uN4V7O2GfXKKbg2bffE3wWfoVhldam7+mL1uVu1Uqnfzf40rcrVHchqiRyad1+50CkRlTrYASBD5SSH2dPVSfkfDQiNsXonCk6r5xIn1kNPY= Received: from PR3P189CA0007.EURP189.PROD.OUTLOOK.COM (2603:10a6:102:52::12) by DB9PR08MB6570.eurprd08.prod.outlook.com (2603:10a6:10:251::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.18; Wed, 28 Aug 2024 17:26:32 +0000 Received: from AM4PEPF00025F9C.EURPRD83.prod.outlook.com (2603:10a6:102:52:cafe::44) by PR3P189CA0007.outlook.office365.com (2603:10a6:102:52::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.26 via Frontend Transport; Wed, 28 Aug 2024 17:26:32 +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 AM4PEPF00025F9C.mail.protection.outlook.com (10.167.16.11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7939.2 via Frontend Transport; Wed, 28 Aug 2024 17:26:32 +0000 Received: ("Tessian outbound bc251c670828:v403"); Wed, 28 Aug 2024 17:26:32 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 114beb05aceef6f8 X-CR-MTA-TID: 64aa7808 Received: from Lcc029bca0bdb.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id AE4A4B2D-0B6E-42AA-A923-F4CC217FC0F1.1; Wed, 28 Aug 2024 17:26:24 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Lcc029bca0bdb.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Aug 2024 17:26:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uuke8e0Zn3Fj3gTkxMyG/sqdz8WBII4AuxCcjL7RZUiI/UxW9avjpQR3FhQpI0urD60w+WfVo+ZvK0Mkm5BgzgOXSgHT+tMvD832so3Kq2jSkkN+xlM+LOoqb564ImOEvtvUIkVuHCa7wX58jSHrR/HRD04V5gggLraZ4MWeYe9WdIO2LTtkJezDJAVqD7QYz9osynYqqTYTVu6P1G454rdsORsYZUy4N4LJIe0a1/vInhPsdmGCKeIfeyH6T75CUOV3Hp1BWSMcA7JhVnQeyTJeviEKlD75db94WiE846+Ljf7gmXXr3eL1Nyf0Ea1xPgT4fN3f0VsehaLMmkOXDA== 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=5m7hf/25ORVUBhUoMY/OJ1lZUWDEtBtLgjWn3WpUW2w=; b=h+kJ7nMOf9vJ6CniEbbAeSGaXH1rwJrsuKYA5X+3eVIOxt1fq7jMc+ZyKtIX22FmJ2bweOUhJOcBJiSV3J1gzvbrq0Pi3SfPSdhJt0zm4+SPoaODCVPdQkRNCQiahvQ5BjdhC8DMOdnXO1Ny7YerBXZS6ZEPrIsH2sv6YMJHhbUoFvpZGiJssQkVTyct67z9opSTaBpmINwIwEToCEb42vBnoBj6S4SVbKi+0pn3NGCTJr9Az9eV6MIEHG7ohFuQK/XgoSBGsldUN898q11MKTB+I2iiXbnKFIG1oe7if71NbYpi+wceFdDqaqgJ+w2nj0kJ2tSBhlukTOypCyBbWA== 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=5m7hf/25ORVUBhUoMY/OJ1lZUWDEtBtLgjWn3WpUW2w=; b=EIvqehKMEo15SqV552K7PAvjSQenaRqryK/wVdHC/eJMoxIhZAao1vMzJmriBg4uN4V7O2GfXKKbg2bffE3wWfoVhldam7+mL1uVu1Uqnfzf40rcrVHchqiRyad1+50CkRlTrYASBD5SSH2dPVSfkfDQiNsXonCk6r5xIn1kNPY= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) by AS8PR08MB6551.eurprd08.prod.outlook.com (2603:10a6:20b:319::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.18; Wed, 28 Aug 2024 17:26:22 +0000 Received: from AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c]) by AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c%7]) with mapi id 15.20.7918.012; Wed, 28 Aug 2024 17:26:22 +0000 From: Mihail Atanassov To: linux-kernel@vger.kernel.org, Boris Brezillon , Liviu Dudau , Steven Price Cc: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Shashank Sharma , Ketil Johnsen , Akash Goel , Mihail Atanassov , Mary Guillemard Subject: [PATCH 1/8] drm/panthor: Add uAPI to submit from user space Date: Wed, 28 Aug 2024 18:25:57 +0100 Message-ID: <20240828172605.19176-2-mihail.atanassov@arm.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240828172605.19176-1-mihail.atanassov@arm.com> References: <20240828172605.19176-1-mihail.atanassov@arm.com> X-ClientProxiedBy: LO4P123CA0652.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:296::13) To AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6263:EE_|AS8PR08MB6551:EE_|AM4PEPF00025F9C:EE_|DB9PR08MB6570:EE_ X-MS-Office365-Filtering-Correlation-Id: b11536b8-c19d-4368-f569-08dcc7868f67 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: H+07acMR5wfp5zw4dTIlj0gT6pIHd6F/XbN42E2J4saFl9bedXzmz2fq7VpyyMK1mEPp46mU6JzjhuGxQmMaeVXsK164a2RdUKV54evZ0uMgchclSsvpNqm6YUD8raav5ob7Qk3iYM3NmqCzxYdS1Ox2msG7wIwkk8qZ9Mc7STmgvvxSIGhfYtWSIzDtqQjp1CV7Hsj0EqE749F2Lq/WPjg0wK3wQDswYuRKEqzteDL4vY1ypN9V3OmSOhtOe3LU3SFRxLlt05Hznqdm0D40Ij8VY++g4TbuvTl1dFPCHJTJW8Dy+KTUDQFssmL5T9EKN1f7PBoJSdU4uEBORWBe1CCE/LpYzTJo68uA5HxmGQH6DAnfnNZ9TLenn1SW+33FNWGBtSqQKCgbIfYFr7Zucw2T8z9Y3rAwU1NmkB+oW6XeuLvZu0xPfWYaJjTLw/fmMSj4/acY45xsKOD983tiFv0Kl3/wp7NWv0Tlvw5aPbLNVs3ExV+WiOTUWLZkTtgwSURVjNE/aWbU11lAVw+9H9rezkYtF652VmNe3ad3JuMg0BrIlCtc9HjoZh+T4KKxdWjFe+rL887ET6yIyRO+YNu665R7amxRBZqCjPV9jXqxgjfFlrMDP2FR6NSYWwJsN1vuxUfRg/8+vaNDjj63Y0fC8G/VLe6RgaXLTSg0T3ij/Fhq5LHdcl7xEMz4zR2uM2dSbBPTkWqELipY0wyCMM/H/HTlE72X/1RWn1KjfUbLgBBghgs1rua7JUTF/W9xUCE7ox1VtAPTouqEWVR2lbx89nnN1WS9NIOfKZrSCgq+jFtGgGTo2x2whgYl+AtGM4fUNkOG2As33t2vFlAN2ZlEdlKdaUOClir4cJE83Abkp7CR/LnbTE2HtwaUzmbj7RBx8t7+oXoyWBAhYwZ/rQwv2qMucD+luQet3OfJRf7Tk9r4FCuD9dKiBco1dFVVyKMGWPVyEYl20PZJNVk2iETxMhgZ7K9JCjGWo6nAjf/4uhqeSBDhQJ35G9CPvjxBnFudRoM4m+bM82OjtjmyGcHUIEtnFEa59CwDzdYOw63gz7G35HStb094xRp7PybwCdPBsK3ju2FxoSXlQ7Wkjm3TB+1KWLzYEMRrfXJMmwlksbXJIasNYKxb1MC63r6+DW02Zcu+TSnPG7LEQrx2NCNnTkJCIC6C0fOrbsFCFCMx2EhvXtOIyS+r3+d3c56swscj52cuPB3BSkbrX8fFNb7jjLmuPO/qFx8S7e0N32+JDNGebZcpBsXqSRRu/nFh1P+Lery+FTG+3D7YINCvYqbiFVs5vfllC41Mtu73Yvg= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6263.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6551 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:20b:290::9]; domain=AS8PR08MB6263.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM4PEPF00025F9C.EURPRD83.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 996232fb-c16a-44cc-1e3e-08dcc7868951 X-Microsoft-Antispam: BCL:0; ARA:13230040|35042699022|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: dOBxCFDdSDv3Tg1SwHxigo038KhVC/jqZanhv2bgeomRQ77FZESySOVBjR9bqkuDCOf3tqbDGFQL+WXj5rqwpnMQvx0SMilQkR+pbjZ9RqNQU5dwEm1P3R2hadQTrILQkouRMCy5o2zRtCn43+kQcTK5f02j9pxjhOvyEktPv7zemSn+TbTsN9kvDFza5CAwdJNAIZahKYoHVgRR/sU/THZsAmNL386J4CJcSw6Ny7b70hkNj2O1OCvp6Q+o8ItH7AeamRgjau+9rSkHI0648N6/8fmm5elkM1c7PgpNPYREXp8t1UxgOd3r1+vg6bOaMFHrlfue6pLwt3brejWBRa6sG9bbcvVpvqAquN1z0ZgbUl6ZDgQDb4zWvNyy6PDq5Wa5CUMEAUmb5fVQuI9BC+Cu1N6uQLHSaluu1CuLpVimk7dx5lWKY+QoaFygXd61lU4A7us4zxRqX0l/E3Ft5r/yaF6Msbh8qqJfxCmxh80U/QTPbZ8GdSDPAw4lQxyr0JK3FzR87Zv9vzB1f/Gs57zTZh4/fxMPRKrF6p9T+UYxmWdqhkQl9okiZXXYDapQJoRuRSn+RczYYAon7ZqM5SmofS0x8djhY+jbshjMeV1KZ6Drf0Ng1dyuQsuHCECyys9+RF8dsRdXU7E44KzkgF/njbgCWpPXSmr+lgWbdogpIxhJF3L41FURYlzX2aWr/xCEw10mqRfifawRu5P6NH+FnIJ8D8+0Y1hOqefLd9htVGEK/Zyv91norOgW6BqTA+XWnfE+hcdweDMjtY/2rC14qNO481/YKd3FHpteOmjXW+TidtFZMnvrwgYJbaLdzHZnyfA77SMfj83w8YWNdeuRXXclsGwVh7PKkPcElZ7kYsIKshVbccbaugA9Ff7G1dXIj01yvm9waWq7C2lwq1vuFSPbUbytV8BpvEZfTDRExc1EmWDeWSx23yuiDpaaGGKBY2oLkv3yY3VPKMJR9S7VUhJRc7hQIP8VCaSAMaOTrlk/HwV7d1VO164ZhZ6wQwG5MfgMsu8MIchfvuuVm5GBkq8VD1xJlqP+v9HDt1xeAVON0coKA00RoHKpt+XqS/gyT2YbdQvgbG4u518zjIKOMIAW3g/dMCQ4ilnNp3HyTa49gAMeJYb9j2H1lNH0CvUdbcnTr0bfYZM51EclEK/B3WulDu3YM2brKZH6AAg2koHXexO3ICnA3f8sj5e8umaFtU2sECZPNREafpUKtlTmuOoocNzIVVi0hEHNXmez9r8k/dkrj3ZOcE/72sDQxzR58NfvZFUEjzzxR3Gw+T3adCtjp09L/i3/uGxKBQk2ToRRdKmFHI+8WDgR31VgaYtz5ci9zL3e8FkBIUkvxtlpepJ6LdgzRDkn4WCpGki+5+3jyVLCSe2JfNRPuK9jeSFIrwQLo3NFiVBBeTGlXA== 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:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230040)(35042699022)(82310400026)(1800799024)(376014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2024 17:26:32.4486 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b11536b8-c19d-4368-f569-08dcc7868f67 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: AM4PEPF00025F9C.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB6570 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ketil Johnsen * Extend GROUP_CREATE to allow the kernel to expose the ringbuf, user I/O and doorbell pages for each queue, and add eventfds to signal sync updates and group state changes * Add a KICK ioctl to re-evaluate queues within a group * Add cross-group sync (XGS) queues as a mechanism to synchronise between groups' queues across a VM * Add a SYNC_UPDATE ioctl for user to notify kernel that it needs to re-evaluate groups and XGS queues; use eventfds for kernel-to-user notifications Signed-off-by: Ketil Johnsen Co-developed-by: Mihail Atanassov Signed-off-by: Mihail Atanassov --- This is going to conflict with [1] due to the driver version bump. [1] https://lore.kernel.org/dri-devel/20240819112508.67988-2-mary.guillemard@collabora.com/ drivers/gpu/drm/panthor/panthor_drv.c | 3 +- drivers/gpu/drm/panthor/panthor_sched.c | 2 +- include/uapi/drm/panthor_drm.h | 243 +++++++++++++++++++++++- 3 files changed, 244 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c index b5e7b919f241..4f1efe616698 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -1372,6 +1372,7 @@ static void panthor_debugfs_init(struct drm_minor *minor) /* * PanCSF driver version: * - 1.0 - initial interface + * - 1.1 - add user submission path */ static const struct drm_driver panthor_drm_driver = { .driver_features = DRIVER_RENDER | DRIVER_GEM | DRIVER_SYNCOBJ | @@ -1385,7 +1386,7 @@ static const struct drm_driver panthor_drm_driver = { .desc = "Panthor DRM driver", .date = "20230801", .major = 1, - .minor = 0, + .minor = 1, .gem_create_object = panthor_gem_create_object, .gem_prime_import_sg_table = drm_gem_shmem_prime_import_sg_table, diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c index 463bcd3cf00f..b2cf053b3601 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -3089,7 +3089,7 @@ int panthor_group_create(struct panthor_file *pfile, u32 gid, i, suspend_size; int ret; - if (group_args->pad) + if (group_args->flags & ~DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT) return -EINVAL; if (group_args->priority > PANTHOR_CSG_PRIORITY_HIGH) diff --git a/include/uapi/drm/panthor_drm.h b/include/uapi/drm/panthor_drm.h index 926b1deb1116..1a6a3877e5b3 100644 --- a/include/uapi/drm/panthor_drm.h +++ b/include/uapi/drm/panthor_drm.h @@ -127,6 +127,21 @@ enum drm_panthor_ioctl_id { /** @DRM_PANTHOR_TILER_HEAP_DESTROY: Destroy a tiler heap. */ DRM_PANTHOR_TILER_HEAP_DESTROY, + + /** @DRM_PANTHOR_GROUP_KICK: Re-evaluate group for scheduling. */ + DRM_PANTHOR_GROUP_KICK, + + /** @DRM_PANTHOR_XGS_QUEUE_CREATE: Create a cross-group sync queue. */ + DRM_PANTHOR_XGS_QUEUE_CREATE, + + /** @DRM_PANTHOR_XGS_QUEUE_DESTROY: Destroy a cross-group sync queue. */ + DRM_PANTHOR_XGS_QUEUE_DESTROY, + + /** @DRM_PANTHOR_XGS_QUEUE_SUBMIT: Submit a cross-group sync op to an XGS queue. */ + DRM_PANTHOR_XGS_QUEUE_SUBMIT, + + /** @DRM_PANTHOR_SYNC_UPDATE: Notify kernel that a HW syncobj has been updated. */ + DRM_PANTHOR_SYNC_UPDATE, }; /** @@ -170,6 +185,16 @@ enum drm_panthor_ioctl_id { DRM_IOCTL_PANTHOR(WR, TILER_HEAP_CREATE, tiler_heap_create) #define DRM_IOCTL_PANTHOR_TILER_HEAP_DESTROY \ DRM_IOCTL_PANTHOR(WR, TILER_HEAP_DESTROY, tiler_heap_destroy) +#define DRM_IOCTL_PANTHOR_GROUP_KICK \ + DRM_IOCTL_PANTHOR(WR, GROUP_KICK, group_kick) +#define DRM_IOCTL_PANTHOR_XGS_QUEUE_CREATE \ + DRM_IOCTL_PANTHOR(WR, XGS_QUEUE_CREATE, xgs_queue_create) +#define DRM_IOCTL_PANTHOR_XGS_QUEUE_DESTROY \ + DRM_IOCTL_PANTHOR(WR, XGS_QUEUE_DESTROY, xgs_queue_destroy) +#define DRM_IOCTL_PANTHOR_XGS_QUEUE_SUBMIT \ + DRM_IOCTL_PANTHOR(WR, XGS_QUEUE_SUBMIT, xgs_queue_submit) +#define DRM_IOCTL_PANTHOR_SYNC_UPDATE \ + DRM_IOCTL_PANTHOR(WR, SYNC_UPDATE, sync_update) /** * DOC: IOCTL arguments @@ -680,6 +705,40 @@ struct drm_panthor_queue_create { /** @ringbuf_size: Size of the ring buffer to allocate to this queue. */ __u32 ringbuf_size; + + /** + * @ringbuf_offset: file offset to map the ring buffer + * + * Returns a file offset which can be used to map the queues ring buffer. + * The size of this buffer is as requested with @ringbuf_size + * + * Only valid if DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT is set in + * the respective drm_panthor_group_create::flags, 0 otherwise. + */ + __u64 ringbuf_offset; + + /** + * @user_io_offset: file offset to map user input/output pages. + * + * Returns a file offset which can be used to map the user input page + * and the user output page (two consecutive pages). + * + * Only valid if DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT is set in + * the respective drm_panthor_group_create::flags, 0 otherwise. + */ + __u64 user_io_offset; + + /** + * @doorbell_offset: file offset to map doorbell page + * + * Returns a file offset which can be used to map the queues HW doorbell page. + * Note: multiple queues can share same HW doorbell page, and this offset + * will be the same in this case. + * + * Only valid if DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT is set in + * the respective drm_panthor_group_create::flags, 0 otherwise. + */ + __u64 doorbell_offset; }; /** @@ -696,6 +755,16 @@ enum drm_panthor_group_priority { PANTHOR_GROUP_PRIORITY_HIGH, }; +/** + * enum drm_panthor_group_create_flags - Flags for group creation + */ +enum drm_panthor_group_create_flags { + /** + * @DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT: Enable user submission + */ + DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT = 1 << 0, +}; + /** * struct drm_panthor_group_create - Arguments passed to DRM_IOCTL_PANTHOR_GROUP_CREATE */ @@ -730,8 +799,8 @@ struct drm_panthor_group_create { /** @priority: Group priority (see enum drm_panthor_group_priority). */ __u8 priority; - /** @pad: Padding field, MBZ. */ - __u32 pad; + /** @flags: Combination of drm_panthor_group_create_flags flags */ + __u32 flags; /** * @compute_core_mask: Mask encoding cores that can be used for compute jobs. @@ -772,6 +841,23 @@ struct drm_panthor_group_create { * destroying a group. */ __u32 group_handle; + + /** + * @eventfd_sync_update: eventfd to increment for group SYNC_UPDATE events + * + * Only valid when DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT is set. + * Can be set to -1 if UMD don't want to receive these events. + */ + __s32 eventfd_sync_update; + + /** + * @eventfd_group_state: eventfd to increment when group state has been changed + * + * Only valid when DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT is set. + * Can be set to -1 if UMD don't want to receive these events. + * DRM_IOCTL_PANTHOR_GROUP_GET_STATE should be used to retrieve the new group state. + */ + __s32 eventfd_group_state; }; /** @@ -955,6 +1041,159 @@ struct drm_panthor_tiler_heap_destroy { __u32 pad; }; +/** + * @struct drm_panthor_group_kick - arguments to DRM_IOCTL_PANTHOR_GROUP_KICK + */ +struct drm_panthor_group_kick { + /** @handle: handle to group */ + __u32 handle; + + /** @queue_mask: mask with queues to kick */ + __u32 queue_mask; +}; + +/** + * struct drm_panthor_xgs_queue_create - Arguments passed to DRM_IOCTL_PANTHOR_XGS_QUEUE_CREATE + */ +struct drm_panthor_xgs_queue_create { + /** @vm_id: VM id to associate this XGS queue with */ + __u32 vm_id; + + /** + * @eventfd_sync_update: eventfd to increment when a XGS object has been set + * + * Can be set to -1 if UMD don't want to receive these events. + */ + __s32 eventfd_sync_update; + + /** @handle: Returned handle to the XGS queue created */ + __u32 handle; + + /** @pad: MBZ */ + __u32 pad; +}; + +/** + * struct drm_panthor_xgs_queue_destroy - Arguments passed to DRM_IOCTL_PANTHOR_XGS_QUEUE_DESTROY + */ +struct drm_panthor_xgs_queue_destroy { + /** @handle: handle to XGS queue to destroy */ + __u32 handle; + + /** @pad: MBZ */ + __u32 pad; +}; + +/** + * enum drm_panthor_xgs_ops - Types of XGS operations + */ +enum drm_panthor_xgs_ops { + /** @DRM_PANTHOR_XGS_OP_WAIT_LE: Wait for condition to be less-or-equal specified value */ + DRM_PANTHOR_XGS_OP_WAIT_LE = 0, + + /** @DRM_PANTHOR_XGS_OP_WAIT_GT: Wait for condition to be greater than specified value */ + DRM_PANTHOR_XGS_OP_WAIT_GT, + + /** @DRM_PANTHOR_XGS_OP_SIGNAL_SET: Set XGS object to specified value */ + DRM_PANTHOR_XGS_OP_SIGNAL_SET, + + /** @DRM_PANTHOR_XGS_OP_SIGNAL_ADD: Add specified value to XGS object */ + DRM_PANTHOR_XGS_OP_SIGNAL_ADD +}; + +/** + * enum drm_panthor_xgs_op_formnat - Format of XGS object + */ +enum drm_panthor_xgs_op_format { + /** @DRM_PANTHOR_XGS_OP_FORMAT_U32: XGS object is of 32-bit format */ + DRM_PANTHOR_XGS_OP_FORMAT_U32 = 0, + + /** @DRM_PANTHOR_XGS_OP_FORMAT_U64: XGS object is of 64-bit format */ + DRM_PANTHOR_XGS_OP_FORMAT_U64 +}; + +/** + * enum drm_panthor_xgs_op_flags - Flags for a XGS operation + */ +enum drm_panthor_xgs_op_flags { + /** + * @DRM_PANTHOR_XGS_OP_INHERIT_ERROR_WAIT: Propagate XGS wait errors to XGS queue + * + * WAIT operations for a XGS which is signaled with error will set this XGS queue + * in an error state. This error state is cleared on next XGS submit with either the + * @DRM_PANTHOR_XGS_QUEUE_SUBMIT_ERROR_BARRIER_PRE or + * DRM_PANTHOR_XGS_QUEUE_SUBMIT_ERROR_BARRIER_POST flag set. + * + * Note: Errors during SIGNAL operations will always set the XGS queue in an error state + */ + DRM_PANTHOR_XGS_OP_INHERIT_ERROR_WAIT = 1 << 0 +}; + +/** + * struct drm_panthor_xgs_op - XGS operation + */ +struct drm_panthor_xgs_op { + /** @addr: GPU address of XGS object */ + __u64 addr; + + /** @value: value to WAIT for or SET/ADD */ + __u64 value; + + /** @op: operation from enum drm_panthor_xgs_ops */ + __u8 op; + + /** @format: format from enum drm_panthor_xgs_op_format */ + __u8 format; + + /** @flags: flags from enum drm_panthor_xgs_op_flags */ + __u16 flags; + + /** @pad: MBZ */ + __u32 pad; +}; + +/** + * enum drm_panthor_xgs_queue_submit_flags - Flags for XGS queue submission + */ +enum drm_panthor_xgs_queue_submit_flags { + /** @DRM_PANTHOR_XGS_QUEUE_SUBMIT_ERROR_BARRIER_PRE: Error barrier pre operation + * + * Clear queue error state before processing the XGS operations + */ + DRM_PANTHOR_XGS_QUEUE_SUBMIT_ERROR_BARRIER_PRE = 1 << 0, + + /** @DRM_PANTHOR_XGS_QUEUE_SUBMIT_ERROR_BARRIER_POST: Error barrier post operation + * + * Clear queue error state after processing the XGS operations + */ + DRM_PANTHOR_XGS_QUEUE_SUBMIT_ERROR_BARRIER_POST = 1 << 1 +}; + +/** + * struct drm_panthor_xgs_queue_submit - Arguments passed to DRM_IOCTL_PANTHOR_XGS_QUEUE_SUBMIT + */ +struct drm_panthor_xgs_queue_submit { + /** @handle: XGS queue handle to submit work to */ + __u32 handle; + + /** @flags: flags from enum drm_panthor_xgs_queue_submit_flags */ + __u32 flags; + + /** @ops: Array of struct drm_panthor_xgs_op sync operations */ + struct drm_panthor_obj_array ops; + + /** @syncs: Array of struct drm_panthor_sync_op sync operations */ + struct drm_panthor_obj_array syncs; +}; + +/** + * struct drm_panthor_sync_update - Arguments passed to DRM_IOCTL_PANTHOR_SYNC_UPDATE + */ +struct drm_panthor_sync_update { + /** @pad: MBZ */ + __u64 pad; +}; + #if defined(__cplusplus) } #endif From patchwork Wed Aug 28 17:25:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 13781613 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FA88C636ED for ; Wed, 28 Aug 2024 17:26:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 978ED10E3C0; Wed, 28 Aug 2024 17:26:56 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.b="ggRj+YrF"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="ggRj+YrF"; dkim-atps=neutral Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2079.outbound.protection.outlook.com [40.107.21.79]) by gabe.freedesktop.org (Postfix) with ESMTPS id AE7B610E319 for ; Wed, 28 Aug 2024 17:26:54 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=s1w/G77LbjF1xAC1m8XXlnH9EBnGKLPuKRz//GGfNUtP2jte5kdBhI7k0ryAnDgs0tVrIRx14qNMwI6OVhmE3xV8fnykXmUNjRhmp6LmuhxswgSQwMVgLSZ0AZrDtpM7o05ps6ycBTgrSu4G3nV6wC3xc07JSu7F55KrDDWqeL8g49CszOBUY1Lu0MI9wdST4Y3qcneVkW5B/edVWp8udG/tHShpTjmBWYS1HBkVwscq6wXO3H1uVsO8799NKIm1+kZlR09QC7tPnVAc6K/Yy7VnhOxU2QSQi4NAZPKe8rubTskhTA3M64eXWM5RXAdeHSlIXRo2nquZvRgI3aSQZw== 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=kbc6k7P+ygVSSbukIIpWKOMTxID22PkF6F3NAlV5wnI=; b=SR5XC5EGEwNhPwvOO97d4/CyUQDUovGyqAd0hEIJCXdCkfN5YEeleDnNX6YGSLhPrQlJdMLyW95JTX9HZGY/0GjZXTQkM360F/Dl+IehbU+xpwqN/a2NIoNPkO3DSlOupE6G/QHgb3x8eHmKOEFqwaj0iQG2EDNO4j4kkFPqTlp0+t1QT+6ddh+kiuvdO9uFoOpF8CkoRw4EB29u5Bs6hQKJNTaZFUu4nAFAsVpdma5jDP1yDizHA63yV9zT0IaZlaDnxCqQ0l0loHCGUznqoRreHSbKb7AAUVr+SVFScPzabPeUSb+tlfdkY7/s6zllBFJZ5xVj7eaXpJDfu4fH6w== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.freedesktop.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=kbc6k7P+ygVSSbukIIpWKOMTxID22PkF6F3NAlV5wnI=; b=ggRj+YrFThahcZTCq2UGeJRsyhpxUpRi3k4ni0IQnPgROUatUDzOZ7Waon+BdGmVdvtvZN0F9Rh7VwHiSqSZLGt8FrzJA/QKb6OBY2LX2KS7zVu2UG7GbK8dTwbfGFAKTyVaJbVDWbsTpXzC5jk/T6LVfHChRH8W9cC9/rwLy04= Received: from AM0PR04CA0128.eurprd04.prod.outlook.com (2603:10a6:208:55::33) by AM8PR08MB5826.eurprd08.prod.outlook.com (2603:10a6:20b:1c6::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.17; Wed, 28 Aug 2024 17:26:44 +0000 Received: from AM4PEPF00025F95.EURPRD83.prod.outlook.com (2603:10a6:208:55:cafe::d8) by AM0PR04CA0128.outlook.office365.com (2603:10a6:208:55::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.33 via Frontend Transport; Wed, 28 Aug 2024 17:26:44 +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 AM4PEPF00025F95.mail.protection.outlook.com (10.167.16.4) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7939.2 via Frontend Transport; Wed, 28 Aug 2024 17:26:44 +0000 Received: ("Tessian outbound 71990416b08d:v403"); Wed, 28 Aug 2024 17:26:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8086614d8e878064 X-CR-MTA-TID: 64aa7808 Received: from L86e926b1e659.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 63E635E0-75D2-4366-93C9-C6EE02F97793.1; Wed, 28 Aug 2024 17:26:32 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id L86e926b1e659.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Aug 2024 17:26:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=f5cNVFECF1wdmtJV7eBZuNIIDSTxOolLgVBKUAYOR1zQMy+rngOBO3jMii2YiLUoXsO2TakEBXYcxAD94TUUjZLOkYnoE0lR5sI3vCYwlMVFpkLwmNV2QpDv0LwXWgzwqkKsH3DV1V5kSxmzhuocThu0N3NnxYm7sTOfblMe3jHaeC46951YBtKCPSxzJ2DNLaj6qYwh97htfTQJ8i1gC3/lr0saU3ZGb7w8Ekr0lBlhFYHIx44tpRHLOHoKm3cCKdFzenpavSnwCu3+5ESXJxj5+FbagDm6w3Jy/NcjEuMdU40VXJ7LjKXIJmvXZVegFfZs09NHNuqCFf/E4VboUg== 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=kbc6k7P+ygVSSbukIIpWKOMTxID22PkF6F3NAlV5wnI=; b=kZEhlGrE7qV93GrZ9GipWGGLj1CfgHzWZJ7uMtQvyjLihEIuV5wchIApdCneyCTMXG039ivHLhjTDXUg/7cNvi7nglng0UTLtoChlBnsknsDQilbEya9RMKdoOgesR+qg+92TWI1AH7Sv3jn7Lu0BZOfm9mcv31uI0Cjzd7wOfTT8K+sF7/nHM1Ogr0vTRwBVOHxOiPD9N8XvEoIN4myIFwnyLvrFq1O3FCAGzaO+qozYMOiIPX8BZYR0e+EeQ2L12oIhf9FS/p+ZuCTOrvPG6ajx+tbLHWe3AsDpK6ySEEoCMth9xkJqwB/aBnXAbT0CzkXK86v7YTn4oEIFZhVNA== 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=kbc6k7P+ygVSSbukIIpWKOMTxID22PkF6F3NAlV5wnI=; b=ggRj+YrFThahcZTCq2UGeJRsyhpxUpRi3k4ni0IQnPgROUatUDzOZ7Waon+BdGmVdvtvZN0F9Rh7VwHiSqSZLGt8FrzJA/QKb6OBY2LX2KS7zVu2UG7GbK8dTwbfGFAKTyVaJbVDWbsTpXzC5jk/T6LVfHChRH8W9cC9/rwLy04= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) by AS8PR08MB6551.eurprd08.prod.outlook.com (2603:10a6:20b:319::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.18; Wed, 28 Aug 2024 17:26:29 +0000 Received: from AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c]) by AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c%7]) with mapi id 15.20.7918.012; Wed, 28 Aug 2024 17:26:29 +0000 From: Mihail Atanassov To: linux-kernel@vger.kernel.org, Boris Brezillon , Liviu Dudau , Steven Price Cc: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Shashank Sharma , Ketil Johnsen , Akash Goel , Mihail Atanassov Subject: [PATCH 2/8] drm/panthor: Extend GROUP_CREATE for user submission Date: Wed, 28 Aug 2024 18:25:58 +0100 Message-ID: <20240828172605.19176-3-mihail.atanassov@arm.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240828172605.19176-1-mihail.atanassov@arm.com> References: <20240828172605.19176-1-mihail.atanassov@arm.com> X-ClientProxiedBy: LO4P123CA0109.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::6) To AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6263:EE_|AS8PR08MB6551:EE_|AM4PEPF00025F95:EE_|AM8PR08MB5826:EE_ X-MS-Office365-Filtering-Correlation-Id: 66b5d66a-4d9a-44ff-5b1f-08dcc7869680 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: jQIXgOjVcv0e2P1DEXvHz7rjGnvI5ZCcKqop232TPx8EHHqTO/p7nWau3E361idcXka2kRI/rY2SfJkgIncmGQdNyOnSppIZhipYyB9ekv6yw+oQ/rBsfNJRn3ZdxNe6/jokvV3uoRv8tlbCN+Mf0XSwTl85U2M+TzMmQTCimDPbikdEaCf1sEdMvPnxinflk1+e9m/Z5pDEtgJdIl8xEBv6ZlJ0ZQwStH0QGBLeAQ1OZ3AhijyAmPCBZnef9Rt3L4Tqzo3EDyANa3N4cSr5/KjZvaGtYB0Xd9Dji8AoJhFySsMTguaUAY/QCC7QDhoWA1o1314HwHnbj2SExlrNcLxNldOjfNzn/LwvgpaCOfxUpJDIb5yq48OhuXIoDP6vkNL4Lyov6fSOdjkhAK4xEPYlF2TcpZ7h+HGC2sfhu6y2mPYs8LP38LVMK6awcRp+bkGmiSK+pNCyz3Ngb72SdEbVKGMUa1IDR/zxx578OUupV0C9r3Tj0fu1+YMoM24t2pHJoxUCGoPVY0UP87wD96s5vHGSf4YMvYsFfdk5BGxQvhtZ250yzhQMSUY27GnFLGYSRARfXmi2Wv3HOPYX2l7g4FxULH0EwlbqiTj0Zx15Dkd9xRFo/xrfm/2kHYttx21ht7xe/jUu1n0ynRg+3L4pNcLEAR3wloa0bfu+ssXAqVEwVv0q51r7vgV1LntxCz32WyoLZxQWds64r4aPMRGB5Lft3Dv/ms92+uUaMduMqFw6MtcaJhEr7UFPZ3rb/k9J+UnQytQ2rXU5LAe9D2PSLvj7clg92rKInQec0h+jmPRKUh36ntwvGzMRMl2dMrx0one0Rhlp74wNRjO9ht09cWDhmoqnBnQpXMgdPnwey3cBruSpjVMAgCgO4s8poKwHz1zQVvcqFI3qvfn+kU4/6qxufdWzd4A2Z7n7DZX3wIj4C4tR+yTAUkXppVTCqrBe5WNwFsS4H2OH5XNA6G5TyMe6xWXQW9Rf/fxD2EdGsv0PAZZRT3E7RFLnQmuTAyRH1oFpJScKT9Bzz90aS+caOS27dlraI85kHnbefCsNeHdvpvaQKQM1lC/Bs9yr3IlLYpxLUm6jIs3EhqDUKjpikKs8tSsyfdEeT2mZAiZgDnEOctOJ7Yc1uf9IavW3gB46z4jZjR7zJ26VKsnCzHViQJjd2PVndqk/JEWh8DNVgqmJ+w3rM23YiPzzwM3+4uhyn/yy2DeBl3+AijKjGqlgd1yuL2kfCSybwyVIkMUAsAhI1tfubJKQuOzxjj3/gFkjwTPS2oP8WnoA9390LT+QsJB9uaeD6nPA2cnBf6LUeS/nP4SPo6T8RhoGwfCovbKh32O28MQcdLUKGK4dcQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6263.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6551 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:20b:290::9]; domain=AS8PR08MB6263.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM4PEPF00025F95.EURPRD83.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 26b15f1a-173d-4bc5-7777-08dcc7868d82 X-Microsoft-Antispam: BCL:0; ARA:13230040|35042699022|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: 6KVzaap0Qu4X/56snWXWKWCzo/SdZFWOGDWEfo4nq8RtMCEECnhYlRqMUvuUeqwsXzX9qNl/MF+grJLu2te1R50jC5Kf5m3bk7rG4wmfBhc2+JYA1c+huXYFuWMUQ3RPolNEv//WcrQMnJNkgBtlKVjkOtcDKjmPVEWP1Zs+OyI48fxwTa0feqROPEqAomY6evIgNco+9duWoAwM9nEtbGIhXo83k94TD3VnYs/kFeVJsrYqWb5R15x37wVc0Xgln+wUbL1CC9KZkHBOtDii7nztdxKzdqKVWkwClSEShMYxhUwsfPR/UUTohBd0PB2DdJIjo5WiLo8I+RIrrI1ZcVV3PIgUHMyX68ZjPaxfsWHl98xd9KjMzYXVF8ZtnrEWIHF4LmCEg8kcLCvJuQlbZtbmAy8PB2pQ+o5Skc7emkViij/6EpaFHs5LF/cVqyiTx9VOOKaWcM/v0CnRbMP4brLlGYdwX7dTPQ55JupjypsAT6vgnjGRWQGU7of1IU/k9cFtd28t766J+aIZ8OkTTRaVTm9GqvsxhE1DimMWuPvA405aJZfWqIKV4SHlFQMPwUKN3USIOtyN1oZlOoejjC5NAhUeHSNwV9l41FgE8e+ityRFKUGnkWzc0iAtKqmUX2xzz4tDBX0ZWXBozN9zoXX6bFnfmjjM4uQRl3fv8NlwyJv7Ozdqx1h1lkOwHtlnxpue/ctJnj6Q7K4m1NimG2E0yUgpXAf/dl4rNHAfr927l1uF4pt8Kdp6JjSGlzAyIJeWw9S4AbIH9xBlXq9gIRRng7r2FMuGXMSOH52jaD1snGsy0VFV69y+y9nCI6Tw8YSpwBuzpOm8dkmb+i7tFnecWkB7PBtZSJu05shm2ZFPHpiEmBSSEvcBtY+U8Q9oOpZtXDmm/xNjpt5fZJ4kmlK72/OGhRAFk/o7Em3s/TlmnboMchD07hIEthVvg03+5fM/fwvmx2kKTzFP/8Irp+tlltOxQUREcztVhpyoyQI0iPY0Ykv/esEfeB/WQMd3LT8sZkZ9C1M/TIg2KN/gxsRhyYgn4bEH4tZuscJrJZE7xnxVPErLC7uImycM7nFXJXNnXsu11rXDzPGFJYokShqQxBijMhxZFqMAvn2gXrt+AFYpHtJSEMb9RnSGqsJKC9KHWjmU1oZidtdQV/dZVC+FdTsZQJVDw93O6q5x0QzNfDNjqiE1i6u4R9MuUuUHxXpjz1zWDkQHdOICMOq2bXNbTHtWCe9ziXIiuef1x80N5oow43Xf15AYhRLO7fqGmB0rtRCHprJgEMKl/ZzISM/CPd6aZV2YYUHuFmvliicrR6kLKRTOt5bGuSfYOz2hYTeIgHZr+8P4g6PnQW5YfzNibkEsRPW7a+FhsjzRC/gTudEM58axRujYHon3fQR93q9mTd7lm56bPeRLC/UTcnyVN9bLpuVO8ksn4dFzVBcweLhZETmMYGk2A13n9WTS 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:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230040)(35042699022)(1800799024)(376014)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2024 17:26:44.3525 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66b5d66a-4d9a-44ff-5b1f-08dcc7869680 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: AM4PEPF00025F95.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5826 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ketil Johnsen Allow userspace to mmap() the ring buffer, and the doorbell and user I/O pages, so that it can submit work directly to queues. Signed-off-by: Ketil Johnsen Co-developed-by: Mihail Atanassov Signed-off-by: Mihail Atanassov Co-developed-by: Akash Goel Signed-off-by: Akash Goel --- drivers/gpu/drm/panthor/panthor_device.h | 24 ++++ drivers/gpu/drm/panthor/panthor_drv.c | 69 ++++++++++- drivers/gpu/drm/panthor/panthor_sched.c | 151 ++++++++++++++++++----- drivers/gpu/drm/panthor/panthor_sched.h | 4 +- 4 files changed, 209 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h index e388c0472ba7..7c27dbba8270 100644 --- a/drivers/gpu/drm/panthor/panthor_device.h +++ b/drivers/gpu/drm/panthor/panthor_device.h @@ -171,6 +171,9 @@ struct panthor_file { /** @ptdev: Device attached to this file. */ struct panthor_device *ptdev; + /** @drm_file: Corresponding drm_file */ + struct drm_file *drm_file; + /** @vms: VM pool attached to this file. */ struct panthor_vm_pool *vms; @@ -353,6 +356,27 @@ static int panthor_request_ ## __name ## _irq(struct panthor_device *ptdev, \ pirq); \ } +/* + * We currently set the maximum of groups per file to an arbitrary low value. + * But this can be updated if we need more. + */ +#define MAX_GROUPS_PER_POOL 128 + +/* + * The maximum page size supported by the driver, when running with a smaller + * page size only the first page at this offset is valid. + */ +#define DRM_PANTHOR_MAX_PAGE_SHIFT 16 + +/* Carve out private MMIO offsets */ +#define PANTHOR_PRIVATE_MMIO_OFFSET (DRM_PANTHOR_USER_MMIO_OFFSET + (1ull << 42)) + +/* Give out file offset for doorbell pages based on the group handle */ +#define PANTHOR_DOORBELL_OFFSET(group) (PANTHOR_PRIVATE_MMIO_OFFSET + \ + ((group) << DRM_PANTHOR_MAX_PAGE_SHIFT)) +#define PANTHOR_DOORBELL_OFFSET_START PANTHOR_DOORBELL_OFFSET(0) +#define PANTHOR_DOORBELL_OFFSET_END PANTHOR_DOORBELL_OFFSET(MAX_GROUPS_PER_POOL) + extern struct workqueue_struct *panthor_cleanup_wq; #endif diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c index 4f1efe616698..0bd600c464b8 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -67,6 +67,54 @@ panthor_set_uobj(u64 usr_ptr, u32 usr_size, u32 min_size, u32 kern_size, const v return 0; } +/** + * panthor_set_uobj_array() - Copy a kernel object array into a user object array. + * @out: The object array to copy to. + * @min_stride: Minimum array stride. + * @obj_size: Kernel object size. + * + * Helper automating kernel -> user object copies. + * + * Don't use this function directly, use PANTHOR_UOBJ_SET_ARRAY() instead. + * + * Return: 0 on success, a negative error code otherwise. + */ +static int +panthor_set_uobj_array(const struct drm_panthor_obj_array *out, u32 min_stride, u32 obj_size, + const void *in) +{ + if (out->stride < min_stride) + return -EINVAL; + + if (!out->count) + return 0; + + if (obj_size == out->stride) { + if (copy_to_user(u64_to_user_ptr(out->array), in, + (unsigned long)obj_size * out->count)) + return -EFAULT; + } else { + u32 cpy_elem_size = min_t(u32, out->stride, obj_size); + void __user *out_ptr = u64_to_user_ptr(out->array); + const void *in_ptr = in; + + for (u32 i = 0; i < out->count; i++) { + if (copy_to_user(out_ptr, in_ptr, cpy_elem_size)) + return -EFAULT; + + if (out->stride > obj_size && + clear_user(out_ptr + cpy_elem_size, out->stride - obj_size)) { + return -EFAULT; + } + + out_ptr += out->stride; + in_ptr += obj_size; + } + } + + return 0; +} + /** * panthor_get_uobj_array() - Copy a user object array into a kernel accessible object array. * @in: The object array to copy. @@ -182,6 +230,20 @@ panthor_get_uobj_array(const struct drm_panthor_obj_array *in, u32 min_stride, PANTHOR_UOBJ_MIN_SIZE(_src_obj), \ sizeof(_src_obj), &(_src_obj)) +/** + * PANTHOR_UOBJ_SET_ARRAY() - Copies from _src_array to @_dest_drm_panthor_obj_array.array. + * @_dest_drm_pvr_obj_array: The &struct drm_pvr_obj_array containing a __u64 raw + * pointer to the destination C array in user space and the size of each array + * element in user space (the 'stride'). + * @_src_array: The source C array object in kernel space. + * + * Return: Error code. See panthor_set_uobj_array(). + */ +#define PANTHOR_UOBJ_SET_ARRAY(_dest_drm_panthor_obj_array, _src_array) \ + panthor_set_uobj_array(_dest_drm_panthor_obj_array, \ + PANTHOR_UOBJ_MIN_SIZE((_src_array)[0]), \ + sizeof((_src_array)[0]), _src_array) + /** * PANTHOR_UOBJ_GET_ARRAY() - Copy a user object array to a kernel accessible * object array. @@ -1012,10 +1074,8 @@ static int panthor_ioctl_group_create(struct drm_device *ddev, void *data, return ret; ret = panthor_group_create(pfile, args, queue_args); - if (ret >= 0) { - args->group_handle = ret; - ret = 0; - } + if (!ret) + ret = PANTHOR_UOBJ_SET_ARRAY(&args->queues, queue_args); kvfree(queue_args); return ret; @@ -1262,6 +1322,7 @@ panthor_open(struct drm_device *ddev, struct drm_file *file) } pfile->ptdev = ptdev; + pfile->drm_file = file; ret = panthor_vm_pool_create(pfile); if (ret) diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c index b2cf053b3601..ad160a821957 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -384,6 +384,21 @@ struct panthor_queue { */ u8 doorbell_id; + /** @doorbell_offset: file offset user space can use to map the doorbell page */ + u64 doorbell_offset; + + /** @ringbuf_offset: file offset user space can use to map the ring buffer + * + * Only valid when group is created with DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT + */ + u64 ringbuf_offset; + + /** @user_io_offset: file offset user space can use to map the two user IO pages + * + * Only valid when group is created with DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT + */ + u64 user_io_offset; + /** * @priority: Priority of the queue inside the group. * @@ -524,6 +539,12 @@ struct panthor_group { /** @ptdev: Device. */ struct panthor_device *ptdev; + /** @pfile: associated panthor_file */ + struct panthor_file *pfile; + + /** @handle: integer value used by user to refer to this group */ + u32 handle; + /** @vm: VM bound to the group. */ struct panthor_vm *vm; @@ -548,6 +569,9 @@ struct panthor_group { /** @priority: Group priority (check panthor_csg_priority). */ u8 priority; + /** @user_submit: true if user space controls submission */ + bool user_submit; + /** @blocked_queues: Bitmask reflecting the blocked queues. */ u32 blocked_queues; @@ -708,12 +732,6 @@ struct panthor_group { mod_delayed_work((sched)->wq, &(sched)->wname ## _work, delay); \ } while (0) -/* - * We currently set the maximum of groups per file to an arbitrary low value. - * But this can be updated if we need more. - */ -#define MAX_GROUPS_PER_POOL 128 - /** * struct panthor_group_pool - Group pool * @@ -836,6 +854,12 @@ static void group_free_queue(struct panthor_group *group, struct panthor_queue * panthor_queue_put_syncwait_obj(queue); + if (queue->ringbuf_offset) + drm_vma_node_revoke(&queue->ringbuf->obj->vma_node, group->pfile->drm_file); + + if (queue->user_io_offset) + drm_vma_node_revoke(&queue->iface.mem->obj->vma_node, group->pfile->drm_file); + panthor_kernel_bo_destroy(queue->ringbuf); panthor_kernel_bo_destroy(queue->iface.mem); @@ -1552,7 +1576,7 @@ static void csg_slot_sync_update_locked(struct panthor_device *ptdev, lockdep_assert_held(&ptdev->scheduler->lock); - if (group) + if (group && !group->user_submit) group_queue_work(group, sync_upd); sched_queue_work(ptdev->scheduler, sync_upd); @@ -2019,10 +2043,12 @@ group_term_post_processing(struct panthor_group *group) } spin_unlock(&queue->fence_ctx.lock); - /* Manually update the syncobj seqno to unblock waiters. */ - syncobj = group->syncobjs->kmap + (i * sizeof(*syncobj)); - syncobj->status = ~0; - syncobj->seqno = atomic64_read(&queue->fence_ctx.seqno); + if (!group->user_submit) { + /* Manually update the syncobj seqno to unblock waiters. */ + syncobj = group->syncobjs->kmap + (i * sizeof(*syncobj)); + syncobj->status = ~0; + syncobj->seqno = atomic64_read(&queue->fence_ctx.seqno); + } sched_queue_work(group->ptdev->scheduler, sync_upd); } dma_fence_end_signalling(cookie); @@ -2785,6 +2811,9 @@ static void group_sync_upd_work(struct work_struct *work) u32 queue_idx; bool cookie; + if (drm_WARN_ON(&group->ptdev->base, group->user_submit)) + return; + cookie = dma_fence_begin_signalling(); for (queue_idx = 0; queue_idx < group->queue_count; queue_idx++) { struct panthor_queue *queue = group->queues[queue_idx]; @@ -3021,6 +3050,9 @@ group_create_queue(struct panthor_group *group, if (args->priority > CSF_MAX_QUEUE_PRIO) return ERR_PTR(-EINVAL); + if (args->ringbuf_offset || args->user_io_offset || args->doorbell_offset) + return ERR_PTR(-EINVAL); + queue = kzalloc(sizeof(*queue), GFP_KERNEL); if (!queue) return ERR_PTR(-ENOMEM); @@ -3046,6 +3078,20 @@ group_create_queue(struct panthor_group *group, if (ret) goto err_free_queue; + if (group->user_submit) { + ret = drm_vma_node_allow(&queue->ringbuf->obj->vma_node, group->pfile->drm_file); + if (ret) + goto err_free_queue; + + ret = drm_gem_create_mmap_offset(queue->ringbuf->obj); + if (ret) { + drm_vma_node_revoke(&queue->ringbuf->obj->vma_node, group->pfile->drm_file); + goto err_free_queue; + } + + queue->ringbuf_offset = drm_vma_node_offset_addr(&queue->ringbuf->obj->vma_node); + } + queue->iface.mem = panthor_fw_alloc_queue_iface_mem(group->ptdev, &queue->iface.input, &queue->iface.output, @@ -3056,6 +3102,21 @@ group_create_queue(struct panthor_group *group, goto err_free_queue; } + if (group->user_submit) { + ret = drm_vma_node_allow(&queue->iface.mem->obj->vma_node, group->pfile->drm_file); + if (ret) + goto err_free_queue; + + ret = drm_gem_create_mmap_offset(queue->iface.mem->obj); + if (ret) { + drm_vma_node_revoke(&queue->iface.mem->obj->vma_node, + group->pfile->drm_file); + goto err_free_queue; + } + + queue->user_io_offset = drm_vma_node_offset_addr(&queue->iface.mem->obj->vma_node); + } + ret = drm_sched_init(&queue->scheduler, &panthor_queue_sched_ops, group->ptdev->scheduler->wq, 1, args->ringbuf_size / (NUM_INSTRS_PER_SLOT * sizeof(u64)), @@ -3075,11 +3136,9 @@ group_create_queue(struct panthor_group *group, return ERR_PTR(ret); } -#define MAX_GROUPS_PER_POOL 128 - int panthor_group_create(struct panthor_file *pfile, - const struct drm_panthor_group_create *group_args, - const struct drm_panthor_queue_create *queue_args) + struct drm_panthor_group_create *group_args, + struct drm_panthor_queue_create *queue_args) { struct panthor_device *ptdev = pfile->ptdev; struct panthor_group_pool *gpool = pfile->groups; @@ -3115,6 +3174,7 @@ int panthor_group_create(struct panthor_file *pfile, group->csg_id = -1; group->ptdev = ptdev; + group->pfile = pfile; group->max_compute_cores = group_args->max_compute_cores; group->compute_core_mask = group_args->compute_core_mask; group->max_fragment_cores = group_args->max_fragment_cores; @@ -3130,6 +3190,9 @@ int panthor_group_create(struct panthor_file *pfile, INIT_WORK(&group->tiler_oom_work, group_tiler_oom_work); INIT_WORK(&group->release_work, group_release_work); + if (group_args->flags & DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT) + group->user_submit = true; + group->vm = panthor_vm_pool_get_vm(pfile->vms, group_args->vm_id); if (!group->vm) { ret = -EINVAL; @@ -3152,25 +3215,27 @@ int panthor_group_create(struct panthor_file *pfile, goto err_put_group; } - group->syncobjs = panthor_kernel_bo_create(ptdev, group->vm, - group_args->queues.count * - sizeof(struct panthor_syncobj_64b), - 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(group->syncobjs)) { - ret = PTR_ERR(group->syncobjs); - goto err_put_group; + if (!group->user_submit) { + group->syncobjs = panthor_kernel_bo_create(ptdev, group->vm, + group_args->queues.count * + sizeof(struct panthor_syncobj_64b), + 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(group->syncobjs)) { + ret = PTR_ERR(group->syncobjs); + goto err_put_group; + } + + ret = panthor_kernel_bo_vmap(group->syncobjs); + if (ret) + goto err_put_group; + + memset(group->syncobjs->kmap, 0, + group_args->queues.count * sizeof(struct panthor_syncobj_64b)); } - ret = panthor_kernel_bo_vmap(group->syncobjs); - if (ret) - goto err_put_group; - - memset(group->syncobjs->kmap, 0, - group_args->queues.count * sizeof(struct panthor_syncobj_64b)); - for (i = 0; i < group_args->queues.count; i++) { group->queues[i] = group_create_queue(group, &queue_args[i]); if (IS_ERR(group->queues[i])) { @@ -3188,6 +3253,21 @@ int panthor_group_create(struct panthor_file *pfile, if (ret) goto err_put_group; + group->handle = gid; + group_args->group_handle = gid; + + if (group->user_submit) { + for (i = 0; i < group_args->queues.count; i++) { + /* All queues in group use the same HW doorbell */ + group->queues[i]->doorbell_offset = PANTHOR_DOORBELL_OFFSET(gid - 1); + + /* copy to queue_args so these values can be returned to user */ + queue_args[i].doorbell_offset = group->queues[i]->doorbell_offset; + queue_args[i].ringbuf_offset = group->queues[i]->ringbuf_offset; + queue_args[i].user_io_offset = group->queues[i]->user_io_offset; + } + } + mutex_lock(&sched->reset.lock); if (atomic_read(&sched->reset.in_progress)) { panthor_group_stop(group); @@ -3199,7 +3279,7 @@ int panthor_group_create(struct panthor_file *pfile, } mutex_unlock(&sched->reset.lock); - return gid; + return 0; err_put_group: group_put(group); @@ -3390,6 +3470,11 @@ panthor_job_create(struct panthor_file *pfile, goto err_put_job; } + if (job->group->user_submit) { + ret = -EINVAL; + goto err_put_job; + } + if (job->queue_idx >= job->group->queue_count || !job->group->queues[job->queue_idx]) { ret = -EINVAL; diff --git a/drivers/gpu/drm/panthor/panthor_sched.h b/drivers/gpu/drm/panthor/panthor_sched.h index 3a30d2328b30..55b6534fa390 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.h +++ b/drivers/gpu/drm/panthor/panthor_sched.h @@ -19,8 +19,8 @@ struct panthor_group_pool; struct panthor_job; int panthor_group_create(struct panthor_file *pfile, - const struct drm_panthor_group_create *group_args, - const struct drm_panthor_queue_create *queue_args); + struct drm_panthor_group_create *group_args, + struct drm_panthor_queue_create *queue_args); int panthor_group_destroy(struct panthor_file *pfile, u32 group_handle); int panthor_group_get_state(struct panthor_file *pfile, struct drm_panthor_group_get_state *get_state); From patchwork Wed Aug 28 17:25:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 13781612 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F31FC636EE for ; Wed, 28 Aug 2024 17:26:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A22B610E319; Wed, 28 Aug 2024 17:26:55 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.b="W2Q7OUXJ"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="W2Q7OUXJ"; dkim-atps=neutral Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2076.outbound.protection.outlook.com [40.107.22.76]) by gabe.freedesktop.org (Postfix) with ESMTPS id 31E2410E319 for ; Wed, 28 Aug 2024 17:26:54 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=e/x4I9mgbY410QHUeKL7fsZwIcpbf+xmOMYVG4bbl1Mq++OkoR5zi3/VCLosJm9vs+gry8F0pet39R4D9vQSQpNC+lE/TDjREo27LUj8n2RG1XdUN7b/7CyB3VQby6BTr2P5VX776g1c1aR2y7dJh3D4FHJOWdqYWH2i5gAOiVRYSyQ1yuldOeh4FOQjcDa40NKt6zKQI30Yhp81ZAhGevmo2PhbxIRUZDQVwLibUvEA4Y0s4uhMUDHZUNG2vjT6HC8z9bXeZfzSNHsAcduqb0cD2sUKb66Q1JXT0AnjCf4p+G+4KiYSS42Vm9GiFZoyYirHP2BLMVY/9pvWJhw51g== 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=xeHX61/O/2umCZPw5t1DtMVfso/n8K7MF+3P+aihtWE=; b=pPzrzkItH3DE+fGevcjqp4BmtS1HbrydqeLSfkOdPRqsmc0K2lN6/45yghavwS4BukxWg83ogoo+VGROSRfDirhzV8g3TZsiEOcV6q4+/zHqgK2KECDF7GK05lmQmMVAIyHCZJEUK8R46t+CCAabAx7NRhbQ6EBafUGTNGRnJ+AfFAEQ3uVx52X210ITtlhluFIum3pwmBbdeTGWAhvmUUlJS5UyUob62cfq5PrsgxSEFAqdG6ZuzkCl+Wdmf57bNU3N8IO3Ia+XcpVeydU8G6g/2qE1jlG/uLwVaBRfEaw7JxCdmDlqbS+RfJ7YrN+1RzMy6XNwjD7+Naf6zlGMhw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.freedesktop.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=xeHX61/O/2umCZPw5t1DtMVfso/n8K7MF+3P+aihtWE=; b=W2Q7OUXJDnmX5WN7lhH06Qt+2hiUtfPCTG6j/Y8wUEIEzN6TkbPIi29DGr04Pyky6z2CIm5E+1geGsk4tHoybU2fcYOvk/dImtCFOlA9cXPslDsShyVOPwhv3xcM9RMPvb7Hy1Fl3a1dxHvss1BUG1AKiBoNOf5txYSk2VqCRG4= Received: from AM4PR05CA0001.eurprd05.prod.outlook.com (2603:10a6:205::14) by PA4PR08MB7571.eurprd08.prod.outlook.com (2603:10a6:102:270::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.14; Wed, 28 Aug 2024 17:26:47 +0000 Received: from AMS1EPF0000004A.eurprd04.prod.outlook.com (2603:10a6:205:0:cafe::d6) by AM4PR05CA0001.outlook.office365.com (2603:10a6:205::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27 via Frontend Transport; Wed, 28 Aug 2024 17:26:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AMS1EPF0000004A.mail.protection.outlook.com (10.167.16.134) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 28 Aug 2024 17:26:47 +0000 Received: ("Tessian outbound 8e666bd17457:v403"); Wed, 28 Aug 2024 17:26:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 15b7cb167668d8f4 X-CR-MTA-TID: 64aa7808 Received: from Lf956fe85abe3.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CDCA5A81-66DA-497B-86BB-23DBFC2F6D54.1; Wed, 28 Aug 2024 17:26:36 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Lf956fe85abe3.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Aug 2024 17:26:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zNXwtjdy0oloupi7lxa8rOnGgFsmwPUq/QlHCXIOtZI69igVML3v/knB1+/x/pk98FW2l7uH6HefK3Iv02mgRPH8RWWu+Q2AA+ISIm+a4EQwePRg6bqfoR3kxoiE846GHHrmF3kyl7oDGxUOuTk4Bg1vOkI2fTqCli6cqf1ny36ZizTkqAx5OrhHmy26Qt1jhxh5S1GdYosvnhiduMpvWOqqUFJ0Lh8sBoHHrgieGfI14Q6lndDnitN3brpeInjeU1F7nu3scvhwdreBWhMeh/WY7iKTIU9lNU1hOgCyEHdyZff3LQE7nJ8RfxGU06ZK0LJdv3u5T0ctbeFsqb6/1A== 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=xeHX61/O/2umCZPw5t1DtMVfso/n8K7MF+3P+aihtWE=; b=c/pOl2fezuzyUwnSqoI2Yr+nSZGVYkkzbueWYY+EdUZqOpZ2bjoKr9UHCqBWYciuMKG46n/AcEyAYWGoFhht/8NPwPoliS0VBn1iciKgA5kS0etXYIwdCmsuozvEQJT8zkhScAK+ohq4znwGpMfR9DytvUsfidaAQ/Q3cGk2bxp2Z/8o2g5rzCQxTzNd0FfMcd91HBcj+8rGF46ZDGB9dCeP4qJ5UfU8CYwGEOTLgKzq7DQgyukx2FPRkWETKp8cOqxymsjt9lLpELRYoG5MhSDyZZ00+2jhZYWcg7Pb8Hg6q6Jm1YNb0NWMTVOv4RAskd15n2sNWN5aGpD6Y1ZJUA== 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=xeHX61/O/2umCZPw5t1DtMVfso/n8K7MF+3P+aihtWE=; b=W2Q7OUXJDnmX5WN7lhH06Qt+2hiUtfPCTG6j/Y8wUEIEzN6TkbPIi29DGr04Pyky6z2CIm5E+1geGsk4tHoybU2fcYOvk/dImtCFOlA9cXPslDsShyVOPwhv3xcM9RMPvb7Hy1Fl3a1dxHvss1BUG1AKiBoNOf5txYSk2VqCRG4= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) by AS8PR08MB6551.eurprd08.prod.outlook.com (2603:10a6:20b:319::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.18; Wed, 28 Aug 2024 17:26:33 +0000 Received: from AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c]) by AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c%7]) with mapi id 15.20.7918.012; Wed, 28 Aug 2024 17:26:33 +0000 From: Mihail Atanassov To: linux-kernel@vger.kernel.org, Boris Brezillon , Liviu Dudau , Steven Price Cc: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Shashank Sharma , Ketil Johnsen , Akash Goel , Mihail Atanassov Subject: [PATCH 3/8] drm/panthor: Map doorbell pages Date: Wed, 28 Aug 2024 18:25:59 +0100 Message-ID: <20240828172605.19176-4-mihail.atanassov@arm.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240828172605.19176-1-mihail.atanassov@arm.com> References: <20240828172605.19176-1-mihail.atanassov@arm.com> X-ClientProxiedBy: LO4P123CA0120.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:192::17) To AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6263:EE_|AS8PR08MB6551:EE_|AMS1EPF0000004A:EE_|PA4PR08MB7571:EE_ X-MS-Office365-Filtering-Correlation-Id: fe0da80c-ec5b-40bb-d9a5-08dcc7869868 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: zrGKAEk/GItpKimgYibyl4ro+EjW0sXNC/EPr6kALlpB1dU7vh4QRocFmzQLnf6bjbKIObjX7m2y2hQIIjXIHg/YYraheZiF4hB6jD+q5mz5z+gWv6jrTq7kMUQCstOcYYrCgE6gBK8fLQckXPGxNNAC6lB64wTGgUp7bNKcIIqHkZRzrPPQ7wKLMnPE5BvNyFIOCY0R+rjIID+vYJkpWMuKvSlupA75e36x7+ILg6TlvzWf/OLlhWrau89DjPZxWwEpoyL5c5O0HWdsT3LFGljhB1Yzkhs2VQjFw4YUlezT+kPsZyPecjR0o/QQfSNlk0sHJBj+/d5OQwUHBCGHNPSzkRcC0r5/GslqaNMpQ3UK04DFW/cPESwYZfH9CgsuEGhrvNtl78f0C+EsPiBDdAAvml7PVyFQ5WljPsSO7oOctR3NfSDkR4yW+2zK9rmuVabseV/kOykWtBESopbkO8SPaL/WFviZqc/T+5Pu2eKTfJB8uRY9KbToGrXOMcjf8pqddMEPT/u7fIe/l5lUsL8fopultoB59KpKr0/bY38IfgcA0BYHpg7c4sYqqIGRil6D8j8VuGacf/I4mfqoJviOLFXE5Bbj8x+CeDtyg3lDBfo44f4v+MBSho4AHfrjNV/WhbaRsj7PuiKF6yvz99iDwTx2U3zsRn9GX+MGXhwIBR8o2fsi1D8uTywpVwwrYUazo9h2GlHYifPc4vY+uKltJCh+iinoWCdoiI/Japw9IOaMif+Zu2HlQAPGrOTU/npuyZyD384SOf8rsg4V0d/bLlCjB2HCIn4UrGIL7+Htn4nbMSziLErvOKRa7lI9jxaevwNe0wEUCEf2hMwBqlD2rOL0pIFjg4SIJMhA9AmAZECP4ISKw3BTrDoe/Z4/uBixdEbSTANVC4YLEwdVzK1hV2X8FGbdzogT/bSmDRhp4+PHmjplIDw8bxKMuKWAzQgQqSh6u7w6wShEJircJqC8vuM7XveKFpKPfFeatdQeccWUEtCEbDC/TZbv5WbsTCRa5+zjjthHguWUHppLhYQIuuDnBaWnnyplK/je4/1ri9KRBkiHjcO38xUlwWsgeEjjVWyjO19dsjY04jazmgU6txBZvCAleS5fTVti420EVWcqIsFpYI9ObYNIERwHy6tcYQR7ygztwUxqDersJJB2NPTzcPYwYYTl139/6+KUwWO692SbZ2a87RLNsyWfxJiZIw+ORIM0k0+7RUbzeqfSvscubIsO2PWk7l97K3N8nm/8P+A97cT1JG2LIFM1lSTLyaPdbpin0xlqaMqauIZZXYYStT8RZJ+7ygd0JISgfIBnMygglbCXd4picchKUwlrG6fYH8T3N2d+4PUQVg== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6263.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6551 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:20b:290::9]; domain=AS8PR08MB6263.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS1EPF0000004A.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 132e0104-8de0-4b94-6cad-08dcc7868fbb X-Microsoft-Antispam: BCL:0; ARA:13230040|35042699022|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: XOc8r2rwIX7XpnMWAUkA/sjn6bqrSR7Ek+yDt/cOfXsyM94eX/PXEzEB8BRVWV55I1YAne/YbIJGwdp0FhF5XsQ9ghNLPvq3G/lJYbW9wB5pBr1BvN4a+af4pac9xA35CLTm76tkfWMA7D9x9OP8yau3lAYGpwZvp8lCZoo37VCpFJVVoPVdQ8bUUoxGp5Lna/b3QfYW0Rtn2ASh0Yez0xxjZah+afffgFNFaPIOK6d3AZUc2oVrmoRGaYApYM4+80eOVjRNiSXBdu6BVlGHo7w213KSaJiTPfSNQq9RZ+dQ4l055N4Gyb6vG2DnN6yQCCwO0eiS9lsgI4h/HGzQmolrk2JNniN9jObLah+kRdMceHvtYCZJzAoTSjxeAq3S7rdAnfCPnS7MwB6qxEMgEvUQLyC5xOz716LIZ5ElQq+pUzcgtl47X6xznLpp5pSLKgIPu62gnK3HkTbQ+7xRCYVCCywIM+E3NHKO/hgZeMSEGpdJ6zb9nbYloO1NoF4nPI4osMnA4HN3ORFl1mr+pl9tTs0S76s5Cre0hWgKCJOcy5ipe0vzh76rbDb1lk5d7y6aUYtGvrSMnIoogZqS31fN5SOvCGRS3gghyFxP1RSHVOnMnSLmi/OVa3E5ULzWTtzCrTrbqE/tS8cXj5HG/8lMcoWfpMJ05fMCGiJ9fagCjI6NaKypbJi+HIjALqrXpZc2nIhs/48ccM86EECy6npoBYOVdZ99MWW8qbdVyXfTNCoGOmvans/u4k05gMKSloa6XMNlHeDnKwa7SVESwDs4Ye1N/yfsDNc8Qa0MDwgKXh0CvzodI6TMP6kKl1/Y4MxAj7OVU6LsjzXl0Abnsa2kqS/cHfIjwed8UHpsVYH2wtqm2wZjjiWv8H0pJVLeyeP6K1WocXUK2nzOBPNHvQZvKAuMDWbGsjPlS8KJ8L1hVjtH8l7X9oVg2+CWUSaOiEzLJII8qAZc+f7YmK4c5PRH8AkfAk6X3XlBN+O/Sb9IIbsjr/7XN8bTDqD76NrHPnCYFjlurD7hco0tKyJMxHqoN5903WXFKEuk1yse1cBjv3B2HHBnhU6th/RE5obmwdQI49HPv4WOU2s3H9uXKNh95/geHh3jJt8CaKNoGKHJdMMatzE/P4YhgY5/fxpP6wJ6q4wD6agOddvJaGPAuTniAnKOm8e1luJyxdwgpPTEUxL0GI1ZiCpx43GeOeKd5eDPzjTO3v6qSHZhS+dxA3eFnivOQnX0tCC7pXPDo5o/IG9N7jB9xp0D6Zs/51SbC0aUbt9MMBE4MBQ7qvUWliYChlHSVSGFuByB+Wv4kSLEmiK9/rUujH5UbZyr+wHx5aqsfNMPFN2PGdj57WDvu6vY+DSvRL+KtO5fj0Xa6yg3eO3b/PCgzjxVCvLcT6sSlyDP3RxWjPe4sSVgh5BuAUAcqPH393Nk9A2r+0JBWim4I31p//lRcjGzAzKInyys 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:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230040)(35042699022)(1800799024)(376014)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2024 17:26:47.5696 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe0da80c-ec5b-40bb-d9a5-08dcc7869868 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AMS1EPF0000004A.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR08MB7571 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ketil Johnsen Dinging the doorbell directly from userspace allows the user driver to bypass the kernel if the group is already assigned and active. Signed-off-by: Ketil Johnsen Signed-off-by: Mihail Atanassov --- drivers/gpu/drm/panthor/panthor_device.c | 66 ++++++++++++++++++------ drivers/gpu/drm/panthor/panthor_device.h | 7 ++- drivers/gpu/drm/panthor/panthor_drv.c | 3 +- drivers/gpu/drm/panthor/panthor_fw.c | 2 +- drivers/gpu/drm/panthor/panthor_sched.c | 46 ++++++++++++++++- drivers/gpu/drm/panthor/panthor_sched.h | 2 + 6 files changed, 104 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c index 4082c8f2951d..3c376e21bd2e 100644 --- a/drivers/gpu/drm/panthor/panthor_device.c +++ b/drivers/gpu/drm/panthor/panthor_device.c @@ -179,6 +179,14 @@ int panthor_device_init(struct panthor_device *ptdev) if (ret) return ret; + ptdev->dummy_doorbell_page = alloc_page(GFP_KERNEL | __GFP_ZERO); + if (!ptdev->dummy_doorbell_page) + return -ENOMEM; + + ret = drmm_add_action_or_reset(&ptdev->base, panthor_device_free_page, + page_address(ptdev->dummy_doorbell_page)); + if (ret) + return ret; /* * Set the dummy page holding the latest flush to 1. This will cause the * flush to avoided as we know it isn't necessary if the submission @@ -343,41 +351,58 @@ const char *panthor_exception_name(struct panthor_device *ptdev, u32 exception_c static vm_fault_t panthor_mmio_vm_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; - struct panthor_device *ptdev = vma->vm_private_data; + struct panthor_file *pfile = vma->vm_private_data; + struct panthor_device *ptdev = pfile->ptdev; u64 offset = (u64)vma->vm_pgoff << PAGE_SHIFT; unsigned long pfn; pgprot_t pgprot; vm_fault_t ret; bool active; int cookie; + u32 group_handle; + u8 doorbell_id; if (!drm_dev_enter(&ptdev->base, &cookie)) return VM_FAULT_SIGBUS; - mutex_lock(&ptdev->pm.mmio_lock); - active = atomic_read(&ptdev->pm.state) == PANTHOR_DEVICE_PM_STATE_ACTIVE; - switch (offset) { case DRM_PANTHOR_USER_FLUSH_ID_MMIO_OFFSET: - if (active) + mutex_lock(&ptdev->pm.mmio_lock); + + pgprot = vma->vm_page_prot; + + active = atomic_read(&ptdev->pm.state) == PANTHOR_DEVICE_PM_STATE_ACTIVE; + if (active) { pfn = __phys_to_pfn(ptdev->phys_addr + CSF_GPU_LATEST_FLUSH_ID); - else + pgprot = pgprot_noncached(pgprot); + } else { pfn = page_to_pfn(ptdev->pm.dummy_latest_flush); + } + + ret = vmf_insert_pfn_prot(vma, vmf->address, pfn, pgprot); + + mutex_unlock(&ptdev->pm.mmio_lock); + + break; + + case PANTHOR_DOORBELL_OFFSET_START ... (PANTHOR_DOORBELL_OFFSET_END - 1): + group_handle = PANTHOR_DOORBELL_GROUP_FROM_OFFSET(offset) + 1; + + doorbell_id = panthor_sched_doorbell_id(pfile, group_handle); + if (doorbell_id != (u8)-1) + pfn = PHYS_PFN(ptdev->phys_addr + CSF_DOORBELL(doorbell_id)); + else + pfn = page_to_pfn(ptdev->dummy_doorbell_page); + + ret = vmf_insert_pfn_prot(vma, vmf->address, pfn, + pgprot_device(vma->vm_page_prot)); + break; default: ret = VM_FAULT_SIGBUS; - goto out_unlock; } - pgprot = vma->vm_page_prot; - if (active) - pgprot = pgprot_noncached(pgprot); - - ret = vmf_insert_pfn_prot(vma, vmf->address, pfn, pgprot); - -out_unlock: - mutex_unlock(&ptdev->pm.mmio_lock); drm_dev_exit(cookie); return ret; } @@ -386,7 +411,7 @@ static const struct vm_operations_struct panthor_mmio_vm_ops = { .fault = panthor_mmio_vm_fault, }; -int panthor_device_mmap_io(struct panthor_device *ptdev, struct vm_area_struct *vma) +int panthor_device_mmap_io(struct panthor_file *pfile, struct vm_area_struct *vma) { u64 offset = (u64)vma->vm_pgoff << PAGE_SHIFT; @@ -398,12 +423,19 @@ int panthor_device_mmap_io(struct panthor_device *ptdev, struct vm_area_struct * break; + case PANTHOR_DOORBELL_OFFSET_START ... (PANTHOR_DOORBELL_OFFSET_END - 1): + if (vma->vm_end - vma->vm_start != PAGE_SIZE || + (vma->vm_flags & (VM_READ | VM_EXEC))) + return -EINVAL; + + break; + default: return -EINVAL; } /* Defer actual mapping to the fault handler. */ - vma->vm_private_data = ptdev; + vma->vm_private_data = pfile; vma->vm_ops = &panthor_mmio_vm_ops; vm_flags_set(vma, VM_IO | VM_DONTCOPY | VM_DONTEXPAND | diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h index 7c27dbba8270..87cce384e36a 100644 --- a/drivers/gpu/drm/panthor/panthor_device.h +++ b/drivers/gpu/drm/panthor/panthor_device.h @@ -162,6 +162,9 @@ struct panthor_device { */ struct page *dummy_latest_flush; } pm; + + /** @dummy_doorbell_page: dummy doorbell page when queue is not on HW */ + struct page *dummy_doorbell_page; }; /** @@ -204,7 +207,7 @@ static inline bool panthor_device_reset_is_pending(struct panthor_device *ptdev) return atomic_read(&ptdev->reset.pending) != 0; } -int panthor_device_mmap_io(struct panthor_device *ptdev, +int panthor_device_mmap_io(struct panthor_file *pfile, struct vm_area_struct *vma); int panthor_device_resume(struct device *dev); @@ -376,6 +379,8 @@ static int panthor_request_ ## __name ## _irq(struct panthor_device *ptdev, \ ((group) << DRM_PANTHOR_MAX_PAGE_SHIFT)) #define PANTHOR_DOORBELL_OFFSET_START PANTHOR_DOORBELL_OFFSET(0) #define PANTHOR_DOORBELL_OFFSET_END PANTHOR_DOORBELL_OFFSET(MAX_GROUPS_PER_POOL) +#define PANTHOR_DOORBELL_GROUP_FROM_OFFSET(offset) \ + ((offset - PANTHOR_PRIVATE_MMIO_OFFSET) >> DRM_PANTHOR_MAX_PAGE_SHIFT) extern struct workqueue_struct *panthor_cleanup_wq; diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c index 0bd600c464b8..e391ab6aaab2 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -1381,7 +1381,6 @@ static int panthor_mmap(struct file *filp, struct vm_area_struct *vma) { struct drm_file *file = filp->private_data; struct panthor_file *pfile = file->driver_priv; - struct panthor_device *ptdev = pfile->ptdev; u64 offset = (u64)vma->vm_pgoff << PAGE_SHIFT; int ret, cookie; @@ -1404,7 +1403,7 @@ static int panthor_mmap(struct file *filp, struct vm_area_struct *vma) #endif if (offset >= DRM_PANTHOR_USER_MMIO_OFFSET) - ret = panthor_device_mmap_io(ptdev, vma); + ret = panthor_device_mmap_io(pfile, vma); else ret = drm_gem_mmap(filp, vma); diff --git a/drivers/gpu/drm/panthor/panthor_fw.c b/drivers/gpu/drm/panthor/panthor_fw.c index ef232c0c2049..ce51f75a419b 100644 --- a/drivers/gpu/drm/panthor/panthor_fw.c +++ b/drivers/gpu/drm/panthor/panthor_fw.c @@ -444,7 +444,7 @@ panthor_fw_alloc_queue_iface_mem(struct panthor_device *ptdev, int ret; mem = panthor_kernel_bo_create(ptdev, ptdev->fw->vm, SZ_8K, - DRM_PANTHOR_BO_NO_MMAP, + 0, DRM_PANTHOR_VM_BIND_OP_MAP_NOEXEC | DRM_PANTHOR_VM_BIND_OP_MAP_UNCACHED, PANTHOR_VM_KERNEL_AUTO_VA); diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c index ad160a821957..471bb8f2b44c 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -954,6 +954,10 @@ group_bind_locked(struct panthor_group *group, u32 csg_id) for (u32 i = 0; i < group->queue_count; i++) group->queues[i]->doorbell_id = csg_id + 1; + /* Unmap the dummy doorbell page (if mapped) */ + unmap_mapping_range(ptdev->base.anon_inode->i_mapping, + PANTHOR_DOORBELL_OFFSET(group->handle - 1), 0, 1); + csg_slot->group = group; return 0; @@ -990,6 +994,10 @@ group_unbind_locked(struct panthor_group *group) for (u32 i = 0; i < group->queue_count; i++) group->queues[i]->doorbell_id = -1; + /* Unmap the dummy doorbell page (if mapped) */ + unmap_mapping_range(ptdev->base.anon_inode->i_mapping, + PANTHOR_DOORBELL_OFFSET(group->handle - 1), 0, 1); + slot->group = NULL; group_put(group); @@ -1726,6 +1734,41 @@ void panthor_sched_report_fw_events(struct panthor_device *ptdev, u32 events) sched_queue_work(ptdev->scheduler, fw_events); } +/** + * panthor_sched_doorbell_id() - Get the doorbell ID for a given group. + * @pfile: Panthor file. + * @group_handle: group slot id + * + * Return: a doorbell ID if valid, -1 otherwise + */ +u8 panthor_sched_doorbell_id(struct panthor_file *pfile, u32 group_handle) +{ + struct panthor_group_pool *gpool = pfile->groups; + struct panthor_scheduler *sched = pfile->ptdev->scheduler; + u8 doorbell_id; + struct panthor_group *group; + + group = group_get(xa_load(&gpool->xa, group_handle)); + if (!group) + return -1; + + if (!group->queue_count) { + doorbell_id = -1; + goto err_put_group; + } + + mutex_lock(&sched->lock); + + /* In current implementation, all queues of same group share same doorbell page. */ + doorbell_id = group->queues[0]->doorbell_id; + + mutex_unlock(&sched->lock); + +err_put_group: + group_put(group); + return doorbell_id; +} + static const char *fence_get_driver_name(struct dma_fence *fence) { return "panthor"; @@ -3057,6 +3100,7 @@ group_create_queue(struct panthor_group *group, if (!queue) return ERR_PTR(-ENOMEM); + queue->doorbell_id = -1; queue->fence_ctx.id = dma_fence_context_alloc(1); spin_lock_init(&queue->fence_ctx.lock); INIT_LIST_HEAD(&queue->fence_ctx.in_flight_jobs); @@ -3065,7 +3109,7 @@ group_create_queue(struct panthor_group *group, queue->ringbuf = panthor_kernel_bo_create(group->ptdev, group->vm, args->ringbuf_size, - DRM_PANTHOR_BO_NO_MMAP, + 0, DRM_PANTHOR_VM_BIND_OP_MAP_NOEXEC | DRM_PANTHOR_VM_BIND_OP_MAP_UNCACHED, PANTHOR_VM_KERNEL_AUTO_VA); diff --git a/drivers/gpu/drm/panthor/panthor_sched.h b/drivers/gpu/drm/panthor/panthor_sched.h index 55b6534fa390..0b3a2ee2a0ad 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.h +++ b/drivers/gpu/drm/panthor/panthor_sched.h @@ -47,4 +47,6 @@ void panthor_sched_resume(struct panthor_device *ptdev); void panthor_sched_report_mmu_fault(struct panthor_device *ptdev); void panthor_sched_report_fw_events(struct panthor_device *ptdev, u32 events); +u8 panthor_sched_doorbell_id(struct panthor_file *pfile, u32 group_handle); + #endif From patchwork Wed Aug 28 17:26:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 13781615 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C424AC677C4 for ; Wed, 28 Aug 2024 17:27:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 37D3010E384; Wed, 28 Aug 2024 17:27:06 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.b="nGHL5dke"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="nGHL5dke"; dkim-atps=neutral Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2063.outbound.protection.outlook.com [40.107.247.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id D933C10E384 for ; Wed, 28 Aug 2024 17:27:02 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=bDWqKmUUklfZkI3vwr/gcvfo1MSPIuzqCx5mwVpNmAqj3pW1vI3etdZiNlLVZYkFqhk2lT3N499OWVrepJ9S5c3FLkRF0pli6mWYH385v/LHaQ7pXgx6/qaNjLuqfRz7mFddhormsALOHER0iqplFJ3D4GYYJnEHaNCYBp1Jn2gk33FkjqvuFm+8FdUZBvNvy5URsguoeOj6ub3UoWat317pxwgIXgmQrgcuzjnDPLUfCCVkbsO0tSInSSRK2WDurSb2+T8Fijpf+0AlFAK0yrK7VCHyx4s4ipaQ3xli9f103Y9yAku6bhQ9OzNajfOqpeY27w1z/zw5s70Z3gsuYg== 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=jsyr/X8MHIRhYF+PyOaSjkZn52wXKUqGIKzc+LyjLpw=; b=dK5XHKK7HMBHDgKJ4PzENsiXFUf8dvOMJuWziww/GAArMCYET04aZAv2bQ+WV2cBJL3znGaz7qE+y8OU97qJHYflWAZMPSsDlupZO+ChBrxy0BvuCcRU1VB4rXTUuLMIuwrxy9hkwXsqwSllTANMT9Uw1flzlxOrXmH1CzT4+Oukak5lJmdo+LnUggN1ApDnlDmQVTRQKp4ALtrv7mUNhtFO0aeJWZj0m4fdGvUmnEy0xsQEeBEEGAYXZhGgN293VXToB5Y9/X3hVaWtzPhsgEfXhtpPFxtmDG92INDRa781ORx2t5PNptuG5CyHgd13Y4hZFDKtwlU8wqkrJX/fYQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.freedesktop.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=jsyr/X8MHIRhYF+PyOaSjkZn52wXKUqGIKzc+LyjLpw=; b=nGHL5dkeJfyQlJbcCC/2iAzM6OCBeRkwc6ojam3wRoGqX9I4oZRadf0TKRWBpIKANnMWeowQ2c6CsKQaoPVlLEUtYErqr3Q6C44848yPy2RKmnw06cOnLtytUvNDbvifYjr3jHjINTAF+VYvugv175pOzbs+8NTTfgyh6JrS1C8= Received: from DUZPR01CA0179.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b3::10) by GV1PR08MB8380.eurprd08.prod.outlook.com (2603:10a6:150:80::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.14; Wed, 28 Aug 2024 17:26:51 +0000 Received: from DU6PEPF0000A7DF.eurprd02.prod.outlook.com (2603:10a6:10:4b3:cafe::91) by DUZPR01CA0179.outlook.office365.com (2603:10a6:10:4b3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27 via Frontend Transport; Wed, 28 Aug 2024 17:26: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 DU6PEPF0000A7DF.mail.protection.outlook.com (10.167.8.36) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 28 Aug 2024 17:26:50 +0000 Received: ("Tessian outbound de2677e4ad72:v403"); Wed, 28 Aug 2024 17:26:50 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d05880de0e48030d X-CR-MTA-TID: 64aa7808 Received: from Lf8210dc8d799.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id CBF86C59-D217-4141-B45D-DF5592FBC08C.1; Wed, 28 Aug 2024 17:26:39 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Lf8210dc8d799.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Aug 2024 17:26:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FA/8Nke9zGa91+MxQKVrdWGX0i9kqbZ5V0FGCdxLQXarAAHhNsDFKkux4E3sLcBwG0iEF8Mg9u7GeIrwIdfXPWAvEM/9rOfWmEO6PWluRG2eM0iGEy97rol3X28Bn5oSCk2BxPMxiLxbkBB5NILeuB8yGeZdMbe2S6tCjWbJdaWREMBYbJehFpqmWOLcpfBchoMi9FJ9IpLE2gZHRDsZaaAAWEmw/b0b6M2f6sAKZjK42vewk0N+lnnR5FXdasU/+VqP+RpnjyG1Oj8ucAHB3W92UnmsAdr1PRxzNp28eqjVIc7xM1+ZsbZ8mSNJ1UR9q7GonchMKV/irAheKG+N5g== 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=jsyr/X8MHIRhYF+PyOaSjkZn52wXKUqGIKzc+LyjLpw=; b=GuJ6NSqaEzTJ3M6BnoL4ThD5vv8hWEdB4D7QSOH0UqntZBM7olq3BsaCElXIrHKQSWLA3J2Imy4+Pc5x6L+SBpBFOcHbDo4to7R2S4iguDMAusMx7nKWveMt2lDJb810iyxhYN6v98/3MXa13F0T9sSxSiQqbQW+BVIe7XKPQa7N/NmhQ/55bNRWFbm3Mdnh+kJ86f4qCno1lQcPsX1FStziY54O18mAvvLtXKVAr+aHRzkaBpfnLhNR6ZO4oE19/GJrT7taPekrKWDWpK0ED4zSgvdPVicm7FJOQ0hi+jgjygMiCk2f6lDhh8FKOtEumC0hqSgqME2RLYSB35Pj6Q== 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=jsyr/X8MHIRhYF+PyOaSjkZn52wXKUqGIKzc+LyjLpw=; b=nGHL5dkeJfyQlJbcCC/2iAzM6OCBeRkwc6ojam3wRoGqX9I4oZRadf0TKRWBpIKANnMWeowQ2c6CsKQaoPVlLEUtYErqr3Q6C44848yPy2RKmnw06cOnLtytUvNDbvifYjr3jHjINTAF+VYvugv175pOzbs+8NTTfgyh6JrS1C8= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) by AS8PR08MB6551.eurprd08.prod.outlook.com (2603:10a6:20b:319::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.18; Wed, 28 Aug 2024 17:26:36 +0000 Received: from AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c]) by AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c%7]) with mapi id 15.20.7918.012; Wed, 28 Aug 2024 17:26:36 +0000 From: Mihail Atanassov To: linux-kernel@vger.kernel.org, Boris Brezillon , Liviu Dudau , Steven Price Cc: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Shashank Sharma , Ketil Johnsen , Akash Goel , Mihail Atanassov Subject: [PATCH 4/8] drm/panthor: Add GROUP_KICK ioctl Date: Wed, 28 Aug 2024 18:26:00 +0100 Message-ID: <20240828172605.19176-5-mihail.atanassov@arm.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240828172605.19176-1-mihail.atanassov@arm.com> References: <20240828172605.19176-1-mihail.atanassov@arm.com> X-ClientProxiedBy: LO2P265CA0076.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::16) To AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6263:EE_|AS8PR08MB6551:EE_|DU6PEPF0000A7DF:EE_|GV1PR08MB8380:EE_ X-MS-Office365-Filtering-Correlation-Id: 07f20e29-5480-41d7-360e-08dcc7869a46 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: xGgHVKwEom//WAyiRqVILzEXylRXdBCZMJ3LN/Cou0l8gsvjp6rUv7+KVno3h22njv/PkQszLL6q791HorrLjLjglLF7/crBbhwsV14BSNh2lZdgablFA3PwU5qy+oVh/DCDtjIygu6o/bKr87OSNzRAZy01t8OK0keVkjQC90t1rxgA/Arg960BoxeDM0Romcw560CMbc84cf6+K/o2faMX00UM471+7oTeAglJxew33oaLmE+c+8F6pRxD86vK7WdwOGlL4AN477TI+iBhurAIMQ5JhGSgLZH7trqND+02jUUzs2EPdR76Wg1y6yM0Lk8+NCrOiplHoH0T4OZTGQkCY0jFopFxFd7LO9hoGh6W60sRIJHMxTe7eH43rW/hDrIIXGDCpIpawUJS10oAo6Lf/Z/kaKoIvxxuLZ+WwqD0GWSkBh1vDd+rDxsNHt4eT6ABEXSfRF/gniogodjHsc/6BIOgiXryun+oVgVeGofVLWz2JzeIeihnk8mijAEyqRTCC8TYNzRQ3WEFvQBCIFpalvkIfQczK0CZZtg1Q/YpJFggiH4LLsPVA503GyhCKSGBo/rUI4bg8YqIW2uz7/mWqiebPCfPNEnS4CvTxlB6f47AlkJKJCBempLkg6uk264Y34YYqdZO0cL229sqqV2kx7Dz0/61XTdb4nYgolhxtfWkQ03HnA73U6gZeg9zxObwb4Hda/1DZCuy+v8tAR4VSHgpKBM8inEbcyP/rlP/SrZHJ/kYTKEpgCnjbaSdnxph15faju3JPAS3xF5WP6PpziJHxeZUr4hQ18O3iPh26Qt6H9mITlU5ESOamVAamf+kDlB4UO2xHVmbbOB/Bsm3h+/O3BI/K1l5mdTTdrVVni/HlR4rRO/7onGhwgkEJLzh6oAf69Yhx9i655FJAFSUnv/oYY2+gOWP+aQ0mkQ5QE0V01uGtZruq5RNuFZUjbqv0fwltpWdgxiu6IDF7e6eKxxNQtqLMQmYohnSFvazZ/kfDpAjCYEta2qPRpiE1cghStjKKJgVJxkWaOL+iKATJ6kwr9cdIiELxgBB7ngWMr83IiyubQ3zj3ARxolq0Rv44Xd0v14+q15m/48F/m0lK7/+O9xYqNEF+j2FkmDwfgm75otmX6dUKJLGsYpHPvCqMdUJnpfpZEcgWWgUQnKO4Cj3sf++5C/d2yWmKyxLg+EEz1LV2TrqSg5HoRynoWgBqHWI4EgyFG01x/TkZQSzA1hpkyZ6MyegGHrMowRGaiNnWxX+2uq2tXOO6O0elP1VLmlZPZvaYgr0ucu2JlIl5U0t+plOt9X625BgWfV/sKwp0VDJ+sPNdmdwcNnTf3H/G60kCvi51Dx3goR97Q== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6263.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6551 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:20b:290::9]; domain=AS8PR08MB6263.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU6PEPF0000A7DF.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a9bb92a3-99fe-420f-05ac-08dcc7869172 X-Microsoft-Antispam: BCL:0; ARA:13230040|35042699022|36860700013|1800799024|376014|82310400026; X-Microsoft-Antispam-Message-Info: 0FeuKenVtKotK4XIHwkmd3MEnmycSVjzicW+UlN3gMR4NiO0VgKtABIk3iTYF7FNbbe45P3og5yBmv0OOWstVsv3WXr3e+ZKRL+2EO0KLyjNkKxpxmpZ15ovNqdVL8H2ErAlJrbZVRGCn3qfc0/9Us3x3cyooMA5XOJOZ+bn1l/lOX9mxJCREaNuq/NH+XH8zSsZx4Fs937GaVeVknE+o+UJEnGr+iBroEnNYqvkBZ3ZBllpP5S8CLJwRmXH2BaZiqH17SWyrQVSURoJTTsAcGWNDE2oVij8ixr4jxkHYE69NRd0tBVBusU8OnQn0K50gXstcK1Z5fSTX7KHCHTUDcFjFhDreJImTo0hezcUNk4vlRwygKoebE51ltHrVvVUGSlcRJTA+KKgZqLU7E3HVXPDvRI1Pv6hhfncpS7vJdKqnZqnTxjhiUn+HTdZq/dMMuPPumaKcrCHqzSv4zLRaOH084pqks/dFagIwOekQ7nvGgUDzi9Y1kEvE0kVTKLwZK1Usaj7d84m9cGpSYdUa9RCrnpWGAkas4D1Qe3UhTiIsbnStWNkbK4C4ZaDiPk6ewG/9QgT77ArsSc8RHssKZ+byXnLt18BD9pvzP5QQUgra5fClnnPb42V2v7e3iCQebTfWbRn5nr8iAOD7oCUkaRl/7uZ0Bjf0LS2hmTDo0U19AyS0YLD+ekxHNY0cd31GRw0Dfd0K3kiESOvi+dT4hbmNiwzVD4MIrNo3Yr9Q7HpraAtHcqTv9PjlHDN0PVEEUxIrffD1aRDHOLLtYTifa5XAOR72vf07vOmLw4vTpSpFZvDiWZFQLi8OMlQ+YEJuZruSRzZxN8ezUwZkdZuWzSVXDp/rlyg4DeHbO11pW00PX15qnyXNm4Btt++EXSC/pkMuF3cadRSq3tu/wREqxTATBH8PGtTLaLkKELQFKXHni/SRCCMQ+4f8MCvu8EPKXTJlQLy19Y7CDert5y/YnecNxQe9mRQZF5SZh4GMdyEPcABhqQypfmTOq6ywSil6NupJxhgtMU+daeGYJ9+b8/LwRK/IAC+GOQqWRDWhhQgznI2htax56OFJCc+BYAPkPe3xVVJiXHqdUu897wRK/IaGOEfrZ3RmUVEiCdatWx7uO3S+QkiF/p0nLBRcbQvcawdCMAY3pm6GNLVEbG2Q1jXry/pyM8cTwABsDSd8OCEOI86YVmX9DzJ0XX7B7Fec2o2lB56a4UvckLxAhz2J2CMMkC1LNMONzG9FmT7mYXABzvqfoez1ovZTji59/TgMq13ryRxVaGYucDe5kM2OFeVm9Syi83RC2DAjRB+L1CAZdRKae1dbTXBSUpp5TSwx+0A9dC7o17I11oWxXogh8J2zZg5TmexZUkMWfc9y5KOOd+4FRKJqKdBWMRSQJnqN7UmvfmPwgI6doqw6GJnfopI4Y31jJyyB/uXFh6sM91HJBomEtmYkgv5eQ6dtYQO 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:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230040)(35042699022)(36860700013)(1800799024)(376014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2024 17:26:50.7136 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07f20e29-5480-41d7-360e-08dcc7869a46 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: DU6PEPF0000A7DF.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8380 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ketil Johnsen In the kernel submission flow, GROUP_SUBMIT will ensure that the group gets assigned to a CSG. Conversely for the user submission flow, work gets added to the ring buffer without kernel supervision, so there needs to be a mechanism to trigger rescheduling. Use a new GROUP_KICK ioctl, to keep it distinct from the existing submit flow. Signed-off-by: Ketil Johnsen Signed-off-by: Mihail Atanassov --- drivers/gpu/drm/panthor/panthor_drv.c | 12 +++++++++++ drivers/gpu/drm/panthor/panthor_sched.c | 27 +++++++++++++++++++++++++ drivers/gpu/drm/panthor/panthor_sched.h | 1 + 3 files changed, 40 insertions(+) diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c index e391ab6aaab2..ce2fdcd3fb42 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -1305,6 +1305,17 @@ static int panthor_ioctl_vm_get_state(struct drm_device *ddev, void *data, return 0; } +static int panthor_ioctl_group_kick(struct drm_device *ddev, void *data, + struct drm_file *file) +{ + struct drm_panthor_group_kick *args = data; + struct panthor_file *pfile = file->driver_priv; + + panthor_sched_kick(pfile, args->handle, args->queue_mask); + + return 0; +} + static int panthor_open(struct drm_device *ddev, struct drm_file *file) { @@ -1375,6 +1386,7 @@ static const struct drm_ioctl_desc panthor_drm_driver_ioctls[] = { 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(GROUP_KICK, group_kick, DRM_RENDER_ALLOW), }; static int panthor_mmap(struct file *filp, struct vm_area_struct *vma) diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c index 471bb8f2b44c..3b56526a4b97 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -2845,6 +2845,33 @@ void panthor_sched_post_reset(struct panthor_device *ptdev, bool reset_failed) } } +void panthor_sched_kick(struct panthor_file *pfile, u32 group_handle, u32 queue_mask) +{ + struct panthor_group_pool *gpool = pfile->groups; + struct panthor_scheduler *sched = pfile->ptdev->scheduler; + struct panthor_group *group; + + group = group_get(xa_load(&gpool->xa, group_handle)); + if (!group) + return; + + if (!group->queue_count) + goto err_put_group; + + mutex_lock(&sched->lock); + + if (group->csg_id < 0) + group_schedule_locked(group, queue_mask); + else + /* All queues share same doorbell page (for now), so we just need to ding one */ + gpu_write(pfile->ptdev, CSF_DOORBELL(group->queues[0]->doorbell_id), 1); + + mutex_unlock(&sched->lock); + +err_put_group: + group_put(group); +} + static void group_sync_upd_work(struct work_struct *work) { struct panthor_group *group = diff --git a/drivers/gpu/drm/panthor/panthor_sched.h b/drivers/gpu/drm/panthor/panthor_sched.h index 0b3a2ee2a0ad..18fb7ad0952e 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.h +++ b/drivers/gpu/drm/panthor/panthor_sched.h @@ -48,5 +48,6 @@ void panthor_sched_report_mmu_fault(struct panthor_device *ptdev); void panthor_sched_report_fw_events(struct panthor_device *ptdev, u32 events); u8 panthor_sched_doorbell_id(struct panthor_file *pfile, u32 group_handle); +void panthor_sched_kick(struct panthor_file *pfile, u32 group_handle, u32 queue_mask); #endif From patchwork Wed Aug 28 17:26:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 13781614 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD6F6C636ED for ; Wed, 28 Aug 2024 17:27:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2EB2C10E34E; Wed, 28 Aug 2024 17:27:02 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.b="B1qg64f5"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="B1qg64f5"; dkim-atps=neutral Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2043.outbound.protection.outlook.com [40.107.104.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3DBEC10E34E for ; Wed, 28 Aug 2024 17:27:00 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=ZqzWhldSCEA6rWcHw+/ZdJ18vONFMddzdChtARzwI+XUGrzDILKEthI3TuEnioAlSm3g21VPeGONTuPksHhdWmehPtDYTV1rbtyA1YhtoiDvlK+EmVc32oWTfhJLxK9+Eoz2KPbtrO20KZs5GvSl4L2HIdzwLCzphyBO48KUu0ZKf5Lvma+X0gqYLdLAOUH6cLzam7deWMvg6WWHB/p8asO6SW7fa4pzHw3/OgDwm5IyuKd1eIFx/Okj+qZvconIW40m03HBIxuv97pCttgm5YjRJxeZ68FNXlSt56iVTIWWTmcMJcCPvYBrHQMSGzC8URaiDjveAW9YPlKNtK4HwA== 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=6orZbKeA+ZAkLam0Ko+xKmcpwenNalfbnojri2vJjus=; b=WQ4YRFtLjajQrxzEkU/xB58o13hXS02mZAfryIiale8Z2A0poij+GD1jWaQqoosVC/LXfRIUwPCgRL0ywzthqZWoVpGWMTUyAw27v/i9fJJM1dNQUdXFJ2CdZov/kSrH8LQas8M4KLEJ8kCldelge9ONZ3NaPjCogszHEf+hNMF4VhrSGVaoSO2M54h09iDl7wSaR25q7mPoxK8B5B4Qcr+XcYf42fr5i2QPsvi+qvvnTgJAiVnLuE0OegG6dvkJ83df3r4Gp28aU5YAW1GBQnpLXvZfrUiqz2B4hbKHOTiAKlzAt78J9hej/a4m4uyMFIgWlRxeKEyGzNW7sgtNKQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.freedesktop.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=6orZbKeA+ZAkLam0Ko+xKmcpwenNalfbnojri2vJjus=; b=B1qg64f5fpQAK7QeE+jc/UMWqxIfnULep8MbWkPM8vW6Xi+jgRkrJ5iwaIU4Dmo9+XnobYV7ajOrLea3rYddmZdSgjknzHLZSpk/Nq1YL5FK95vVM7KsT1FL+I4oo56psDplOE2nEPVcf28plhik5YcLPbIg+6ic9oRcgq8cNp4= Received: from DUZP191CA0028.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:4f8::24) by AS8PR08MB9599.eurprd08.prod.outlook.com (2603:10a6:20b:619::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.18; Wed, 28 Aug 2024 17:26:53 +0000 Received: from DB5PEPF00014B8C.eurprd02.prod.outlook.com (2603:10a6:10:4f8::4) by DUZP191CA0028.outlook.office365.com (2603:10a6:10:4f8::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.26 via Frontend Transport; Wed, 28 Aug 2024 17:26:53 +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 DB5PEPF00014B8C.mail.protection.outlook.com (10.167.8.200) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 28 Aug 2024 17:26:53 +0000 Received: ("Tessian outbound 8e666bd17457:v403"); Wed, 28 Aug 2024 17:26:53 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2b872d9813555bf6 X-CR-MTA-TID: 64aa7808 Received: from L5ae389042c40.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 03390737-02AB-42FD-89D8-CAF50D87C549.1; Wed, 28 Aug 2024 17:26:41 +0000 Received: from EUR02-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id L5ae389042c40.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Aug 2024 17:26:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qTj/U41KGxl+XBlTQ2ATU6L6xTDGx1sxNjrIbMQPHRQqDwRCWE7oZRjIRU6imvT94OQcMln2M0EqiTt2T+hvTkTNdQ6cr+4PGueTNJPnpbARYFusytGJv39Gi2PE5IK7QIKl4l4eofGEsS5xws6XZRw+Iw9GWjdhXpwHM0Iu+Vd5rSvzBOStGrSY10AtFt+3IOBmfqgpaDFgW7KRkHvMZYmuNwX/yJ/1c5yUFaHqFBYFCdzClSWqGN87/ljLaUs9aO4udJy3saqNSt/iKvEGSl1yThxB7+fhiKnJUwycLTF84oaqJDX03Q2ddOoET4fGElNeJAxy7rN5Tx85JY8Wzg== 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=6orZbKeA+ZAkLam0Ko+xKmcpwenNalfbnojri2vJjus=; b=x+D61ChCtx23rvxtwuzmSC/atblBrPn6lmZKLYUkrov0sYUHXthpltbSVMOoH+x1pNaPeNIfQ9ykbSgrW2X/VQhWEEoRXJ46kyEY5AlGZ/Tv70ijOl/6S+tI4vX59arxOwF8TbQA0vaFav7BrrU7CqD+8DK46pPzagHgQyT+ZS2hV5aOAbzVv/95nDui2OM30RxoIjmqjQNNaE+wfiMxmrikc6xGT8t2YsI0h8UfsyL917Z4PlaJtl9n7si7lYn0dHgb0Iqred2u1lJQribefWkZvvXIkOa04+kmBd5fHZE5uVBnRg/JAImoE6WQgTAfZTpJbt82BcfUWdER1yubRA== 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=6orZbKeA+ZAkLam0Ko+xKmcpwenNalfbnojri2vJjus=; b=B1qg64f5fpQAK7QeE+jc/UMWqxIfnULep8MbWkPM8vW6Xi+jgRkrJ5iwaIU4Dmo9+XnobYV7ajOrLea3rYddmZdSgjknzHLZSpk/Nq1YL5FK95vVM7KsT1FL+I4oo56psDplOE2nEPVcf28plhik5YcLPbIg+6ic9oRcgq8cNp4= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) by AS8PR08MB6551.eurprd08.prod.outlook.com (2603:10a6:20b:319::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.18; Wed, 28 Aug 2024 17:26:38 +0000 Received: from AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c]) by AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c%7]) with mapi id 15.20.7918.012; Wed, 28 Aug 2024 17:26:38 +0000 From: Mihail Atanassov To: linux-kernel@vger.kernel.org, Boris Brezillon , Liviu Dudau , Steven Price Cc: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Shashank Sharma , Ketil Johnsen , Akash Goel , Mihail Atanassov Subject: [PATCH 5/8] drm/panthor: Factor out syncobj handling Date: Wed, 28 Aug 2024 18:26:01 +0100 Message-ID: <20240828172605.19176-6-mihail.atanassov@arm.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240828172605.19176-1-mihail.atanassov@arm.com> References: <20240828172605.19176-1-mihail.atanassov@arm.com> X-ClientProxiedBy: LO4P265CA0070.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2af::10) To AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6263:EE_|AS8PR08MB6551:EE_|DB5PEPF00014B8C:EE_|AS8PR08MB9599:EE_ X-MS-Office365-Filtering-Correlation-Id: 29f8a603-12c6-4f6a-d61d-08dcc7869c00 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: qfUxHBytr7mLBBJKwDvvr4SWTv/JicsftDfdX3Yy6ZL2ORZtK8VP36AyV0KYgCyk57/nmRLI2kBlM9DgRpPaBoczOQx1nX33F8Y7Lws+ahFiFLMh4XGsFXDk0YeBsWRO3kEwq4R/wlTTic2xLAL7hubg+Yv+AjBltfZM+czCndeCx1kBXwCPBBBvA/yPBhCxz/0feuLsDQEq9a4N+yFdFzhQGi4PFokEsTCu0xUGOQOBg/nMlWl1pATYS5MFsc9pS3C36CXyMsDiG5wed4RWYmWCe9otdsMfILCITqm59lgmcQt6yhxyq3vWWziXiBAgRtmfo+g7fX0s5q1nc4t+rmy1gDWKAUH4Rr46Yb6L8M2DHbTlwx8G1GlDdMfadDkrGR1cg8eeFFWpEx3sWIuRcryENyI5FOh194adnBt+FFYIPt9jKffzIpUIhx7eAut5PSV4rFwBvHeysPq9c1sA0Rj0CdNAznvecB/yYKFyIOUkYxZq6f3V/2OuX/oqvcQlinXTIKkJVxRWn5fNm+hzxiC19QFjObOz05UnrErxFMha4atJCUFF+AoB9B23pU4PP7I7QY053pWqQOxnVNFG84uZLZgY6RJdUCBoicOxgkEeadfH8l9w0QLmE2yIiVlzDZ1gq0xVxDAI55xS8mf9+V6Jpl1B/Bxc42XjviXzrLEfWx/j34TE7YFrk/6QVyguB0xjE5dXNeerUXY4Krg7n780sEFPpgvXln8obsLVyqOV4j/oSNxplIs06FptRkAeUh9IfVDQHnTJxd30NyEwJeQ/iYwUh9Ef4pcTqb/PX7KVVe/YScHwRRAawL1i1z/5hsohp+XIZODzpxA+qI2zINVmMvZc8SL0urOyYH7TTGXq+N6JVvfL3YQ3Nd1JiQ0XIbO2IksQv1GCIjSY/ZbIgVJZkWFojzNYCpOaVvmkwjoAWSQrk52XA1O67GydOqykm++1pxS1YxmVgrbrGxZazfmausdlffVO/3xYleSdWUXODRz3N8lXnjjqIzmHBLYAi/0AoKumDZ/zuUQy//mLsERB2SZq9rBuRJX2e0m6+t8CPY4up4FtT32ok85MzHciYmhYfxEg7J/yuvz2FKKhts8bBVksvoRG+aT0FL0+4OUT/qa9dNHww7x8JdKojtzivs0pDd4I7RD4+9U3oBAVLu3xkHGVbFhG8vqkEUVd9c6xHoc/EhPqsM9lSybo1/KnFHLyhRMAbYmBpcQ6WKfNM3wp+yl+4R6BigGxgdSm9A0I+B4t7Mz0ca3NA4v5Ie5bNPyDMMywN0Wj2SKtX+wAM2c6nukY8IraqEF0QNX8XsHSfTwmoPY/MKPntZ8YxFAYU7wn6OtFp1cGocDxBw5y8Q== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6263.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6551 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:20b:290::9]; domain=AS8PR08MB6263.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5PEPF00014B8C.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 01395da6-af7b-4ad3-76df-08dcc7869285 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026|35042699022; X-Microsoft-Antispam-Message-Info: 4pqHZUfVOhTmGUkDGydq4uSFXCZnuSNlu4w4/+ndPDBw9lm0YgOsElBxOvgMAZPuQUOcjJnVnxcffzkvpxVbGAqBp3uzot8WfbRb3FVrrgJDV4CfSRqjS5781X+9JJpG/7biMhOgXpo3Cox1j9w+j6vc0892jE3/W4hG+W6NwpGAY6E5gqhCgsg6yTAzGpywQYkTjc1tL9GeyEpaWC6c2UUad//6h8RH16TXKcTdinVSUsNI243OqD8RxzICH7UM7ei2OldSPxSAEnj4SMQvP3FTS+GF6gHd7B9doDR9zXf6HIgysNsIJ40ITqemd0sZjyYojvCzgsby2rnFDCqj/AS77XlVmK6MPng2qwIfMg9qcDDHun8HTHIy9mhgGwCs67vGKqRV1oAydMBZ8W47x9HBjccfRneJuHdhe8eeWSuER9ww2h9ofN0RqG2ZHxM073t/nCYa2eOs64z4p9aK5uebVYPH++1ieDSOg1rBXCc+BCWRPG7/bnLQraBG8rc9u8zh9CK8gS21uS8/fw5uNfOdd7ImJ8hHmsf1LHRJSxoW+GVBUTyDE8eoek+txxsm03IF3w7hD0qwjayrpWVhSp+/lzUzACFSl6fKQOIMxXTD3LvueIDjedMh660j7ZpgvVjUO9PIQ1Sdj2SFmpwJl971niDTkUPndPNFGYmk5qX+b+v7LSMhdPuAlD8AtNBvyX1fbA++yrVaUvlXtxWMqaaClzzbhZnebKwDZO3tfrRrpsvy3YZE5mqgRid2c21NgUyoF2CfvsM9nRddWblrVUxw+tax34vYHLruUCyAg4O9FIS1dmTIEMRLu1XkQ+ccx7LNl+Wciq80VqMp1XCl+FqGYZHqcXpnnHCX9tHaqeikVCOfc3ta3o36oxQMYQioa4gsKyEapEXVLdZSzT2u9BF9lNz2WqgDynD8si7Q9mtcVSSMLGh3KjG9B7NQ+IIk0iX7P8LNUkced5sjiIXv1z3j1sm7LcSjWutHlxwO+LSZVtY1bUEAOwiYhm2mmVdm/hgTyCNQKuCZc4iLo3Hm40KXwpxciC0yKlPQrUa0bQb8pPLsuj+F2nYJO0gB21y22QbeVXTpTj3ZPKhIMGywUQMPGWYcIxhXCMMqox9eE7Mv7Ce9vfz0ETBrd0NY51vUJVMqESenZL9uo5/ddluQ2NTgktJWOV80+oaGbRY715g/4RPCqo1Jc5faWdG5b3JcRmsxpp4jSo+kSAJ85fRcSEvucyPJjLxKbm6yYIAtiKAh40vdsHGRIScWkyjtBCw0Qg0usK/HHzmL4nSsyeC4mgyHxVr2zw8jagnW9CSRXopxbgFAFOnHdn3kpsItc6Mj59pPDOfVErYjrWAA+ZAwwZiwZUBu0eMxXkyYMLr9ByP+ItLbqY0xzDwE2BkXYVy7cSfD0qvkbpNWRS/h4xFJooJCDZMUq55hpJBy4u67kIiMXDkmjOBXEaLeaClxV59A 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:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230040)(36860700013)(376014)(1800799024)(82310400026)(35042699022); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2024 17:26:53.5988 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 29f8a603-12c6-4f6a-d61d-08dcc7869c00 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: DB5PEPF00014B8C.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9599 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ketil Johnsen The code is needed both for the existing kernel submission path and for implementing cross-group sync (XGS) queues which link between drm_syncobj and the HW syncobj primitives. Signed-off-by: Ketil Johnsen Signed-off-by: Mihail Atanassov --- drivers/gpu/drm/panthor/Makefile | 3 +- drivers/gpu/drm/panthor/panthor_sched.c | 154 +++++--------------- drivers/gpu/drm/panthor/panthor_syncobj.c | 167 ++++++++++++++++++++++ drivers/gpu/drm/panthor/panthor_syncobj.h | 27 ++++ 4 files changed, 234 insertions(+), 117 deletions(-) create mode 100644 drivers/gpu/drm/panthor/panthor_syncobj.c create mode 100644 drivers/gpu/drm/panthor/panthor_syncobj.h diff --git a/drivers/gpu/drm/panthor/Makefile b/drivers/gpu/drm/panthor/Makefile index 15294719b09c..0af27f33bfe2 100644 --- a/drivers/gpu/drm/panthor/Makefile +++ b/drivers/gpu/drm/panthor/Makefile @@ -9,6 +9,7 @@ panthor-y := \ panthor_gpu.o \ panthor_heap.o \ panthor_mmu.o \ - panthor_sched.o + panthor_sched.o \ + panthor_syncobj.o obj-$(CONFIG_DRM_PANTHOR) += panthor.o diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c index 3b56526a4b97..f272aeee8a8f 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -31,6 +31,7 @@ #include "panthor_mmu.h" #include "panthor_regs.h" #include "panthor_sched.h" +#include "panthor_syncobj.h" /** * DOC: Scheduler @@ -318,39 +319,6 @@ struct panthor_scheduler { } reset; }; -/** - * struct panthor_syncobj_32b - 32-bit FW synchronization object - */ -struct panthor_syncobj_32b { - /** @seqno: Sequence number. */ - u32 seqno; - - /** - * @status: Status. - * - * Not zero on failure. - */ - u32 status; -}; - -/** - * struct panthor_syncobj_64b - 64-bit FW synchronization object - */ -struct panthor_syncobj_64b { - /** @seqno: Sequence number. */ - u64 seqno; - - /** - * @status: Status. - * - * Not zero on failure. - */ - u32 status; - - /** @pad: MBZ. */ - u32 pad; -}; - /** * struct panthor_queue - Execution queue */ @@ -445,17 +413,8 @@ struct panthor_queue { /** @sync64: True if this is a 64-bit sync object. */ bool sync64; - /** @bo: Buffer object holding the synchronization object. */ - struct drm_gem_object *obj; - - /** @offset: Offset of the synchronization object inside @bo. */ - u64 offset; - - /** - * @kmap: Kernel mapping of the buffer object holding the - * synchronization object. - */ - void *kmap; + /** @syncobj: Wrapper for the syncobj in memory */ + struct panthor_syncobj *syncobj; } syncwait; /** @fence_ctx: Fence context fields. */ @@ -794,53 +753,6 @@ struct panthor_job { struct dma_fence *done_fence; }; -static void -panthor_queue_put_syncwait_obj(struct panthor_queue *queue) -{ - if (queue->syncwait.kmap) { - struct iosys_map map = IOSYS_MAP_INIT_VADDR(queue->syncwait.kmap); - - drm_gem_vunmap_unlocked(queue->syncwait.obj, &map); - queue->syncwait.kmap = NULL; - } - - drm_gem_object_put(queue->syncwait.obj); - queue->syncwait.obj = NULL; -} - -static void * -panthor_queue_get_syncwait_obj(struct panthor_group *group, struct panthor_queue *queue) -{ - struct panthor_device *ptdev = group->ptdev; - struct panthor_gem_object *bo; - struct iosys_map map; - int ret; - - if (queue->syncwait.kmap) - return queue->syncwait.kmap + queue->syncwait.offset; - - bo = panthor_vm_get_bo_for_va(group->vm, - queue->syncwait.gpu_va, - &queue->syncwait.offset); - if (drm_WARN_ON(&ptdev->base, IS_ERR_OR_NULL(bo))) - goto err_put_syncwait_obj; - - queue->syncwait.obj = &bo->base.base; - ret = drm_gem_vmap_unlocked(queue->syncwait.obj, &map); - if (drm_WARN_ON(&ptdev->base, ret)) - goto err_put_syncwait_obj; - - queue->syncwait.kmap = map.vaddr; - if (drm_WARN_ON(&ptdev->base, !queue->syncwait.kmap)) - goto err_put_syncwait_obj; - - return queue->syncwait.kmap + queue->syncwait.offset; - -err_put_syncwait_obj: - panthor_queue_put_syncwait_obj(queue); - return NULL; -} - static void group_free_queue(struct panthor_group *group, struct panthor_queue *queue) { if (IS_ERR_OR_NULL(queue)) @@ -852,7 +764,7 @@ static void group_free_queue(struct panthor_group *group, struct panthor_queue * if (queue->scheduler.ops) drm_sched_fini(&queue->scheduler); - panthor_queue_put_syncwait_obj(queue); + panthor_syncobj_release(queue->syncwait.syncobj); if (queue->ringbuf_offset) drm_vma_node_revoke(&queue->ringbuf->obj->vma_node, group->pfile->drm_file); @@ -2065,7 +1977,6 @@ group_term_post_processing(struct panthor_group *group) cookie = dma_fence_begin_signalling(); for (i = 0; i < group->queue_count; i++) { struct panthor_queue *queue = group->queues[i]; - struct panthor_syncobj_64b *syncobj; int err; if (group->fatal_queues & BIT(i)) @@ -2086,12 +1997,13 @@ group_term_post_processing(struct panthor_group *group) } spin_unlock(&queue->fence_ctx.lock); - if (!group->user_submit) { + if (!group->user_submit) /* Manually update the syncobj seqno to unblock waiters. */ - syncobj = group->syncobjs->kmap + (i * sizeof(*syncobj)); - syncobj->status = ~0; - syncobj->seqno = atomic64_read(&queue->fence_ctx.seqno); - } + panthor_syncobj_ptr64_signal_with_error( + group->syncobjs->kmap + (i * PANTHOR_SYNCOBJ64_SIZE), + atomic64_read(&queue->fence_ctx.seqno), + ~0); + sched_queue_work(group->ptdev->scheduler, sync_upd); } dma_fence_end_signalling(cookie); @@ -2461,28 +2373,32 @@ static void tick_work(struct work_struct *work) static int panthor_queue_eval_syncwait(struct panthor_group *group, u8 queue_idx) { struct panthor_queue *queue = group->queues[queue_idx]; - union { - struct panthor_syncobj_64b sync64; - struct panthor_syncobj_32b sync32; - } *syncobj; + struct panthor_syncobj *syncobj; bool result; u64 value; - syncobj = panthor_queue_get_syncwait_obj(group, queue); - if (!syncobj) - return -EINVAL; + if (!queue->syncwait.syncobj) { + syncobj = panthor_syncobj_create(group->ptdev, + group->vm, + queue->syncwait.gpu_va, + queue->syncwait.sync64); + if (IS_ERR_OR_NULL(syncobj)) + return PTR_ERR(syncobj); - value = queue->syncwait.sync64 ? - syncobj->sync64.seqno : - syncobj->sync32.seqno; + queue->syncwait.syncobj = syncobj; + } + + value = panthor_syncobj_get_value(queue->syncwait.syncobj); if (queue->syncwait.gt) result = value > queue->syncwait.ref; else result = value <= queue->syncwait.ref; - if (result) - panthor_queue_put_syncwait_obj(queue); + if (result) { + panthor_syncobj_release(queue->syncwait.syncobj); + queue->syncwait.syncobj = NULL; + } return result; } @@ -2887,16 +2803,22 @@ static void group_sync_upd_work(struct work_struct *work) cookie = dma_fence_begin_signalling(); for (queue_idx = 0; queue_idx < group->queue_count; queue_idx++) { struct panthor_queue *queue = group->queues[queue_idx]; - struct panthor_syncobj_64b *syncobj; + void *syncobj; if (!queue) continue; - syncobj = group->syncobjs->kmap + (queue_idx * sizeof(*syncobj)); + syncobj = group->syncobjs->kmap + (queue_idx * PANTHOR_SYNCOBJ64_SIZE); spin_lock(&queue->fence_ctx.lock); list_for_each_entry_safe(job, job_tmp, &queue->fence_ctx.in_flight_jobs, node) { - if (syncobj->seqno < job->done_fence->seqno) + u64 value; + + if (!job->call_info.size) + continue; + + value = panthor_syncobj_ptr64_get_value(syncobj); + if (value < job->done_fence->seqno) break; list_move_tail(&job->node, &done_jobs); @@ -2928,7 +2850,7 @@ queue_run_job(struct drm_sched_job *sched_job) ptdev->csif_info.unpreserved_cs_reg_count; u64 val_reg = addr_reg + 2; u64 sync_addr = panthor_kernel_bo_gpuva(group->syncobjs) + - job->queue_idx * sizeof(struct panthor_syncobj_64b); + job->queue_idx * PANTHOR_SYNCOBJ64_SIZE; u32 waitall_mask = GENMASK(sched->sb_slot_count - 1, 0); struct dma_fence *done_fence; int ret; @@ -3289,7 +3211,7 @@ int panthor_group_create(struct panthor_file *pfile, if (!group->user_submit) { group->syncobjs = panthor_kernel_bo_create(ptdev, group->vm, group_args->queues.count * - sizeof(struct panthor_syncobj_64b), + PANTHOR_SYNCOBJ64_SIZE, DRM_PANTHOR_BO_NO_MMAP, DRM_PANTHOR_VM_BIND_OP_MAP_NOEXEC | DRM_PANTHOR_VM_BIND_OP_MAP_UNCACHED, @@ -3304,7 +3226,7 @@ int panthor_group_create(struct panthor_file *pfile, goto err_put_group; memset(group->syncobjs->kmap, 0, - group_args->queues.count * sizeof(struct panthor_syncobj_64b)); + group_args->queues.count * PANTHOR_SYNCOBJ64_SIZE); } for (i = 0; i < group_args->queues.count; i++) { diff --git a/drivers/gpu/drm/panthor/panthor_syncobj.c b/drivers/gpu/drm/panthor/panthor_syncobj.c new file mode 100644 index 000000000000..337f75bfa648 --- /dev/null +++ b/drivers/gpu/drm/panthor/panthor_syncobj.c @@ -0,0 +1,167 @@ +// SPDX-License-Identifier: GPL-2.0 or MIT +/* Copyright 2024 ARM Limited. All rights reserved. */ + +#include + +#include "panthor_device.h" +#include "panthor_gem.h" +#include "panthor_mmu.h" +#include "panthor_syncobj.h" + +/** + * struct panthor_syncobj_32b - 32-bit FW synchronization object + */ +struct panthor_syncobj_32b { + /** @value: Value field. */ + u32 value; + + /** + * @error: Error status. + * + * Not zero on failure. + */ + u32 error; +}; + +/** + * struct panthor_syncobj_64b - 64-bit FW synchronization object + */ +struct panthor_syncobj_64b { + /** @value: Value field. */ + u64 value; + + /** + * @error: Error status. + * + * Not zero on failure. + */ + u32 error; + + /** @pad: MBZ. */ + u32 pad; +}; + +struct panthor_syncobj { + /** @bo: Buffer object holding the synchronization object. */ + struct drm_gem_object *bo; + + /** @offset: Offset of the synchronization object inside @bo. */ + u64 offset; + + /** + * @kmap: Kernel mapping of the buffer object holding the + * synchronization object. + */ + void *kmap; + + /** @ptr: CPU ptr to synchronization object */ + union { + struct panthor_syncobj_64b sync64; + struct panthor_syncobj_32b sync32; + } *ptr; + + /** @sync64: true for 64-bit synchronization object, otherwise 32-bit */ + bool sync64; +}; + + + +struct panthor_syncobj *panthor_syncobj_create(struct panthor_device *ptdev, + struct panthor_vm *vm, u64 gpu_va, + bool sync64) +{ + struct panthor_gem_object *bo; + struct iosys_map map; + struct panthor_syncobj *syncobj; + int err; + + syncobj = kzalloc(sizeof(*syncobj), GFP_KERNEL); + if (!syncobj) { + err = -ENOMEM; + goto err; + } + + bo = panthor_vm_get_bo_for_va(vm, gpu_va, &syncobj->offset); + if (drm_WARN_ON(&ptdev->base, IS_ERR_OR_NULL(bo))) { + err = -EINVAL; + goto err_free_syncobj; + } + + syncobj->bo = &bo->base.base; + + err = drm_gem_vmap_unlocked(syncobj->bo, &map); + if (drm_WARN_ON(&ptdev->base, err)) + goto err_put_gem_object; + + syncobj->kmap = map.vaddr; + syncobj->ptr = syncobj->kmap + syncobj->offset; + syncobj->sync64 = sync64; + + return syncobj; + +err_put_gem_object: + drm_gem_object_put(syncobj->bo); +err_free_syncobj: + kfree(syncobj); +err: + return ERR_PTR(err); +} + +void panthor_syncobj_release(struct panthor_syncobj *syncobj) +{ + if (syncobj) { + struct iosys_map map = IOSYS_MAP_INIT_VADDR(syncobj->kmap); + + drm_gem_vunmap_unlocked(syncobj->bo, &map); + drm_gem_object_put(syncobj->bo); + kfree(syncobj); + } +} + +u64 panthor_syncobj_get_value(struct panthor_syncobj *syncobj) +{ + return syncobj->sync64 ? + syncobj->ptr->sync64.value : + syncobj->ptr->sync32.value; +} + +u32 panthor_syncobj_get_error(struct panthor_syncobj *syncobj) +{ + return syncobj->sync64 ? + syncobj->ptr->sync64.error : + syncobj->ptr->sync32.error; +} + +void panthor_syncobj_signal(struct panthor_syncobj *syncobj, u64 value) +{ + if (syncobj->sync64) + syncobj->ptr->sync64.value = value; + else + syncobj->ptr->sync32.value = (u32)value; +} + +void panthor_syncobj_signal_with_error(struct panthor_syncobj *syncobj, u64 value, u32 error) +{ + if (syncobj->sync64) { + syncobj->ptr->sync64.value = value; + syncobj->ptr->sync64.error = error; + } else { + syncobj->ptr->sync32.value = (u32)value; + syncobj->ptr->sync32.error = error; + } +} + +u64 panthor_syncobj_ptr64_get_value(void *syncobj_ptr) +{ + struct panthor_syncobj_64b *syncobj = syncobj_ptr; + + return syncobj->value; +} + +void panthor_syncobj_ptr64_signal_with_error(void *syncobj_ptr, u64 value, u32 error) +{ + struct panthor_syncobj_64b *syncobj = syncobj_ptr; + + syncobj->value = value; + syncobj->error = error; +} diff --git a/drivers/gpu/drm/panthor/panthor_syncobj.h b/drivers/gpu/drm/panthor/panthor_syncobj.h new file mode 100644 index 000000000000..018cfc87cdaa --- /dev/null +++ b/drivers/gpu/drm/panthor/panthor_syncobj.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 or MIT */ +/* Copyright 2024 ARM Limited. All rights reserved. */ + +#ifndef __PANTHOR_SYNCOBJ_H__ +#define __PANTHOR_SYNCOBJ_H__ + +#define PANTHOR_SYNCOBJ32_SIZE 8 +#define PANTHOR_SYNCOBJ64_SIZE 16 + +struct panthor_syncobj; +struct panthor_vm; + +struct panthor_syncobj *panthor_syncobj_create(struct panthor_device *ptdev, + struct panthor_vm *vm, u64 gpu_va, + bool sync64); +void panthor_syncobj_release(struct panthor_syncobj *syncobj); + +u64 panthor_syncobj_get_value(struct panthor_syncobj *syncobj); +u32 panthor_syncobj_get_error(struct panthor_syncobj *syncobj); + +void panthor_syncobj_signal(struct panthor_syncobj *syncobj, u64 value); +void panthor_syncobj_signal_with_error(struct panthor_syncobj *syncobj, u64 value, u32 error); + +u64 panthor_syncobj_ptr64_get_value(void *syncobj_ptr); +void panthor_syncobj_ptr64_signal_with_error(void *syncobj_ptr, u64 value, u32 error); + +#endif From patchwork Wed Aug 28 17:26:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 13781617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 233CEC636EE for ; Wed, 28 Aug 2024 17:27:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A41C710E42E; Wed, 28 Aug 2024 17:27:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.b="WuShEUxk"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="WuShEUxk"; dkim-atps=neutral Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2070.outbound.protection.outlook.com [40.107.241.70]) by gabe.freedesktop.org (Postfix) with ESMTPS id D4BA110E42E for ; Wed, 28 Aug 2024 17:27:35 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=AY543w3StQghhKnYbLrDQT78o02fGXSWNzknML0BcHbcLfDS/9pFPoPeOHfstK3J9FbJA22hjaB/z6V25EvHLB5JKq1gdeCDBxJqYx53znaT/6FtMQgs3+8eBLxeiUSu17mTokA7NhvUOC5Y9M13OT6lMNKtzq3Lb8qqas5DJuK1v5VCyzdh2tTiMG3a9BHfFBEe6/ASCKfpiNsajs+5pE18TuL1Z9QRTKuQo4ZMonUhp4vP+MrTSYOhrKF3fyqxrmWrrPq7nk7l5lKRR6N7nKYKUPzztjCO7nmKO8ZgphaWnPUoBVi5x4GZ3jnSapjYJi1i9FXj5XElIDGYvy+CQQ== 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=iXCyxG0usG7a1DvzITihDgiGfgG7tlcbmCP4nOK6SOU=; b=VY+BgVJtpo9iG8IyTxW63oO5+YuHzKAaDyeBAyZ/GrJi/qmEAdJdP5Xjjxw63FnM87F0CbfH/7me11M0f9ovoO/QYPAKYIoBh4wOb63caMeu8qkicSO1raCgMtr7Gj1V5TW8q8/wn2TtLwTvuhw2fsseHo6FTvUs+8RNYxkIzN6GpXxS2D2WEQvdk9ytD+HAC9qrd8uX9clkv6SdA69L5FKyTHR36WsZf8hgUEoWPVRA+PetC/NOAk1zrrrDsJHL48sJtwB3ZyDBnhMyIgzGX84waJbw+xBDDcKMn5DiUZQA0Q8izaR5TYFwa1d4w6/i1IgNe1jXhtODCC1EjIpLkQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.freedesktop.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=iXCyxG0usG7a1DvzITihDgiGfgG7tlcbmCP4nOK6SOU=; b=WuShEUxke3VcM9YUWmmeOJchJspauP6QSO9BonEJPHoXi2jui6sYS+KkADHd7ajZ+wHfJEXSUcC6RZU+6RRn6ii4axyxfrExKSu3aMiREn2r3wpJ6gtwv46lGRRg/j6UsMAvXlwKwoev4RWuOWygCClgTuP7lifswR/FZJRLi/o= Received: from AS9PR04CA0064.eurprd04.prod.outlook.com (2603:10a6:20b:48b::17) by DU0PR08MB9799.eurprd08.prod.outlook.com (2603:10a6:10:444::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.14; Wed, 28 Aug 2024 17:27:25 +0000 Received: from AM4PEPF00027A5F.eurprd04.prod.outlook.com (2603:10a6:20b:48b:cafe::47) by AS9PR04CA0064.outlook.office365.com (2603:10a6:20b:48b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27 via Frontend Transport; Wed, 28 Aug 2024 17:27:25 +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 AM4PEPF00027A5F.mail.protection.outlook.com (10.167.16.74) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 28 Aug 2024 17:27:25 +0000 Received: ("Tessian outbound 22f8cf4ed816:v403"); Wed, 28 Aug 2024 17:27:25 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a7dcc06a3ee0b256 X-CR-MTA-TID: 64aa7808 Received: from Ld28cb033b529.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8BE817FC-9AF7-4D39-81D2-0CA4EF7A4BA4.1; Wed, 28 Aug 2024 17:27:14 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Ld28cb033b529.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Aug 2024 17:27:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BJoHzw2uPJI4Hz97/kVLRzflYYUFyfdpMZW7XN7Bqx2iX9rnFMnvLcQ6Mj3FA/keHoWtKttFg5f05b1aRehk3zQHM7ejr6+9AoByro3ucwt5IHb9RnM0iUY61Sn8JygqWM7uO+phbE5uh1DvYJixnjf7PDNGrGzN+0M3wJJ0TRKreYjrJvmxD2oov0F62ww1MsyAFHyLe9lgKfEl4BdhyBiYHqj4bhJuAkZn/HYrhCZH11HIN1u6vIB6wIPc9/P1PKdQ1giUI/e/mrjCPcVQfppFu/wBKDY3WlDM95Zcp7yrE5S1Z3ZZ47uRTRjZOMnPRGdUR+sUB9SGGXdajKthMA== 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=iXCyxG0usG7a1DvzITihDgiGfgG7tlcbmCP4nOK6SOU=; b=YhGAC4Sez9vTNH2l4dSuHiEKIeqeineNJylJndc6JF61K8qA1OUqymigNpt8UtUHqgmBaf9+a2PqjiyAB1mDI4xRPrOkCq3c28cNjfIcOcrwKjWf1v6ZhAV/ODszrdSuhe+G74tBdRgB+vGoXB3qSSTb1zDg4w6reV/YDMWcUj463wZlqJdy41ko0FaaMXbG7chcJ3oOk2g2dz99R4N16j8NDfR7H/9qEz/N9TlxL5sUcytVdsNGN0BAJuKNWjhEE+u4+8o8azhfZnfdRJMySAccWdc2AL829cxo8fe+ncafyl43XPA6aOiAlqEY+kqyTDi6oKa6vjVlulRPort5uA== 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=iXCyxG0usG7a1DvzITihDgiGfgG7tlcbmCP4nOK6SOU=; b=WuShEUxke3VcM9YUWmmeOJchJspauP6QSO9BonEJPHoXi2jui6sYS+KkADHd7ajZ+wHfJEXSUcC6RZU+6RRn6ii4axyxfrExKSu3aMiREn2r3wpJ6gtwv46lGRRg/j6UsMAvXlwKwoev4RWuOWygCClgTuP7lifswR/FZJRLi/o= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) by AS8PR08MB6551.eurprd08.prod.outlook.com (2603:10a6:20b:319::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.18; Wed, 28 Aug 2024 17:27:11 +0000 Received: from AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c]) by AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c%7]) with mapi id 15.20.7918.012; Wed, 28 Aug 2024 17:27:11 +0000 From: Mihail Atanassov To: linux-kernel@vger.kernel.org, Boris Brezillon , Liviu Dudau , Steven Price Cc: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Shashank Sharma , Ketil Johnsen , Akash Goel , Mihail Atanassov Subject: [PATCH 6/8] drm/panthor: Implement XGS queues Date: Wed, 28 Aug 2024 18:26:02 +0100 Message-ID: <20240828172605.19176-7-mihail.atanassov@arm.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240828172605.19176-1-mihail.atanassov@arm.com> References: <20240828172605.19176-1-mihail.atanassov@arm.com> X-ClientProxiedBy: LO4P123CA0395.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18f::22) To AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6263:EE_|AS8PR08MB6551:EE_|AM4PEPF00027A5F:EE_|DU0PR08MB9799:EE_ X-MS-Office365-Filtering-Correlation-Id: fe604c47-6f40-4711-bf3e-08dcc786af35 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: 6kUYDRjAH4PXf2RC0CF71iA5l/hQr6WSfZptPkfmel0TISpaGs5R3YTQsvLNIrM1Rw4VrOCXZDCty7H/EdyhqWsc5405MdW9deU5nv5iTKgqRBAE5J+m6Ru+jgDNqZb19fFJV7c6NiyiKvCeEmDJiS2m9YohxYiUroMddVC7REiBcl9XVAnObENwJ9H/kOtYi/RmCOrMUWvx7sKDpDJZdwrqNYf75ojtT34q4hDrv83Do4SVDnXBSVaEVIgE32Bqnm3E4DGAjOVor/WkWorH8KNUDrZN9pJqeN0Rd1Q59+sCfiWYXziuIiN7JAZTqpun5Djrny8aF33/FeyRx6HcrnepOocIPUertUoeXRKYzW0G43azu6ik5UpExfKyui39Dhj5215oElaANY390yy6yeydiLOZ/+S6b8XM5cexlZqIKZJLqUAMxSn78mlNgsjsi9oohUxN8q4wTwroHOqA/VJFGarsgXHso6Y/i2HC1JCvhFAoQ+ayjPwQ2ZW/cu3UmYqRhe+M8av0scGo5ttrOQo/i04lrzFg0TNaioRZSuZnJFjehROO7ycccBTkFrYDJWmoPiEjHeUhkkdJa/2xb1jJORrUsIsUjjMK5BsbJAIPQX5cXkikQQhXi+6XON5lAtuldiOT3BlbpT5iR0MuVLUXJPijEF+CMF4k62mLTiWsxefX8NVcZEEOphZnqkPM0x0hETZy0tXBLGNQPLvLOWx28w7mjEeQT4DIYclD3Kl+8umZbKQxE2ra8Bt8B+1t9/l2aSd7PkKc59eeVZxKWUfciyTZC8kRyOR2j8sI2NtEB09iu4GJLSeNYnDKKPk69JlsulmWCyAaMWee13P+Isa9m6apiwXijZTUjcMEf2sCHe+YRWc9anJscqMREQ2MFgR+krILxGO9Z0BmFDxYCHsfZQboE+bUlcD9YSS8eyNPjB1qeUOmSIpiA0nXiefoQxYxikPqDQGJIL/6fq5REESB4CO5vYPoZJGTAm4orzkm+iHE5sUtLliQLV8r5sqDONIDLjqSVPHLqdiM19VZ3VH0u29dOTYx7VodwuY3kXWSrX+WRaZcc3t38Y/f7GtJ4F7ocxys5BVn9SO+2z9v5xDkvQ0j4mroBYmK80myjxbQuUUN3jQSwx0vrwhu7BbEm1+e9y/zwBNbBdombRLKCIlpL2ZTToLijym9+CVNSeyH01qOwlsyneekbowrpvfg83bDZnrvFix89vVAA9i+S8NMuly14SBcY+mZ4xnaORCPsW/oMPrt2Jz7UE1dcfQOOfQeO21WdGS1Ckp8wGWLPLwHu0o6meMXBTPkoWylxu53FePPyJJZ5C1FDeeJWXMjytHIKn57f5duF6i4RVPveQ== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6263.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6551 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:20b:290::9]; domain=AS8PR08MB6263.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM4PEPF00027A5F.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 58034394-4022-4958-eba0-08dcc786a69b X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|35042699022|82310400026; X-Microsoft-Antispam-Message-Info: dBaa900R7Bs9GHyzYSh4Xw2WwG7eKnzEE4UfIfymtDQj7JAae6YCsQYgXO7CusswvSoW0xf6LjOmypDTW2IRO2gE2XWgMMGUEJqI6cvYzs9X+7f5M63DJvGPbN2XT5VMxBX+2L/By3GK84vaAKz1rzHov811j2Y3gmaNDUMNnf+WcMQ0/GpokSsL7NdZ7p23XuRbO4CJIDh+t6I1mhIdNivzFRiZ29aFbIJ1aoQBpG0TbPfgJSL2fhHHujdIZdMOCQ8pd67KzMogxBn3+8ftgnECqa6XGonPBfYQE30iZ4mhybb71qD1weT1cUmKWXzhuvF4oMNTLC+Nlm6O3Pp+Ucr2u0xPO4fEpLBbMfuY7abU9fng7EHva4SfQYU7CJIfceg/qIxb2UkROA+f6zW/e1SMOtAw3fYm3qN0MUn1LuPFlrCvLCyLBS7Hau+eYCgDDbH/sH5caLDgC/3tUq5/1hWCRWgrPKsuHKYLkvDDV6vHVMIVY/rwbmCq1C6uMPFaPsxNpRmb9iSbK19kKEKoKXKbfc5yvRwHS3xQf6BzT0Ig5bZ4BzI/M7uD9hqytGlR1jkj6FkpFZe+FiOx0myYrbMbsgQcg/ywbGgcllU8L2RS5IiT9KSjnJP6svWX155v/60lxFpIAv6+udy9e4PxIQsaS3jYF6NPw7dZEV/tYhrg6wG/TRu5T9RhMM1afbvJ1FYiMtORTAwV3rCkib1u9V/ptFcgXbcLmwTFDxzHhNonnkwJDUssn/7zWRmUCbUlMKimbHzqA10H9nAJKQPKl413kf1Z5VJXbM1+e9wttGD0rnOLSpne5lzDzF7DgNPHXRCkNq+Fxh1tqvjsfskz+70wnvff5g5bW58p74lnRJ8LkHK2VUSzycTuowBnhHy7Cau0a+JUzZcRT0+Kydqt/p8jlnDyiWBnnNj8zk5v+Nh6hrhw/8cmTlglD+CLFI/SGs/6n6NtlS+odoP6mD4OHZ8qtcyndUkTtGb9jbT7O4UN7YXb66Cdj0gjlbO272v49fxhiVu3XFUMtC6+Ttct6twArT9aoIplHCtdD+xBHE1PY0X3/AFKV1EZGsL9zwcY9b639x1zb1sE9tG/a5KH0Y3hk2DyQ8RPMdvzwE/ED0xQtfQoplu34JqckcaIU+StK3WAbkhC0FdT1hHV+sR8OnhM6p0WjRtzTZOfPLukRqlQREDEVTmBXXM4+e2g/+2ZD4+X6bJo3Bc1gwusqDwRgusN1tNPVG/4floQN4B6uFR8UyRr7GqsZgvp1+duOl3DJQ7WkwWrTXmehqRlvf7oRUocU8aMWacjiqC9W1pNIwgEjdwNmorUXRNRb2Nzkg9rCaKs+i+/kPQ6OTsqPjauydQYTpEVViee3qtNyJ3QOxegKNsvfMi+s67q4k+NQ5RyqGoKCx/7HV6aEFNtbIfYOFYlS8qJvdNK1XWCRY6z9g41J9306slGfv44nhYkPvfq 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:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(35042699022)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2024 17:27:25.8066 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe604c47-6f40-4711-bf3e-08dcc786af35 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: AM4PEPF00027A5F.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9799 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ketil Johnsen Synchronisation between GPU queues in groups from the same VM is achieved using either 32b or 64b synchronisation objects (see panthor_syncobj.(c|h)). They are also the mechanism to sync between a queue and the kernel (or the user application). To allow for the latter case, introduce cross-group sync (XGS) queues. They are a drm scheduler-entity pair, associated with a VM, which runs XGS jobs -- WAITs or SETs/ADDs on those HW syncobjs -- to enable a userspace driver to do CPU-to-GPU (and vice-versa) synchronisation, and link that up with DRM sync primitives. Signed-off-by: Ketil Johnsen Co-developed-by: Akash Goel Signed-off-by: Akash Goel Signed-off-by: Mihail Atanassov --- drivers/gpu/drm/panthor/Makefile | 3 +- drivers/gpu/drm/panthor/panthor_device.h | 4 + drivers/gpu/drm/panthor/panthor_drv.c | 123 ++++- drivers/gpu/drm/panthor/panthor_sched.c | 25 +- drivers/gpu/drm/panthor/panthor_sched.h | 1 + drivers/gpu/drm/panthor/panthor_xgs.c | 638 +++++++++++++++++++++++ drivers/gpu/drm/panthor/panthor_xgs.h | 42 ++ 7 files changed, 832 insertions(+), 4 deletions(-) create mode 100644 drivers/gpu/drm/panthor/panthor_xgs.c create mode 100644 drivers/gpu/drm/panthor/panthor_xgs.h diff --git a/drivers/gpu/drm/panthor/Makefile b/drivers/gpu/drm/panthor/Makefile index 0af27f33bfe2..7637bae47e26 100644 --- a/drivers/gpu/drm/panthor/Makefile +++ b/drivers/gpu/drm/panthor/Makefile @@ -10,6 +10,7 @@ panthor-y := \ panthor_heap.o \ panthor_mmu.o \ panthor_sched.o \ - panthor_syncobj.o + panthor_syncobj.o \ + panthor_xgs.o obj-$(CONFIG_DRM_PANTHOR) += panthor.o diff --git a/drivers/gpu/drm/panthor/panthor_device.h b/drivers/gpu/drm/panthor/panthor_device.h index 87cce384e36a..1e98d2a856b7 100644 --- a/drivers/gpu/drm/panthor/panthor_device.h +++ b/drivers/gpu/drm/panthor/panthor_device.h @@ -17,6 +17,7 @@ #include #include +struct panthor_xgs_queue_pool; struct panthor_csf; struct panthor_csf_ctx; struct panthor_device; @@ -182,6 +183,9 @@ struct panthor_file { /** @groups: Scheduling group pool attached to this file. */ struct panthor_group_pool *groups; + + /** @xgs_queues: XGS queues attached to this file. */ + struct panthor_xgs_queue_pool *xgs_queues; }; int panthor_device_init(struct panthor_device *ptdev); diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c index ce2fdcd3fb42..681ac09b6343 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -19,6 +19,7 @@ #include #include +#include "panthor_xgs.h" #include "panthor_device.h" #include "panthor_fw.h" #include "panthor_gem.h" @@ -215,7 +216,8 @@ panthor_get_uobj_array(const struct drm_panthor_obj_array *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_xgs_op, pad)) /** * PANTHOR_UOBJ_SET() - Copy a kernel object to a user object. @@ -1316,6 +1318,114 @@ static int panthor_ioctl_group_kick(struct drm_device *ddev, void *data, return 0; } +static int panthor_ioctl_xgs_queue_create(struct drm_device *ddev, void *data, + struct drm_file *file) +{ + struct drm_panthor_xgs_queue_create *args = data; + struct panthor_file *pfile = file->driver_priv; + + if (args->pad) + return -EINVAL; + + return panthor_xgs_queue_create(pfile, args->vm_id, + args->eventfd_sync_update, &args->handle); +} + +static int panthor_ioctl_xgs_queue_destroy(struct drm_device *ddev, void *data, + struct drm_file *file) +{ + struct drm_panthor_xgs_queue_destroy *args = data; + struct panthor_file *pfile = file->driver_priv; + + if (args->pad) + return -EINVAL; + + return panthor_xgs_queue_destroy(pfile, args->handle); +} + +#define XGS_QUEUE_SUBMIT_FLAGS (DRM_PANTHOR_XGS_QUEUE_SUBMIT_ERROR_BARRIER_PRE | \ + DRM_PANTHOR_XGS_QUEUE_SUBMIT_ERROR_BARRIER_POST) + +static int panthor_ioctl_xgs_queue_submit(struct drm_device *ddev, void *data, + struct drm_file *file) +{ + struct drm_panthor_xgs_queue_submit *args = data; + struct panthor_file *pfile = file->driver_priv; + struct drm_panthor_xgs_op *ops_args; + struct panthor_xgs_queue *queue; + struct panthor_submit_ctx ctx; + struct drm_sched_job *job; + struct panthor_vm *vm; + int ret; + + if (args->flags & ~XGS_QUEUE_SUBMIT_FLAGS) + return -EINVAL; + + if (args->ops.count) { + ret = PANTHOR_UOBJ_GET_ARRAY(ops_args, &args->ops); + if (ret) + return ret; + } else { + ops_args = NULL; + } + + queue = panthor_xgs_queue_pool_get_xgs_queue(pfile->xgs_queues, args->handle); + if (!queue) + goto out_free_ops_args; + + ret = panthor_submit_ctx_init(&ctx, file, 1); + if (ret) + goto out_put_queue; + + /* Create job object */ + job = panthor_xgs_job_create(queue, ops_args, args->ops.count); + if (IS_ERR(job)) { + ret = PTR_ERR(job); + goto out_cleanup_submit_ctx; + } + + /* handed over to the job object */ + ops_args = NULL; + + /* attach sync operations */ + ret = panthor_submit_ctx_add_job(&ctx, 0, job, &args->syncs); + if (ret) + goto out_cleanup_submit_ctx; + + /* Collect signal operations on all */ + ret = panthor_submit_ctx_collect_jobs_signal_ops(&ctx); + if (ret) + goto out_cleanup_submit_ctx; + + /* The group already have a VM ref, so we don't need to take an extra one */ + vm = panthor_xgs_queue_vm(queue); + + /* We acquire/prepare revs on the job */ + drm_exec_until_all_locked(&ctx.exec) { + ret = panthor_vm_prepare_mapped_bos_resvs(&ctx.exec, vm, 1); + } + + if (ret) + goto out_cleanup_submit_ctx; + + /* Add deps, arm job fence and register the job fence to signal array */ + ret = panthor_submit_ctx_add_deps_and_arm_jobs(&ctx); + if (ret) + goto out_cleanup_submit_ctx; + + /* Nothing can fail after that point */ + panthor_submit_ctx_push_jobs(&ctx, panthor_xgs_job_update_resvs); + +out_cleanup_submit_ctx: + panthor_submit_ctx_cleanup(&ctx, panthor_xgs_job_put); +out_put_queue: + panthor_xgs_queue_put(queue); +out_free_ops_args: + kvfree(ops_args); + + return ret; +} + static int panthor_open(struct drm_device *ddev, struct drm_file *file) { @@ -1343,9 +1453,16 @@ panthor_open(struct drm_device *ddev, struct drm_file *file) if (ret) goto err_destroy_vm_pool; + ret = panthor_xgs_queue_pool_create(pfile); + if (ret) + goto err_destroy_group_pool; + file->driver_priv = pfile; return 0; +err_destroy_group_pool: + panthor_group_pool_destroy(pfile); + err_destroy_vm_pool: panthor_vm_pool_destroy(pfile); @@ -1363,6 +1480,7 @@ panthor_postclose(struct drm_device *ddev, struct drm_file *file) struct panthor_file *pfile = file->driver_priv; panthor_group_pool_destroy(pfile); + panthor_xgs_queue_pool_destroy(pfile); panthor_vm_pool_destroy(pfile); kfree(pfile); @@ -1387,6 +1505,9 @@ static const struct drm_ioctl_desc panthor_drm_driver_ioctls[] = { PANTHOR_IOCTL(TILER_HEAP_DESTROY, tiler_heap_destroy, DRM_RENDER_ALLOW), PANTHOR_IOCTL(GROUP_SUBMIT, group_submit, DRM_RENDER_ALLOW), PANTHOR_IOCTL(GROUP_KICK, group_kick, DRM_RENDER_ALLOW), + PANTHOR_IOCTL(XGS_QUEUE_CREATE, xgs_queue_create, DRM_RENDER_ALLOW), + PANTHOR_IOCTL(XGS_QUEUE_DESTROY, xgs_queue_destroy, DRM_RENDER_ALLOW), + PANTHOR_IOCTL(XGS_QUEUE_SUBMIT, xgs_queue_submit, DRM_RENDER_ALLOW), }; static int panthor_mmap(struct file *filp, struct vm_area_struct *vma) diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c index f272aeee8a8f..92172b2c6253 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -22,6 +22,7 @@ #include #include +#include "panthor_xgs.h" #include "panthor_devfreq.h" #include "panthor_device.h" #include "panthor_fw.h" @@ -1496,8 +1497,13 @@ static void csg_slot_sync_update_locked(struct panthor_device *ptdev, lockdep_assert_held(&ptdev->scheduler->lock); - if (group && !group->user_submit) - group_queue_work(group, sync_upd); + if (group) { + /* Rerun XGS jobs immediately, as this can potentially unblock the group */ + panthor_xgs_queue_pool_recheck(group->pfile); + + if (!group->user_submit) + group_queue_work(group, sync_upd); + } sched_queue_work(ptdev->scheduler, sync_upd); } @@ -1691,9 +1697,15 @@ static const char *queue_fence_get_timeline_name(struct dma_fence *fence) return "queue-fence"; } +static void job_fence_free(struct dma_fence *fence) +{ + dma_fence_free(fence); +} + static const struct dma_fence_ops panthor_queue_fence_ops = { .get_driver_name = fence_get_driver_name, .get_timeline_name = queue_fence_get_timeline_name, + .release = job_fence_free, }; struct panthor_csg_slots_upd_ctx { @@ -2431,6 +2443,10 @@ static void sync_upd_work(struct work_struct *work) if (unblocked_queues) { group->blocked_queues &= ~unblocked_queues; + /* Sync updates from XGS queue could happen when we are not ticking */ + if (sched->resched_target == U64_MAX) + immediate_tick = true; + if (group->csg_id < 0) { list_move(&group->run_node, &sched->groups.runnable[group->priority]); @@ -2788,6 +2804,11 @@ void panthor_sched_kick(struct panthor_file *pfile, u32 group_handle, u32 queue_ group_put(group); } +void panthor_sched_sync_update(struct panthor_device *ptdev) +{ + sched_queue_work(ptdev->scheduler, sync_upd); +} + static void group_sync_upd_work(struct work_struct *work) { struct panthor_group *group = diff --git a/drivers/gpu/drm/panthor/panthor_sched.h b/drivers/gpu/drm/panthor/panthor_sched.h index 18fb7ad0952e..2cb58c66b8ac 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.h +++ b/drivers/gpu/drm/panthor/panthor_sched.h @@ -49,5 +49,6 @@ void panthor_sched_report_fw_events(struct panthor_device *ptdev, u32 events); u8 panthor_sched_doorbell_id(struct panthor_file *pfile, u32 group_handle); void panthor_sched_kick(struct panthor_file *pfile, u32 group_handle, u32 queue_mask); +void panthor_sched_sync_update(struct panthor_device *ptdev); #endif diff --git a/drivers/gpu/drm/panthor/panthor_xgs.c b/drivers/gpu/drm/panthor/panthor_xgs.c new file mode 100644 index 000000000000..a900badb9224 --- /dev/null +++ b/drivers/gpu/drm/panthor/panthor_xgs.c @@ -0,0 +1,638 @@ +// SPDX-License-Identifier: GPL-2.0 or MIT +/* Copyright 2024 ARM Limited. All rights reserved. */ + +#include +#include +#include +#include +#include + +#include + +#include "panthor_xgs.h" +#include "panthor_device.h" +#include "panthor_gem.h" +#include "panthor_mmu.h" +#include "panthor_sched.h" +#include "panthor_syncobj.h" + +#define JOB_TIMEOUT_MS 5000 + +/** + * struct panthor_xgs_queue - Scheduling group object + */ +struct panthor_xgs_queue { + /** @refcount: Reference count */ + struct kref refcount; + + /** @lock: Lock to synchronize access to this queue */ + struct mutex lock; + + /** @handle: integer value used by user to refer to this queue */ + u32 handle; + + /** @ptdev: Panthor device for which this queue was created */ + struct panthor_device *ptdev; + + /** @vm: VM associated with this XGS queue */ + struct panthor_vm *vm; + + /** @eventfd_sync_update_ctx: eventfd context to signal on XGS set ops */ + struct eventfd_ctx *eventfd_sync_update_ctx; + + /** @scheduler: scheduler instance used to execute XGS jobs */ + struct drm_gpu_scheduler scheduler; + + /** @entity: Scheduler entity with XGS jobs */ + struct drm_sched_entity entity; + + /** @fence_ctx: Fence context fields. */ + struct { + /** @lock: Used to protect access to all fences allocated by this context. */ + spinlock_t lock; + + /** + * @id: Fence context ID. + * + * Allocated with dma_fence_context_alloc(). + */ + u64 id; + + /** @seqno: Sequence number of the last initialized fence. */ + atomic64_t seqno; + + /** + * @in_flight_jobs: List containing all in-flight jobs. + * + * Used to keep track and signal panthor_job::done_fence when the + * synchronization object attached to the queue is signaled. + */ + struct list_head in_flight_jobs; + } fence_ctx; + + /** @destroyed: True if queue is marked for destruction and should not be used */ + bool destroyed; + + /** + * @release_work: Work used to release XGS queue resources. + * + * We need to postpone the queue release to avoid a deadlock, + * otherwise "free_job" could end up calling back into DRM sched. + */ + struct work_struct release_work; +}; + +/* + * We currently set the maximum of XGS queues per file to an arbitrary low value. + * But this can be updated if we need more. + */ +#define MAX_XGS_QUEUES_PER_POOL 128 + +/** + * struct panthor_xgs_queue_pool - XGS queue pool + * + * Each file get assigned a XGS queue pool. + */ +struct panthor_xgs_queue_pool { + /** @xa: Xarray used to manage XGS queue handles. */ + struct xarray xa; +}; + +/** + * struct panthor_xgs_job - Used to manage XGS job + */ +struct panthor_xgs_job { + /** @base: Inherit from drm_sched_job. */ + struct drm_sched_job base; + + /** @refcount: Reference count. */ + struct kref refcount; + + /** @group: XGS queue this job will be pushed to. */ + struct panthor_xgs_queue *queue; + + /** @ops: List of XGS operations to execute */ + struct drm_panthor_xgs_op *ops; + + /** @ops_count: Number of operations in the ops array */ + u32 ops_count; + + /** @done_fence: Fence signaled when the job is finished or cancelled. */ + struct dma_fence *done_fence; + + /** @node: Node used to insert job into in_flight_jobs list of queue */ + struct list_head node; + +}; + +static int panthor_xgs_try_run_job(struct panthor_xgs_job *job); + +static const char *xgs_fence_get_driver_name(struct dma_fence *fence) +{ + return "panthor"; +} + +static const char *xgs_fence_get_timeline_name(struct dma_fence *fence) +{ + return "xgs-fence"; +} + +static void xgs_fence_free(struct dma_fence *fence) +{ + dma_fence_free(fence); +} + +static const struct dma_fence_ops panthor_xgs_fence_ops = { + .get_driver_name = xgs_fence_get_driver_name, + .get_timeline_name = xgs_fence_get_timeline_name, + .release = xgs_fence_free, +}; + +static void xgs_queue_release_work(struct work_struct *work) +{ + struct panthor_xgs_queue *queue = container_of(work, struct panthor_xgs_queue, + release_work); + + if (queue->entity.fence_context) + drm_sched_entity_destroy(&queue->entity); + + if (queue->scheduler.ops) + drm_sched_fini(&queue->scheduler); + + panthor_vm_put(queue->vm); + + if (queue->eventfd_sync_update_ctx) + eventfd_ctx_put(queue->eventfd_sync_update_ctx); + + kfree(queue); +} + +static void xgs_queue_release(struct kref *kref) +{ + struct panthor_xgs_queue *queue = container_of(kref, struct panthor_xgs_queue, refcount); + struct panthor_device *ptdev = queue->ptdev; + + drm_WARN_ON(&ptdev->base, !list_empty(&queue->fence_ctx.in_flight_jobs)); + + queue_work(panthor_cleanup_wq, &queue->release_work); +} + +static struct panthor_xgs_queue *xgs_queue_get(struct panthor_xgs_queue *queue) +{ + if (queue) + kref_get(&queue->refcount); + + return queue; +} + +static void xgs_queue_recheck(struct panthor_xgs_queue *queue) +{ + struct panthor_xgs_job *job, *tmp; + int ret; + + mutex_lock(&queue->lock); + + list_for_each_entry_safe(job, tmp, &queue->fence_ctx.in_flight_jobs, node) { + ret = panthor_xgs_try_run_job(job); + + if (ret != -EBUSY) { + /* completed or failed */ + list_del_init(&job->node); + + if (ret) + dma_fence_set_error(job->done_fence, -ETIMEDOUT); + + dma_fence_signal(job->done_fence); + + /* Ditch ref we took when adding it to the in_flight_jobs */ + panthor_xgs_job_put(&job->base); + } + } + + mutex_unlock(&queue->lock); +} + +/* Internal flag to mark operations as completed. Avoid clashes with drm_panthor_xgs_op_flags */ +#define DRM_PANTHOR_XGS_OP_COMPLETED (1 << 15) + +static int panthor_xgs_wait(struct panthor_xgs_queue *queue, struct drm_panthor_xgs_op *xgs_op) +{ + struct panthor_device *ptdev = queue->ptdev; + struct panthor_syncobj *syncobj; + int ret; + u64 value; + + if (xgs_op->flags & DRM_PANTHOR_XGS_OP_COMPLETED) + return 0; + + syncobj = panthor_syncobj_create(ptdev, queue->vm, xgs_op->addr, + xgs_op->format == DRM_PANTHOR_XGS_OP_FORMAT_U64); + if (IS_ERR_OR_NULL(syncobj)) + return PTR_ERR(syncobj); + + value = panthor_syncobj_get_value(syncobj); + + ret = -EBUSY; + + if (xgs_op->op == DRM_PANTHOR_XGS_OP_WAIT_LE) { + if (value <= xgs_op->value) { + ret = 0; + xgs_op->flags |= DRM_PANTHOR_XGS_OP_COMPLETED; + } + } else if (xgs_op->op == DRM_PANTHOR_XGS_OP_WAIT_GT) { + if (value > xgs_op->value) { + ret = 0; + xgs_op->flags |= DRM_PANTHOR_XGS_OP_COMPLETED; + } + } + + panthor_syncobj_release(syncobj); + + return ret; +} + +static void +panthor_xgs_signal(struct panthor_xgs_queue *queue, struct drm_panthor_xgs_op *xgs_op, u32 error) +{ + struct panthor_device *ptdev = queue->ptdev; + struct panthor_syncobj *syncobj; + u64 value; + + if (xgs_op->flags & DRM_PANTHOR_XGS_OP_COMPLETED) + return; + + syncobj = panthor_syncobj_create(ptdev, queue->vm, xgs_op->addr, + xgs_op->format == DRM_PANTHOR_XGS_OP_FORMAT_U64); + if (IS_ERR_OR_NULL(syncobj)) + return; + + value = panthor_syncobj_get_value(syncobj); + + if (xgs_op->op == DRM_PANTHOR_XGS_OP_SIGNAL_SET) + value = xgs_op->value; + else if (xgs_op->op == DRM_PANTHOR_XGS_OP_SIGNAL_ADD) + value += xgs_op->value; + + if (!error) + panthor_syncobj_signal(syncobj, value); + else + panthor_syncobj_signal_with_error(syncobj, value, error); + + panthor_sched_sync_update(ptdev); + + if (queue->eventfd_sync_update_ctx) + eventfd_signal(queue->eventfd_sync_update_ctx); + + xgs_op->flags |= DRM_PANTHOR_XGS_OP_COMPLETED; + + panthor_syncobj_release(syncobj); +} + +static int panthor_xgs_try_run_job(struct panthor_xgs_job *job) +{ + int i; + int err_wait = 0; + struct drm_panthor_xgs_op *xgs_op; + + lockdep_assert_held(&job->queue->lock); + + for (i = 0; i < job->ops_count; i++) { + xgs_op = &job->ops[i]; + + switch (xgs_op->op & ~DRM_PANTHOR_XGS_OP_COMPLETED) { + case DRM_PANTHOR_XGS_OP_WAIT_LE: + case DRM_PANTHOR_XGS_OP_WAIT_GT: + if (!err_wait) + err_wait = panthor_xgs_wait(job->queue, &job->ops[i]); + if (err_wait == -EBUSY) + return err_wait; + break; + case DRM_PANTHOR_XGS_OP_SIGNAL_SET: + case DRM_PANTHOR_XGS_OP_SIGNAL_ADD: + panthor_xgs_signal(job->queue, &job->ops[i], err_wait); + break; + default: + /* unknown operation, assume this could be a critical error */ + err_wait = -EINVAL; + break; + } + } + + return err_wait; +} + +static struct dma_fence *panthor_xgs_run_job(struct drm_sched_job *sched_job) +{ + struct panthor_xgs_job *job = container_of(sched_job, struct panthor_xgs_job, base); + struct panthor_xgs_queue *queue = job->queue; + struct dma_fence *done_fence; + int ret; + + mutex_lock(&queue->lock); + + ret = panthor_xgs_try_run_job(job); + if (ret == -EBUSY) { + dma_fence_init(job->done_fence, + &panthor_xgs_fence_ops, + &queue->fence_ctx.lock, + queue->fence_ctx.id, + atomic64_inc_return(&queue->fence_ctx.seqno)); + + done_fence = dma_fence_get(job->done_fence); + panthor_xgs_job_get(&job->base); + + list_add_tail(&job->node, &queue->fence_ctx.in_flight_jobs); + + } else if (ret) { + done_fence = ERR_PTR(ret); + } else { + /* job completed immediately, no need to return fence */ + done_fence = NULL; + } + + mutex_unlock(&queue->lock); + + return done_fence; +} + +static enum drm_gpu_sched_stat +panthor_xgs_job_timedout(struct drm_sched_job *sched_job) +{ + struct panthor_xgs_job *job = container_of(sched_job, struct panthor_xgs_job, base); + struct panthor_xgs_queue *queue = job->queue; + int ret; + + mutex_lock(&queue->lock); + + list_del_init(&job->node); + + /* Ditch ref we took when adding it to the in_flight_jobs */ + panthor_xgs_job_put(&job->base); + + ret = panthor_xgs_try_run_job(job); + if (ret) + dma_fence_set_error(job->done_fence, -ETIMEDOUT); + + mutex_unlock(&queue->lock); + + dma_fence_signal(job->done_fence); + + panthor_xgs_job_put(sched_job); + + return DRM_GPU_SCHED_STAT_NOMINAL; +} + +static const struct drm_sched_backend_ops panthor_xgs_sched_ops = { + .run_job = panthor_xgs_run_job, + .timedout_job = panthor_xgs_job_timedout, + .free_job = panthor_xgs_job_put, +}; + +int panthor_xgs_queue_create(struct panthor_file *pfile, u32 vm_id, + int eventfd_sync_update, u32 *handle) +{ + struct panthor_device *ptdev = pfile->ptdev; + struct panthor_xgs_queue_pool *xgs_queue_pool = pfile->xgs_queues; + struct panthor_xgs_queue *queue; + struct drm_gpu_scheduler *drm_sched; + int ret; + int qid; + + queue = kzalloc(sizeof(*queue), GFP_KERNEL); + if (!queue) + return -ENOMEM; + + kref_init(&queue->refcount); + INIT_LIST_HEAD(&queue->fence_ctx.in_flight_jobs); + INIT_WORK(&queue->release_work, xgs_queue_release_work); + queue->ptdev = ptdev; + + ret = drmm_mutex_init(&ptdev->base, &queue->lock); + if (ret) + goto err_put_queue; + + if (eventfd_sync_update >= 0) { + queue->eventfd_sync_update_ctx = eventfd_ctx_fdget(eventfd_sync_update); + ret = PTR_ERR_OR_ZERO(queue->eventfd_sync_update_ctx); + if (ret) + goto err_put_queue; + } + + queue->vm = panthor_vm_pool_get_vm(pfile->vms, vm_id); + if (!queue->vm) { + ret = -EINVAL; + goto err_put_queue; + } + + ret = drm_sched_init(&queue->scheduler, &panthor_xgs_sched_ops, + NULL, 1, 1, 0, + msecs_to_jiffies(JOB_TIMEOUT_MS), + NULL, NULL, + "panthor_xgs", + ptdev->base.dev); + if (ret) + goto err_put_queue; + + drm_sched = &queue->scheduler; + ret = drm_sched_entity_init(&queue->entity, 0, &drm_sched, 1, NULL); + if (ret) + goto err_put_queue; + + queue->fence_ctx.id = dma_fence_context_alloc(1); + spin_lock_init(&queue->fence_ctx.lock); + + ret = xa_alloc(&xgs_queue_pool->xa, &qid, queue, + XA_LIMIT(1, MAX_XGS_QUEUES_PER_POOL), GFP_KERNEL); + if (ret) + goto err_put_queue; + + queue->handle = qid; + *handle = qid; + + return 0; + +err_put_queue: + panthor_xgs_queue_put(queue); + return ret; +} + +int panthor_xgs_queue_destroy(struct panthor_file *pfile, u32 handle) +{ + struct panthor_xgs_queue_pool *pool = pfile->xgs_queues; + struct panthor_xgs_queue *queue; + struct panthor_xgs_job *job, *tmp; + LIST_HEAD(faulty_jobs); + int err = -ECANCELED; + + queue = xa_erase(&pool->xa, handle); + if (!queue) + return -EINVAL; + + queue->destroyed = true; + + mutex_lock(&queue->lock); + + list_for_each_entry_safe(job, tmp, &queue->fence_ctx.in_flight_jobs, node) { + list_move_tail(&job->node, &faulty_jobs); + dma_fence_set_error(job->done_fence, err); + dma_fence_signal(job->done_fence); + } + + mutex_unlock(&queue->lock); + + list_for_each_entry_safe(job, tmp, &faulty_jobs, node) { + list_del_init(&job->node); + /* Ditch ref we took when adding it to the in_flight_jobs */ + panthor_xgs_job_put(&job->base); + } + + panthor_xgs_queue_put(queue); + + return 0; +} + +void panthor_xgs_queue_put(struct panthor_xgs_queue *queue) +{ + if (queue) + kref_put(&queue->refcount, xgs_queue_release); +} + +struct panthor_vm *panthor_xgs_queue_vm(struct panthor_xgs_queue *queue) +{ + return queue->vm; +} + +int panthor_xgs_queue_pool_create(struct panthor_file *pfile) +{ + struct panthor_xgs_queue_pool *pool; + + pool = kzalloc(sizeof(*pool), GFP_KERNEL); + if (!pool) + return -ENOMEM; + + xa_init_flags(&pool->xa, XA_FLAGS_ALLOC1); + pfile->xgs_queues = pool; + return 0; +} + +void panthor_xgs_queue_pool_destroy(struct panthor_file *pfile) +{ + struct panthor_xgs_queue_pool *pool = pfile->xgs_queues; + struct panthor_xgs_queue *queue; + unsigned long i; + + if (IS_ERR_OR_NULL(pool)) + return; + + xa_for_each(&pool->xa, i, queue) + panthor_xgs_queue_destroy(pfile, i); + + xa_destroy(&pool->xa); + kfree(pool); + pfile->xgs_queues = NULL; +} + +struct panthor_xgs_queue *panthor_xgs_queue_pool_get_xgs_queue(struct panthor_xgs_queue_pool *pool, + u32 handle) +{ + struct panthor_xgs_queue *queue; + + queue = xgs_queue_get(xa_load(&pool->xa, handle)); + + return queue; +} + +void panthor_xgs_queue_pool_recheck(struct panthor_file *ptfile) +{ + unsigned long i; + struct panthor_xgs_queue *queue; + + xa_for_each(&ptfile->xgs_queues->xa, i, queue) + xgs_queue_recheck(queue); +} + +struct drm_sched_job *panthor_xgs_job_create(struct panthor_xgs_queue *queue, + struct drm_panthor_xgs_op *ops, u32 ops_count) +{ + struct panthor_xgs_job *job; + int ret; + + job = kzalloc(sizeof(*job), GFP_KERNEL); + if (!job) + return ERR_PTR(-ENOMEM); + + kref_init(&job->refcount); + INIT_LIST_HEAD(&job->node); + + job->queue = xgs_queue_get(queue); + if (!job->queue) { + ret = -EINVAL; + goto err_put_job; + } + + job->done_fence = kzalloc(sizeof(*job->done_fence), GFP_KERNEL); + if (!job->done_fence) { + ret = -ENOMEM; + goto err_put_job; + } + + ret = drm_sched_job_init(&job->base, &queue->entity, 1, queue); + if (ret) + goto err_put_job; + + /* take ownership of ops array */ + job->ops = ops; + job->ops_count = ops_count; + + return &job->base; + +err_put_job: + panthor_xgs_job_put(&job->base); + return ERR_PTR(ret); +} + +static void xgs_job_release(struct kref *ref) +{ + struct panthor_xgs_job *job = container_of(ref, struct panthor_xgs_job, refcount); + + drm_WARN_ON(&job->queue->ptdev->base, !list_empty(&job->node)); + + if (job->base.s_fence) + drm_sched_job_cleanup(&job->base); + + if (job->done_fence && job->done_fence->ops) + dma_fence_put(job->done_fence); + else + dma_fence_free(job->done_fence); + + panthor_xgs_queue_put(job->queue); + kvfree(job->ops); + kfree(job); +} + +struct drm_sched_job *panthor_xgs_job_get(struct drm_sched_job *sched_job) +{ + if (sched_job) { + struct panthor_xgs_job *job = container_of(sched_job, struct panthor_xgs_job, base); + + kref_get(&job->refcount); + } + + return sched_job; +} + +void panthor_xgs_job_put(struct drm_sched_job *sched_job) +{ + struct panthor_xgs_job *job = container_of(sched_job, struct panthor_xgs_job, base); + + if (sched_job) + kref_put(&job->refcount, xgs_job_release); +} + +void panthor_xgs_job_update_resvs(struct drm_exec *exec, struct drm_sched_job *sched_job) +{ + struct panthor_xgs_job *job = container_of(sched_job, struct panthor_xgs_job, base); + + panthor_vm_update_resvs(job->queue->vm, exec, &sched_job->s_fence->finished, + DMA_RESV_USAGE_BOOKKEEP, DMA_RESV_USAGE_WRITE); +} diff --git a/drivers/gpu/drm/panthor/panthor_xgs.h b/drivers/gpu/drm/panthor/panthor_xgs.h new file mode 100644 index 000000000000..fa7dd5e5ef83 --- /dev/null +++ b/drivers/gpu/drm/panthor/panthor_xgs.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0 or MIT */ +/* Copyright 2024 ARM Limited. All rights reserved. */ + +#ifndef __PANTHOR_XGS_H__ +#define __PANTHOR_XGS_H__ + +struct drm_exec; +struct drm_panthor_xgs_op; +struct drm_panthor_xgs_queue_create; +struct drm_sched_job; +struct panthor_xgs_queue; +struct panthor_xgs_queue_pool; +struct panthor_file; +struct panthor_vm; + +int panthor_xgs_queue_create(struct panthor_file *pfile, u32 vm_id, + int eventfd_sync_update, u32 *handle); +int panthor_xgs_queue_destroy(struct panthor_file *pfile, u32 handle); + +void panthor_xgs_queue_put(struct panthor_xgs_queue *queue); + +struct panthor_vm *panthor_xgs_queue_vm(struct panthor_xgs_queue *queue); + +int panthor_xgs_queue_pool_create(struct panthor_file *pfile); +void panthor_xgs_queue_pool_destroy(struct panthor_file *pfile); + +struct panthor_xgs_queue * +panthor_xgs_queue_pool_get_xgs_queue(struct panthor_xgs_queue_pool *pool, u32 handle); + +void panthor_xgs_queue_pool_recheck(struct panthor_file *ptfile); + +struct drm_sched_job * +panthor_xgs_job_create(struct panthor_xgs_queue *queue, + struct drm_panthor_xgs_op *ops, + u32 ops_count); + +void panthor_xgs_job_put(struct drm_sched_job *sched_job); +struct drm_sched_job *panthor_xgs_job_get(struct drm_sched_job *sched_job); + +void panthor_xgs_job_update_resvs(struct drm_exec *exec, struct drm_sched_job *sched_job); + +#endif From patchwork Wed Aug 28 17:26:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 13781616 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2C081C636EE for ; Wed, 28 Aug 2024 17:27:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9B11310E40F; Wed, 28 Aug 2024 17:27:29 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.b="kGg8/Kny"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="kGg8/Kny"; dkim-atps=neutral Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2082.outbound.protection.outlook.com [40.107.247.82]) by gabe.freedesktop.org (Postfix) with ESMTPS id B94B410E40F for ; Wed, 28 Aug 2024 17:27:27 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=wCEtUsYMvzCrtd4+HqUO3m91jVJpYsMi++8MVGAKmamtO2QEvHeLCM+e+8E97V/+W0FDJ0URCId4LP7ndt/MUGbpd62fmxsf4XvjrHobqrzo9VBwipBc8P3ceHswqiX08o0muIqeHnlwYrLUiNyPSPKN7ktzu1nYHbO3Dr0SK+y7sF7DBPqHBYs7pHsCgGuQvivA484hrT4LnsKC1Hhiw8dJ4OibHsLIqQZj/64zNFEfu4wWxaFVgGqgtv+Rkay74NuadI1H1JnXe3PCVS2gI8dBUEvF66zcHZ2IuJJhCWTb/NetmFYyTY3Q7cAQAB5g85LCPa+Nk8p+9sPsUtBmdg== 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=bISh8gDHA2aB6rJ/FU9XT0iKSAxjuwvzXzNlpSL3RQI=; b=PENkHX9E8bbK+qL2GlKtR9CgufJ+QVfCDahQGzoGuwk8B+AGPOWS6F7rizses0+lSysBPjk8hxyRj7OTqsOXzfFRWU8as+GjbnWluVcSMalSF3BPrKjY3STyHdN/i0j1d/xILI5uGnEzRffBFqI6Y8RERYFinfZEUZ2qrLthjsxxtkrACOLUVVdad5v/F5APLzJu3eFWvzA9mtYQJRLdH7I0OhDUgZeCV8XyVrWORb4apwGLPS7kGptLE+sPgm7aHIFmdwcfwPouHLgCqpOtdYDth7U/WkIBPmOvRWAr9UexHf4/kemzYde5u1wZQVAjcOD5t57rW56djNSP6zJOzg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.freedesktop.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=bISh8gDHA2aB6rJ/FU9XT0iKSAxjuwvzXzNlpSL3RQI=; b=kGg8/KnyBJpeUMmlWzCOQXctJTks+PDmmKatJsjDzPS9AR+1P6TIJIl6Uv5Lc280xIUXilZdjzLB3WP23s99feLbTA15ItyUVnuFZ3N4/bk8/A1mvGl5Ml1AxxxuHqhhoTR14Xc4zTU5NE7lT4E9/W9vEtO0LUfpsKBHG2+Y04w= Received: from DU2PR04CA0229.eurprd04.prod.outlook.com (2603:10a6:10:2b1::24) by GV2PR08MB8270.eurprd08.prod.outlook.com (2603:10a6:150:c1::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.14; Wed, 28 Aug 2024 17:27:23 +0000 Received: from DB5PEPF00014B96.eurprd02.prod.outlook.com (2603:10a6:10:2b1:cafe::13) by DU2PR04CA0229.outlook.office365.com (2603:10a6:10:2b1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.26 via Frontend Transport; Wed, 28 Aug 2024 17:27:22 +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 DB5PEPF00014B96.mail.protection.outlook.com (10.167.8.234) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 28 Aug 2024 17:27:22 +0000 Received: ("Tessian outbound bc251c670828:v403"); Wed, 28 Aug 2024 17:27:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2eba0d675f59de90 X-CR-MTA-TID: 64aa7808 Received: from L738b975a3c72.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F3E66A33-4DC5-42D8-80B1-9C7B4D8BCA14.1; Wed, 28 Aug 2024 17:27:15 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id L738b975a3c72.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Aug 2024 17:27:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oTpGFBU4ylFc7VDxGevQCl71FXDYTAZjlYniIVIix1X0v/cvJvvh1+jrcNI9plYGCez1Wq/4PdZCgVWsGoZzFnkDpr1lCOgYWtvR84+EpQtjSK3KJQj2fUNn+1vBPOEbApjsTxbxtOfGQRoz1WfdpkM0iX5/JLC4jNAe4g1M8/cdF/EKiOHAe5DU7r+ncsv6NgI4771+BinbBAMCjoUARCpEVpOHAYF83Jb8Ah6om7JadYzUvLCdFzc5hKieKxH+F858xRtj0i+F6kuza+7xyr1TEFanwiR9fePN4PRJR6eGn3yC9weQ4IQI88ZBlhzyXFvlCVme+g7SDtza/w9DZQ== 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=bISh8gDHA2aB6rJ/FU9XT0iKSAxjuwvzXzNlpSL3RQI=; b=jy+NCMsX3EkGJR6/Um9e453bV7Wln1h6gzyZQZz037nsZbQWNyHinQlwdQ8434i2dF9As1Kgzu9EObzsmbWiOZphz+lOIp+41EmH2KAHwfeAVod5UwgsWZIRw1Rm6G/aqiWZV7cHVaIyt1FjTaAd0zAh6CSz4aiEzoCYPIVV9vPlc5YB2XKjkZvRvIxt+P/zlBHFW5RvoOFoMGDMKL+czeFFdoMthx36of1NMuA6JoCC0kjBttEIhWdefskMxIpz8173Iq3Xxe9UYLYJJDaz3+295Ng/xDq+RETN8qFDcc5UHKF2LWCml6KzXiet2MCROjpyXEtAy9ibR1DtSxBNAQ== 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=bISh8gDHA2aB6rJ/FU9XT0iKSAxjuwvzXzNlpSL3RQI=; b=kGg8/KnyBJpeUMmlWzCOQXctJTks+PDmmKatJsjDzPS9AR+1P6TIJIl6Uv5Lc280xIUXilZdjzLB3WP23s99feLbTA15ItyUVnuFZ3N4/bk8/A1mvGl5Ml1AxxxuHqhhoTR14Xc4zTU5NE7lT4E9/W9vEtO0LUfpsKBHG2+Y04w= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) by AS8PR08MB6551.eurprd08.prod.outlook.com (2603:10a6:20b:319::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.18; Wed, 28 Aug 2024 17:27:13 +0000 Received: from AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c]) by AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c%7]) with mapi id 15.20.7918.012; Wed, 28 Aug 2024 17:27:13 +0000 From: Mihail Atanassov To: linux-kernel@vger.kernel.org, Boris Brezillon , Liviu Dudau , Steven Price Cc: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Shashank Sharma , Ketil Johnsen , Akash Goel , Mihail Atanassov Subject: [PATCH 7/8] drm/panthor: Add sync_update eventfd handling Date: Wed, 28 Aug 2024 18:26:03 +0100 Message-ID: <20240828172605.19176-8-mihail.atanassov@arm.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240828172605.19176-1-mihail.atanassov@arm.com> References: <20240828172605.19176-1-mihail.atanassov@arm.com> X-ClientProxiedBy: LO4P123CA0596.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:295::10) To AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6263:EE_|AS8PR08MB6551:EE_|DB5PEPF00014B96:EE_|GV2PR08MB8270:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c37c526-9a3d-45b2-805b-08dcc786ad74 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: tk43Yx9zNIgKswtzWoTtsvQUXlFt13pQTi07QyUf3hqqW43Wk3mqAuM9NBOukecATUoBWui0cxKvftvz1GLHtNdfiW5yeVcAU4YG6grP+e4dvAVN5+wQaBVbFZiEqr0/FlretXiU/iPPLTN+tQCzZWg3wDH/m+zeQwpiE4DCGRsn7rbc6yICPtxn0f+MoMTnyv8Jz6VjVi4kuUe4OznsXc6txSDT1wog9VUj+b/lTgLj+W2E0pe29zCXj2Gu19PVKbDteE6e7WvHwXDh1HP/Xp0/Ep1ujJFkgajSQvah4Q6xqKjuaI+oPIiD/0rn3R+NIOIzer2jpw4hwob+PZDkzrZ0eO6hWKb80mNR39Pf5B/p5RPNgX7nwi6TmxQcyx91cWGZ8irqdXZuBnriqUtXW1RvlqjNzk+DU+A7rUxSx93pC82Z5agDUJRgwfcv77T1b1zabDmpwolIIvCWxazAAlBwcthiIL8T9ltuBMLAdG+Hsdg40sd0jcA7bbAnVnEOU9GQAUNTtBsQeUl82Abo38ovN3BsqVyvLW/opSP0sWyB+mbWGR/MvefKSvkM5pTS6nLQj08BElyFeKucZDx8DrvfNoKzqZLJZeHoOJEJbJEgVyi/ziZocVvXj3c4Mi0plzGm2EpUwNvwqFJoc1b4l+sn7gzXiXciQzufuduxQR5ai9A0JWV9qBmMftXbDpEWfMFnoOX12QpqMTa776O93UzzqenSdXtKGUuoHUAwDBkeRDHvdduJS/wn9ICMsm85FlavitsX22w54c3yE2Obm5ZJRaM3EgK14R8eoX4ApoufQOWSYna2Kwf1qd7J8sCBmtdTndg1yXlkImY7VNnzXclQJw5UALzZ6kFP9ns9YOrmj51Gfqtur+9+4qTNZmpnSorMHR9/tIJhXziB2F69DIk1DStKn+A8LfTDeumJocbJzuDOCkSnCeyTdt759GD1zwcd6BiREt+N6QG+lIY3PhKICBrw37bT/4yycI7/cBqi5XsWT3RuKe8IujIBBO8hX6LiluZ4gZe27y4dcfQWcoDzmW7/X0cKRC56ofuPHQCfjOWdyXjpO8Py1SZPZSAOUbnhhucShZ19cFgoEPi/CJw6y3gHzf87C1VvxPmOciTjn5/KlKK3kj33TnFkNjy2k6i/Y5iGhtT0f2CF+GE/4GottK7ConNEk305vxImidHnqQOGreHiSY1u3C2UL36+142uEntBevP3iLFD3j3NPvI52qfOJrD5U+eH26wsMcJqPVUbju7BjGDzc7gnfr5GjEfH6S4Fce6OydLmUm2Bk0qXgYtF1tpZ51lUHOgVJfr8g1NQvV0cvjY3eM+wGp4p3VEzqhMM9w2/jA/hA+8AQw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6263.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6551 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:20b:290::9]; domain=AS8PR08MB6263.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5PEPF00014B96.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b5e35f7c-6a63-444e-c411-08dcc786a7fc X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|35042699022|36860700013; X-Microsoft-Antispam-Message-Info: 6i2czN1+lGMpqZsXxOkH1VT2HMkuV1Yf3KWyUENYnvZguB1J6cdu5eukSz6IVSRjMbQ081paka9cU3DJWfGQm43g2Q6yNZ1U5Q6qGj44zz+3CMAphqQHT0ZWLdgry5k0umzG2+06Q4SK+V97iLKew8XmG/kxTMB99rqycFn76+eDwSJ+hD1luPojgKA50E8bZ4XTO5AVUfHPPkltmzuCDtUzv3TSsQJsiCkAatynOrQgJrL5ioH28hpwWQDYsaS4NzJF4GCbHH3Jr0VZzpx4pv7IljmJmRaRthE6jNnIJWQBsRtbKQPGhe/V0pY9zWB5AAiiRpuHdf8J+LxuHHgdN0dq/7AW05PMpJh5Ovm2SuN8KQBQt7bpRhBDzgmHG6jFv4aKlQzJz2Vw7i3/gqd6qTKPQv2h8ajwK0buyEpGduvTiI2T7cums2Pdh6r05/+2VBqzm/WUCNcqSAjevrTVpczITOukCocmudrJPxvBh+gZ/yFMdYw9IKsSyG2jAUaZ4RWJ9WuY+/Afmj8reHwpBz8PadsMyyuC1zVEflr/17FpwPnm1hKXYJfxKrnovPALXgBWneIYVeyFcUYbGnv5NC4Lo3xAy/YvpodyyYUCILzYK8IJdr/phuUIdPSc9+uOQeioKnyIvUADTgKRxyur+uyQ5oW8/GKALDfRtu9MBMdJzM00q9DxXfbC6yDqXZsx7/PK3FJVWlv2EdVdgLbXhOWc0GuJ/KfJxh31R8XAEl87SsHGhbk0+aiD+tc8zvKA2lYWJYXrJ/32bLX3kQj5QWYPXqFjPOHAJQy0iBQZX75nCe2UUrlCffju2/5S9dyuljAO5OjhIOoxo/ObIVFA71pwnKt/hyyLVVIyML3G31PchcAMimh8kDZ0Tk4RUVXxEgnnaj56Fjv1Qm8M3FuhfuqKHr2sgrSmeQ5QDk9IirtDZV8D4cesvgCiiyI4hvS03nLNg41oZnsB/Cmst3P5P3j80aees5/FgxmzHCibafrfhyiNOKx+DGLuvwoXJ7Wd308Q0wLEVRZXy9Pp6rfl+UoqHmKrhCdTWpKqpzrwT7lyKBiRGjWSHRVd5ItrkVCjjMqDrmvhVh5h5gvVSeEUizK22uo5YSR3ChawEY5vf9Oz0OXZCiXIVC7Jzq8+FNbd1A+Y+3shtA7ethUDSvaBQvjjkBvuKzFKTVHRzqMh1FK5oHmMDLvmqBBeyxy3Z36gqlx/ZysGqgjZyaszupIbXgaGrqZMgRQjT3tvOb89oKrBqSN9LLZHL1P5lIWpGgczfCrYT7NGWgGPEEcSfIZiOkCKDnmwX7fmAiEfJ1X8RnawzbJv3SGoduKbQv0tPKhSSiYFOd9rJCyfEBwWXieeLjmsLK17s2ntMkaK6Lta+eWThGEnfpzivf04R1YwFUXWAJ14muwA+fs8Y8N13o7IgkgCZAjW9vYYpTxhvz3TroPKv0dDUn4a3kh/u1z/0edX 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:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230040)(376014)(82310400026)(1800799024)(35042699022)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2024 17:27:22.9093 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c37c526-9a3d-45b2-805b-08dcc786ad74 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: DB5PEPF00014B96.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8270 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Expose the SYNC_UPDATE event to userspace so it can respond to changes in syncobj state. Signed-off-by: Mihail Atanassov --- drivers/gpu/drm/panthor/panthor_sched.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c index 92172b2c6253..67c27fcc3345 100644 --- a/drivers/gpu/drm/panthor/panthor_sched.c +++ b/drivers/gpu/drm/panthor/panthor_sched.c @@ -643,6 +643,9 @@ struct panthor_group { * panthor_group::groups::waiting list. */ struct list_head wait_node; + + /** @eventfd_sync_update_ctx: eventfd context to signal on GPU_SYNC_UPDATE */ + struct eventfd_ctx *eventfd_sync_update_ctx; }; /** @@ -797,6 +800,10 @@ static void group_release_work(struct work_struct *work) panthor_kernel_bo_destroy(group->syncobjs); panthor_vm_put(group->vm); + + if (group->eventfd_sync_update_ctx) + eventfd_ctx_put(group->eventfd_sync_update_ctx); + kfree(group); } @@ -1501,6 +1508,9 @@ static void csg_slot_sync_update_locked(struct panthor_device *ptdev, /* Rerun XGS jobs immediately, as this can potentially unblock the group */ panthor_xgs_queue_pool_recheck(group->pfile); + if (group->eventfd_sync_update_ctx) + eventfd_signal(group->eventfd_sync_update_ctx); + if (!group->user_submit) group_queue_work(group, sync_upd); } @@ -3204,9 +3214,18 @@ int panthor_group_create(struct panthor_file *pfile, INIT_WORK(&group->tiler_oom_work, group_tiler_oom_work); INIT_WORK(&group->release_work, group_release_work); - if (group_args->flags & DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT) + if (group_args->flags & DRM_PANTHOR_GROUP_CREATE_USER_SUBMIT) { group->user_submit = true; + if (group_args->eventfd_sync_update >= 0) { + group->eventfd_sync_update_ctx = eventfd_ctx_fdget( + group_args->eventfd_sync_update); + ret = PTR_ERR_OR_ZERO(group->eventfd_sync_update_ctx); + if (ret) + goto err_put_group; + } + } + group->vm = panthor_vm_pool_get_vm(pfile->vms, group_args->vm_id); if (!group->vm) { ret = -EINVAL; From patchwork Wed Aug 28 17:26:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihail Atanassov X-Patchwork-Id: 13781618 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7B3C3C636EE for ; Wed, 28 Aug 2024 17:27:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC50910E54F; Wed, 28 Aug 2024 17:27:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.b="ReNAqNPO"; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="ReNAqNPO"; dkim-atps=neutral Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2053.outbound.protection.outlook.com [40.107.20.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5E93E10E54F for ; Wed, 28 Aug 2024 17:27:40 +0000 (UTC) ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=oPxHgNWI0kwsbhCqHzlrI4xIF8bBLhR8xDQQ6TYXelG9Jn3RIEPswQ1qxVZll/iF6jHl7Ao40evZjhxjtZFL6mWbMARoAJMkAxzBT7TjO/tE9iZrWfrbyDl+fZkJjdk5wT663n3LYhcCLQTISc0jcBbleTF2/EupvTJP1pwlXcviBctIELu0dI63b6Ef8/fnd74RHk3rOfmBKJaeHrixmdJy2fjR9yUF0VKqVyX5LkpJCg+HtCdKr6dqvwcdxo7Czs40D74ss24enPX/pISWXmyW00qQRzzTS1F8nUwJTqCTyBzPFHmyGZHiz0AcRhukDLUtTZI3L7C74bLfOpbdug== 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=vmd1NFhAixuB392WGGWTY8mLiA3VFQLMI4H/ONrGpqg=; b=XAjqMnHleOthmJGMwo1k/8DQzQrfBYZg/trcrQjN6rniAh6F+GBdRffPbRU6cioHoCDAGcIY7KicOcfXrTRCIgi7R9sMzmVu3zZqupaVK1HRLMsGnrMzlkwh2XmLUnwCCXk6WtgKZP0DGHs3PC7o4C/oAVl3ySAGWwNLKdOyGaiwzZbrnVyAEeh3Yw21uOQUuMR5XLEDEJmQO9ByG2CChyiHy9Jms6rc8Qz59kY7wp3v9RElfWoNzuGRJ91p7UAfQ6TRg02HFLABMMySewz/BR0WcBLRR8FbD6zAG0Qm4O3N1jDycR5NXyKY0/i3njFCDN1BHVKbwVzenInoI9C65A== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.freedesktop.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=vmd1NFhAixuB392WGGWTY8mLiA3VFQLMI4H/ONrGpqg=; b=ReNAqNPOE7cdbb9VUK/pHTuj9qwoPp4TDxQT+7vFZV6lEX3Hz5IfIIqoDy8uRq7A4INWIMOiiSER32mE0xw8nTq9LeidSuE3SQoDPr21LO94/Q668c5USkt97qFqZtG2QvB2UqlVsvvhJkl23NcqMYGV3JoAXCldEHnafK3Jhac= Received: from AM0PR02CA0218.eurprd02.prod.outlook.com (2603:10a6:20b:28f::25) by AS8PR08MB8971.eurprd08.prod.outlook.com (2603:10a6:20b:5b2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.14; Wed, 28 Aug 2024 17:27:33 +0000 Received: from AM4PEPF00027A63.eurprd04.prod.outlook.com (2603:10a6:20b:28f:cafe::96) by AM0PR02CA0218.outlook.office365.com (2603:10a6:20b:28f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.27 via Frontend Transport; Wed, 28 Aug 2024 17:27:33 +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 AM4PEPF00027A63.mail.protection.outlook.com (10.167.16.73) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 28 Aug 2024 17:27:33 +0000 Received: ("Tessian outbound 8e666bd17457:v403"); Wed, 28 Aug 2024 17:27:32 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b771c889ed2d3c06 X-CR-MTA-TID: 64aa7808 Received: from Lf6cffd2a39ab.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9D0A480D-8F3E-4EF8-8850-1258E836B2E5.1; Wed, 28 Aug 2024 17:27:21 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id Lf6cffd2a39ab.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 28 Aug 2024 17:27:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kCk1B2iPLFOXzijNMUu6RGNhNI1BWyQfOyM9LfXOxlTA0WRuSNf7WEqyG8q8+lleVnYhl9/55nff/hxNpuwCVrwTfbPjxrgVnaeNqyl8KgWsQo6ozK5jPcTx6fBp3UIB9voy/HFaExpW65Pzgtio+t3/1gSLpbOC7GPguCGeQwW4IBog0hWRG7ijLgA3lkyWuyAOaib2XoJH+iLNzW3hGurRwfQrhFuCe0fcmBsv0fXS70BDnKNC3Y2+7ypHv09wzqL9etPZVTKuo4V/G8CGYtD7ub17J6e2sj9dkqxQeJZuyq49/Uw7uwEX17oEO0qkLqTSL4Yodf9a/KM0kKxinw== 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=vmd1NFhAixuB392WGGWTY8mLiA3VFQLMI4H/ONrGpqg=; b=JXij3Fp6F+yNFiWV+RREEWvtZRVk0mmBjPzfhwCQrtbU7I8EvmHmtXBoYkG9+hrsdZUhnEuRLEwyvn9gLUArDkPMS9YxQE+72ZpnaELrlShcWZYIXOerQnKKuUAVeapibukzetxV71BLLGOpO+s95jrFkum+LBoY6iXl4Py3OIFHCPzv/ToSDbRLhR/7lhxCd+KtcQkZtwcfZcqY4um0pL+Ay9eRrcOYxRjzQc7F8BFRsG635UU2oOlcVHtfdcrVrsGfUAwC6PmKaM+MMIm6akJsUM4HNecMcyIJoIkQunU+hAJRAf3RmowGKQPGS79KBn3jDWmsJtmQNdc/fUBQOA== 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=vmd1NFhAixuB392WGGWTY8mLiA3VFQLMI4H/ONrGpqg=; b=ReNAqNPOE7cdbb9VUK/pHTuj9qwoPp4TDxQT+7vFZV6lEX3Hz5IfIIqoDy8uRq7A4INWIMOiiSER32mE0xw8nTq9LeidSuE3SQoDPr21LO94/Q668c5USkt97qFqZtG2QvB2UqlVsvvhJkl23NcqMYGV3JoAXCldEHnafK3Jhac= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) by AS8PR08MB6551.eurprd08.prod.outlook.com (2603:10a6:20b:319::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.18; Wed, 28 Aug 2024 17:27:19 +0000 Received: from AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c]) by AS8PR08MB6263.eurprd08.prod.outlook.com ([fe80::12b5:3f0a:2090:fa7c%7]) with mapi id 15.20.7918.012; Wed, 28 Aug 2024 17:27:19 +0000 From: Mihail Atanassov To: linux-kernel@vger.kernel.org, Boris Brezillon , Liviu Dudau , Steven Price Cc: dri-devel@lists.freedesktop.org, Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , Shashank Sharma , Ketil Johnsen , Akash Goel , Mihail Atanassov Subject: [PATCH 8/8] drm/panthor: Add SYNC_UPDATE ioctl Date: Wed, 28 Aug 2024 18:26:04 +0100 Message-ID: <20240828172605.19176-9-mihail.atanassov@arm.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240828172605.19176-1-mihail.atanassov@arm.com> References: <20240828172605.19176-1-mihail.atanassov@arm.com> X-ClientProxiedBy: LO2P123CA0029.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600::17) To AS8PR08MB6263.eurprd08.prod.outlook.com (2603:10a6:20b:290::9) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6263:EE_|AS8PR08MB6551:EE_|AM4PEPF00027A63:EE_|AS8PR08MB8971:EE_ X-MS-Office365-Filtering-Correlation-Id: 1c33e526-45e8-46f4-cdda-08dcc786b383 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|7416014|1800799024|366016; X-Microsoft-Antispam-Message-Info-Original: 5d+T0opbfSDpM2cNxak+5DFUXzVYC6ahjTEXKIb/tweqt2GCYhoN6ydFYcIzX7OhTbvHtJmFN1fokjJzyqN8HqNNBoOyPq4MbSlUxWd9XOUeZmo06IWZYl5YiIrpN9LfmOZNGemHjTPh0DxrznWo+rN4psuPqbIGPs3kpD7GxS/vZGIMbEi+lAR/49S8q0aHZssSEeMM61qARaUC2KBY6dzqkN6kcZ7mW5YQoBFR9qoH84jsvflRNpmGVtPOyM4kfCNRcP8UH9k1xteUXB2ZyW6kOxSYCqOh7z62rm6ozqAG4ErJxV+gu8MXrY79/+1+9mnfat7T6U6rx1rdQZvg/h34bfZNNZSU8ZfA00sqPvvDCGihMaEBK9Pdw81dM2h0moB0aHogg5bIXwDeWnAbQ+kkAXRhf6Mh3IBGvJhSteRXshJyN0WUu8nvgAdqPhnHikvCKJagMToqzSYOfFD4M8AOEZeVPafLP5t55SD0SRRnBvWFef3I8BpbIaW0rDkQXV2Bj/rTuaUw/JeKMKh9tzeCV3PFH3ZL1DTh1ofYN+2y8Zv3+sVXWzgYYj2rk9X28yeAfA6Os5CnVhemZrtukCdzU40VFAaf0P0HPt7cAvABdHdmMAHfGswq8VFiS+65ezGx6u0RxkWcaQcx6dnehq6VjgCt9Vv6cpkBUzw1W1+z5q4AG5I2EkHcA3JUZPsfaR5KJQc3/qERQy0MmoocQMksCUiodu5uaFgvqDW3+uXff/zt+2N/6XMNPVQQeXQ2udSQGWixgC7hdU8mUxzqbN+QjyadzNPiyirbQfTkMR9njTuCOU4mtoDmwjqBTjkyOduFl0lG7jPDZ81CIcKgdkVTIKfnk0UCLNhj4+AX6s8fYhxYnLj2krdqHIPN7KVFqQ4Enh+dvIHLoYQbTT/aKTjJ0sdx87vNPCcW52vFlUnfeOTN8U0RLKR0zpB0Uw92OF3Fq/8+deFk6ksD0+HERnGJkv6vs2zzlIbMuXBDrOjoeq4QmljkdUONHw9Ai0MAhhBLN1I9r9Wh6Tfu2eytt9NPelpdjVL/X7tytyhH7L5wBquwYaXGLh7CtQe2q26UJKtTD3HB/CMFQqbL73usv+Ur7whjV/Idy4qkBHehxyP4AmNstsC5uPQLSICDONODms1Df4717LWKAjqKkr66eNV43lnqU/EbDgW14im0ra9My+n6padRS28I1qBCtIgnYzyd55TbwXNAt1+r0GFuapmvVwKx0hPWrJAwECoiuRVckt0M3iaXMGsOOD7EEOi+gNXIXkpvdEcPsgUACRCZ2/oUlvLfeFwmHRIUaewdI3LEkhVjz8dHjDwr8mh2DAFypGzI97VEbRG25rQivxYB7Q== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR08MB6263.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6551 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:20b:290::9]; domain=AS8PR08MB6263.eurprd08.prod.outlook.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM4PEPF00027A63.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 561ef853-d6ec-40da-b0e7-08dcc786aac5 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700013|1800799024|376014|35042699022; X-Microsoft-Antispam-Message-Info: J1EASqi362yTYo+jiE3QOqQbL2h7Y+eyGfFbitva1IvwnSaEzX/9R1qgqXI8o4yySiJXvsCAi9Mu5ZJCb3l0Sx2lLVdl65MMf4XEwCx89CHv+1RczL8p7xQW14Mfb6u8lSNFppbsmgg2itwpT48WgDYgSLujIJ4Me20r/7VKy9slf4Au/VuhPZVMk5HdeadTB9jTUUufnJ8lL16kKIe0vS4HRemprfxoEloNPgIh+dY13SLT8Two3p59Q5VPKWw8f0Jb8Qj0Qy0jDltcDnH7SiFQk54Xpo1BiHPcj2O+GTAJnVY49fO7KCwJb+cSpN56KzTxFm1ugRr4jhgS2b6z4Mc0QSf5o0TYzqfdXB8Ej/CUJSnhg0dX6z0v/BUCntxei+953ibZ+5sJV81ppzREvsnXJi1MlUaSLSGUcer7hCWjBqIIr3E+tH5qsy2JnNYWx8bec9NTXDRfLFTsHwZe3x/OTlN7ybkDFvhV86Lq7GdmfeJEu+iBJGQVEx8WneSqPqMuxYHpTx1ddrRrJilf443OPLjKENhFrylKoN5ig70JDfzW6DLUNask0LHO7UCVaAXhNuEcKiIvoqkMiG56PkMIw8NRMJvKvX16OMZ99mZZs06gFuRlm01OT7Ux/GR2Gr4Z+tDBZEpGX87gzu1AejFfwwsDw/uZ0KYE1ifbRIIuHuh10izwyirRZcb2GlQpH2XhJMUwnzK3O3UybEUPq7OeDqa/178eTAhqDca7Wag4EytSBmUBWZ4IEkR2Is/betMLr13PbJ2S0WBS8YLXba0VQryenk7j6OC+bWIFEO9/gO3T2AeQStxo7rGo+AD/vayNA/DdarQVqB2bLbEE3SQVoC0X0gb6iYwne4Nn0n7WCtkWCfMOlOZQYkoxulM7NZJkPa/0fyn/q9NV39eR5yDYga1FA+7DCW0AfU4g4SeGK7tf1pQNcGMMkhiULVwgfTMla6LtIaOt3X+elJAxRq4JQcdmyao3EZ0dP7ecFO2EUvn8pzJ9S/QJoTp6XTPDBLTgg7hLHCCf3xWuMa3TkQJAXPco4Oe+OndFxiFmheZ98F8UU6jL9Wbyj1Q1iLIR8zi1B2jz00/4hBgNKOcMZs9aXfr8BLSoO43cDnCMtBfVq9pp4yIEmsIrAKx+NUVN5L+VBZuc9/17USj3qbbufUNs+C4eTvwsUkwHlMgM/bHmX+dF8ui3pxJSjD7dblostvs9GRNveBAWI//ITthux8TomLqcB9y0+f1VFd7iG7h+gNQDb7TDXrJEc6uqm7bLzDYuV2kJ17a52jfo2u3ZMFnDexJYT51O8KstVUQzRAKe3jPQ4hS4J3zpZtTOmeScqndCPhUdv7rmGmSEOg5tjmUi7Ga2oYPniM95S1OObC+wih11EZDjy+b1SCfDmjv/IREacK/5eFU5mEfVfc8ymPOPhK0qG6gHb6tVMKDWic0gbKdKQ5p/de2A5Vi914q8 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:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230040)(82310400026)(36860700013)(1800799024)(376014)(35042699022); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2024 17:27:33.0603 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1c33e526-45e8-46f4-cdda-08dcc786b383 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: AM4PEPF00027A63.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8971 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Ketil Johnsen Similar to how the kernel driver notifies userspace about syncobj modifications, the reverse notification is also necessary to let panthor re-evaluate any queues (GPU or XGS) that were blocked on wait operations. Signed-off-by: Mihail Atanassov Signed-off-by: Ketil Johnsen --- drivers/gpu/drm/panthor/panthor_drv.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c index 681ac09b6343..1734a52dc3b5 100644 --- a/drivers/gpu/drm/panthor/panthor_drv.c +++ b/drivers/gpu/drm/panthor/panthor_drv.c @@ -1426,6 +1426,28 @@ static int panthor_ioctl_xgs_queue_submit(struct drm_device *ddev, void *data, return ret; } +static int panthor_ioctl_sync_update(struct drm_device *ddev, void *data, + struct drm_file *file) +{ + struct drm_panthor_sync_update *args = data; + struct panthor_device *ptdev = container_of(ddev, struct panthor_device, base); + struct panthor_file *pfile = file->driver_priv; + + if (args->pad) + return -EINVAL; + + if (pm_runtime_get_if_in_use(ddev->dev)) { + /* All sync wait ops will be re-evaluated when we ding the global doorbell */ + gpu_write(ptdev, CSF_DOORBELL(0), 1); + pm_runtime_put_autosuspend(ddev->dev); + } + + panthor_sched_sync_update(ptdev); + panthor_xgs_queue_pool_recheck(pfile); + + return 0; +} + static int panthor_open(struct drm_device *ddev, struct drm_file *file) { @@ -1508,6 +1530,7 @@ static const struct drm_ioctl_desc panthor_drm_driver_ioctls[] = { PANTHOR_IOCTL(XGS_QUEUE_CREATE, xgs_queue_create, DRM_RENDER_ALLOW), PANTHOR_IOCTL(XGS_QUEUE_DESTROY, xgs_queue_destroy, DRM_RENDER_ALLOW), PANTHOR_IOCTL(XGS_QUEUE_SUBMIT, xgs_queue_submit, DRM_RENDER_ALLOW), + PANTHOR_IOCTL(SYNC_UPDATE, sync_update, DRM_RENDER_ALLOW), }; static int panthor_mmap(struct file *filp, struct vm_area_struct *vma)