From nobody Sat Feb 7 19:45:37 2026 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010006.outbound.protection.outlook.com [52.101.61.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBF2A1DEFE0; Wed, 8 Oct 2025 00:13:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.61.6 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882394; cv=fail; b=DjJxC2iZ4jMiRdLq/kKFQgfqsjyFZ0rCAk/vgZWZIPevNnEfYZkfTtUZp/qiW4bYIUfGuo0GPUG0LO9IO9lFNKoYxPdlKn3XHMofl8itsdFlrZOXrI+cktu7ZwuS+SBQ/T1LPXLp36fvAO1/p8Xru5mmDMygwMVBBiANrE91lVw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882394; c=relaxed/simple; bh=Pn1Fvyr5f6Oetma7RRtTBB3fu/AM/LCxIZdtGkTaN/M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=TOR5kqRqBMgGW5mekx3O2n3yM0gYO7a3LJpUqZX7fYHvENKi92MzW7ruIh+CuyzHEub+b3zJzRdByYFaLlWe9EFosr6iVJgJIOwaKk57Hg+SbDEcard8kOedo4KSUh919lAljnMUjLY76NrkbtsySH4ZIALGpKB2HVqc/OeAN4Q= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=iNML2Ozs; arc=fail smtp.client-ip=52.101.61.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="iNML2Ozs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=zQv6aqVIxRBqK/kCTfHrhIs+X1p1RM7au9Qt95aoK1YYbfSG5z655WWwMZz07Om4ZEOaqOTOJVhHxCxg4K78iZtncaSe8WqGJvZ/Af0MFlIT6KxCC4HJukjgJw2YyBJt0ftqeTbHeue3AhpQa7hj6f6TkgA22pPkCBSs3VNwG/+kQuVwoXe7hRlDnJDJbPMjpm3CdgL6ZzSeeRcNj0KNfYP2ZpdDjzZCjLmR3uDqhga40KvwIlZxhzqScxbww231qlo3OMJ9zyqkLPiQNpXrMYN27HKgwevJVECHl3zUMD+1PGGigylDOaPnnWSeg+fga29BS3kT9HJxmrUp3ZDI8A== 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=ytvQ/l9zmZXBrcIspPYTd/CBkZ1WeDssNh2+lQEEZU0=; b=KCNRLruXnCZFWS5t9o7IG0DAP7B5+HCFCsHy3os4j4xGvG2s0G1KjXNapbJiwOswIIHpJwq5zL4TIJYt27CEbrzmQZus2nh9YCXjS6pgz7AG8ksQxzqilfY+YPJkUEE1MRTofjl0b26MxTASd6cnvZvEhLY0F6HsNhvmtiDOomEX1l3Ynwjh67lNNRvp6yxUghvpGV/W0/5Fg/GAY6MR/bJGt/1jjr3vnUGrUYBmStfu+HbYql3p8cAGhC+vogKWT5Tz/bkVET1L/j+zsaO2bQSEilYjAIW/BCvbYwNM8PySHgteb1fVQ4omF/OFtXwwJWIfdbjPLy04r9eJ/dcGtg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ytvQ/l9zmZXBrcIspPYTd/CBkZ1WeDssNh2+lQEEZU0=; b=iNML2OzsjZx27QGxgT708TSk4d1t0BXei4nNOodn9HN2a+4ijCA2qzcZSHnKKANN83jyzUq7qbvhvnTTPOfMcI0zNn1GGsrSmJMJspELmDGl6XxsXg31c+hDnK6n2tx3AAChX0FItPl14WB2PqFg4dDU/6O3Eq0WdZnf75bDJgR483tHwk6JACaU39Y8ptcEwFJ9g+nglkob7GJy+Vhbgy7NpUgyyzR45Osvg0PV68gthtYoxmwgMsEsYGGksaRbSZmkXKoyDa/OM42sYmKcZq0c2P+MIl6gbVTBzHKj7FoT4rDqXon2eufmZhgyU9diRKLDG7ZEwgUSlrGDSlCHRw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:13:05 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:13:05 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org Subject: [PATCH v4 01/13] gpu: nova-core: Set correct DMA mask Date: Wed, 8 Oct 2025 11:12:40 +1100 Message-ID: <20251008001253.437911-2-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SY5P300CA0015.AUSP300.PROD.OUTLOOK.COM (2603:10c6:10:1fb::7) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: dec9af66-abd0-4b96-401f-08de05ff7394 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?yVVBnpDCyo8m6+noNYhykyh5g/JyOnBg2pewdZNrZWKMZ5qucmsPT2sfU6gq?= =?us-ascii?Q?mXuhTn9dVjmmG0kon1hy/Y0RbvFXznvdq1du1mNKA/SJ2o2jMBiIX3o1Abrc?= =?us-ascii?Q?s7/+dq685/RjNNrX4sx6Rl2LT9E8Hd/gNSTT1/jUkhrKZjMcGcgoRoGoPqrU?= =?us-ascii?Q?9+BvVAy2b+mVAAaGJ00Z6smx34sRL0YgY0LPXm8RpN9lrg/jUGeoekysqFS4?= =?us-ascii?Q?rEJgh7mrRSR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wz/m2iofQF?= =?us-ascii?Q?x99MFTuPgcKy2/SuFOmB+f3VpM1nrM4F6S85kJXgTm1Nb90QCJB6U68zDgOD?= =?us-ascii?Q?QV1d3c9kcjPWuO8AmzevORaSg8eyVPCry8yx7zU7GK8cHpH+r6HNgDHIXUMF?= =?us-ascii?Q?Om/4omszNhyzWYZ9ZUcbMIFnWZoB1W1J9bICrrnRfrZ7gf3FhndEbNzK9aPy?= =?us-ascii?Q?JIBTwajMEsX43MYqpvTkCjF/25yjNjMHO1uJNf8mqfKE06ppb5Wf1YfIWy9M?= =?us-ascii?Q?MG0n1rdrI12xJJkTzFkfpbn4BfPuwYqlPs4/ZPX0K8TJ0JDr5ZmfQOwiA79x?= =?us-ascii?Q?10OTJPJD0WE4fvvHDxINiasiz3q9segs?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?v6FcJiYaY9UGzlHXZwE+AaFktk+Ba/hcBid/H/q8NbACW9gmNdgHbiXsXIR0?= =?us-ascii?Q?yaLqnY7f9/11BWzMQWx1EUP8VDd9Eps2oWjQTHU6f/yC81m8ZuTRZ0hFyHte?= =?us-ascii?Q?zSvKeJKj3AkPCT8WcUrRjxJh6fzPrc2sC56z3btZGvZwGuNMuErS1zmXaJv8?= =?us-ascii?Q?xVZXk/S2Nj4UnslIQKG6dFnkOJjU5K8MFVDHY9R3JjiQZm/5rlf136InwHiu?= =?us-ascii?Q?Y2Uzf/Ms7q2x9QFeXT9wLHCW/0aqTbrr5Ky2wVPhmlKaSYzm7g33Q04JgEhJ?= =?us-ascii?Q?vqIzqR6G8tluizVlXpVsnmKbINEvhuliI9cZSE4PMdqI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D5tEv9SOzs+TCaF/0BO0W001iG/2kMHWc1mQO8QvsI4p0ng9StYTU?= =?us-ascii?Q?T/P8sQOwr41/Eu/yGcCTACNOj7V2LHA+AiLaC12kRM1Cix2Vc+f7nSy1r6ev?= =?us-ascii?Q?rfab0zIW0ur4sfV7nwT4K9iOIc9Q5jDIerv2MrvP6nLbYZIxAOegxBmAmGPx?= =?us-ascii?Q?2SIAZrbRpuwvFuGY6koFHYkil75AfbtUZczv2JdPsz5XbwuVmRZZ1gKb2Uxo?= =?us-ascii?Q?wNK9U3YG2sG4o+LsyUx/NOMTBDYoPOT2fat5lF4M6brqZwImIMlmtqDTZLvh?= =?us-ascii?Q?YFPqr0SpM3tFd8s5yMlo5S/rrBWC0TiYBHi7j3IsNpo9Ntqh25rE5Pw+axRc?= =?us-ascii?Q?d9NM2OsCNZTc8U1cJoSYEsZcAehmgf3/ryMbAx5N?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: dec9af66-abd0-4b96-401f-08de05ff7394 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:13:04.9054 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tcd1iOpCdcOV6EXrFeN3kLEzMumNsWhr8apuvcSQypf2P+PxqBtL27Dktkc6p7ro40bqmfR9N4I4TY6D1d0Crw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Content-Type: text/plain; charset="utf-8" Set the correct DMA mask. Without this DMA will fail on some setups. Signed-off-by: Alistair Popple --- Changes for v4: - Use a const (GPU_DMA_BITS) instead of a magic number Changes for v2: - Update DMA mask to correct value for Ampere/Turing (47 bits) --- drivers/gpu/nova-core/driver.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver= .rs index edc72052e27a..84fe4a45eb6a 100644 --- a/drivers/gpu/nova-core/driver.rs +++ b/drivers/gpu/nova-core/driver.rs @@ -3,6 +3,8 @@ use kernel::{ auxiliary, c_str, device::Core, + dma::Device, + dma::DmaMask, pci, pci::{Class, ClassMask, Vendor}, prelude::*, @@ -20,6 +22,10 @@ pub(crate) struct NovaCore { } =20 const BAR0_SIZE: usize =3D SZ_16M; + +// For now we only support Ampere which can use up to 47-bit DMA addresses. +const GPU_DMA_BITS: u32 =3D 47; + pub(crate) type Bar0 =3D pci::Bar; =20 kernel::pci_device_table!( @@ -57,6 +63,9 @@ fn probe(pdev: &pci::Device, _info: &Self::IdInfo) = -> Result())? }; + let devres_bar =3D Arc::pin_init( pdev.iomap_region_sized::(0, c_str!("nova-core/bar0= ")), GFP_KERNEL, --=20 2.50.1 From nobody Sat Feb 7 19:45:37 2026 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013070.outbound.protection.outlook.com [40.93.196.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 973A71FFC7B; Wed, 8 Oct 2025 00:13:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.196.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882400; cv=fail; b=IwHelTK5GPMSlJe9Dap5ZotGwB+s4X3hECeVXL61RJ/2dMTagAszdI59Jlxz56WdZTzxicjaO6tTToSuQC1JH/6aCpHdL1dskx2RbjkpKOymLTb1rW7MaLfnnEUlNQlB0GyfQBnbDBArPF4mpqJpnHBGf9bn2p7AmmCst1PPcwE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882400; c=relaxed/simple; bh=vOuts62tFcfA7R+AJpfi+kZ7R6nUCevObMsHxqZFIo4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=UqY0tdfQufU1oU0Q9yXi9F48VM9bmWl0yPS15zmLu/OfJrZiYbKeVivbCMidMKKsmn5WuPcjXVJazIPgXWaiJQDzJeJ6Uj8qf7u0pfff+wsOheVWqCObsj6tAZ3+UhbGPRGpu8I502z3N8bQQyIidImkVc6y2VCGubFttzWDEds= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=iOZgQem8; arc=fail smtp.client-ip=40.93.196.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="iOZgQem8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=APN6cJB+185z8DhL0/Q88a1HNL50o7eaNE6rOLCeLeLkV0paYlKZHottlNeTMqEWItPlqWHwpCTX429BWbzctKqXp7mTv7kkAzuxI66LJ8UIp4glW4GN56QfehpopOREg+MXWmm9XWVfJLV4UqevHyJS0RmS+xj2APgHhctkQlBDphCl8gM5EFF4MwO20OBH3TY0zt4puB/fVgrJDoInFopLAmwK4B/QfQhpI9Fl5hkvsoNQE22j/WJMBScaO/tiyU4rFXd4YpB0ua1+DlB2IOTXtF6yc5W5NyaA1bYhg80F5mGMP6yrg9h9gZ5C1zoidRMvHzRupFR1EbgErOi1kg== 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=dko/wWidHD8joPGknBqsA5MAfDvAD/eyVJhKCm5iqQ0=; b=Vj1V33t66O/QKVpVpVc1O1+mMt4paDqJQr3uNWUYLaDXs9U8Im9Hml8A1lSS/MwKdhdRW+dNDHYs5cMgjroqgPpvG6rwriKvKyKU+g8USgbSj5p7MS+igPSrVQ4qZTHTpwZqvav1ASozVMZe7DPsBUkC64go9v23NrC+DaDAcLkSDzHU+FXVvynTabZlB3VYv50dQ+voFgAhqoHK07OLFIxxN6qahpwhUwTWa1cEEU9Moe2QbC5JvN2iIAeU309BDc5p+O/e37YmFG9RGn5rPKaDLiA4GgwOv6wmEEuND6ViECpkZnJCuMiFRZCVi9Li4AnqXEpABnTZtcGtk3KH/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dko/wWidHD8joPGknBqsA5MAfDvAD/eyVJhKCm5iqQ0=; b=iOZgQem8Z55ds5ANvUzKqNwkFI6dGKAW2I99e3ReC23l7vArt+oA9hvulc8HlKx2Y/yPbh/l69GzJcH+3Gz4iHKQmMDflmbbKFzxae1IHPbtPMjtWWOfc1qsTWiJsZLsn33qvHTM5SMEQ+XdUG3ADyCk+iErcYcbG3V7h8Fp7vM+8bVgwjo6JWQUfU+3hzyOonCpjh+fRomX6D9gTsd89X9GdtGPkVaN2Fx6BhGnac4pkR4wmBPVmXbxvkT9JJaWaoOca7MYcvkKvqIZioF4SluddjneFZrZg76UcN6Zh17tl9q54YNKcTaSANUvQSbCqZXCwWud5SbbgrvWqkRwqg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:13:10 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:13:10 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org Subject: [PATCH v4 02/13] gpu: nova-core: Create initial Gsp Date: Wed, 8 Oct 2025 11:12:41 +1100 Message-ID: <20251008001253.437911-3-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SY5PR01CA0093.ausprd01.prod.outlook.com (2603:10c6:10:207::16) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: fa7a2207-5916-45f9-f69a-08de05ff7692 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?gZldX3fcFo3FV0xOknPQpeqmlXRnfwZtfjDqDBEzvFa3nzM5V+516HuBU3cC?= =?us-ascii?Q?mE6kNLI8WQAI1D8HAgGEAMQf14f5dKX2Cw0pv3UaRJ8eTOJ/bPoq3s2yw/AB?= =?us-ascii?Q?WsOguzCr6XTZNtM0Gt4Q5VMx1+So1F+F9AS/kclZ5rV4nDUC8M96OAHUkJwO?= =?us-ascii?Q?75pbciIp7k0TdyNlSDEHM4TSAJSltX/p7kYU+vPVhfvuEE3EYFbzQ13//kSf?= =?us-ascii?Q?OWF4qfyTm+N10450Vy28fIRjCS1M1wCHcIvgdQmIk8mdqL54i0HRfzS74jH/?= =?us-ascii?Q?CX9SxclTnTzP41jERznb5qlOg4sb6KKQsmE2TWCgPdL5iJGXfLuH+Mb0MMlQ?= =?us-ascii?Q?5Y+jChei6vsNMOyfo31rjzeJ6LOsZYWSxXieliEPysLbuMgjQl491hCYFRVM?= =?us-ascii?Q?Zsl7+gEFsSyp8jIyMGnFZTcjYViMtqYB2jCDBQ9DaiMcEpmv8ile0iz3yHIy?= =?us-ascii?Q?Hu+PQzetPxKgl9Ho2umtPhjI96Gb6YPTZoTja6s8Rx0XFsKgP+1SOwmsYG+7?= =?us-ascii?Q?Y/GM5Y64SHILppbHkaeacnYJ8psfoGqjA3v/FTtgmcJyWiX/0H0DoO1l8fJL?= =?us-ascii?Q?hwmgijO4VIEt0UznAsEJjeCGeumMpzPEx2Kg4T9G6k8d0pJDY+XS+vzM2LEQ?= =?us-ascii?Q?8ZJzlVjogFMJGbz/UGdVbOSO4Zws+0dIG1oue/9jel46G4eclFioYhJlTR55?= =?us-ascii?Q?t6w7+Ok8zRLpdc0minv6oq7j73S6EqVGzANXfs6V59e7bXCwsIXbrfaTK5Bk?= =?us-ascii?Q?L7r8ua7pH6boZRSkNhKMBJL2Yltc9QdjE8oXEFr8OfkMXxBrxBbmwo6H1kxq?= =?us-ascii?Q?3aMy5YzluUTgrNhb4TTTwLxmkfeQd1XEI2S0yow3GL6K/r1B3uSfOsaIUZdV?= =?us-ascii?Q?cKgMEJz2Jpvn7f/1GhM7NhiiId9Ik0k6dCPlguy5YmhOG8qpnKlPMGS9Stpb?= =?us-ascii?Q?5TgZHEJNDLRP0vqtJXBl4hDMnMzuFP+cxD+cfzvpaYR85vmoEBaRlcZGtHR1?= =?us-ascii?Q?RV2GY0uSQalnllonwnbM977A8LVmOejySwyoYecxxJMjPW/AsjNKgMm6PGPh?= =?us-ascii?Q?QmRhaqpycWthnbKE5wBKET79hk8zmBqScDOXeWphutUPabKZrRZBT8wQdZDs?= =?us-ascii?Q?WBvvN2KjoJ8RUgIESNPi40yfeGnEAQasVmaC4enPEaxhiCL6bOUxIhg1tslW?= =?us-ascii?Q?+VyzKHSer1x/m43FJOo25Clw1hA8o5BS8VYdzrg8K3+upw/w2UZIYZp/3O19?= =?us-ascii?Q?iQGvgjTm/L8aROuupQNSkfUdsG4dJX3WIvK79syEAz9PM/gEZ6q5VQC4t027?= =?us-ascii?Q?dAQZZhjJYnIMt4NfBXr+NxSQIcZ8QCeFMcQc37B+q3k8YVI0JOfClFE+sc6Z?= =?us-ascii?Q?1eUpEooibOOO8q3/0iTVJ7TVWEqB08+iM3gHHp56v4/XVUo9h8vTMgcxDak9?= =?us-ascii?Q?EehXbOvGd7CWKYndhbLHxnR3gPjPUrSu?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?N3TqMYgRTDBi6Up+W7yIVPByeMy+lQYbgSv79Q+Z7KUYrjgirJiPw0DKwMf3?= =?us-ascii?Q?0Bsl6v494taVs6UeXIM5eYtoVCSqCDkNSGx3kCR/5PxzNJfIIHJWtLtD2Hd+?= =?us-ascii?Q?rQcKgTmbBOyLazekD5bAbmWmDLh3VHMIM5EVlrOv/uhX6BIw5seStvr0Ftwt?= =?us-ascii?Q?TA22L9PjYdXzPp93iiby08bwCDR/pvF0ncetPgqz0kwymoclQkGBTrPWG7Ah?= =?us-ascii?Q?E3/eRZmjiTg7gsZz421qQQogTwYmx4ohlo2Edfqiy6lQRx4BdnHBnxqUZgzb?= =?us-ascii?Q?Nbk7VmE+9WaNUKDkqxLIjPuwdqWa/tbrH8Vv6M04VaRjNyIHikZlVwZpJl1Q?= =?us-ascii?Q?iFI1AadVYN1fOllbsoR2EB9hVeTxI64bgYjg6hTbCnTl/ziolSbJEzDvMJcr?= =?us-ascii?Q?uUwsfHZp3DyWx0SjYNpmlGQa2n9Sj1II+wZE5pOPJxAzuI3oITsYSsHssUyC?= =?us-ascii?Q?tEEfGm1A6jb01pjPjAa88Qipe9velQZcE2OM+DEsiF/oOcttaFHsp5IhYyci?= =?us-ascii?Q?tQguwIwjTeF5LonWdscfOIsg9RlJ1n7FwJp4kemlSBepU1Fehd/c4PGE9hms?= =?us-ascii?Q?kGE9Avk3BFtq4OKzR+55QPm66TLsrw7KYd3PPEBpxujo0DIALdS8CymSKoLr?= =?us-ascii?Q?QCImkv4pJ/qmyqp1HunxpQxYTcXcOmwHVdomhDe6oFYs0qIajqR2FyPJ4gPL?= =?us-ascii?Q?TfbI/MayWioGyJqa7V01zZaF4io7vT8KEwDn6edF4lSuqlUHj5Kco/nBsI5X?= =?us-ascii?Q?qK+kuAD4I53D3gTIzfaFy8LR5oQc3fR36wPTqx4fyWd8tslUIAZ2lx+twJ9E?= =?us-ascii?Q?/pai9qpuR7JsL3uue+4j76SjATd8GsRktwXl96cEB0c1eSDDGYoHHqgcbsDM?= =?us-ascii?Q?mpUJG/DmhpyVy2EY+QtkWjP7NDDKRK5kNfqidludOJqjIVsVPlwFEsaPQ02t?= =?us-ascii?Q?/u0SRsDESOqJE2gHG+mcBxc0vopaMoos/6MSpq6QgQv73Q7ldBs1jFmwta8J?= =?us-ascii?Q?rN1XTDUVIchJoknvIo/6FFiz6lyz0RzPqchDTTSgy7Yg8N+abiD5hQbB+dv2?= =?us-ascii?Q?ZBsVWWTQ8NrDimykG/nFh08yko8KJEylPwQSuGwO5Czhv0Ix3PVRVaIKr5Kl?= =?us-ascii?Q?B6bRzI7/r/zewbOe/b/o4joEq3+mv5+KEAECJdmjMayth4+AyORgEvV08V0P?= =?us-ascii?Q?9bmX6WE8D9YL2CxLrbv6bOBDwnKK4xXRslD9k5BBtJnEAZSCgNjXAiTepL5u?= =?us-ascii?Q?zeD/4PDpsC8l4BE1fenyR0uIBFbBF9e//Gq4o+CGLc+M2Ew3uAO0/o35stfr?= =?us-ascii?Q?LldZDGlVjPFRLA6dftr15jlN0hBV8Hr6CqZyK03yvHtxgZrYixpsLiP3vzq0?= =?us-ascii?Q?Vs2sLgLoa0woXE4lUPdYUSapfEeOAX5X/CJOcTdFENKo/qCqs61CvkshsKVV?= =?us-ascii?Q?Y5S23PMiC4hALb9vU39Fny1IrGuMxqGSXcxeIn2O1f5MPdr1CXJFkL54UTYC?= =?us-ascii?Q?TMeK9kjbMTWRUmjAxrviednC2l3CJe6BJGWGTRB09Gq1scaltGdj6Sxp/b1J?= =?us-ascii?Q?X/V+9HBGDHeshXzUjtMEGlxYOVa49PNqrhQkX3M6?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa7a2207-5916-45f9-f69a-08de05ff7692 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:13:09.9485 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6J+8fKewtqG98AEwXgp59McCaoLeeYFkeDshBlBLaSE7qswEVFKJC9yEzEnl7uxgwO32m1lx4OJd5FydqVvVYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Content-Type: text/plain; charset="utf-8" The GSP requires several areas of memory to operate. Each of these have their own simple embedded page tables. Set these up and map them for DMA to/from GSP using CoherentAllocation's. Return the DMA handle describing where each of these regions are for future use when booting GSP. Signed-off-by: Alistair Popple --- Change for v3: - Clean up the PTE array creation, with much thanks to Alex for doing most it (please let me know if I should put you as co-developer!) Changes for v2: - Renamed GspMemOjbects to Gsp as that is what they are - Rebased on Alex's latest series --- drivers/gpu/nova-core/gpu.rs | 2 +- drivers/gpu/nova-core/gsp.rs | 79 +++++++++++++++++-- drivers/gpu/nova-core/gsp/fw.rs | 39 +++++++++ .../gpu/nova-core/gsp/fw/r570_144/bindings.rs | 19 +++++ 4 files changed, 133 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs index ea124d1912e7..c1396775e9b6 100644 --- a/drivers/gpu/nova-core/gpu.rs +++ b/drivers/gpu/nova-core/gpu.rs @@ -197,7 +197,7 @@ pub(crate) fn new<'a>( =20 sec2_falcon: Falcon::new(pdev.as_ref(), spec.chipset, bar, tru= e)?, =20 - gsp <- Gsp::new(), + gsp <- Gsp::new(pdev)?, =20 _: { gsp.boot(pdev, bar, spec.chipset, gsp_falcon, sec2_falcon= )? }, =20 diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs index 221281da1a45..63099df77348 100644 --- a/drivers/gpu/nova-core/gsp.rs +++ b/drivers/gpu/nova-core/gsp.rs @@ -2,25 +2,94 @@ =20 mod boot; =20 +use kernel::device; +use kernel::dma::CoherentAllocation; +use kernel::dma::DmaAddress; +use kernel::dma_write; +use kernel::pci; use kernel::prelude::*; use kernel::ptr::Alignment; +use kernel::transmute::AsBytes; =20 pub(crate) use fw::{GspFwWprMeta, LibosParams}; =20 mod fw; =20 +use fw::LibosMemoryRegionInitArgument; + pub(crate) const GSP_PAGE_SHIFT: usize =3D 12; pub(crate) const GSP_PAGE_SIZE: usize =3D 1 << GSP_PAGE_SHIFT; pub(crate) const GSP_HEAP_ALIGNMENT: Alignment =3D Alignment::new::<{ 1 <<= 20 }>(); =20 +/// Number of GSP pages to use in a RM log buffer. +const RM_LOG_BUFFER_NUM_PAGES: usize =3D 0x10; + /// GSP runtime data. -/// -/// This is an empty pinned placeholder for now. #[pin_data] -pub(crate) struct Gsp {} +pub(crate) struct Gsp { + libos: CoherentAllocation, + pub loginit: CoherentAllocation, + pub logintr: CoherentAllocation, + pub logrm: CoherentAllocation, +} + +#[repr(C)] +struct PteArray([u64; NUM_ENTRIES]); +/// SAFETY: arrays of `u64` implement `AsBytes` and we are but a wrapper a= round it. +unsafe impl AsBytes for PteArray {} +impl PteArray { + fn new(handle: DmaAddress) -> Self { + let mut ptes =3D [0u64; NUM_PAGES]; + for (i, pte) in ptes.iter_mut().enumerate() { + *pte =3D handle + ((i as u64) << GSP_PAGE_SHIFT); + } + + Self(ptes) + } +} + +/// Creates a new `CoherentAllocation` with `name` of `size` elements, = and +/// register it into the `libos` object at argument position `libos_arg_nr= `. +fn create_logbuffer_dma_object( + dev: &device::Device, +) -> Result> { + let mut obj =3D CoherentAllocation::::alloc_coherent( + dev, + RM_LOG_BUFFER_NUM_PAGES * GSP_PAGE_SIZE, + GFP_KERNEL | __GFP_ZERO, + )?; + let ptes =3D PteArray::::new(obj.dma_handle()= ); + + // SAFETY: `obj` has just been created and we are its sole user. + unsafe { + // Copy the self-mapping PTE at the expected location. + obj.as_slice_mut(size_of::(), size_of_val(&ptes))? + .copy_from_slice(ptes.as_bytes()) + }; + + Ok(obj) +} =20 impl Gsp { - pub(crate) fn new() -> impl PinInit { - pin_init!(Self {}) + pub(crate) fn new(pdev: &pci::Device) -> Result> { + let dev =3D pdev.as_ref(); + let libos =3D CoherentAllocation:::= :alloc_coherent( + dev, + GSP_PAGE_SIZE / size_of::(), + GFP_KERNEL | __GFP_ZERO, + )?; + let loginit =3D create_logbuffer_dma_object(dev)?; + dma_write!(libos[0] =3D LibosMemoryRegionInitArgument::new("LOGINI= T", &loginit))?; + let logintr =3D create_logbuffer_dma_object(dev)?; + dma_write!(libos[1] =3D LibosMemoryRegionInitArgument::new("LOGINT= R", &logintr))?; + let logrm =3D create_logbuffer_dma_object(dev)?; + dma_write!(libos[2] =3D LibosMemoryRegionInitArgument::new("LOGRM"= , &logrm))?; + + Ok(try_pin_init!(Self { + libos, + loginit, + logintr, + logrm, + })) } } diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw= .rs index 181baa401770..dd1e7fc85d85 100644 --- a/drivers/gpu/nova-core/gsp/fw.rs +++ b/drivers/gpu/nova-core/gsp/fw.rs @@ -7,8 +7,10 @@ =20 use core::ops::Range; =20 +use kernel::dma::CoherentAllocation; use kernel::ptr::Alignable; use kernel::sizes::SZ_1M; +use kernel::transmute::{AsBytes, FromBytes}; =20 use crate::gpu::Chipset; use crate::gsp; @@ -99,3 +101,40 @@ pub(crate) fn wpr_heap_size(&self, chipset: Chipset, fb= _size: u64) -> u64 { /// addresses of the GSP bootloader and firmware. #[repr(transparent)] pub(crate) struct GspFwWprMeta(bindings::GspFwWprMeta); + +#[repr(transparent)] +pub(crate) struct LibosMemoryRegionInitArgument(bindings::LibosMemoryRegio= nInitArgument); + +// SAFETY: Padding is explicit and will not contain uninitialized data. +unsafe impl AsBytes for LibosMemoryRegionInitArgument {} + +// SAFETY: This struct only contains integer types for which all bit patte= rns +// are valid. +unsafe impl FromBytes for LibosMemoryRegionInitArgument {} + +impl LibosMemoryRegionInitArgument { + pub(crate) fn new( + name: &'static str, + obj: &CoherentAllocation, + ) -> Self { + /// Generates the `ID8` identifier required for some GSP objects. + fn id8(name: &str) -> u64 { + let mut bytes =3D [0u8; core::mem::size_of::()]; + + for (c, b) in name.bytes().rev().zip(&mut bytes) { + *b =3D c; + } + + u64::from_ne_bytes(bytes) + } + + Self(bindings::LibosMemoryRegionInitArgument { + id8: id8(name), + pa: obj.dma_handle(), + size: obj.size() as u64, + kind: bindings::LibosMemoryRegionKind_LIBOS_MEMORY_REGION_CONT= IGUOUS as u8, + loc: bindings::LibosMemoryRegionLoc_LIBOS_MEMORY_REGION_LOC_SY= SMEM as u8, + ..Default::default() + }) + } +} diff --git a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs b/drivers/gp= u/nova-core/gsp/fw/r570_144/bindings.rs index 0407000cca22..6a14cc324391 100644 --- a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs +++ b/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs @@ -124,3 +124,22 @@ fn default() -> Self { } } } +pub type LibosAddress =3D u64_; +pub const LibosMemoryRegionKind_LIBOS_MEMORY_REGION_NONE: LibosMemoryRegio= nKind =3D 0; +pub const LibosMemoryRegionKind_LIBOS_MEMORY_REGION_CONTIGUOUS: LibosMemor= yRegionKind =3D 1; +pub const LibosMemoryRegionKind_LIBOS_MEMORY_REGION_RADIX3: LibosMemoryReg= ionKind =3D 2; +pub type LibosMemoryRegionKind =3D ffi::c_uint; +pub const LibosMemoryRegionLoc_LIBOS_MEMORY_REGION_LOC_NONE: LibosMemoryRe= gionLoc =3D 0; +pub const LibosMemoryRegionLoc_LIBOS_MEMORY_REGION_LOC_SYSMEM: LibosMemory= RegionLoc =3D 1; +pub const LibosMemoryRegionLoc_LIBOS_MEMORY_REGION_LOC_FB: LibosMemoryRegi= onLoc =3D 2; +pub type LibosMemoryRegionLoc =3D ffi::c_uint; +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct LibosMemoryRegionInitArgument { + pub id8: LibosAddress, + pub pa: LibosAddress, + pub size: LibosAddress, + pub kind: u8_, + pub loc: u8_, + pub __bindgen_padding_0: [u8; 6usize], +} --=20 2.50.1 From nobody Sat Feb 7 19:45:37 2026 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013048.outbound.protection.outlook.com [40.93.196.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4459220299B; Wed, 8 Oct 2025 00:13:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.196.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882405; cv=fail; b=Ypv7cLrGtFC/m7amFqXt2yZC8Wpbca1NWvnkGbZsBUFDJURWkQC166JXXcAb4ziUkA67Er2Oq97t2PzxYIT8ZrHnks9cVkp/kruCaxciC4MRKS6teE0TOI+zpPDzVUCFSghx5Xv+L6qAL6l8knz7smCPwKx0+W12YhsNDxMZHR8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882405; c=relaxed/simple; bh=cvqZZgXdQJ1afN+EBva41jbnI/mCzVquaOWmWET4UX0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=q9ZGMZRwuIHZaX1+abnf9EZ/43nCkRrY6bqoUt+IuWbD78PHGvBJyghh08dNt9+DUsWcCno7eMQPcY3/BUaqIYIhnSvAOZnyOikn5DLPYjcoiaTBFP73QeMRlRSg0p8RMXdjnCJf0aC8z7aYb9bbjUGEtkZwkO7xzgSHIkQWiPc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=o1zRspxY; arc=fail smtp.client-ip=40.93.196.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="o1zRspxY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vBcT2AzA0VjeKAoKFhqLA3x3kv5c9eDy0sGnmLdp9tSXq0xQjjEtgi2tNj0Dpj9nmePEtsvpH+BleJWcEPac483QW9mAfGFNXZt6gKxNYzY7V2seMM9FFJ9rrcAqufo/ovN4AXeL4KPxxwr0yIVYK32VJ5QzRknBoNY/eAj6LVtPvFR3JefiiJRE9b6zJIO5fUN4L1HqOvbN/NwYxDAzRfYoVebDGeyml2mwcie9cfzZsvox++ZLdb0NLIWXnkvRHV8P1C6VBNTqHtKywQXnQAv0PqOcaLx4b5FwaZ4wq45fimRY+BJqe55YcOvwCKi1vu5B3aCWeZ18ii4PrX8H6A== 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=53tGN4UwNmKwwEuS4jT5M7mquZuTfQLg6qO8ouA+/qM=; b=McohUKPU6tY8y7zvHp0InjAKM0TDiqvvPTH5YPhMUXK9qr23dGgaATdokSsCgaaUklBlia39UDe5hU8rOoeeNvqkALpr9Tmwwn7xdJ6l3NQ5Qw9Au2zzGW7QBiPF9E+QqBgd01iMx349c+14cRD6E3M8+hbCSLX7BKpbrHN6iO2oPD1DV7mSvnrcnMZt3Ut5X3wTU/jxK+V1+a9mi8K9LRIpj7V5W41UYY3UN9sz52hab66Ha3QIcz8tPtGCs1Sh26+oAPXlHhMfHgvv96B487ry2julv01jK4Zb+rrz4nlhz6iwu09FaC4+BSmu4vNaouJaAIxsZWEL+hG22ZS+XA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=53tGN4UwNmKwwEuS4jT5M7mquZuTfQLg6qO8ouA+/qM=; b=o1zRspxY4tOA+rhq9YDC/bVPB3Sl2OAfHkt1LTj4JibQL53latdwC+id9+mAPZpbeZvxz/ULpJXf228Bgp1nIotDFVr/pqVZfWmG8okczEYCaHKTRETibrRNrtE0hYroAzugOhD++dIhKVjoCVNkEymGTbQbxffD5cUyXnqwQU47/49NDU1TyTRFdpArmyjgjwKFv4PHkGv4GzC2Wqha9r37iPXM51cJjEuZva0CERG/d1002haksdVBKXfOLIfdoxcudB3JHyqz4BZRKXTIMDCNxUAgoUJp98cNxCqFHs0+v5QyeisVICPL+l6PxLqpzPwDuA5wtGc8EhAcD2jQbA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:13:15 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:13:15 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org Subject: [PATCH v4 03/13] gpu: nova-core: gsp: Create wpr metadata Date: Wed, 8 Oct 2025 11:12:42 +1100 Message-ID: <20251008001253.437911-4-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SY5P282CA0138.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:205::18) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d079f31-6cbf-427b-6da5-08de05ff79e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WvVW2F618ued8NxUY7eb04ivotpz4jsLU5dWbcCsbNgyhsGkqouZlrrT2TAg?= =?us-ascii?Q?7uQG9/xeC0UTmtBCs/UowWf7n+DpUwjmotdqGV9bqos4H3y0KLJTNZ1Da51i?= =?us-ascii?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YZQADwN/wg03Lrmv?= =?us-ascii?Q?50wU3YjEfS4gjMUFcFqmjZ7zJBTfPnA9HPDkZH+cyCwNVFx5rXwWsjlAXZwG?= =?us-ascii?Q?ie3/OwLYuUOC0cQkCfqQEIXdTs7u4biNVFrYJnC00+/rlp4xfHjH9wbZwzZC?= =?us-ascii?Q?scqeBgNzLnHWuIc9r9NDTxE/E+Vb39Tr1yrvnja4RGBwt14hEHdj/3PW+LfT?= =?us-ascii?Q?yjwc3ti+7AmrU4Cm/R9oPzQ2ImsaIUq844S4Ll43c9s0J55iTDs+cWhVBpYA?= =?us-ascii?Q?69AVGg4/PNJD/dz/k+GUF1E4dzB1sEvHS1sRrV94jrfdyaKKGA9WEHcF+7H1?= =?us-ascii?Q?h5PMcsNhKfrDAw0TCpUllT55+xwRkIQzVZZ7OczceI1HtrjyKWJ97EXCE8Jv?= =?us-ascii?Q?ZbP9y/PRImB79dRbQTdr5R9L8mOBm2Qw3RWIekoTLMo48Kp0pKKWO8BS9Dsq?= =?us-ascii?Q?MuSkq009W6QZflXb8xYlehJdrgM9ptrY?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lbdltScgklf6wwc3SVlJlqenhRrJS+9NWDO2abvp+4ZXefMeoc8XxciQcddv?= =?us-ascii?Q?ccYNbY6Kx0LAa16yOS2IeEgNh8q3TuIP3LaTrtzsvp6N3EYI+wi+8o1Qiqy4?= =?us-ascii?Q?Ji6J6tnme0G4fvIfWhV4OqRN7x7qfGEwOF/9M0ImV8P0nsFmAVEFie1HkJnt?= =?us-ascii?Q?8SPNLbcFX6E3owq+r2i7dcEQfhxzN9LtfhG7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t4pBgC4ngqSmwn+GhGKs17VeUec2svluaGLWPXkmJssYUUG9V0w8?= =?us-ascii?Q?eEKEyuyxT7u/5FV+9EC3Q1jKIZi+NmiNafADXyySrIYLdkPJihm1eID5IH/t?= =?us-ascii?Q?+BtoNVwu2Jt3uOUtOsI5qJa1pQE7yVqtD/YxyQJECGfw7FMRCCB+6u9ZeC1b?= =?us-ascii?Q?mJBI8OF73fBucrLN6G+PfJBqofE/aCFf4RGr3CUtqjLYp/reBHrWsp9Sfig8?= =?us-ascii?Q?nvZN36ZVN8My+9y+1vqdGD2A8inhMaCyu97E3aALtFRdCYk6JtKxeEtHMP9P?= =?us-ascii?Q?xeLmB2HnMDzVHQgqsyfgXxzC4amt+SbcW+SYxMdV8dt1csvaS0wEAbvDzTB6?= =?us-ascii?Q?xJ9DUUZ/7PxaQLhzGoglCj6h9/KQ+RhZJplaudiChQhZ1Zie09fhwUExBmO0?= =?us-ascii?Q?ZMbGrJ/OjoyNo/cbKNWkxXk9jbQJhg4dmNfzB6pCP7YGUneAUEwGfdxvznIP?= =?us-ascii?Q?r+fEAQhRCc/pnwBZO55FF5bpfH8vq8pdYL83s5tt?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4d079f31-6cbf-427b-6da5-08de05ff79e0 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:13:15.4972 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: i2NJ6nz0e2/bsfjMY0l4p3AKy4irc+jsfkXScSCY29Ch0CGsvaL7ZQw3a/0p+kHCYFQKlMhPGg0na9jbnCdfXA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Content-Type: text/plain; charset="utf-8" The GSP requires some pieces of metadata to boot. These are passed in a struct which the GSP transfers via DMA. Create this struct and get a handle to it for future use when booting the GSP. Signed-off-by: Alistair Popple --- Changes for v3: - Don't re-export WPR constants (thanks Alex) Changes for v2: - Rebased on Alex's latest version --- drivers/gpu/nova-core/fb.rs | 1 - drivers/gpu/nova-core/firmware/gsp.rs | 3 +- drivers/gpu/nova-core/firmware/riscv.rs | 6 +- drivers/gpu/nova-core/gsp.rs | 2 + drivers/gpu/nova-core/gsp/boot.rs | 7 +++ drivers/gpu/nova-core/gsp/fw.rs | 57 ++++++++++++++++++- .../gpu/nova-core/gsp/fw/r570_144/bindings.rs | 2 + 7 files changed, 70 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/nova-core/fb.rs b/drivers/gpu/nova-core/fb.rs index 4d6a1f452183..5580498ba2fb 100644 --- a/drivers/gpu/nova-core/fb.rs +++ b/drivers/gpu/nova-core/fb.rs @@ -87,7 +87,6 @@ pub(crate) fn unregister(&self, bar: &Bar0) { /// /// Contains ranges of GPU memory reserved for a given purpose during the = GSP boot process. #[derive(Debug)] -#[expect(dead_code)] pub(crate) struct FbLayout { /// Range of the framebuffer. Starts at `0`. pub(crate) fb: Range, diff --git a/drivers/gpu/nova-core/firmware/gsp.rs b/drivers/gpu/nova-core/= firmware/gsp.rs index 3a1cf0607de7..c9ad912a3150 100644 --- a/drivers/gpu/nova-core/firmware/gsp.rs +++ b/drivers/gpu/nova-core/firmware/gsp.rs @@ -131,7 +131,7 @@ pub(crate) struct GspFirmware { /// Size in bytes of the firmware contained in [`Self::fw`]. pub size: usize, /// Device-mapped GSP signatures matching the GPU's [`Chipset`]. - signatures: DmaObject, + pub signatures: DmaObject, /// GSP bootloader, verifies the GSP firmware before loading and runni= ng it. pub bootloader: RiscvFirmware, } @@ -216,7 +216,6 @@ pub(crate) fn new<'a, 'b>( })) } =20 - #[expect(unused)] /// Returns the DMA handle of the radix3 level 0 page table. pub(crate) fn radix3_dma_handle(&self) -> DmaAddress { self.level0.dma_handle() diff --git a/drivers/gpu/nova-core/firmware/riscv.rs b/drivers/gpu/nova-cor= e/firmware/riscv.rs index 04f1283abb72..76d0d36fee3e 100644 --- a/drivers/gpu/nova-core/firmware/riscv.rs +++ b/drivers/gpu/nova-core/firmware/riscv.rs @@ -55,11 +55,11 @@ fn new(bin_fw: &BinFirmware<'_>) -> Result { #[expect(unused)] pub(crate) struct RiscvFirmware { /// Offset at which the code starts in the firmware image. - code_offset: u32, + pub code_offset: u32, /// Offset at which the data starts in the firmware image. - data_offset: u32, + pub data_offset: u32, /// Offset at which the manifest starts in the firmware image. - manifest_offset: u32, + pub manifest_offset: u32, /// Application version. app_version: u32, /// Device-mapped firmware image. diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs index 63099df77348..fc8fe6ffe439 100644 --- a/drivers/gpu/nova-core/gsp.rs +++ b/drivers/gpu/nova-core/gsp.rs @@ -11,6 +11,8 @@ use kernel::ptr::Alignment; use kernel::transmute::AsBytes; =20 +use crate::fb::FbLayout; + pub(crate) use fw::{GspFwWprMeta, LibosParams}; =20 mod fw; diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/= boot.rs index fb22508128c4..1d2448331d7a 100644 --- a/drivers/gpu/nova-core/gsp/boot.rs +++ b/drivers/gpu/nova-core/gsp/boot.rs @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 =20 use kernel::device; +use kernel::dma::CoherentAllocation; +use kernel::dma_write; use kernel::pci; use kernel::prelude::*; =20 @@ -14,6 +16,7 @@ FIRMWARE_VERSION, }; use crate::gpu::Chipset; +use crate::gsp::GspFwWprMeta; use crate::regs; use crate::vbios::Vbios; =20 @@ -132,6 +135,10 @@ pub(crate) fn boot( bar, )?; =20 + let wpr_meta =3D + CoherentAllocation::::alloc_coherent(dev, 1, GFP= _KERNEL | __GFP_ZERO)?; + dma_write!(wpr_meta[0] =3D GspFwWprMeta::new(&gsp_fw, &fb_layout))= ?; + Ok(()) } } diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw= .rs index dd1e7fc85d85..68a7059bc965 100644 --- a/drivers/gpu/nova-core/gsp/fw.rs +++ b/drivers/gpu/nova-core/gsp/fw.rs @@ -8,12 +8,14 @@ use core::ops::Range; =20 use kernel::dma::CoherentAllocation; -use kernel::ptr::Alignable; -use kernel::sizes::SZ_1M; +use kernel::ptr::{Alignable, Alignment}; +use kernel::sizes::{SZ_128K, SZ_1M}; use kernel::transmute::{AsBytes, FromBytes}; =20 +use crate::firmware::gsp::GspFirmware; use crate::gpu::Chipset; use crate::gsp; +use crate::gsp::FbLayout; =20 /// Dummy type to group methods related to heap parameters for running the= GSP firmware. pub(crate) struct GspFwHeapParams(()); @@ -102,6 +104,57 @@ pub(crate) fn wpr_heap_size(&self, chipset: Chipset, f= b_size: u64) -> u64 { #[repr(transparent)] pub(crate) struct GspFwWprMeta(bindings::GspFwWprMeta); =20 +// SAFETY: Padding is explicit and will not contain uninitialized data. +unsafe impl AsBytes for GspFwWprMeta {} + +// SAFETY: This struct only contains integer types for which all bit patte= rns +// are valid. +unsafe impl FromBytes for GspFwWprMeta {} + +type GspFwWprMetaBootResumeInfo =3D r570_144::GspFwWprMeta__bindgen_ty_1; +type GspFwWprMetaBootInfo =3D r570_144::GspFwWprMeta__bindgen_ty_1__bindge= n_ty_1; + +impl GspFwWprMeta { + pub(crate) fn new(gsp_firmware: &GspFirmware, fb_layout: &FbLayout) ->= Self { + Self(bindings::GspFwWprMeta { + magic: r570_144::GSP_FW_WPR_META_MAGIC as u64, + revision: u64::from(r570_144::GSP_FW_WPR_META_REVISION), + sysmemAddrOfRadix3Elf: gsp_firmware.radix3_dma_handle(), + sizeOfRadix3Elf: gsp_firmware.size as u64, + sysmemAddrOfBootloader: gsp_firmware.bootloader.ucode.dma_hand= le(), + sizeOfBootloader: gsp_firmware.bootloader.ucode.size() as u64, + bootloaderCodeOffset: u64::from(gsp_firmware.bootloader.code_o= ffset), + bootloaderDataOffset: u64::from(gsp_firmware.bootloader.data_o= ffset), + bootloaderManifestOffset: u64::from(gsp_firmware.bootloader.ma= nifest_offset), + __bindgen_anon_1: GspFwWprMetaBootResumeInfo { + __bindgen_anon_1: GspFwWprMetaBootInfo { + sysmemAddrOfSignature: gsp_firmware.signatures.dma_han= dle(), + sizeOfSignature: gsp_firmware.signatures.size() as u64, + }, + }, + gspFwRsvdStart: fb_layout.heap.start, + nonWprHeapOffset: fb_layout.heap.start, + nonWprHeapSize: fb_layout.heap.end - fb_layout.heap.start, + gspFwWprStart: fb_layout.wpr2.start, + gspFwHeapOffset: fb_layout.wpr2_heap.start, + gspFwHeapSize: fb_layout.wpr2_heap.end - fb_layout.wpr2_heap.s= tart, + gspFwOffset: fb_layout.elf.start, + bootBinOffset: fb_layout.boot.start, + frtsOffset: fb_layout.frts.start, + frtsSize: fb_layout.frts.end - fb_layout.frts.start, + gspFwWprEnd: fb_layout + .vga_workspace + .start + .align_down(Alignment::new::()), + gspFwHeapVfPartitionCount: fb_layout.vf_partition_count, + fbSize: fb_layout.fb.end - fb_layout.fb.start, + vgaWorkspaceOffset: fb_layout.vga_workspace.start, + vgaWorkspaceSize: fb_layout.vga_workspace.end - fb_layout.vga_= workspace.start, + ..Default::default() + }) + } +} + #[repr(transparent)] pub(crate) struct LibosMemoryRegionInitArgument(bindings::LibosMemoryRegio= nInitArgument); =20 diff --git a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs b/drivers/gp= u/nova-core/gsp/fw/r570_144/bindings.rs index 6a14cc324391..392b25dc6991 100644 --- a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs +++ b/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs @@ -9,6 +9,8 @@ pub const GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS2_MAX_MB: u32 =3D 256; pub const GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MIN_MB: u32 =3D 88; pub const GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MAX_MB: u32 =3D 280; +pub const GSP_FW_WPR_META_REVISION: u32 =3D 1; +pub const GSP_FW_WPR_META_MAGIC: i64 =3D -2577556379034558285; pub type __u8 =3D ffi::c_uchar; pub type __u16 =3D ffi::c_ushort; pub type __u32 =3D ffi::c_uint; --=20 2.50.1 From nobody Sat Feb 7 19:45:37 2026 Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11011067.outbound.protection.outlook.com [52.101.62.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C98B212550; Wed, 8 Oct 2025 00:13:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.62.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882410; cv=fail; b=arcfhkCeFdVaNNsjXMORclz660yORnnYPZJfJP8gPZJx7z8z1837F0Jdr7WINWs8XOtH1LOGyGdBdsYLW2lM8rCoxna1nne9tbnPFxKMriyXDXLsCqMnIdrVph9BBlAhTTEB92kzEshfpZkKkDMCxCH5thb3Fw+bLGggOiIvHww= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882410; c=relaxed/simple; bh=+cHKVP23Yy1fOJwPNfC9ptdSqXLAIO/z3tzmP/4xYr8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=lG3Ta0kj8BMYIY321durWzNoaOZWP4+jbdAcvqEUGeP7WAfaoBxhkGbFb6CkNvZ1rEg4YZ/BKwbTSfIaNOP7j21E6id0OidLZsgG1kYi3KO5PYVVQAtuYEuUqd1ub3Aw9JCuwsXUPkLTx9oS8NR/r9+f2QH8KNQJHDd5pSS1ktA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=pOd5hePl; arc=fail smtp.client-ip=52.101.62.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="pOd5hePl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M6O+DVr+4bA2Zlin1GNCxFzoUGpPlKdLfV0PD+hOD1NiGKcVZ2/RgRfECEu3RNigdxp/A6WSAdHaksN2W3QS1U1bYKloqfbXPMHxiTSIivHHBKri7JrAfhrQGbkS0De2URSP51ZVDBD8IWEPlUWQwmijJaBgaV0ctYgbzyIl0cePb/D0+p59wdS8fy09B3eeHR9kOhW9a1cI3zkuvvRlmjMOmGgX+6L/FWDRCTH2G5AOSeIBdMfJ0Kty9/qnvYihY3DqQWG36S3AWe3izQOZ8G0S2NjIUvQt7fBjFAe4qsdgUgL+Xisg05UlnDJaBJ4A9LxFfbQ3ML2oGT5o5WVsbA== 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=fOWlqySJYqmaqVVjJ9kbX2P7Epwe6TjAUQ7JG9gSIjM=; b=ndXK30PHDoLcVHbxIyVreS3/yV7sHATB8CDV2M4G0a1MYy4I8fmaqPPynBeA8RumHqyAI7GFitn3/+ceqQ78SvPLZHvFhUpdQuPAFWq9NfzEo80wSLHC9MW7irSR6Luqe7i4BeJJltNYrefQ7Dkk1bAF2Frwx/qn+u9e4RdajmFu7qjY6UH5s3+qZ25ulehbN228osEdcjMZkT57X+kEzOQGTFsipI/PTitzWlXAOGPOZYB3ubpzRsRFnZVWZ44Qv96j630C9eR/krg3LPh4jOL6k4dILqMpVgMuS3RUaHT4AaJOy3uNwGFeds+Z8tzhyfjZgQtyfb+oSU/NCiMliA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fOWlqySJYqmaqVVjJ9kbX2P7Epwe6TjAUQ7JG9gSIjM=; b=pOd5hePlPqvsJAFIHxLvzAv/n9LmeeSl4for5TtpS3uCZHSKxoEeDLdyBJrak4Vr6QfsZyAxEtQvZrNs+23o1fkOuShe1A5KWyTFvKKTLHItA25zaXDAXU0ffVi3n7q7aV4OsQv4yxKJYqhqFPSngmn8BPnGH/S038PmxGFQWUN6viWQS4ypc339cJYFUuoWFG5jysuFlOlHeEU/r/fayMz8o+LO+TFMrVxldIbjP4GRk/+b4GH7+WoWM+OaZTWHtqDa9P8iIiMhyxaO2AkackjeClR0VCn79zkEGKw24Uko2gCMQ52a3Wo3r96Bry8wbzc7WYy7gLfLEWlS7bbrFQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:13:21 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:13:21 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, Lyude Paul Subject: [PATCH v4 04/13] gpu: nova-core: Add a slice-buffer (sbuffer) datastructure Date: Wed, 8 Oct 2025 11:12:43 +1100 Message-ID: <20251008001253.437911-5-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SY5P282CA0143.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:205::15) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: c4ca3e54-6b48-4bcf-364e-08de05ff7d4d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?mxTcvmCWsLliMx5yyTWO0sXoq3TheHFc3vWCR6a8S+oiA1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ka2OLf4gTcIR1qvxKthnwv0GKrXGElLo27GSXFe31nhrt6AR1ZOxGw9?= =?us-ascii?Q?cJk+gPffPINaKP007E4AZ+Ixubp7ghWCGtolEBAXXYC3bTWGwbOZrf0GZk4l?= =?us-ascii?Q?GbMZKi5y7gcvCfRSHmtM5bZlABH5VB13NeHgjmfwuLA4VivlUAZ1BNpn3Kr2?= =?us-ascii?Q?BdSfrIYnd1z22d0RV8EvzTt7tLfuR2xlIYayYDIyqxgrQtW2lameasb3QjCr?= =?us-ascii?Q?GBUD0KjMgoLmlZQ4V11vTii3ucvVRGI9KIZgV4sLGiaH+T8sGxnzth57IfoH?= =?us-ascii?Q?6de5X8jBw8UK7JQICgMKyrp/Cnq9sI9G6IdfgJMPgu95skWvwcBk6Lafc60C?= =?us-ascii?Q?GmXvZALYyj4CSAIcPiMMiwXwaMbBYSCy4R3rOBPCIkIAb1mDAYBxfS6L3LMU?= =?us-ascii?Q?P79CVvNruI3hqKp2rDBZQAucc58vfxtvAT8QiKjURiaMBN/UQCWGb13D7fuc?= =?us-ascii?Q?IuTy2cwIPTbGUyzlkW0jsZr/rFgxhJLH5kKZl8VpwH9LaHYdd6C1twV3QBgb?= =?us-ascii?Q?On9g58KLySzIVl+7UWYwrAs3ZaJv4O7Q?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?bIWwQ8LibSfiZVzZ8rwAkG0wvu2jBB6rzyIgABmKnDixBYx5h6e21Me7YQVv?= =?us-ascii?Q?iJXhavgbdzVrk5SIXP0New2mfSgJ20e0C/bhz7cZrVUcZDxmoVJlKKyb4RRt?= =?us-ascii?Q?1T2ybS3gMy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WkS3ax/?= =?us-ascii?Q?Y+qpgdY1U/gfvqRmW52qmQGL9Gbj16/nnxuIZ4NOyL0VWXg7gtPkOaF+t8YQ?= =?us-ascii?Q?lpWaEjgDcIjVpb28PvFes1e6oWT5G7sid/Erb7Kie4AHnL9dks+IcBaKdu6D?= =?us-ascii?Q?v5hgsmTM7dsOeJLgeBMQrGsD9wh6A6ivFXqyX7LuofKyzYHoqTOHdDP7vsEE?= =?us-ascii?Q?88fBWcVV1iV27JNO0jsf0FGsk4KoSokn1+7/XThf7QYGtORLLF68AHq6sj9i?= =?us-ascii?Q?0tFrx4k31hkkgsU7DJ6EhLsUGKTaPVVqk61VUD2I4KEHO73KEs8l1dv5PEYF?= =?us-ascii?Q?8c/vt8AvSeuolemER8eNRuWXXY3ngZ1A/bsghFJLZWLpZ5GbePEEQOiOBy/u?= =?us-ascii?Q?/ie/oqSZHOPkH4dAkihySphlkn/uYX1x+6Y0UMtGrehBm1L+7lRJk8iSSKKF?= =?us-ascii?Q?easHBI5QHqljtA0he9FuFwwQyj9Fhwb8l7Hs9W+OmsgSymuuHcCcQq9naL3B?= =?us-ascii?Q?xLZV/0YKEXw4jO8ZzLbsSjmTCHEyN/osJE9IntH/tK9pkuVn/Z4/spaVkhhe?= =?us-ascii?Q?OILcKG7E+yZYDV4lVS3pwvnEMJqByINUCPUSsrMd?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4ca3e54-6b48-4bcf-364e-08de05ff7d4d X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:13:21.3495 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: C/ZfdFZBKmAFVb6gkNrkiuBj5L0ydkjUcmEVdgnMaoizjlVKRlIoRddqPmPwwRz2UbzPCdUvExBrBYlkn0FMeQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Content-Type: text/plain; charset="utf-8" From: Joel Fernandes A data structure that can be used to write across multiple slices which may be out of order in memory. This lets SBuffer user correctly and safely write out of memory order, without error-prone tracking of pointers/offsets. let mut buf1 =3D [0u8; 3]; let mut buf2 =3D [0u8; 5]; let mut sbuffer =3D SBuffer::new([&mut buf1[..], &mut buf2[..]]); let data =3D b"hello"; let result =3D sbuffer.write(data); An internal conversion of gsp.rs to use this resulted in a nice -ve delta: gsp.rs: 37 insertions(+), 99 deletions(-) Co-developed-by: Alistair Popple Signed-off-by: Alistair Popple Signed-off-by: Joel Fernandes Reviewed-by: Lyude Paul --- Changes for v3: - Addressed minor review comment from Lyude --- drivers/gpu/nova-core/nova_core.rs | 1 + drivers/gpu/nova-core/sbuffer.rs | 191 +++++++++++++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 drivers/gpu/nova-core/sbuffer.rs diff --git a/drivers/gpu/nova-core/nova_core.rs b/drivers/gpu/nova-core/nov= a_core.rs index fffcaee2249f..a6feeba6254c 100644 --- a/drivers/gpu/nova-core/nova_core.rs +++ b/drivers/gpu/nova-core/nova_core.rs @@ -11,6 +11,7 @@ mod gpu; mod gsp; mod regs; +mod sbuffer; mod util; mod vbios; =20 diff --git a/drivers/gpu/nova-core/sbuffer.rs b/drivers/gpu/nova-core/sbuff= er.rs new file mode 100644 index 000000000000..e82f9d97ad21 --- /dev/null +++ b/drivers/gpu/nova-core/sbuffer.rs @@ -0,0 +1,191 @@ +// SPDX-License-Identifier: GPL-2.0 + +use core::ops::Deref; + +use kernel::alloc::KVec; +use kernel::error::code::*; +use kernel::prelude::*; + +/// A buffer abstraction for discontiguous byte slices. +/// +/// This allows you to treat multiple non-contiguous `&mut [u8]` slices +/// as a single stream-like read/write buffer. +/// +/// Example: +/// +/// let mut buf1 =3D [0u8; 3]; +/// let mut buf2 =3D [0u8; 5]; +/// let mut sbuffer =3D SWriteBuffer::new([&buf1, &buf2]); +/// +/// let data =3D b"hellowo"; +/// let result =3D sbuffer.write_all(0, data); +/// +/// A sliding window of slices to proceed. +/// +/// Both read and write buffers are implemented in terms of operating on s= lices of a requested +/// size. This base class implements logic that can be shared between the = two to support that. +/// +/// `S` is a slice type, `I` is an iterator yielding `S`. +pub(crate) struct SBuffer { + /// `Some` if we are not at the end of the data yet. + cur_slice: Option, + /// All the slices remaining after `cur_slice`. + slices: I, +} + +impl<'a, I> SBuffer +where + I: Iterator, +{ + #[expect(unused)] + pub(crate) fn new_reader(slices: impl IntoIterator) ->= Self + where + I: Iterator, + { + Self::new(slices) + } + + #[expect(unused)] + pub(crate) fn new_writer(slices: impl IntoIterator) ->= Self + where + I: Iterator, + { + Self::new(slices) + } + + fn new(slices: impl IntoIterator) -> Self + where + I::Item: Deref, + { + let mut slices =3D slices.into_iter(); + + Self { + // Skip empty slices to avoid trouble down the road. + cur_slice: slices.find(|s| !s.deref().is_empty()), + slices, + } + } + + fn get_slice_internal( + &mut self, + len: usize, + mut f: impl FnMut(I::Item, usize) -> (I::Item, I::Item), + ) -> Option + where + I::Item: Deref, + { + match self.cur_slice.take() { + None =3D> None, + Some(cur_slice) =3D> { + if len >=3D cur_slice.len() { + // Caller requested more data than is in the current s= lice, return it entirely + // and prepare the following slice for being used. Ski= p empty slices to avoid + // trouble. + self.cur_slice =3D self.slices.find(|s| !s.is_empty()); + + Some(cur_slice) + } else { + // The current slice can satisfy the request, split it= and return a slice of + // the requested size. + let (ret, next) =3D f(cur_slice, len); + self.cur_slice =3D Some(next); + + Some(ret) + } + } + } + } +} + +/// Provides a way to get non-mutable slices of data to read from. +impl<'a, I> SBuffer +where + I: Iterator, +{ + /// Returns a slice of at most `len` bytes, or `None` if we are at the= end of the data. + /// + /// If a slice shorter than `len` bytes has been returned, the caller = can call this method + /// again until it returns `None` to try and obtain the remainder of t= he data. + fn get_slice(&mut self, len: usize) -> Option<&'a [u8]> { + self.get_slice_internal(len, |s, pos| s.split_at(pos)) + } + + /// Ideally we would implement `Read`, but it is not available in `cor= e`. + /// So mimic `std::io::Read::read_exact`. + #[expect(unused)] + pub(crate) fn read_exact(&mut self, mut dst: &mut [u8]) -> Result { + while !dst.is_empty() { + match self.get_slice(dst.len()) { + None =3D> return Err(ETOOSMALL), + Some(src) =3D> { + let dst_slice; + (dst_slice, dst) =3D dst.split_at_mut(src.len()); + dst_slice.copy_from_slice(src); + } + } + } + + Ok(()) + } + + /// Read all the remaining data into a `KVec`. + /// + /// `self` will be empty after this operation. + #[expect(unused)] + pub(crate) fn read_into_kvec(&mut self, flags: kernel::alloc::Flags) -= > Result> { + let mut buf =3D KVec::::new(); + + if let Some(slice) =3D core::mem::take(&mut self.cur_slice) { + buf.extend_from_slice(slice, flags)?; + } + for slice in &mut self.slices { + buf.extend_from_slice(slice, flags)?; + } + + Ok(buf) + } +} + +/// Provides a way to get mutable slices of data to write into. +impl<'a, I> SBuffer +where + I: Iterator, +{ + /// Returns a mutable slice of at most `len` bytes, or `None` if we ar= e at the end of the data. + /// + /// If a slice shorter than `len` bytes has been returned, the caller = can call this method + /// again until it returns `None` to try and obtain the remainder of t= he data. + fn get_slice_mut(&mut self, len: usize) -> Option<&'a mut [u8]> { + self.get_slice_internal(len, |s, pos| s.split_at_mut(pos)) + } + + /// Ideally we would implement `Write`, but it is not available in `co= re`. + /// So mimic `std::io::Write::write_all`. + #[expect(unused)] + pub(crate) fn write_all(&mut self, mut src: &[u8]) -> Result { + while !src.is_empty() { + match self.get_slice_mut(src.len()) { + None =3D> return Err(ETOOSMALL), + Some(dst) =3D> { + let src_slice; + (src_slice, src) =3D src.split_at(dst.len()); + dst.copy_from_slice(src_slice); + } + } + } + + Ok(()) + } +} + +impl<'a, I> Iterator for SBuffer +where + I: Iterator, +{ + type Item =3D u8; + + fn next(&mut self) -> Option { + // Returned slices are guaranteed to not be empty so we can safely= index the first entry. + self.get_slice(1).map(|s| s[0]) + } +} --=20 2.50.1 From nobody Sat Feb 7 19:45:37 2026 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012062.outbound.protection.outlook.com [52.101.53.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BB291E00A0; Wed, 8 Oct 2025 00:13:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.53.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882420; cv=fail; b=Igu/y0qVpBImVbFwcMMwNLMB+HdPotfIYjMLdcoq73oVV71QaZBeyiACaaUJzT+jZP39tPKHlHnGWvWNpZbSPJEqtzKO36KmWPQ+zpICPb3ducTw0mReYcOlFNIvDIGTU9sPu+/QleLic4Rj6D6lySmaH5HWjZoS2J1Drh0alaw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882420; c=relaxed/simple; bh=CVSaWKfsbPMR3GtniJphaIB+qOsX1sSfiOjAkiz7sHI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=mRChoqVpjV+Uj7IHfhX+LTxXmhsbTZPsWvvtdLqKaPFxsGzqyckfrBg1v12GdJCnkBN0FDpRZH1gOz4uvcRVTTsrVkBqecrsREyCf/bMxdZyO91v+o6YSlLBWevYLUxj4mh/b6MzLsPBGSQUlx+J6U8JVazbbhwAovYcdjLqOlA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=KINd4/+U; arc=fail smtp.client-ip=52.101.53.62 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="KINd4/+U" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nxA85XjJziOsvygzlvSn3roITJm3trq1RfTV4XqBFR3DvyjB5aTscGMXc5ICTLd4RJGSAu7oLen4tdHcvNBv2iF0V0fL066HM6qqznTm8cCSJ3KevYQlfI4qoz3OjPysn/mBncp71Zw+btV79ijNEKkD4vDAz8lTVsrhJqTY5KUDHFXh9B3OwC5LURzamIxV7C/JFEiL+04Fa3SROLxUt6yJ1N/2JXfCjp9Ct4R/Q8aRymNYvuqbQjl9zXBWM116FU2ccedMWVbY/rpdO7bSLnS9yOZG2seKgQZGDe0ICgEFPq7AXsr1+eZ8C22ty6SmQyY+W2/Mnh7lnZ+2K3bSrw== 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=xcBXfzU/uxY56EyN15dFGf8/t0VHJ3jAzJKcBN8UCc4=; b=ep9cSnrR9Vv3ZbFQLlcCgBTWVtQKIxF4wNFDGzXwP4+tbaaa1epEt8gzmU27CvtYEcykf9mVMV0cCbtKhSmY3iPiaIYeVGuzT57CChgTviAYRFmy3273ATov6p1avhL/gHe0K9eRPRpa8v4g6KpXnVCltUEsZplEMTQMpHPFl0p4D/vuXVlwAzwPaZpggp7RZhCKgPl1aqWGfTmz9fYkGIB0BkcMd+EBqSvHTTjE4aKRYauXP7TASeqF1mZl32FQoy0WLBOX4FzLSN+SDDMb1qVlKeW5daj6fN9aZCU1NtEjly8rsVxM7mHAZB9Gws0KilPmiXaN3T9vVixvd9PBVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xcBXfzU/uxY56EyN15dFGf8/t0VHJ3jAzJKcBN8UCc4=; b=KINd4/+UN6KSFMj+znhMurwYSMHHBHN10PPQNNyBwUnKoROKIOIg5Mm5rdd+L+G8x1OT+f8FpXqeLmgDwzCWxSle16t4poW1dyYpz1+UFUsXJp3dSmOOH3aGQN3YGB2SiySMzh2h/MDCgrTVaZV8twcQMOr4SXc37iudD+v+EiFfK4aqEmzA6i/3EOVTA4I8mBBBScuW3RWnhGpsGpTyrjEUfpof2bV9zzoVvPA7loFLhfmZPHb+XG8A82NN9uaPu0noudDelc3HBz/TGbozcA7kHLLlLyQyGBtNWv51Q219ZYIBZpu75/LE0jOjX3sNZNU72rOgYoeJKOV0zed/ag== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:13:27 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:13:27 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org Subject: [PATCH v4 05/13] gpu: nova-core: Add GSP command queue bindings Date: Wed, 8 Oct 2025 11:12:44 +1100 Message-ID: <20251008001253.437911-6-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SYBPR01CA0110.ausprd01.prod.outlook.com (2603:10c6:10:1::26) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: d0d8beec-30bd-4987-ad70-08de05ff8090 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024|13003099007; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?LAfMsQxBgJV+yYvsopKaAlrU/+36dS/UvWrKcc3tMvstcfdV1RgkB6RlFA+S?= =?us-ascii?Q?v5kVmjIDNAC9xws2g9SJ2CEtXC7BYtOMO4BahKXHdnBqmFutzPE4C7/+gNql?= =?us-ascii?Q?XKw1sDdCbDalvr5OCoOJsmutLZM8b+tjmW8Zq4EeXg9yF0yuQAoA6pt0cfxs?= =?us-ascii?Q?U4C1g2VmjGDFDXCCgE/wU3RPyPTHu4wren87V4WDx8cb3EJYPloF/e0wDxRW?= =?us-ascii?Q?bI/LVikn22yTtHCLvwKpxuKpQamTI7fa7gl+GzwJOBUGrxI+m870OYoXZTuv?= =?us-ascii?Q?wPf9/iweso+OMGtYA82tz5d8law9smqLEARNJj4oHFyzlZkAp/zUbkxZB3sE?= =?us-ascii?Q?EWz55mNVgXq/p/qnxm8QhyjavOZ79xhjQL09wpoIIpUb1NQBIHu46K1EbosA?= =?us-ascii?Q?IfImtthktzUcjRk37MqafVDMDGxiTCv5NOv54zRCv82B54Zd61t/zluFGqlc?= =?us-ascii?Q?mBevcw5ReuNrCwDmllvArIrqLlAQZsh+COOSTtNxzRapP2hLJurhZ9f8PXc2?= =?us-ascii?Q?+0kJWy3xAr5IkybgBi88SgUz8l5Y+ygt1/ADK6St0OLq1CYSer142BoSRn02?= =?us-ascii?Q?vlheoixFAcMNJOOM2QQbQD9XH4j2ehXYtFYuWF6+R6S366r3T2BoYaanJUZZ?= =?us-ascii?Q?pvIfU5ett513SVm7FdXao24OD63hYZYTy4RkLiePKKvGHO7Gi4Fp2P4zWbjj?= =?us-ascii?Q?H+vQf+j5v1JqVnAZFrbBO5pKxemdOg0dhfssD/ftMLa5Jb0VKL6p3KxItZRN?= =?us-ascii?Q?6CdgDKd8xbTm9QE6tDY34NUMslRsyRtPT/CE9Cvmnsrlevh683MQbe4bFeD1?= =?us-ascii?Q?Mtg0kEXOmxKGI+hcKeMpMsfZ1ghNsSPpKz86+r2YWqzKCRZd1J40/TT08YZ2?= =?us-ascii?Q?btU9IopW2ckhGo5NSaUi1d0ZzvNEOs/n1ps+d9pS/jhSHePL30fA7pI3hQWG?= =?us-ascii?Q?liYyWWGpjxaOuqt21u6FilGAyP+QSPsfkq2kaSgvjYEDxcSDNRjL7b+mbD7v?= =?us-ascii?Q?GDZ1TEZTxPYttZyHgbYYGcZZvs7iaW2QgFhw40ksWBicComPpagEXyMZiVBX?= =?us-ascii?Q?pQZO0TLrEju81rKmCPAKqMMCV4H4tU8pnqjOPnH4bbHCwSe3rJkJDgDYN3Ys?= =?us-ascii?Q?ckfPbuOb5mAIHARKInMmI+6ZikgV+sB/SUEWizl6rPgOLpu0OZkuMI/65YUr?= =?us-ascii?Q?MkOWJJgwFn9J4927yRm9BxR67SyA+F/0kR1PuhhWJ7PBClo4T9UU+EDsSOC4?= =?us-ascii?Q?/fFedpRbGd1asFQYilrIKtgtirMv/XN6neajWkppANSd/vzZ58cCNHy8dmZw?= =?us-ascii?Q?9r49AzyN0mZ2rWYB7p2oT7ziymbDVoontqSQxB59AxPN9Db/kuTjicVev3J5?= =?us-ascii?Q?qy4qZjC3Ny2tD4LAHQU4TgYSHByroB1i6XqfrnggQSuNztuGjHxSV47PV8CF?= =?us-ascii?Q?jVFfS5MokXiEic8DR4Hz+b6TNCni1rGf?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024)(13003099007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?mgmjHAWjQLVWfmwcTQCgUOQn0DKPKECts4PDgLoee25Cpy0NpMOw5gnktsHP?= =?us-ascii?Q?r36N4tlM4fitrlBaBHCgGkZYvnWzSNUIywyuADRKQ2kGpGCY5g4iPHcWjHHr?= =?us-ascii?Q?Uwq63KlhkEBXRPEhWZnou2z7ODS8MB+R4/a1u+HXUJDbkx8q9mtplGxevMV/?= =?us-ascii?Q?3O4X6tv4Ze1EBWsrnEbRAWyXcTDn/5EzKNrfKnjlDj2DWk+XQ7ajF9xoXM/L?= =?us-ascii?Q?wEtArBNuduW0BBwNMBK/cx4FfZ1Y70OORmMOJpeoFww+Caio0UxmmDzTrpCB?= =?us-ascii?Q?XS657mlDxT8v0zyWbTKN/BVvXs3oP56RssqNO+sQNRJS65xqhpA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ytrUxMZiCqdUL2wyQ0Q+inyiv?= =?us-ascii?Q?KcfT0CIp90xlKrIWWO5aK+3xchKL/+a+4b1ZvEb7XDapyFKuiQJ3aWdFyV87?= =?us-ascii?Q?UK8stEyHMkLDUycpTIutm1Dk7+w+6/iSWqKnxiuzgWnC9e515xO1MLGW+rgX?= =?us-ascii?Q?VmKkY9Rcc87lona7f2mizUZihN+zleQ497//EUnJS06fqxp+0qCdJ5OBdM1R?= =?us-ascii?Q?v6zGth3rJJnhaRIk/BhFbyC/N5ZjYTFYYNKj7EsAiwjnfeJ2bWF/bqEUMedu?= =?us-ascii?Q?TL9LloH7fQFolivtz5ijaxfmYtcqUxy7GPnq4Fu09lRQDGB0eudCNE2ymRYe?= =?us-ascii?Q?cm4JFsly4PCC/n3PeLQhDLqR67TDgnmskm4lyoJY?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0d8beec-30bd-4987-ad70-08de05ff8090 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:13:26.9406 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: y5CXMQ67mll2dbvDVmCvbbn7o3nsKNY2OnH36kd5CWXiuFYNGm+qif718ZPBkrkUakXR6nkrneHDCyog511xKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Content-Type: text/plain; charset="utf-8" Add bindings and accessors used for the GSP command queue. Signed-off-by: Alistair Popple --- Changes for v4: - Don't panic the kernel if trying to initialise a large (> 4GB) message header. - Use `init!` to provide safe and complete initialisers. - Take an enum type instead of a u32 for the function. Changes for v3: - New for v3 --- drivers/gpu/nova-core/gsp/fw.rs | 277 +++++++++++++ .../gpu/nova-core/gsp/fw/r570_144/bindings.rs | 374 ++++++++++++++++++ 2 files changed, 651 insertions(+) diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw= .rs index 68a7059bc965..ca3a33ab21db 100644 --- a/drivers/gpu/nova-core/gsp/fw.rs +++ b/drivers/gpu/nova-core/gsp/fw.rs @@ -5,9 +5,11 @@ // Alias to avoid repeating the version number with every use. use r570_144 as bindings; =20 +use core::fmt; use core::ops::Range; =20 use kernel::dma::CoherentAllocation; +use kernel::prelude::*; use kernel::ptr::{Alignable, Alignment}; use kernel::sizes::{SZ_128K, SZ_1M}; use kernel::transmute::{AsBytes, FromBytes}; @@ -16,6 +18,7 @@ use crate::gpu::Chipset; use crate::gsp; use crate::gsp::FbLayout; +use crate::gsp::GSP_PAGE_SIZE; =20 /// Dummy type to group methods related to heap parameters for running the= GSP firmware. pub(crate) struct GspFwHeapParams(()); @@ -155,6 +158,120 @@ pub(crate) fn new(gsp_firmware: &GspFirmware, fb_layo= ut: &FbLayout) -> Self { } } =20 +#[derive(PartialEq)] +pub(crate) enum MsgFunction { + // Common function codes + Nop =3D bindings::NV_VGPU_MSG_FUNCTION_NOP as isize, + SetGuestSystemInfo =3D bindings::NV_VGPU_MSG_FUNCTION_SET_GUEST_SYSTEM= _INFO as isize, + AllocRoot =3D bindings::NV_VGPU_MSG_FUNCTION_ALLOC_ROOT as isize, + AllocDevice =3D bindings::NV_VGPU_MSG_FUNCTION_ALLOC_DEVICE as isize, + AllocMemory =3D bindings::NV_VGPU_MSG_FUNCTION_ALLOC_MEMORY as isize, + AllocCtxDma =3D bindings::NV_VGPU_MSG_FUNCTION_ALLOC_CTX_DMA as isize, + AllocChannelDma =3D bindings::NV_VGPU_MSG_FUNCTION_ALLOC_CHANNEL_DMA a= s isize, + MapMemory =3D bindings::NV_VGPU_MSG_FUNCTION_MAP_MEMORY as isize, + BindCtxDma =3D bindings::NV_VGPU_MSG_FUNCTION_BIND_CTX_DMA as isize, + AllocObject =3D bindings::NV_VGPU_MSG_FUNCTION_ALLOC_OBJECT as isize, + Free =3D bindings::NV_VGPU_MSG_FUNCTION_FREE as isize, + Log =3D bindings::NV_VGPU_MSG_FUNCTION_LOG as isize, + GetGspStaticInfo =3D bindings::NV_VGPU_MSG_FUNCTION_GET_GSP_STATIC_INF= O as isize, + SetRegistry =3D bindings::NV_VGPU_MSG_FUNCTION_SET_REGISTRY as isize, + GspSetSystemInfo =3D bindings::NV_VGPU_MSG_FUNCTION_GSP_SET_SYSTEM_INF= O as isize, + GspInitPostObjGpu =3D bindings::NV_VGPU_MSG_FUNCTION_GSP_INIT_POST_OBJ= GPU as isize, + GspRmControl =3D bindings::NV_VGPU_MSG_FUNCTION_GSP_RM_CONTROL as isiz= e, + GetStaticInfo =3D bindings::NV_VGPU_MSG_FUNCTION_GET_STATIC_INFO as is= ize, + + // Event codes + GspInitDone =3D bindings::NV_VGPU_MSG_EVENT_GSP_INIT_DONE as isize, + GspRunCpuSequencer =3D bindings::NV_VGPU_MSG_EVENT_GSP_RUN_CPU_SEQUENC= ER as isize, + PostEvent =3D bindings::NV_VGPU_MSG_EVENT_POST_EVENT as isize, + RcTriggered =3D bindings::NV_VGPU_MSG_EVENT_RC_TRIGGERED as isize, + MmuFaultQueued =3D bindings::NV_VGPU_MSG_EVENT_MMU_FAULT_QUEUED as isi= ze, + OsErrorLog =3D bindings::NV_VGPU_MSG_EVENT_OS_ERROR_LOG as isize, + GspPostNoCat =3D bindings::NV_VGPU_MSG_EVENT_GSP_POST_NOCAT_RECORD as = isize, + GspLockdownNotice =3D bindings::NV_VGPU_MSG_EVENT_GSP_LOCKDOWN_NOTICE = as isize, + UcodeLibOsPrint =3D bindings::NV_VGPU_MSG_EVENT_UCODE_LIBOS_PRINT as i= size, +} + +impl fmt::Display for MsgFunction { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + // Common function codes + MsgFunction::Nop =3D> write!(f, "NOP"), + MsgFunction::SetGuestSystemInfo =3D> write!(f, "SET_GUEST_SYST= EM_INFO"), + MsgFunction::AllocRoot =3D> write!(f, "ALLOC_ROOT"), + MsgFunction::AllocDevice =3D> write!(f, "ALLOC_DEVICE"), + MsgFunction::AllocMemory =3D> write!(f, "ALLOC_MEMORY"), + MsgFunction::AllocCtxDma =3D> write!(f, "ALLOC_CTX_DMA"), + MsgFunction::AllocChannelDma =3D> write!(f, "ALLOC_CHANNEL_DMA= "), + MsgFunction::MapMemory =3D> write!(f, "MAP_MEMORY"), + MsgFunction::BindCtxDma =3D> write!(f, "BIND_CTX_DMA"), + MsgFunction::AllocObject =3D> write!(f, "ALLOC_OBJECT"), + MsgFunction::Free =3D> write!(f, "FREE"), + MsgFunction::Log =3D> write!(f, "LOG"), + MsgFunction::GetGspStaticInfo =3D> write!(f, "GET_GSP_STATIC_I= NFO"), + MsgFunction::SetRegistry =3D> write!(f, "SET_REGISTRY"), + MsgFunction::GspSetSystemInfo =3D> write!(f, "GSP_SET_SYSTEM_I= NFO"), + MsgFunction::GspInitPostObjGpu =3D> write!(f, "GSP_INIT_POST_O= BJGPU"), + MsgFunction::GspRmControl =3D> write!(f, "GSP_RM_CONTROL"), + MsgFunction::GetStaticInfo =3D> write!(f, "GET_STATIC_INFO"), + + // Event codes + MsgFunction::GspInitDone =3D> write!(f, "INIT_DONE"), + MsgFunction::GspRunCpuSequencer =3D> write!(f, "RUN_CPU_SEQUEN= CER"), + MsgFunction::PostEvent =3D> write!(f, "POST_EVENT"), + MsgFunction::RcTriggered =3D> write!(f, "RC_TRIGGERED"), + MsgFunction::MmuFaultQueued =3D> write!(f, "MMU_FAULT_QUEUED"), + MsgFunction::OsErrorLog =3D> write!(f, "OS_ERROR_LOG"), + MsgFunction::GspPostNoCat =3D> write!(f, "NOCAT"), + MsgFunction::GspLockdownNotice =3D> write!(f, "LOCKDOWN_NOTICE= "), + MsgFunction::UcodeLibOsPrint =3D> write!(f, "LIBOS_PRINT"), + } + } +} + +impl TryFrom for MsgFunction { + type Error =3D kernel::error::Error; + + fn try_from(value: u32) -> Result { + match value { + bindings::NV_VGPU_MSG_FUNCTION_NOP =3D> Ok(MsgFunction::Nop), + bindings::NV_VGPU_MSG_FUNCTION_SET_GUEST_SYSTEM_INFO =3D> { + Ok(MsgFunction::SetGuestSystemInfo) + } + bindings::NV_VGPU_MSG_FUNCTION_ALLOC_ROOT =3D> Ok(MsgFunction:= :AllocRoot), + bindings::NV_VGPU_MSG_FUNCTION_ALLOC_DEVICE =3D> Ok(MsgFunctio= n::AllocDevice), + bindings::NV_VGPU_MSG_FUNCTION_ALLOC_MEMORY =3D> Ok(MsgFunctio= n::AllocMemory), + bindings::NV_VGPU_MSG_FUNCTION_ALLOC_CTX_DMA =3D> Ok(MsgFuncti= on::AllocCtxDma), + bindings::NV_VGPU_MSG_FUNCTION_ALLOC_CHANNEL_DMA =3D> Ok(MsgFu= nction::AllocChannelDma), + bindings::NV_VGPU_MSG_FUNCTION_MAP_MEMORY =3D> Ok(MsgFunction:= :MapMemory), + bindings::NV_VGPU_MSG_FUNCTION_BIND_CTX_DMA =3D> Ok(MsgFunctio= n::BindCtxDma), + bindings::NV_VGPU_MSG_FUNCTION_ALLOC_OBJECT =3D> Ok(MsgFunctio= n::AllocObject), + bindings::NV_VGPU_MSG_FUNCTION_FREE =3D> Ok(MsgFunction::Free), + bindings::NV_VGPU_MSG_FUNCTION_LOG =3D> Ok(MsgFunction::Log), + bindings::NV_VGPU_MSG_FUNCTION_GET_GSP_STATIC_INFO =3D> Ok(Msg= Function::GetGspStaticInfo), + bindings::NV_VGPU_MSG_FUNCTION_SET_REGISTRY =3D> Ok(MsgFunctio= n::SetRegistry), + bindings::NV_VGPU_MSG_FUNCTION_GSP_SET_SYSTEM_INFO =3D> Ok(Msg= Function::GspSetSystemInfo), + bindings::NV_VGPU_MSG_FUNCTION_GSP_INIT_POST_OBJGPU =3D> { + Ok(MsgFunction::GspInitPostObjGpu) + } + bindings::NV_VGPU_MSG_FUNCTION_GSP_RM_CONTROL =3D> Ok(MsgFunct= ion::GspRmControl), + bindings::NV_VGPU_MSG_FUNCTION_GET_STATIC_INFO =3D> Ok(MsgFunc= tion::GetStaticInfo), + bindings::NV_VGPU_MSG_EVENT_GSP_INIT_DONE =3D> Ok(MsgFunction:= :GspInitDone), + bindings::NV_VGPU_MSG_EVENT_GSP_RUN_CPU_SEQUENCER =3D> { + Ok(MsgFunction::GspRunCpuSequencer) + } + bindings::NV_VGPU_MSG_EVENT_POST_EVENT =3D> Ok(MsgFunction::Po= stEvent), + bindings::NV_VGPU_MSG_EVENT_RC_TRIGGERED =3D> Ok(MsgFunction::= RcTriggered), + bindings::NV_VGPU_MSG_EVENT_MMU_FAULT_QUEUED =3D> Ok(MsgFuncti= on::MmuFaultQueued), + bindings::NV_VGPU_MSG_EVENT_OS_ERROR_LOG =3D> Ok(MsgFunction::= OsErrorLog), + bindings::NV_VGPU_MSG_EVENT_GSP_POST_NOCAT_RECORD =3D> Ok(MsgF= unction::GspPostNoCat), + bindings::NV_VGPU_MSG_EVENT_GSP_LOCKDOWN_NOTICE =3D> Ok(MsgFun= ction::GspLockdownNotice), + bindings::NV_VGPU_MSG_EVENT_UCODE_LIBOS_PRINT =3D> Ok(MsgFunct= ion::UcodeLibOsPrint), + _ =3D> Err(EINVAL), + } + } +} + #[repr(transparent)] pub(crate) struct LibosMemoryRegionInitArgument(bindings::LibosMemoryRegio= nInitArgument); =20 @@ -191,3 +308,163 @@ fn id8(name: &str) -> u64 { }) } } + +#[repr(transparent)] +pub(crate) struct MsgqTxHeader(bindings::msgqTxHeader); + +impl MsgqTxHeader { + pub(crate) fn new(msgq_size: u32, rx_hdr_offset: u32, msg_count: u32) = -> Self { + Self(bindings::msgqTxHeader { + version: 0, + size: msgq_size, + msgSize: GSP_PAGE_SIZE as u32, + msgCount: msg_count, + writePtr: 0, + flags: 1, + rxHdrOff: rx_hdr_offset, + entryOff: GSP_PAGE_SIZE as u32, + }) + } + + pub(crate) fn write_ptr(&self) -> u32 { + let ptr =3D (&self.0.writePtr) as *const u32; + + // SAFETY: This is part of a CoherentAllocation and implements the + // equivalent as what the dma_read! macro would and is therefore s= afe + // for the same reasons. + unsafe { ptr.read_volatile() } + } + + pub(crate) fn set_write_ptr(&mut self, val: u32) { + let ptr =3D (&mut self.0.writePtr) as *mut u32; + + // SAFETY: This is part of a CoherentAllocation and implements the + // equivalent as what the dma_write! macro would and is therefore = safe + // for the same reasons. + unsafe { ptr.write_volatile(val) } + } +} + +// SAFETY: Padding is explicit and will not contain uninitialized data. +unsafe impl AsBytes for MsgqTxHeader {} + +/// RX header for setting up a message queue with the GSP. +#[repr(transparent)] +pub(crate) struct MsgqRxHeader(bindings::msgqRxHeader); + +impl MsgqRxHeader { + pub(crate) fn new() -> Self { + Self(Default::default()) + } + + pub(crate) fn read_ptr(&self) -> u32 { + let ptr =3D (&self.0.readPtr) as *const u32; + + // SAFETY: This is part of a CoherentAllocation and implements the + // equivalent as what the dma_read! macro would and is therefore s= afe + // for the same reasons. + unsafe { ptr.read_volatile() } + } + + pub(crate) fn set_read_ptr(&mut self, val: u32) { + let ptr =3D (&mut self.0.readPtr) as *mut u32; + + // SAFETY: This is part of a CoherentAllocation and implements the + // equivalent as what the dma_write! macro would and is therefore = safe + // for the same reasons. + unsafe { ptr.write_volatile(val) } + } +} + +// SAFETY: Padding is explicit and will not contain uninitialized data. +unsafe impl AsBytes for MsgqRxHeader {} + +impl bindings::rpc_message_header_v { + pub(crate) fn init(cmd_size: u32, function: MsgFunction) -> impl Init<= Self, Error> { + type RpcMessageHeader =3D bindings::rpc_message_header_v; + try_init!(RpcMessageHeader { + // TODO: magic number + header_version: 0x03000000, + signature: bindings::NV_VGPU_MSG_SIGNATURE_VALID, + function: function as u32, + length: (size_of::() as u32) + .checked_add(cmd_size) + .ok_or(EOVERFLOW)?, + rpc_result: 0xffffffff, + rpc_result_private: 0xffffffff, + ..Zeroable::init_zeroed() + }) + } +} + +// TODO: Ideally we would derive this for all our bindings, using the same= technique as +// https://lore.kernel.org/rust-for-linux/20250814093046.2071971-3-lossin@= kernel.org/ +unsafe impl Zeroable for bindings::rpc_message_header_v {} + +#[repr(transparent)] +pub(crate) struct GspMsgElement { + inner: bindings::GSP_MSG_QUEUE_ELEMENT, +} + +impl GspMsgElement { + #[allow(non_snake_case)] + pub(crate) fn init( + sequence: u32, + cmd_size: usize, + function: MsgFunction, + ) -> impl Init { + type RpcMessageHeader =3D bindings::rpc_message_header_v; + type InnerGspMsgElement =3D bindings::GSP_MSG_QUEUE_ELEMENT; + let init_inner =3D try_init!(InnerGspMsgElement { + seqNum: sequence, + elemCount: size_of::() + .checked_add(cmd_size) + .ok_or(EOVERFLOW)? + .div_ceil(GSP_PAGE_SIZE) as u32, + rpc <- RpcMessageHeader::init(cmd_size as u32, function), + ..Zeroable::init_zeroed() + }); + + try_init!(GspMsgElement { + inner <- init_inner, + }) + } + + pub(crate) fn set_checksum(&mut self, checksum: u32) { + self.inner.checkSum =3D checksum; + } + + // Return the total length of the message, noting that rpc.length incl= udes + // the length of the GspRpcHeader but not the message header. + pub(crate) fn length(&self) -> u32 { + size_of::() as u32 - size_of::() as u32 + + self.inner.rpc.length + } + + pub(crate) fn sequence(&self) -> u32 { + self.inner.rpc.sequence + } + + pub(crate) fn function_number(&self) -> u32 { + self.inner.rpc.function + } + + pub(crate) fn function(&self) -> Result { + self.inner.rpc.function.try_into() + } + + pub(crate) fn element_count(&self) -> u32 { + self.inner.elemCount + } +} + +// TODO: Ideally we would derive this for all our bindings, using the same= technique as +// https://lore.kernel.org/rust-for-linux/20250814093046.2071971-3-lossin@= kernel.org/ +unsafe impl Zeroable for bindings::GSP_MSG_QUEUE_ELEMENT {} + +// SAFETY: Padding is explicit and will not contain uninitialized data. +unsafe impl AsBytes for GspMsgElement {} + +// SAFETY: This struct only contains integer types for which all bit patte= rns +// are valid. +unsafe impl FromBytes for GspMsgElement {} diff --git a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs b/drivers/gp= u/nova-core/gsp/fw/r570_144/bindings.rs index 392b25dc6991..3d96d91e5b12 100644 --- a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs +++ b/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs @@ -1,5 +1,36 @@ // SPDX-License-Identifier: GPL-2.0 =20 +#[repr(C)] +#[derive(Default)] +pub struct __IncompleteArrayField(::core::marker::PhantomData, [T; 0= ]); +impl __IncompleteArrayField { + #[inline] + pub const fn new() -> Self { + __IncompleteArrayField(::core::marker::PhantomData, []) + } + #[inline] + pub fn as_ptr(&self) -> *const T { + self as *const _ as *const T + } + #[inline] + pub fn as_mut_ptr(&mut self) -> *mut T { + self as *mut _ as *mut T + } + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + ::core::slice::from_raw_parts(self.as_ptr(), len) + } + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + ::core::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } +} +impl ::core::fmt::Debug for __IncompleteArrayField { + fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Re= sult { + fmt.write_str("__IncompleteArrayField") + } +} +pub const NV_VGPU_MSG_SIGNATURE_VALID: u32 =3D 1129337430; pub const GSP_FW_HEAP_PARAM_OS_SIZE_LIBOS2: u32 =3D 0; pub const GSP_FW_HEAP_PARAM_OS_SIZE_LIBOS3_BAREMETAL: u32 =3D 23068672; pub const GSP_FW_HEAP_PARAM_BASE_RM_SIZE_TU10X: u32 =3D 8388608; @@ -19,6 +50,312 @@ pub type u16_ =3D __u16; pub type u32_ =3D __u32; pub type u64_ =3D __u64; +pub const NV_VGPU_MSG_FUNCTION_NOP: _bindgen_ty_2 =3D 0; +pub const NV_VGPU_MSG_FUNCTION_SET_GUEST_SYSTEM_INFO: _bindgen_ty_2 =3D 1; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_ROOT: _bindgen_ty_2 =3D 2; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_DEVICE: _bindgen_ty_2 =3D 3; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_MEMORY: _bindgen_ty_2 =3D 4; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_CTX_DMA: _bindgen_ty_2 =3D 5; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_CHANNEL_DMA: _bindgen_ty_2 =3D 6; +pub const NV_VGPU_MSG_FUNCTION_MAP_MEMORY: _bindgen_ty_2 =3D 7; +pub const NV_VGPU_MSG_FUNCTION_BIND_CTX_DMA: _bindgen_ty_2 =3D 8; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_OBJECT: _bindgen_ty_2 =3D 9; +pub const NV_VGPU_MSG_FUNCTION_FREE: _bindgen_ty_2 =3D 10; +pub const NV_VGPU_MSG_FUNCTION_LOG: _bindgen_ty_2 =3D 11; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_VIDMEM: _bindgen_ty_2 =3D 12; +pub const NV_VGPU_MSG_FUNCTION_UNMAP_MEMORY: _bindgen_ty_2 =3D 13; +pub const NV_VGPU_MSG_FUNCTION_MAP_MEMORY_DMA: _bindgen_ty_2 =3D 14; +pub const NV_VGPU_MSG_FUNCTION_UNMAP_MEMORY_DMA: _bindgen_ty_2 =3D 15; +pub const NV_VGPU_MSG_FUNCTION_GET_EDID: _bindgen_ty_2 =3D 16; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_DISP_CHANNEL: _bindgen_ty_2 =3D 17; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_DISP_OBJECT: _bindgen_ty_2 =3D 18; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_SUBDEVICE: _bindgen_ty_2 =3D 19; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_DYNAMIC_MEMORY: _bindgen_ty_2 =3D 20; +pub const NV_VGPU_MSG_FUNCTION_DUP_OBJECT: _bindgen_ty_2 =3D 21; +pub const NV_VGPU_MSG_FUNCTION_IDLE_CHANNELS: _bindgen_ty_2 =3D 22; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_EVENT: _bindgen_ty_2 =3D 23; +pub const NV_VGPU_MSG_FUNCTION_SEND_EVENT: _bindgen_ty_2 =3D 24; +pub const NV_VGPU_MSG_FUNCTION_REMAPPER_CONTROL: _bindgen_ty_2 =3D 25; +pub const NV_VGPU_MSG_FUNCTION_DMA_CONTROL: _bindgen_ty_2 =3D 26; +pub const NV_VGPU_MSG_FUNCTION_DMA_FILL_PTE_MEM: _bindgen_ty_2 =3D 27; +pub const NV_VGPU_MSG_FUNCTION_MANAGE_HW_RESOURCE: _bindgen_ty_2 =3D 28; +pub const NV_VGPU_MSG_FUNCTION_BIND_ARBITRARY_CTX_DMA: _bindgen_ty_2 =3D 2= 9; +pub const NV_VGPU_MSG_FUNCTION_CREATE_FB_SEGMENT: _bindgen_ty_2 =3D 30; +pub const NV_VGPU_MSG_FUNCTION_DESTROY_FB_SEGMENT: _bindgen_ty_2 =3D 31; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_SHARE_DEVICE: _bindgen_ty_2 =3D 32; +pub const NV_VGPU_MSG_FUNCTION_DEFERRED_API_CONTROL: _bindgen_ty_2 =3D 33; +pub const NV_VGPU_MSG_FUNCTION_REMOVE_DEFERRED_API: _bindgen_ty_2 =3D 34; +pub const NV_VGPU_MSG_FUNCTION_SIM_ESCAPE_READ: _bindgen_ty_2 =3D 35; +pub const NV_VGPU_MSG_FUNCTION_SIM_ESCAPE_WRITE: _bindgen_ty_2 =3D 36; +pub const NV_VGPU_MSG_FUNCTION_SIM_MANAGE_DISPLAY_CONTEXT_DMA: _bindgen_ty= _2 =3D 37; +pub const NV_VGPU_MSG_FUNCTION_FREE_VIDMEM_VIRT: _bindgen_ty_2 =3D 38; +pub const NV_VGPU_MSG_FUNCTION_PERF_GET_PSTATE_INFO: _bindgen_ty_2 =3D 39; +pub const NV_VGPU_MSG_FUNCTION_PERF_GET_PERFMON_SAMPLE: _bindgen_ty_2 =3D = 40; +pub const NV_VGPU_MSG_FUNCTION_PERF_GET_VIRTUAL_PSTATE_INFO: _bindgen_ty_2= =3D 41; +pub const NV_VGPU_MSG_FUNCTION_PERF_GET_LEVEL_INFO: _bindgen_ty_2 =3D 42; +pub const NV_VGPU_MSG_FUNCTION_MAP_SEMA_MEMORY: _bindgen_ty_2 =3D 43; +pub const NV_VGPU_MSG_FUNCTION_UNMAP_SEMA_MEMORY: _bindgen_ty_2 =3D 44; +pub const NV_VGPU_MSG_FUNCTION_SET_SURFACE_PROPERTIES: _bindgen_ty_2 =3D 4= 5; +pub const NV_VGPU_MSG_FUNCTION_CLEANUP_SURFACE: _bindgen_ty_2 =3D 46; +pub const NV_VGPU_MSG_FUNCTION_UNLOADING_GUEST_DRIVER: _bindgen_ty_2 =3D 4= 7; +pub const NV_VGPU_MSG_FUNCTION_TDR_SET_TIMEOUT_STATE: _bindgen_ty_2 =3D 48; +pub const NV_VGPU_MSG_FUNCTION_SWITCH_TO_VGA: _bindgen_ty_2 =3D 49; +pub const NV_VGPU_MSG_FUNCTION_GPU_EXEC_REG_OPS: _bindgen_ty_2 =3D 50; +pub const NV_VGPU_MSG_FUNCTION_GET_STATIC_INFO: _bindgen_ty_2 =3D 51; +pub const NV_VGPU_MSG_FUNCTION_ALLOC_VIRTMEM: _bindgen_ty_2 =3D 52; +pub const NV_VGPU_MSG_FUNCTION_UPDATE_PDE_2: _bindgen_ty_2 =3D 53; +pub const NV_VGPU_MSG_FUNCTION_SET_PAGE_DIRECTORY: _bindgen_ty_2 =3D 54; +pub const NV_VGPU_MSG_FUNCTION_GET_STATIC_PSTATE_INFO: _bindgen_ty_2 =3D 5= 5; +pub const NV_VGPU_MSG_FUNCTION_TRANSLATE_GUEST_GPU_PTES: _bindgen_ty_2 =3D= 56; +pub const NV_VGPU_MSG_FUNCTION_RESERVED_57: _bindgen_ty_2 =3D 57; +pub const NV_VGPU_MSG_FUNCTION_RESET_CURRENT_GR_CONTEXT: _bindgen_ty_2 =3D= 58; +pub const NV_VGPU_MSG_FUNCTION_SET_SEMA_MEM_VALIDATION_STATE: _bindgen_ty_= 2 =3D 59; +pub const NV_VGPU_MSG_FUNCTION_GET_ENGINE_UTILIZATION: _bindgen_ty_2 =3D 6= 0; +pub const NV_VGPU_MSG_FUNCTION_UPDATE_GPU_PDES: _bindgen_ty_2 =3D 61; +pub const NV_VGPU_MSG_FUNCTION_GET_ENCODER_CAPACITY: _bindgen_ty_2 =3D 62; +pub const NV_VGPU_MSG_FUNCTION_VGPU_PF_REG_READ32: _bindgen_ty_2 =3D 63; +pub const NV_VGPU_MSG_FUNCTION_SET_GUEST_SYSTEM_INFO_EXT: _bindgen_ty_2 = =3D 64; +pub const NV_VGPU_MSG_FUNCTION_GET_GSP_STATIC_INFO: _bindgen_ty_2 =3D 65; +pub const NV_VGPU_MSG_FUNCTION_RMFS_INIT: _bindgen_ty_2 =3D 66; +pub const NV_VGPU_MSG_FUNCTION_RMFS_CLOSE_QUEUE: _bindgen_ty_2 =3D 67; +pub const NV_VGPU_MSG_FUNCTION_RMFS_CLEANUP: _bindgen_ty_2 =3D 68; +pub const NV_VGPU_MSG_FUNCTION_RMFS_TEST: _bindgen_ty_2 =3D 69; +pub const NV_VGPU_MSG_FUNCTION_UPDATE_BAR_PDE: _bindgen_ty_2 =3D 70; +pub const NV_VGPU_MSG_FUNCTION_CONTINUATION_RECORD: _bindgen_ty_2 =3D 71; +pub const NV_VGPU_MSG_FUNCTION_GSP_SET_SYSTEM_INFO: _bindgen_ty_2 =3D 72; +pub const NV_VGPU_MSG_FUNCTION_SET_REGISTRY: _bindgen_ty_2 =3D 73; +pub const NV_VGPU_MSG_FUNCTION_GSP_INIT_POST_OBJGPU: _bindgen_ty_2 =3D 74; +pub const NV_VGPU_MSG_FUNCTION_SUBDEV_EVENT_SET_NOTIFICATION: _bindgen_ty_= 2 =3D 75; +pub const NV_VGPU_MSG_FUNCTION_GSP_RM_CONTROL: _bindgen_ty_2 =3D 76; +pub const NV_VGPU_MSG_FUNCTION_GET_STATIC_INFO2: _bindgen_ty_2 =3D 77; +pub const NV_VGPU_MSG_FUNCTION_DUMP_PROTOBUF_COMPONENT: _bindgen_ty_2 =3D = 78; +pub const NV_VGPU_MSG_FUNCTION_UNSET_PAGE_DIRECTORY: _bindgen_ty_2 =3D 79; +pub const NV_VGPU_MSG_FUNCTION_GET_CONSOLIDATED_STATIC_INFO: _bindgen_ty_2= =3D 80; +pub const NV_VGPU_MSG_FUNCTION_GMMU_REGISTER_FAULT_BUFFER: _bindgen_ty_2 = =3D 81; +pub const NV_VGPU_MSG_FUNCTION_GMMU_UNREGISTER_FAULT_BUFFER: _bindgen_ty_2= =3D 82; +pub const NV_VGPU_MSG_FUNCTION_GMMU_REGISTER_CLIENT_SHADOW_FAULT_BUFFER: _= bindgen_ty_2 =3D 83; +pub const NV_VGPU_MSG_FUNCTION_GMMU_UNREGISTER_CLIENT_SHADOW_FAULT_BUFFER:= _bindgen_ty_2 =3D 84; +pub const NV_VGPU_MSG_FUNCTION_CTRL_SET_VGPU_FB_USAGE: _bindgen_ty_2 =3D 8= 5; +pub const NV_VGPU_MSG_FUNCTION_CTRL_NVFBC_SW_SESSION_UPDATE_INFO: _bindgen= _ty_2 =3D 86; +pub const NV_VGPU_MSG_FUNCTION_CTRL_NVENC_SW_SESSION_UPDATE_INFO: _bindgen= _ty_2 =3D 87; +pub const NV_VGPU_MSG_FUNCTION_CTRL_RESET_CHANNEL: _bindgen_ty_2 =3D 88; +pub const NV_VGPU_MSG_FUNCTION_CTRL_RESET_ISOLATED_CHANNEL: _bindgen_ty_2 = =3D 89; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GPU_HANDLE_VF_PRI_FAULT: _bindgen_ty_2= =3D 90; +pub const NV_VGPU_MSG_FUNCTION_CTRL_CLK_GET_EXTENDED_INFO: _bindgen_ty_2 = =3D 91; +pub const NV_VGPU_MSG_FUNCTION_CTRL_PERF_BOOST: _bindgen_ty_2 =3D 92; +pub const NV_VGPU_MSG_FUNCTION_CTRL_PERF_VPSTATES_GET_CONTROL: _bindgen_ty= _2 =3D 93; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GET_ZBC_CLEAR_TABLE: _bindgen_ty_2 =3D= 94; +pub const NV_VGPU_MSG_FUNCTION_CTRL_SET_ZBC_COLOR_CLEAR: _bindgen_ty_2 =3D= 95; +pub const NV_VGPU_MSG_FUNCTION_CTRL_SET_ZBC_DEPTH_CLEAR: _bindgen_ty_2 =3D= 96; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GPFIFO_SCHEDULE: _bindgen_ty_2 =3D 97; +pub const NV_VGPU_MSG_FUNCTION_CTRL_SET_TIMESLICE: _bindgen_ty_2 =3D 98; +pub const NV_VGPU_MSG_FUNCTION_CTRL_PREEMPT: _bindgen_ty_2 =3D 99; +pub const NV_VGPU_MSG_FUNCTION_CTRL_FIFO_DISABLE_CHANNELS: _bindgen_ty_2 = =3D 100; +pub const NV_VGPU_MSG_FUNCTION_CTRL_SET_TSG_INTERLEAVE_LEVEL: _bindgen_ty_= 2 =3D 101; +pub const NV_VGPU_MSG_FUNCTION_CTRL_SET_CHANNEL_INTERLEAVE_LEVEL: _bindgen= _ty_2 =3D 102; +pub const NV_VGPU_MSG_FUNCTION_GSP_RM_ALLOC: _bindgen_ty_2 =3D 103; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GET_P2P_CAPS_V2: _bindgen_ty_2 =3D 104; +pub const NV_VGPU_MSG_FUNCTION_CTRL_CIPHER_AES_ENCRYPT: _bindgen_ty_2 =3D = 105; +pub const NV_VGPU_MSG_FUNCTION_CTRL_CIPHER_SESSION_KEY: _bindgen_ty_2 =3D = 106; +pub const NV_VGPU_MSG_FUNCTION_CTRL_CIPHER_SESSION_KEY_STATUS: _bindgen_ty= _2 =3D 107; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_CLEAR_ALL_SM_ERROR_STATES: _bindge= n_ty_2 =3D 108; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_READ_ALL_SM_ERROR_STATES: _bindgen= _ty_2 =3D 109; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_SET_EXCEPTION_MASK: _bindgen_ty_2 = =3D 110; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GPU_PROMOTE_CTX: _bindgen_ty_2 =3D 111; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GR_CTXSW_PREEMPTION_BIND: _bindgen_ty_= 2 =3D 112; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GR_SET_CTXSW_PREEMPTION_MODE: _bindgen= _ty_2 =3D 113; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GR_CTXSW_ZCULL_BIND: _bindgen_ty_2 =3D= 114; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GPU_INITIALIZE_CTX: _bindgen_ty_2 =3D = 115; +pub const NV_VGPU_MSG_FUNCTION_CTRL_VASPACE_COPY_SERVER_RESERVED_PDES: _bi= ndgen_ty_2 =3D 116; +pub const NV_VGPU_MSG_FUNCTION_CTRL_FIFO_CLEAR_FAULTED_BIT: _bindgen_ty_2 = =3D 117; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GET_LATEST_ECC_ADDRESSES: _bindgen_ty_= 2 =3D 118; +pub const NV_VGPU_MSG_FUNCTION_CTRL_MC_SERVICE_INTERRUPTS: _bindgen_ty_2 = =3D 119; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DMA_SET_DEFAULT_VASPACE: _bindgen_ty_2= =3D 120; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GET_CE_PCE_MASK: _bindgen_ty_2 =3D 121; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GET_ZBC_CLEAR_TABLE_ENTRY: _bindgen_ty= _2 =3D 122; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GET_NVLINK_PEER_ID_MASK: _bindgen_ty_2= =3D 123; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GET_NVLINK_STATUS: _bindgen_ty_2 =3D 1= 24; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GET_P2P_CAPS: _bindgen_ty_2 =3D 125; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GET_P2P_CAPS_MATRIX: _bindgen_ty_2 =3D= 126; +pub const NV_VGPU_MSG_FUNCTION_RESERVED_0: _bindgen_ty_2 =3D 127; +pub const NV_VGPU_MSG_FUNCTION_CTRL_RESERVE_PM_AREA_SMPC: _bindgen_ty_2 = =3D 128; +pub const NV_VGPU_MSG_FUNCTION_CTRL_RESERVE_HWPM_LEGACY: _bindgen_ty_2 =3D= 129; +pub const NV_VGPU_MSG_FUNCTION_CTRL_B0CC_EXEC_REG_OPS: _bindgen_ty_2 =3D 1= 30; +pub const NV_VGPU_MSG_FUNCTION_CTRL_BIND_PM_RESOURCES: _bindgen_ty_2 =3D 1= 31; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_SUSPEND_CONTEXT: _bindgen_ty_2 =3D= 132; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_RESUME_CONTEXT: _bindgen_ty_2 =3D = 133; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_EXEC_REG_OPS: _bindgen_ty_2 =3D 13= 4; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_SET_MODE_MMU_DEBUG: _bindgen_ty_2 = =3D 135; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_READ_SINGLE_SM_ERROR_STATE: _bindg= en_ty_2 =3D 136; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_CLEAR_SINGLE_SM_ERROR_STATE: _bind= gen_ty_2 =3D 137; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_SET_MODE_ERRBAR_DEBUG: _bindgen_ty= _2 =3D 138; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_SET_NEXT_STOP_TRIGGER_TYPE: _bindg= en_ty_2 =3D 139; +pub const NV_VGPU_MSG_FUNCTION_CTRL_ALLOC_PMA_STREAM: _bindgen_ty_2 =3D 14= 0; +pub const NV_VGPU_MSG_FUNCTION_CTRL_PMA_STREAM_UPDATE_GET_PUT: _bindgen_ty= _2 =3D 141; +pub const NV_VGPU_MSG_FUNCTION_CTRL_FB_GET_INFO_V2: _bindgen_ty_2 =3D 142; +pub const NV_VGPU_MSG_FUNCTION_CTRL_FIFO_SET_CHANNEL_PROPERTIES: _bindgen_= ty_2 =3D 143; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GR_GET_CTX_BUFFER_INFO: _bindgen_ty_2 = =3D 144; +pub const NV_VGPU_MSG_FUNCTION_CTRL_KGR_GET_CTX_BUFFER_PTES: _bindgen_ty_2= =3D 145; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GPU_EVICT_CTX: _bindgen_ty_2 =3D 146; +pub const NV_VGPU_MSG_FUNCTION_CTRL_FB_GET_FS_INFO: _bindgen_ty_2 =3D 147; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GRMGR_GET_GR_FS_INFO: _bindgen_ty_2 = =3D 148; +pub const NV_VGPU_MSG_FUNCTION_CTRL_STOP_CHANNEL: _bindgen_ty_2 =3D 149; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GR_PC_SAMPLING_MODE: _bindgen_ty_2 =3D= 150; +pub const NV_VGPU_MSG_FUNCTION_CTRL_PERF_RATED_TDP_GET_STATUS: _bindgen_ty= _2 =3D 151; +pub const NV_VGPU_MSG_FUNCTION_CTRL_PERF_RATED_TDP_SET_CONTROL: _bindgen_t= y_2 =3D 152; +pub const NV_VGPU_MSG_FUNCTION_CTRL_FREE_PMA_STREAM: _bindgen_ty_2 =3D 153; +pub const NV_VGPU_MSG_FUNCTION_CTRL_TIMER_SET_GR_TICK_FREQ: _bindgen_ty_2 = =3D 154; +pub const NV_VGPU_MSG_FUNCTION_CTRL_FIFO_SETUP_VF_ZOMBIE_SUBCTX_PDB: _bind= gen_ty_2 =3D 155; +pub const NV_VGPU_MSG_FUNCTION_GET_CONSOLIDATED_GR_STATIC_INFO: _bindgen_t= y_2 =3D 156; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_SET_SINGLE_SM_SINGLE_STEP: _bindge= n_ty_2 =3D 157; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GR_GET_TPC_PARTITION_MODE: _bindgen_ty= _2 =3D 158; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GR_SET_TPC_PARTITION_MODE: _bindgen_ty= _2 =3D 159; +pub const NV_VGPU_MSG_FUNCTION_UVM_PAGING_CHANNEL_ALLOCATE: _bindgen_ty_2 = =3D 160; +pub const NV_VGPU_MSG_FUNCTION_UVM_PAGING_CHANNEL_DESTROY: _bindgen_ty_2 = =3D 161; +pub const NV_VGPU_MSG_FUNCTION_UVM_PAGING_CHANNEL_MAP: _bindgen_ty_2 =3D 1= 62; +pub const NV_VGPU_MSG_FUNCTION_UVM_PAGING_CHANNEL_UNMAP: _bindgen_ty_2 =3D= 163; +pub const NV_VGPU_MSG_FUNCTION_UVM_PAGING_CHANNEL_PUSH_STREAM: _bindgen_ty= _2 =3D 164; +pub const NV_VGPU_MSG_FUNCTION_UVM_PAGING_CHANNEL_SET_HANDLES: _bindgen_ty= _2 =3D 165; +pub const NV_VGPU_MSG_FUNCTION_UVM_METHOD_STREAM_GUEST_PAGES_OPERATION: _b= indgen_ty_2 =3D 166; +pub const NV_VGPU_MSG_FUNCTION_CTRL_INTERNAL_QUIESCE_PMA_CHANNEL: _bindgen= _ty_2 =3D 167; +pub const NV_VGPU_MSG_FUNCTION_DCE_RM_INIT: _bindgen_ty_2 =3D 168; +pub const NV_VGPU_MSG_FUNCTION_REGISTER_VIRTUAL_EVENT_BUFFER: _bindgen_ty_= 2 =3D 169; +pub const NV_VGPU_MSG_FUNCTION_CTRL_EVENT_BUFFER_UPDATE_GET: _bindgen_ty_2= =3D 170; +pub const NV_VGPU_MSG_FUNCTION_GET_PLCABLE_ADDRESS_KIND: _bindgen_ty_2 =3D= 171; +pub const NV_VGPU_MSG_FUNCTION_CTRL_PERF_LIMITS_SET_STATUS_V2: _bindgen_ty= _2 =3D 172; +pub const NV_VGPU_MSG_FUNCTION_CTRL_INTERNAL_SRIOV_PROMOTE_PMA_STREAM: _bi= ndgen_ty_2 =3D 173; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GET_MMU_DEBUG_MODE: _bindgen_ty_2 =3D = 174; +pub const NV_VGPU_MSG_FUNCTION_CTRL_INTERNAL_PROMOTE_FAULT_METHOD_BUFFERS:= _bindgen_ty_2 =3D 175; +pub const NV_VGPU_MSG_FUNCTION_CTRL_FLCN_GET_CTX_BUFFER_SIZE: _bindgen_ty_= 2 =3D 176; +pub const NV_VGPU_MSG_FUNCTION_CTRL_FLCN_GET_CTX_BUFFER_INFO: _bindgen_ty_= 2 =3D 177; +pub const NV_VGPU_MSG_FUNCTION_DISABLE_CHANNELS: _bindgen_ty_2 =3D 178; +pub const NV_VGPU_MSG_FUNCTION_CTRL_FABRIC_MEMORY_DESCRIBE: _bindgen_ty_2 = =3D 179; +pub const NV_VGPU_MSG_FUNCTION_CTRL_FABRIC_MEM_STATS: _bindgen_ty_2 =3D 18= 0; +pub const NV_VGPU_MSG_FUNCTION_SAVE_HIBERNATION_DATA: _bindgen_ty_2 =3D 18= 1; +pub const NV_VGPU_MSG_FUNCTION_RESTORE_HIBERNATION_DATA: _bindgen_ty_2 =3D= 182; +pub const NV_VGPU_MSG_FUNCTION_CTRL_INTERNAL_MEMSYS_SET_ZBC_REFERENCED: _b= indgen_ty_2 =3D 183; +pub const NV_VGPU_MSG_FUNCTION_CTRL_EXEC_PARTITIONS_CREATE: _bindgen_ty_2 = =3D 184; +pub const NV_VGPU_MSG_FUNCTION_CTRL_EXEC_PARTITIONS_DELETE: _bindgen_ty_2 = =3D 185; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GPFIFO_GET_WORK_SUBMIT_TOKEN: _bindgen= _ty_2 =3D 186; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GPFIFO_SET_WORK_SUBMIT_TOKEN_NOTIF_IND= EX: _bindgen_ty_2 =3D 187; +pub const NV_VGPU_MSG_FUNCTION_PMA_SCRUBBER_SHARED_BUFFER_GUEST_PAGES_OPER= ATION: _bindgen_ty_2 =3D + 188; +pub const NV_VGPU_MSG_FUNCTION_CTRL_MASTER_GET_VIRTUAL_FUNCTION_ERROR_CONT= _INTR_MASK: + _bindgen_ty_2 =3D 189; +pub const NV_VGPU_MSG_FUNCTION_SET_SYSMEM_DIRTY_PAGE_TRACKING_BUFFER: _bin= dgen_ty_2 =3D 190; +pub const NV_VGPU_MSG_FUNCTION_CTRL_SUBDEVICE_GET_P2P_CAPS: _bindgen_ty_2 = =3D 191; +pub const NV_VGPU_MSG_FUNCTION_CTRL_BUS_SET_P2P_MAPPING: _bindgen_ty_2 =3D= 192; +pub const NV_VGPU_MSG_FUNCTION_CTRL_BUS_UNSET_P2P_MAPPING: _bindgen_ty_2 = =3D 193; +pub const NV_VGPU_MSG_FUNCTION_CTRL_FLA_SETUP_INSTANCE_MEM_BLOCK: _bindgen= _ty_2 =3D 194; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GPU_MIGRATABLE_OPS: _bindgen_ty_2 =3D = 195; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GET_TOTAL_HS_CREDITS: _bindgen_ty_2 = =3D 196; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GET_HS_CREDITS: _bindgen_ty_2 =3D 197; +pub const NV_VGPU_MSG_FUNCTION_CTRL_SET_HS_CREDITS: _bindgen_ty_2 =3D 198; +pub const NV_VGPU_MSG_FUNCTION_CTRL_PM_AREA_PC_SAMPLER: _bindgen_ty_2 =3D = 199; +pub const NV_VGPU_MSG_FUNCTION_INVALIDATE_TLB: _bindgen_ty_2 =3D 200; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GPU_QUERY_ECC_STATUS: _bindgen_ty_2 = =3D 201; +pub const NV_VGPU_MSG_FUNCTION_ECC_NOTIFIER_WRITE_ACK: _bindgen_ty_2 =3D 2= 02; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_GET_MODE_MMU_DEBUG: _bindgen_ty_2 = =3D 203; +pub const NV_VGPU_MSG_FUNCTION_RM_API_CONTROL: _bindgen_ty_2 =3D 204; +pub const NV_VGPU_MSG_FUNCTION_CTRL_CMD_INTERNAL_GPU_START_FABRIC_PROBE: _= bindgen_ty_2 =3D 205; +pub const NV_VGPU_MSG_FUNCTION_CTRL_NVLINK_GET_INBAND_RECEIVED_DATA: _bind= gen_ty_2 =3D 206; +pub const NV_VGPU_MSG_FUNCTION_GET_STATIC_DATA: _bindgen_ty_2 =3D 207; +pub const NV_VGPU_MSG_FUNCTION_RESERVED_208: _bindgen_ty_2 =3D 208; +pub const NV_VGPU_MSG_FUNCTION_CTRL_GPU_GET_INFO_V2: _bindgen_ty_2 =3D 209; +pub const NV_VGPU_MSG_FUNCTION_GET_BRAND_CAPS: _bindgen_ty_2 =3D 210; +pub const NV_VGPU_MSG_FUNCTION_CTRL_CMD_NVLINK_INBAND_SEND_DATA: _bindgen_= ty_2 =3D 211; +pub const NV_VGPU_MSG_FUNCTION_UPDATE_GPM_GUEST_BUFFER_INFO: _bindgen_ty_2= =3D 212; +pub const NV_VGPU_MSG_FUNCTION_CTRL_CMD_INTERNAL_CONTROL_GSP_TRACE: _bindg= en_ty_2 =3D 213; +pub const NV_VGPU_MSG_FUNCTION_CTRL_SET_ZBC_STENCIL_CLEAR: _bindgen_ty_2 = =3D 214; +pub const NV_VGPU_MSG_FUNCTION_CTRL_SUBDEVICE_GET_VGPU_HEAP_STATS: _bindge= n_ty_2 =3D 215; +pub const NV_VGPU_MSG_FUNCTION_CTRL_SUBDEVICE_GET_LIBOS_HEAP_STATS: _bindg= en_ty_2 =3D 216; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_SET_MODE_MMU_GCC_DEBUG: _bindgen_t= y_2 =3D 217; +pub const NV_VGPU_MSG_FUNCTION_CTRL_DBG_GET_MODE_MMU_GCC_DEBUG: _bindgen_t= y_2 =3D 218; +pub const NV_VGPU_MSG_FUNCTION_CTRL_RESERVE_HES: _bindgen_ty_2 =3D 219; +pub const NV_VGPU_MSG_FUNCTION_CTRL_RELEASE_HES: _bindgen_ty_2 =3D 220; +pub const NV_VGPU_MSG_FUNCTION_CTRL_RESERVE_CCU_PROF: _bindgen_ty_2 =3D 22= 1; +pub const NV_VGPU_MSG_FUNCTION_CTRL_RELEASE_CCU_PROF: _bindgen_ty_2 =3D 22= 2; +pub const NV_VGPU_MSG_FUNCTION_RESERVED: _bindgen_ty_2 =3D 223; +pub const NV_VGPU_MSG_FUNCTION_CTRL_CMD_GET_CHIPLET_HS_CREDIT_POOL: _bindg= en_ty_2 =3D 224; +pub const NV_VGPU_MSG_FUNCTION_CTRL_CMD_GET_HS_CREDITS_MAPPING: _bindgen_t= y_2 =3D 225; +pub const NV_VGPU_MSG_FUNCTION_CTRL_EXEC_PARTITIONS_EXPORT: _bindgen_ty_2 = =3D 226; +pub const NV_VGPU_MSG_FUNCTION_NUM_FUNCTIONS: _bindgen_ty_2 =3D 227; +pub type _bindgen_ty_2 =3D ffi::c_uint; +pub const NV_VGPU_MSG_EVENT_FIRST_EVENT: _bindgen_ty_3 =3D 4096; +pub const NV_VGPU_MSG_EVENT_GSP_INIT_DONE: _bindgen_ty_3 =3D 4097; +pub const NV_VGPU_MSG_EVENT_GSP_RUN_CPU_SEQUENCER: _bindgen_ty_3 =3D 4098; +pub const NV_VGPU_MSG_EVENT_POST_EVENT: _bindgen_ty_3 =3D 4099; +pub const NV_VGPU_MSG_EVENT_RC_TRIGGERED: _bindgen_ty_3 =3D 4100; +pub const NV_VGPU_MSG_EVENT_MMU_FAULT_QUEUED: _bindgen_ty_3 =3D 4101; +pub const NV_VGPU_MSG_EVENT_OS_ERROR_LOG: _bindgen_ty_3 =3D 4102; +pub const NV_VGPU_MSG_EVENT_RG_LINE_INTR: _bindgen_ty_3 =3D 4103; +pub const NV_VGPU_MSG_EVENT_GPUACCT_PERFMON_UTIL_SAMPLES: _bindgen_ty_3 = =3D 4104; +pub const NV_VGPU_MSG_EVENT_SIM_READ: _bindgen_ty_3 =3D 4105; +pub const NV_VGPU_MSG_EVENT_SIM_WRITE: _bindgen_ty_3 =3D 4106; +pub const NV_VGPU_MSG_EVENT_SEMAPHORE_SCHEDULE_CALLBACK: _bindgen_ty_3 =3D= 4107; +pub const NV_VGPU_MSG_EVENT_UCODE_LIBOS_PRINT: _bindgen_ty_3 =3D 4108; +pub const NV_VGPU_MSG_EVENT_VGPU_GSP_PLUGIN_TRIGGERED: _bindgen_ty_3 =3D 4= 109; +pub const NV_VGPU_MSG_EVENT_PERF_GPU_BOOST_SYNC_LIMITS_CALLBACK: _bindgen_= ty_3 =3D 4110; +pub const NV_VGPU_MSG_EVENT_PERF_BRIDGELESS_INFO_UPDATE: _bindgen_ty_3 =3D= 4111; +pub const NV_VGPU_MSG_EVENT_VGPU_CONFIG: _bindgen_ty_3 =3D 4112; +pub const NV_VGPU_MSG_EVENT_DISPLAY_MODESET: _bindgen_ty_3 =3D 4113; +pub const NV_VGPU_MSG_EVENT_EXTDEV_INTR_SERVICE: _bindgen_ty_3 =3D 4114; +pub const NV_VGPU_MSG_EVENT_NVLINK_INBAND_RECEIVED_DATA_256: _bindgen_ty_3= =3D 4115; +pub const NV_VGPU_MSG_EVENT_NVLINK_INBAND_RECEIVED_DATA_512: _bindgen_ty_3= =3D 4116; +pub const NV_VGPU_MSG_EVENT_NVLINK_INBAND_RECEIVED_DATA_1024: _bindgen_ty_= 3 =3D 4117; +pub const NV_VGPU_MSG_EVENT_NVLINK_INBAND_RECEIVED_DATA_2048: _bindgen_ty_= 3 =3D 4118; +pub const NV_VGPU_MSG_EVENT_NVLINK_INBAND_RECEIVED_DATA_4096: _bindgen_ty_= 3 =3D 4119; +pub const NV_VGPU_MSG_EVENT_TIMED_SEMAPHORE_RELEASE: _bindgen_ty_3 =3D 412= 0; +pub const NV_VGPU_MSG_EVENT_NVLINK_IS_GPU_DEGRADED: _bindgen_ty_3 =3D 4121; +pub const NV_VGPU_MSG_EVENT_PFM_REQ_HNDLR_STATE_SYNC_CALLBACK: _bindgen_ty= _3 =3D 4122; +pub const NV_VGPU_MSG_EVENT_NVLINK_FAULT_UP: _bindgen_ty_3 =3D 4123; +pub const NV_VGPU_MSG_EVENT_GSP_LOCKDOWN_NOTICE: _bindgen_ty_3 =3D 4124; +pub const NV_VGPU_MSG_EVENT_MIG_CI_CONFIG_UPDATE: _bindgen_ty_3 =3D 4125; +pub const NV_VGPU_MSG_EVENT_UPDATE_GSP_TRACE: _bindgen_ty_3 =3D 4126; +pub const NV_VGPU_MSG_EVENT_NVLINK_FATAL_ERROR_RECOVERY: _bindgen_ty_3 =3D= 4127; +pub const NV_VGPU_MSG_EVENT_GSP_POST_NOCAT_RECORD: _bindgen_ty_3 =3D 4128; +pub const NV_VGPU_MSG_EVENT_FECS_ERROR: _bindgen_ty_3 =3D 4129; +pub const NV_VGPU_MSG_EVENT_RECOVERY_ACTION: _bindgen_ty_3 =3D 4130; +pub const NV_VGPU_MSG_EVENT_NUM_EVENTS: _bindgen_ty_3 =3D 4131; +pub type _bindgen_ty_3 =3D ffi::c_uint; +#[repr(C)] +#[derive(Copy, Clone)] +pub union rpc_message_rpc_union_field_v03_00 { + pub spare: u32_, + pub cpuRmGfid: u32_, +} +impl Default for rpc_message_rpc_union_field_v03_00 { + fn default() -> Self { + let mut s =3D ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +pub type rpc_message_rpc_union_field_v =3D rpc_message_rpc_union_field_v03= _00; +#[repr(C)] +pub struct rpc_message_header_v03_00 { + pub header_version: u32_, + pub signature: u32_, + pub length: u32_, + pub function: u32_, + pub rpc_result: u32_, + pub rpc_result_private: u32_, + pub sequence: u32_, + pub u: rpc_message_rpc_union_field_v, + pub rpc_message_data: __IncompleteArrayField, +} +impl Default for rpc_message_header_v03_00 { + fn default() -> Self { + let mut s =3D ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +pub type rpc_message_header_v =3D rpc_message_header_v03_00; #[repr(C)] #[derive(Copy, Clone)] pub struct GspFwWprMeta { @@ -145,3 +482,40 @@ pub struct LibosMemoryRegionInitArgument { pub loc: u8_, pub __bindgen_padding_0: [u8; 6usize], } +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct msgqTxHeader { + pub version: u32_, + pub size: u32_, + pub msgSize: u32_, + pub msgCount: u32_, + pub writePtr: u32_, + pub flags: u32_, + pub rxHdrOff: u32_, + pub entryOff: u32_, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct msgqRxHeader { + pub readPtr: u32_, +} +#[repr(C)] +#[repr(align(8))] +pub struct GSP_MSG_QUEUE_ELEMENT { + pub authTagBuffer: [u8_; 16usize], + pub aadBuffer: [u8_; 16usize], + pub checkSum: u32_, + pub seqNum: u32_, + pub elemCount: u32_, + pub __bindgen_padding_0: [u8; 4usize], + pub rpc: rpc_message_header_v, +} +impl Default for GSP_MSG_QUEUE_ELEMENT { + fn default() -> Self { + let mut s =3D ::core::mem::MaybeUninit::::uninit(); + unsafe { + ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} --=20 2.50.1 From nobody Sat Feb 7 19:45:37 2026 Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11011070.outbound.protection.outlook.com [52.101.62.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF8B81E0DD9; Wed, 8 Oct 2025 00:13:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.62.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882424; cv=fail; b=u493C5pL5TpMq/K1SrqQAkIHqVJamfkG6ZQlNmWnoRh8/jKMQ9UZ0He9jltbfUluUA7ghwMbOi2RdeVWMz5HrfE5BVMwlvs9mYi+lTXKl6ZjTrZ8cxW8uDIULtQy9wcaboE7dy2wGAegiXcjWJcL/O0IYNUFPOcrO7oJa4QtGJ4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882424; c=relaxed/simple; bh=A/++y1V/ko1SofzvLUYHXnwxSaxYsjnE7Eb+tvX5Cx4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=sHhtijAHcgn9tORlcAEChT0xr/KGyMYH04VJZepGbn0KzvCkiuzaLck0P/7eS/wSWckCxN4D570HELVAM86vYuOjUqHhTs6aRjQd+be47sx02tMBRi2QX+Bxb3O60JtRt+YtRmogb5MToDLg/9cg2OmXQ5nqJasTpj1PNA0svm8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=LE7ulsh+; arc=fail smtp.client-ip=52.101.62.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="LE7ulsh+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fX1y9JvcW4EiCyR8YzlhL+zYVeUpR2sEmaZJPETjV+edr+j6lTxyAziBdqdfvz12t3mP9QjO/Dyo3l7+8q5pzIDUU4eTpUJhZ5/owsdkEjJ2E0CTughw0Xqa9ywCYsueVXQDKpuBnwLvSN2D8Scj9OQ1/QJ5a0LtNqcYT1XuVjza3NS96Oi0BK1v0ERasTsyvykx5axtwgG8v5k2VzElTx6WO3fN/kc3tOWSWG8jRPoRxtf/ZZut9UNcFP3sDwLu8s6p7EbACyJjxAVOiwyzwXiWrtG041kE6X5PIid0a+u4jVSpFa2KrJgDD75OmXJtI9nBa8Ez4wHAz+GwAKuwhQ== 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=xofCYcLP4TjhR+s/JRcUJXvTCoxdHkhTOy1x/jKO7OA=; b=kPFkzw7ixk/lJUWiD1Up0OzDtJM+epHSIQLjr1V798bEkdan2HqxWjqie6FiOxp4ebKenxj2x2uYB4Rltd2claPb6iWzHmgV625xmwXuE8HDQR8Tu4t8qF2JE9b4cJ+nYdvwNZ9aT30DOy55xl8x9ctVC/pi1gFuHuLOB7ewMriN6W7EhXibweDXHn9YgbSmIlSHVwLlcPjuv/JqYPyNUl4EXRx1heYdoHs+TJnd1xWdRRK5m8bGLwqx0/51Fm112x0kpnXEKiLYtYNp/CJXp3sn1b640ZdUAjb+IJxTxmtQwTQTaven6WiiHuMDMc7GP9VRs8RPAw11MgNJS+3bQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xofCYcLP4TjhR+s/JRcUJXvTCoxdHkhTOy1x/jKO7OA=; b=LE7ulsh+NNuCV6WymI5BrJ2+5kJJlLqVeb2DoV1bMWv0sSmNBlWWHRKv514OAtgw+dezb4OGHS64E1zhRXR0eMpPYAj86W5bCGZISYUY1ZzIZsPMd0w16CGl9lM5nMiWyT0Na32iscipgI/7xZYq605UG7KePFVdMPetrszUnIOUN2RgDEa31n6vVzCteuxXXV5Sh7LigdvwXLIBL1V6B5BNDGifQtH7GVlppvENGcrOTzw4rFaHV7wuG6XMm8H1pv/hV+ZGYI12XXXUTmR9/8roIBlsbYrH4OB4128oAadr01F8/m7buFQEXqMCTk+ViCB+7vxqrFIAJvFONMdu3A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:13:32 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:13:32 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org Subject: [PATCH v4 06/13] gpu: nova-core: gsp: Add GSP command queue handling Date: Wed, 8 Oct 2025 11:12:45 +1100 Message-ID: <20251008001253.437911-7-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SY6PR01CA0062.ausprd01.prod.outlook.com (2603:10c6:10:ea::13) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: 170b6927-c91e-40da-8f8c-08de05ff83d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?OJldByYDPhN1Z2Zc5hRbrATLAiit80DlCiI3q3oFZT8TMEak4mfaSwsOkF6K?= =?us-ascii?Q?xi5QfCJzZ/RJMpnh4BEnNRFWdenMQ9INJWaICiPPo30o/esobDT+AUDh3Z2D?= =?us-ascii?Q?Ac7uQXzHpK3UCKrNFO8my8zy62FPLHgzw6JIOEx8x3mkSIsobQBT9zYN2gwF?= =?us-ascii?Q?Txg/fVFcDnGht7JBc+nuugLAqdL60RYE+J+Xe5VSgd0I53lPjO5DVekIb1TD?= =?us-ascii?Q?N4/wMRiozuRqEYTR054oCMOsABi5hEiHLwliQgk+63PAi9pAaA5Hh2XIvpVh?= =?us-ascii?Q?7IFoVTGhmhjT+NkLKNKtX6OpqOQaHTFSAHKSzKJfRsQ9O5V5N8Tl+KC517CM?= =?us-ascii?Q?cd2niamogG+yLLxwaCHFTwdX7MgPez2JiD8u5PsbV2cS+DiSoIoGZj9MsEeU?= =?us-ascii?Q?H1MQlZwzOkLxaaeFPUNVx6JL4ug9ImHbJWczZJ5hD0fN7TvhfuROA7GaKcGe?= =?us-ascii?Q?LnDqntino5yznZRFzAyJhOpKB8FjV88DUvV1YHlkP9a8jcZD1xWTC+8fr37j?= =?us-ascii?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YRL57X2?= =?us-ascii?Q?O9vMRTZh72VYs26J7prDT0r9HCSbDGFLv4cgxX/ccCrvjCa1fjxpJw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?wc63wUTuVOHJzgQ5shN1OV3iwRae5jlibDSrAtL8xqCd2zOEcdmlLRC7Kgn3?= =?us-ascii?Q?aPY9ph7NGTtp+c/KAh5B8ujsMUnXMb0DQ5rdoVM9hE+GgtRXsk3XSrD12ZaE?= =?us-ascii?Q?OMI4rWhhdLtVhWFt3zdAEKux/BbH6geQO1U9+vs/sBEkbP1yumch9LH5Xji1?= =?us-ascii?Q?fnZjRWQI3aJS7GZ951P79jdwehfFCroACBCq5iE1Ta0GL1OP9pBF2R1DjKGe?= =?us-ascii?Q?ksVtK3aqtGTams+tqiArorSJBqKlHyon4VZ0PW0OypUFNRKpzeQqsDqFc430?= =?us-ascii?Q?VrscjL1NbBa9ZJg9diXOx3IZw5dqTHI/6gUKuqthbVTd2YaIAj90f4vHPUFr?= =?us-ascii?Q?FXMDGrhIrz4gSEbVELdJQBniaqkYCR/6jzYhIqwoS0oFenKvnUXVD96Oftvd?= =?us-ascii?Q?mxUtcj//I6fWWz9m6V0TvE4z42y3jVADIkNDr59fhKtI6TORmMs+/URK4bl5?= =?us-ascii?Q?NuyVE/h+Q2J+mz3ydbgzbGd7FDcJaL7FLR35Hnyq2+/kIvZZftT/Fw4emFAA?= =?us-ascii?Q?mfDzHrAmcQSf/qsJH7MS/tAEa4jfmZQad7qaxupEEquupXjm16H6BhQ57khA?= =?us-ascii?Q?wKTaq8xre02BZbTmSBRXdtI7Va0j6uUSJOQS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gPwF4VzUDYK4RqEMPam8Hq1gdAe5pbDp5i9Z9eRrgoa0aL?= =?us-ascii?Q?pKV89rk77jHLvPaQXV2L3Sq5m88AchubtBajPVOW?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 170b6927-c91e-40da-8f8c-08de05ff83d6 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:13:32.5336 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oEC4pbbm/kUWyCSXfsLf3tn75LfGikclqhUhjRWzQ5SlsFGRtCepVuAzQlnR9C7TF7HYPFKZ6HBZfTUmaugajA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Content-Type: text/plain; charset="utf-8" This commit introduces core infrastructure for handling GSP command and message queues in the nova-core driver. The command queue system enables bidirectional communication between the host driver and GSP firmware through a remote message passing interface. The interface is based on passing serialised data structures over a ring buffer with separate transmit and receive queues. Commands are sent by writing to the CPU transmit queue and waiting for completion via the receive queue. To ensure safety mutable or immutable (depending on whether it is a send or receive operation) references are taken on the command queue when allocating the message to write/read to. This ensures message memory remains valid and the command queue can't be mutated whilst an operation is in progress. Currently this is only used by the probe() routine and therefore can only used by a single thread of execution. Locking to enable safe access from multiple threads will be introduced in a future series when that becomes necessary. Signed-off-by: Alistair Popple --- Changes for v4: - Use read_poll_timeout() instead of wait_on() - Switch to using `init!` (Thanks Alex for figuring out the required workarounds) - Pass the enum type into the RPC bindings instead of a raw u32 - Fixup the TODOs for extracting/allocating the send command regions - Split the sending functions into one taking just a command struct and another taking a command struct with extra payload Changes for v3: - Reduce the receive payloads to the correct size - Use opaque bindings - Clean up of the command queue PTE creation - Add an enum for the GSP functions - Rename GspCommandToGsp and GspMessageFromGsp - Rename GspCmdq - Add function to notify GSP of updated queue pointers - Inline driver area access functions - Fixup receive area calculations Changes for v2: - Rebased on Alex's latest series --- drivers/gpu/nova-core/gsp.rs | 9 + drivers/gpu/nova-core/gsp/cmdq.rs | 493 ++++++++++++++++++++++++++++++ drivers/gpu/nova-core/regs.rs | 4 + drivers/gpu/nova-core/sbuffer.rs | 2 - scripts/Makefile.build | 2 +- 5 files changed, 507 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/nova-core/gsp/cmdq.rs diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs index fc8fe6ffe439..ba385114498c 100644 --- a/drivers/gpu/nova-core/gsp.rs +++ b/drivers/gpu/nova-core/gsp.rs @@ -2,6 +2,7 @@ =20 mod boot; =20 +use kernel::alloc::flags::GFP_KERNEL; use kernel::device; use kernel::dma::CoherentAllocation; use kernel::dma::DmaAddress; @@ -12,6 +13,7 @@ use kernel::transmute::AsBytes; =20 use crate::fb::FbLayout; +use crate::gsp::cmdq::Cmdq; =20 pub(crate) use fw::{GspFwWprMeta, LibosParams}; =20 @@ -19,6 +21,8 @@ =20 use fw::LibosMemoryRegionInitArgument; =20 +pub(crate) mod cmdq; + pub(crate) const GSP_PAGE_SHIFT: usize =3D 12; pub(crate) const GSP_PAGE_SIZE: usize =3D 1 << GSP_PAGE_SHIFT; pub(crate) const GSP_HEAP_ALIGNMENT: Alignment =3D Alignment::new::<{ 1 <<= 20 }>(); @@ -33,6 +37,7 @@ pub(crate) struct Gsp { pub loginit: CoherentAllocation, pub logintr: CoherentAllocation, pub logrm: CoherentAllocation, + pub cmdq: Cmdq, } =20 #[repr(C)] @@ -87,11 +92,15 @@ pub(crate) fn new(pdev: &pci::Device) ->= Result() =3D=3D GSP_PAGE_SIZE); + +// There is no struct defined for this in the open-gpu-kernel-source heade= rs. +// Instead it is defined by code in GspMsgQueuesInit(). +#[repr(C)] +struct Msgq { + tx: MsgqTxHeader, + rx: MsgqRxHeader, + msgq: MsgqData, +} + +#[repr(C)] +struct GspMem { + ptes: PteArray<{ GSP_PAGE_SIZE / size_of::() }>, + cpuq: Msgq, + gspq: Msgq, +} + +// SAFETY: These structs don't meet the no-padding requirements of AsBytes= but +// that is not a problem because they are not used outside the kernel. +unsafe impl AsBytes for GspMem {} + +// SAFETY: These structs don't meet the no-padding requirements of FromByt= es but +// that is not a problem because they are not used outside the kernel. +unsafe impl FromBytes for GspMem {} + +/// `GspMem` struct that is shared with the GSP. +struct DmaGspMem(CoherentAllocation); + +impl DmaGspMem { + fn new(dev: &device::Device) -> Result { + const MSGQ_SIZE: u32 =3D size_of::() as u32; + const RX_HDR_OFF: u32 =3D offset_of!(Msgq, rx) as u32; + + let gsp_mem =3D + CoherentAllocation::::alloc_coherent(dev, 1, GFP_KERNE= L | __GFP_ZERO)?; + dma_write!(gsp_mem[0].ptes =3D PteArray::new(gsp_mem.dma_handle())= )?; + dma_write!(gsp_mem[0].cpuq.tx =3D MsgqTxHeader::new(MSGQ_SIZE, RX_= HDR_OFF, MSGQ_NUM_PAGES))?; + dma_write!(gsp_mem[0].cpuq.rx =3D MsgqRxHeader::new())?; + + Ok(Self(gsp_mem)) + } + + // Allocates the various regions for the command and reduces the paylo= ad size + // to match what is needed for the command. + // + // # Errors + // + // Returns `Err(EAGAIN)` if the driver area is too small to hold the + // requested command. + fn allocate_command_regions<'a, M: CommandToGsp>( + &'a mut self, + payload_size: usize, + ) -> Result<(&'a mut GspMsgElement, &'a mut M, &'a mut [u8], &'a mut [= u8])> { + let driver_area =3D self.driver_write_area(); + let msg_size =3D size_of::() + size_of::() + pay= load_size; + let driver_area_size =3D (driver_area.0.len() + driver_area.1.len(= )) << GSP_PAGE_SHIFT; + + if msg_size > driver_area_size { + return Err(EAGAIN); + } + + #[allow(clippy::incompatible_msrv)] + let (msg_header_slice, slice_1) =3D driver_area + .0 + .as_flattened_mut() + .split_at_mut(size_of::()); + let msg_header =3D GspMsgElement::from_bytes_mut(msg_header_slice)= .ok_or(EINVAL)?; + let (cmd_slice, payload_1) =3D slice_1.split_at_mut(size_of::()= ); + let cmd =3D M::from_bytes_mut(cmd_slice).ok_or(EINVAL)?; + + #[allow(clippy::incompatible_msrv)] + let payload_2 =3D driver_area.1.as_flattened_mut(); + + let (payload_1, payload_2) =3D if payload_1.len() > payload_size { + // Payload fits entirely in payload_1 + (&mut payload_1[..payload_size], &mut payload_2[0..0]) + } else { + // Need all of payload_1 and some of payload_2 + let payload_2_len =3D payload_size - payload_1.len(); + (payload_1, &mut payload_2[..payload_2_len]) + }; + + Ok((msg_header, cmd, payload_1, payload_2)) + } + + fn driver_write_area(&mut self) -> (&mut [[u8; GSP_PAGE_SIZE]], &mut [= [u8; GSP_PAGE_SIZE]]) { + let tx =3D self.cpu_write_ptr() as usize; + let rx =3D self.gsp_read_ptr() as usize; + + // SAFETY: + // - The [`CoherentAllocation`] contains exactly one object. + // - We will only access the driver-owned part of the shared memor= y. + // - Per the safety statement of the function, no concurrent acces= s wil be performed. + let gsp_mem =3D &mut unsafe { self.0.as_slice_mut(0, 1) }.unwrap()= [0]; + let (before_tx, after_tx) =3D gsp_mem.cpuq.msgq.data.split_at_mut(= tx); + + if rx <=3D tx { + // The area from `tx` up to the end of the ring, and from the = beginning of the ring up + // to `rx`, minus one unit, belongs to the driver. + if rx =3D=3D 0 { + let last =3D after_tx.len() - 1; + (&mut after_tx[..last], &mut before_tx[0..0]) + } else { + (after_tx, &mut before_tx[..rx]) + } + } else { + // The area from `tx` to `rx`, minus one unit, belongs to the = driver. + (after_tx.split_at_mut(rx - tx).0, &mut before_tx[0..0]) + } + } + + fn driver_read_area(&self) -> (&[[u8; GSP_PAGE_SIZE]], &[[u8; GSP_PAGE= _SIZE]]) { + let tx =3D self.gsp_write_ptr() as usize; + let rx =3D self.cpu_read_ptr() as usize; + + // SAFETY: + // - The [`CoherentAllocation`] contains exactly one object. + // - We will only access the driver-owned part of the shared memor= y. + // - Per the safety statement of the function, no concurrent acces= s wil be performed. + let gsp_mem =3D &unsafe { self.0.as_slice(0, 1) }.unwrap()[0]; + let (before_rx, after_rx) =3D gsp_mem.gspq.msgq.data.split_at(rx); + + if tx =3D=3D rx { + (&after_rx[0..0], &after_rx[0..0]) + } else if tx > rx { + (&after_rx[..tx], &before_rx[0..0]) + } else { + (after_rx, &before_rx[..tx]) + } + } + + fn gsp_write_ptr(&self) -> u32 { + let gsp_mem =3D self.0.start_ptr(); + + // SAFETY: + // - The ['CoherentAllocation'] contains at least one object. + // - By the invariants of CoherentAllocation the pointer is valid. + (unsafe { (*gsp_mem).gspq.tx.write_ptr() } % MSGQ_NUM_PAGES) + // dma_read!(gsp_mem[0].gspq.tx.writePtr).unwrap() % MSGQ_NUM_PAGES + } + + fn gsp_read_ptr(&self) -> u32 { + let gsp_mem =3D self.0.start_ptr(); + + // SAFETY: + // - The ['CoherentAllocation'] contains at least one object. + // - By the invariants of CoherentAllocation the pointer is valid. + (unsafe { (*gsp_mem).gspq.rx.read_ptr() } % MSGQ_NUM_PAGES) + } + + fn cpu_read_ptr(&self) -> u32 { + let gsp_mem =3D self.0.start_ptr(); + + // SAFETY: + // - The ['CoherentAllocation'] contains at least one object. + // - By the invariants of CoherentAllocation the pointer is valid. + (unsafe { (*gsp_mem).cpuq.rx.read_ptr() } % MSGQ_NUM_PAGES) + } + + /// Inform the GSP that it can send `elem_count` new pages into the me= ssage queue. + fn advance_cpu_read_ptr(&mut self, elem_count: u32) { + // let gsp_mem =3D &self.0; + let rptr =3D self.cpu_read_ptr().wrapping_add(elem_count) % MSGQ_N= UM_PAGES; + + // Ensure read pointer is properly ordered + fence(Ordering::SeqCst); + + let gsp_mem =3D self.0.start_ptr_mut(); + + // SAFETY: + // - The ['CoherentAllocation'] contains at least one object. + // - By the invariants of CoherentAllocation the pointer is valid. + unsafe { (*gsp_mem).cpuq.rx.set_read_ptr(rptr) }; + } + + fn cpu_write_ptr(&self) -> u32 { + let gsp_mem =3D self.0.start_ptr(); + + // SAFETY: + // - The ['CoherentAllocation'] contains at least one object. + // - By the invariants of CoherentAllocation the pointer is valid. + (unsafe { (*gsp_mem).cpuq.tx.write_ptr() } % MSGQ_NUM_PAGES) + } + + /// Inform the GSP that it can process `elem_count` new pages from the= command queue. + fn advance_cpu_write_ptr(&mut self, elem_count: u32) { + let wptr =3D self.cpu_write_ptr().wrapping_add(elem_count) & MSGQ_= NUM_PAGES; + let gsp_mem =3D self.0.start_ptr_mut(); + + // SAFETY: + // - The ['CoherentAllocation'] contains at least one object. + // - By the invariants of CoherentAllocation the pointer is valid. + unsafe { (*gsp_mem).cpuq.tx.set_write_ptr(wptr) }; + + // Ensure all command data is visible before triggering the GSP re= ad + fence(Ordering::SeqCst); + } +} + +pub(crate) struct Cmdq { + dev: ARef, + seq: u32, + gsp_mem: DmaGspMem, + pub _nr_ptes: u32, +} + +impl Cmdq { + pub(crate) fn new(dev: &device::Device) -> Result= { + let gsp_mem =3D DmaGspMem::new(dev)?; + let nr_ptes =3D size_of::() >> GSP_PAGE_SHIFT; + build_assert!(nr_ptes * size_of::() <=3D GSP_PAGE_SIZE); + + Ok(Cmdq { + dev: dev.into(), + seq: 0, + gsp_mem, + _nr_ptes: nr_ptes as u32, + }) + } + + fn calculate_checksum>(it: T) -> u32 { + let sum64 =3D it + .enumerate() + .map(|(idx, byte)| (((idx % 8) * 8) as u32, byte)) + .fold(0, |acc, (rol, byte)| acc ^ u64::from(byte).rotate_left(= rol)); + + ((sum64 >> 32) as u32) ^ (sum64 as u32) + } + + // Notify GSP that we have updated the command queue pointers. + fn notify_gsp(bar: &Bar0) { + NV_PGSP_QUEUE_HEAD::default().set_address(0).write(bar); + } + + #[expect(unused)] + pub(crate) fn send_gsp_command(&mut self, bar: &Bar0, init: impl= Init) -> Result + where + M: CommandToGsp, + // This allows all error types, including `Infallible`, to be used= with `init`. Without + // this we cannot use regular stack objects as `init` since their = `Init` implementation + // does not return any error. + Error: From, + { + #[repr(C)] + struct FullCommand { + hdr: GspMsgElement, + cmd: M, + } + let (msg_header, cmd, _, _) =3D self.gsp_mem.allocate_command_regi= ons::(0)?; + + let seq =3D self.seq; + let initializer =3D try_init!(FullCommand { + hdr <- GspMsgElement::init(seq, size_of::(), M::FUNCTION), + cmd <- init, + }); + + // Fill the header and command in-place. + // SAFETY: + // - allocate_command_regions guarantees msg_header points to eno= ugh + // space in the command queue to contain FullCommand + // - __init ensures the command header and struct a fully initial= ized + unsafe { + initializer.__init(msg_header.as_bytes_mut().as_mut_ptr().cast= ())?; + } + + msg_header.set_checksum(Cmdq::calculate_checksum(SBuffer::new_read= er([ + msg_header.as_bytes(), + cmd.as_bytes(), + ]))); + + dev_info!( + &self.dev, + "GSP RPC: send: seq# {}, function=3D0x{:x} ({}), length=3D0x{:= x}\n", + self.seq, + msg_header.function_number(), + msg_header.function()?, + msg_header.length(), + ); + + let elem_count =3D msg_header.element_count(); + self.seq +=3D 1; + self.gsp_mem.advance_cpu_write_ptr(elem_count); + Cmdq::notify_gsp(bar); + + Ok(()) + } + + #[expect(unused)] + pub(crate) fn send_gsp_command_with_payload( + &mut self, + bar: &Bar0, + payload_size: usize, + init: impl Init, + init_payload: impl FnOnce(SBuffer>) -> Result, + ) -> Result + where + M: CommandToGspWithPayload, + // This allows all error types, including `Infallible`, to be used= with `init`. Without + // this we cannot use regular stack objects as `init` since their = `Init` implementation + // does not return any error. + Error: From, + { + #[repr(C)] + struct FullCommand { + hdr: GspMsgElement, + cmd: M, + } + let (msg_header, cmd, payload_1, payload_2) =3D + self.gsp_mem.allocate_command_regions::(payload_size)?; + + let seq =3D self.seq; + let initializer =3D try_init!(FullCommand { + hdr <- GspMsgElement::init(seq, size_of::() + payload_size,= M::FUNCTION), + cmd <- init, + }); + + // Fill the header and command in-place. + // SAFETY: + // - allocate_command_regions guarantees msg_header points to eno= ugh + // space in the command queue to contain FullCommand + // - __init ensures the command header and struct a fully initial= ized + unsafe { + initializer.__init(msg_header.as_bytes_mut().as_mut_ptr().cast= ())?; + } + + // Fill the payload + let sbuffer =3D SBuffer::new_writer([&mut payload_1[..], &mut payl= oad_2[..]]); + init_payload(sbuffer)?; + + msg_header.set_checksum(Cmdq::calculate_checksum(SBuffer::new_read= er([ + msg_header.as_bytes(), + cmd.as_bytes(), + payload_1, + payload_2, + ]))); + + dev_info!( + &self.dev, + "GSP RPC: send: seq# {}, function=3D0x{:x} ({}), length=3D0x{:= x}\n", + self.seq, + msg_header.function_number(), + msg_header.function()?, + msg_header.length(), + ); + + let elem_count =3D msg_header.element_count(); + self.seq +=3D 1; + self.gsp_mem.advance_cpu_write_ptr(elem_count); + Cmdq::notify_gsp(bar); + + Ok(()) + } + + #[expect(unused)] + pub(crate) fn receive_msg_from_gsp( + &mut self, + timeout: Delta, + init: impl FnOnce(&M, SBuffer>) ->= Result, + ) -> Result { + let driver_area =3D read_poll_timeout( + || Ok(self.gsp_mem.driver_read_area()), + |driver_area: &(&[[u8; 4096]], &[[u8; 4096]])| !driver_area.0.= is_empty(), + Delta::from_millis(10), + timeout, + )?; + + #[allow(clippy::incompatible_msrv)] + let (msg_header_slice, slice_1) =3D driver_area + .0 + .as_flattened() + .split_at(size_of::()); + let msg_header =3D GspMsgElement::from_bytes(msg_header_slice).ok_= or(EIO)?; + if msg_header.length() < size_of::() as u32 { + return Err(EIO); + } + + let function: MsgFunction =3D msg_header.function().map_err(|_| { + dev_info!( + self.dev, + "GSP RPC: receive: seq# {}, bad function=3D0x{:x}, length= =3D0x{:x}\n", + msg_header.sequence(), + msg_header.function_number(), + msg_header.length(), + ); + EIO + })?; + + // Log RPC receive with message type decoding + dev_info!( + self.dev, + "GSP RPC: receive: seq# {}, function=3D0x{:x} ({}), length=3D0= x{:x}\n", + msg_header.sequence(), + msg_header.function_number(), + function, + msg_header.length(), + ); + + let (cmd_slice, payload_1) =3D slice_1.split_at(size_of::()); + #[allow(clippy::incompatible_msrv)] + let payload_2 =3D driver_area.1.as_flattened(); + + // Cut the payload slice(s) down to the actual length of the paylo= ad. + let (cmd_payload_1, cmd_payload_2) =3D + if payload_1.len() > msg_header.length() as usize - size_of::<= M>() { + ( + payload_1 + .split_at(msg_header.length() as usize - size_of::= ()) + .0, + &payload_2[0..0], + ) + } else { + ( + payload_1, + payload_2 + .split_at(msg_header.length() as usize - size_of::= () - payload_1.len()) + .0, + ) + }; + + if Cmdq::calculate_checksum(SBuffer::new_reader([ + msg_header.as_bytes(), + cmd_slice, + cmd_payload_1, + cmd_payload_2, + ])) !=3D 0 + { + dev_err!( + self.dev, + "GSP RPC: receive: Call {} - bad checksum", + msg_header.sequence() + ); + return Err(EIO); + } + + let result =3D if function =3D=3D M::FUNCTION { + let cmd =3D M::from_bytes(cmd_slice).ok_or(EINVAL)?; + let sbuffer =3D SBuffer::new_reader([cmd_payload_1, cmd_payloa= d_2]); + init(cmd, sbuffer) + } else { + Err(ERANGE) + }; + + self.gsp_mem + .advance_cpu_read_ptr(msg_header.length().div_ceil(GSP_PAGE_SI= ZE as u32)); + result + } +} diff --git a/drivers/gpu/nova-core/regs.rs b/drivers/gpu/nova-core/regs.rs index 206dab2e1335..0585699ae951 100644 --- a/drivers/gpu/nova-core/regs.rs +++ b/drivers/gpu/nova-core/regs.rs @@ -71,6 +71,10 @@ pub(crate) fn chipset(self) -> Result { 30:30 ecc_mode_enabled as bool; }); =20 +register!(NV_PGSP_QUEUE_HEAD @ 0x00110c00 { + 31:0 address as u32; +}); + impl NV_PFB_PRI_MMU_LOCAL_MEMORY_RANGE { /// Returns the usable framebuffer size, in bytes. pub(crate) fn usable_fb_size(self) -> u64 { diff --git a/drivers/gpu/nova-core/sbuffer.rs b/drivers/gpu/nova-core/sbuff= er.rs index e82f9d97ad21..bde80cc3fa63 100644 --- a/drivers/gpu/nova-core/sbuffer.rs +++ b/drivers/gpu/nova-core/sbuffer.rs @@ -37,7 +37,6 @@ impl<'a, I> SBuffer where I: Iterator, { - #[expect(unused)] pub(crate) fn new_reader(slices: impl IntoIterator) ->= Self where I: Iterator, @@ -45,7 +44,6 @@ pub(crate) fn new_reader(slices: impl IntoIterator) -> Self Self::new(slices) } =20 - #[expect(unused)] pub(crate) fn new_writer(slices: impl IntoIterator) ->= Self where I: Iterator, diff --git a/scripts/Makefile.build b/scripts/Makefile.build index d0ee33a487be..4ac6304332b6 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -317,7 +317,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE # # Please see https://github.com/Rust-for-Linux/linux/issues/2 for details = on # the unstable features in use. -rust_allowed_features :=3D asm_const,asm_goto,arbitrary_self_types,lint_re= asons,offset_of_nested,raw_ref_op,used_with_arg +rust_allowed_features :=3D asm_const,asm_goto,arbitrary_self_types,lint_re= asons,offset_of_nested,raw_ref_op,used_with_arg,slice_flatten =20 # `--out-dir` is required to avoid temporaries being created by `rustc` in= the # current working directory, which may be not accessible in the out-of-tree --=20 2.50.1 From nobody Sat Feb 7 19:45:37 2026 Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11011048.outbound.protection.outlook.com [52.101.62.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 518BB1F7569; Wed, 8 Oct 2025 00:13:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.62.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882427; cv=fail; b=oeg+6gkCRJnNZ0OMBjXx/VOhHgsy4fRnNiWsIa6HpFgPHIBfUeqr+3nnhV8gbXUJzB8TZlHY8h8H6OMRzYhM+eOfVelkeXdEcCgGGK8pY9LVJtotIK2ZAQ9R/v4dB9Fjm0mD5fHsjuIW2CYiPZek7LblNY9SGHfoSd1In2nQ9MY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882427; c=relaxed/simple; bh=8XGuWZGLwBC3DcpNVKiEbbJysuF76xZalrrji2uCYNs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=lSSdGJQUwp6KyYGESkVzh1b1FOJ3ECG7YHDSf50eka4RvmZlh//PMwgO/hIeZBQc4qQZFvunL4uePOssQXOjcO09c/oHcs8CWw0UvjU9KYA4sbYnQaAgFrMQJ7etigjvnZUtRq4RUHgSxnbIyuGz2OcCxSrRagItLpBOIUwco7g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=dfXZIrbc; arc=fail smtp.client-ip=52.101.62.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="dfXZIrbc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=U2QWfH1AzSP5sdNd+w2YOxDGi8jyYff7SED59T27PTw4ZDRMIicWKbMnQqfdnGUOyUz5Ypu0iu7UX2BFYV5OBnTfMuxqKB2Xie+a3bpKddrjjdMmmjimpPAXKBYJFRAqyMXp+3IznZz3n28swWzYK/oiC9za3f3DbGngwLMxbVJugGCdsxfMt5ev0STcDf6+Lm6xMfueZX32zCRk99ZlQWqGKOHuDNKygUO0deU6FdFtmI5itSmainvbfbdA1ebBvl8wkwIoJWHpeFx4zFgA+cysiYbcNKOsv1V4ETWEMWgVgGhyEGyl/93bchHyxOwrMV9ZsZAaZ9BdwjprUy9+LQ== 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=haj6CmXWFs+KS1ndsFVx69MaimWuE7xOBWVvQg8qyfk=; b=Ze+dQnjCI8OT0T6Cahc5bzFD1CGZ4Hm7jua8fl2DSvjgTxpv1zVduvC7qQ7p8qO8KNSOOU5oSTStLgPhV4iFVZWEeufJOkO5q1rUgjXza/4ksqe+alr9Rywk2eX2YDygW9Io9xDQJETJCi8lhMU9zMgtjlbM23aMmryEnuwMqO1VNNYH+iLdb9kKc7iBQ+GsTLhDYB4s64eHdqtU+GCWlU/u30ggfbUVf2GPiCOIMA4owpD9qB9YNKVlCm/jRffggIgmFVvKnY7QAKEa7XFtWscw0CXqMqyxBJspIIc9FOBxnVeHArC/tPRsbPu8so+kclyXknCYpRlnWgZETWRpYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=haj6CmXWFs+KS1ndsFVx69MaimWuE7xOBWVvQg8qyfk=; b=dfXZIrbcKouRiZsLbHj3dri65I0IEyXPtBEYHmkxgl1efWo0/grZIeC5g+XQK5y9G+GcTMzhfeF7aSwLNDelf0mlXMghn/HoDPkx0T8jYB3lKlR7FZih4pHSzf37x5ISYCSLNsypWMj/81xMg4wsVFBC1BPcF+EXvLGJ0ThyaifoQHZtFnGvNZ3IS3E/u9mICtJa93Cz5dQoiMQtbvgfifift06eukNW7j3q2wxbZbeJXK64lkXcA0SjLfdSznfoDpHuMA591YStm+EqUOUphGPO0ZSnfyyAxPkypGcg5N+oLngQe5CcuahpfH440FCJ/xLBOBrCxZOewqz76f7Qpg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:13:37 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:13:37 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org Subject: [PATCH v4 07/13] gpu: nova-core: gsp: Create rmargs Date: Wed, 8 Oct 2025 11:12:46 +1100 Message-ID: <20251008001253.437911-8-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SY6PR01CA0068.ausprd01.prod.outlook.com (2603:10c6:10:ea::19) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: 71edb129-68c8-45b5-fa37-08de05ff871c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?28MmmP7PcepEmrwYHPGFUpaVSwDMm0ravEPaBzc0mgwKM+lR1aUEYC9tZ75k?= =?us-ascii?Q?GJdbL4GJSyKg5LsQMLyr4ToBU3uOz4KCQwMAIQnz5jQ5bqi0Cx92krRe2/n6?= =?us-ascii?Q?xHFXgwK8MpKblTPm26QfZadWcHZpr5pbTVpC8oIwDq2MDP88vG8mag3jnq+u?= =?us-ascii?Q?zQpbLKM1ZJQzpPBtlAUliI9HgTcriRF16NGb+KlBSUYbcmInvHPdZSI0xh52?= =?us-ascii?Q?94OyalpxdNFG+1ZWe/E2NdLrWgKavNJ/RqtU0BnEDXr2TZKujpIs8lGCB0MS?= =?us-ascii?Q?X5UCMUCU0nuYYnWeIuicJd79hdgWFHETg7FIBl4OGJclmiQit0kY01BXPl+0?= =?us-ascii?Q?O3PE83hA7f5vVlsNvNsUa/TNYZ0nCfMBpgO9Zz50NisOqhd6ahO8SCpnE+LW?= =?us-ascii?Q?cuiU1LrgAw0UyPOhTo9u3f6nSZSXbyv6dtBesd7WeVUduwAjON9Zz5w9dBZl?= =?us-ascii?Q?7Kf412SkzICxJpcKn5v/wo4CA8ygQkhB7JleKUuBzmOmCJb7tWYF0ZvEEDYF?= =?us-ascii?Q?X3aWCoOs4odksXzRY3BkFl3btT7e0qwaGSeR7FSAS08mWLtyBdRtLCdyQBL8?= =?us-ascii?Q?pzGSJ3S5Lh3gmZRj99jzfQ5s8qlBk5ZjNgi1FPJMxLFfsJ85a4SuGeMcIBqp?= =?us-ascii?Q?KRCTCs42qeR7Qbh36UNzPQPW+25n6suy01h6mt8Irq3aURjJmSZXaOYFU6m6?= =?us-ascii?Q?rEL7Us5QaB/Cvufw2lWOaFRKImXX1/yUN7KO6sRDH6T+O5ptOyTwOJGS9FK8?= =?us-ascii?Q?47xUW6AfVNKfeamGAiGPOIOCpQ7PVgu2kBL+bobCScDX93gyTy4nCQj67LIY?= =?us-ascii?Q?XTggvsrgOjibbz4CKCZQypl3oKU+8aSJsEEPfm21HW0xODiD7MGNAzQtqEqA?= =?us-ascii?Q?txzoarB91AIUsKn7UXctDPgM+3b6wZLImUNwT9NO66P8H5GDheeZL+gbMyOC?= =?us-ascii?Q?Xab0oZWj1EK3HXCuVeddG/xn/Xu6UD11W3XkGwsOX/CgwhqCZuiDw+74Px9F?= =?us-ascii?Q?HGxlgx8vQGKloEZSc+m7cAI9YFo44YccFoylHRIo9AUWX4RvoOS+JGxC6rpE?= =?us-ascii?Q?F528E12sBm2V7u693g/Z3SxHYGkEFIAAWYrLUEpQXcTpQ8zyth/rPamF8Lrd?= =?us-ascii?Q?6xorsPZC8A1QxAgBq0Mnb7ToBDMVLKdU/hUJtdJHpeDMP3WuJQKN3CClsdVm?= =?us-ascii?Q?KXj8pKYtk6xMlsTnejirQ7RRFoLzuHfpcxeJ6YEN+rhkXeklokLT9fND+LFk?= =?us-ascii?Q?/mCE6Q90bTEe+as6B/N5j2qCYFzQmdpy1Q+tNbYXqbnGmY3C0b+LFhyBeYqN?= =?us-ascii?Q?rs38AVdb7J56VDImsGC8N/PXO2qZEEnQqHYVyCc04v+CppMvFqFx2EiMBLhX?= =?us-ascii?Q?b4Jp5PK3f3X1h56I2ukEWWv0bdHDS/bnC1kIbl4uHHr74iqkzGUo3GBVaQAD?= =?us-ascii?Q?yVVOrVhESRPoyznY+mR0TcVvvTTmBn7Q?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4wDYu6B9FEf7OHZYPp08wh5F2PzIJ5H1P9rztcwSLgjwFWpgzOzS5VLSFe/t?= =?us-ascii?Q?B/V47QlCZzUxp1TiExgXKBr+EHw9eQw1xQHX6Rc2N1uf8RKWN4f1cuqaDsxk?= =?us-ascii?Q?ebaBpGrgLQU7T4Besvg8PQZsJo1Z9SteCurkrGvBgtwqElAmxslS4PfyQHxZ?= =?us-ascii?Q?TVCcNfyJpehjoqATmHgLsSM1tsYHIdE018xZ/zZObktPMKbLKeSAp/cbt6Ft?= =?us-ascii?Q?g9eoTUarU448rOVCGPgbRIjsLpmAa76eyNWCskk7cu4/0aY9CYx9wOUjv+dX?= =?us-ascii?Q?UjUnewWJ5GTfRiB08LQZmffSrgduRfmqrojkn8H0JVcV0yYkYloLKbL+Ef8O?= =?us-ascii?Q?NSuZv+YgbeUwC2vUIUqDc9qhBnXX6RTtT9axu8AfGndhfKPkmI84J4k8zqac?= =?us-ascii?Q?Zon1yFvNpSSuSGEaScqj4Gountgzgayi882TASw5RCzLGWjmG7IjlaaLXOuJ?= =?us-ascii?Q?xZV/KPdaQXgphblgJnBsmlt4J8FAtsJuJypEY6/+4Iveze7cgpqgsosIpWO8?= =?us-ascii?Q?GDS7NtD9siS0q34qi6HhP38nFSc2J8Ww1copmXWvaIFYhHW+Xfmvgvl4lKc5?= =?us-ascii?Q?5sRY/1zODOSG7osW/z0hwrOHkTdHaJ7Zdp0ktB4JR9hbIZM+/F058y294Ggu?= =?us-ascii?Q?KbLXEvAxFZ3Zkha0VNBiFARieb7/H6p6BiNW1PzYUflol7/U20zmibgnQ+0Z?= =?us-ascii?Q?r6flvTv/NoFUsvQR1q8QpVIgat1svOqGMJZxkUgU8wCWi9IcwLQk4izfW9dT?= =?us-ascii?Q?fPGM8BMIbALp+cS0hwe84n3jeAdvgAKralS+9dS8y9Xtq+++WB4iQKuHkKUD?= =?us-ascii?Q?LIH+hYmm2DbEIGUYPw9MrGPLsfoymxiiBE9CdNmZ03wCdOslPNZJgf4KEE8U?= =?us-ascii?Q?rZJwVdW3N9qKGfuCpOIbaaF6RzWwGH5jQO5B6BuuVvAPlkEOA22UoIpFpFpI?= =?us-ascii?Q?jWEN5xR7KxIn0UOtST5448YmWHr+acOd5Ty3tl7dzLLUxKUQWCuVK3ZYXWly?= =?us-ascii?Q?KJ3FIoO+0OpVV1SvF0Cq3uLHSR1g5RFxrdD5F3fQr6Yev3JZI4OGcJdno8cs?= =?us-ascii?Q?EE01b144UT8zpEaw51fIGA6enVJ8gGo/0OQdWxFNeCeZNU6u/EtlOxaYt7K0?= =?us-ascii?Q?mELMLIrpFShzsHySBu5+e/dDmGcgMbEKTazrBo7gcXbjknK/FpNCh5DxDz03?= =?us-ascii?Q?su4I9H5g8CTANtWHc4y9Ikhr2mc/apPfJgNFUO8BSeW4Iz4R1kh2JHv4LdTF?= =?us-ascii?Q?baP9FFw9NS2CzhAuDzEpmR1iNk8We0oM/VIPVTQSufyVDQzvz0hpyIhpfMUR?= =?us-ascii?Q?VlO+uIuWK5/cKvgKPftGm0lEWVfPTTcgpaW2FxSktQ6zPrwCQrMS5YY7DItc?= =?us-ascii?Q?idBRtZtqVFHsEBfb7olKNBgOpjYwWLgNZ0hPvFs4odhVhDS2CLZ1312vaV82?= =?us-ascii?Q?+Tv5ffCdKVGL6xkEVp/cI0uSk1nwvrohOACZOUt0gDiq6eVFQX8ZZ63SK7Ak?= =?us-ascii?Q?PPrGklbTg1IbjtzIVKDP8+6lMoA63q9+krQjBPYB7K6B6qT7hwYgsE5nWQ4w?= =?us-ascii?Q?u2yNALVX5O5grvWLom6VaiZbPURd6ck0vrNWJaSe?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71edb129-68c8-45b5-fa37-08de05ff871c X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:13:37.6703 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Pm6TY4wHsHjskfIejFrjAcHiGC7mdSs1dAfOWheB9vJURE+9JccqsEZppEIS0OKCp+5gsBbZ/FHfLpD9RRLuQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Content-Type: text/plain; charset="utf-8" Initialise the GSP resource manager arguments (rmargs) which provide initialisation parameters to the GSP firmware during boot. The rmargs structure contains arguments to configure the GSP message/command queue location. These are mapped for coherent DMA and added to the libos data structure for access when booting GSP. Signed-off-by: Alistair Popple --- Changes for v2: - Rebased on Alex's latest series --- drivers/gpu/nova-core/gsp.rs | 16 +++++ drivers/gpu/nova-core/gsp/cmdq.rs | 24 +++++++- drivers/gpu/nova-core/gsp/fw.rs | 60 +++++++++++++++++++ .../gpu/nova-core/gsp/fw/r570_144/bindings.rs | 33 ++++++++++ 4 files changed, 130 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs index ba385114498c..ef48da6afacd 100644 --- a/drivers/gpu/nova-core/gsp.rs +++ b/drivers/gpu/nova-core/gsp.rs @@ -20,6 +20,7 @@ mod fw; =20 use fw::LibosMemoryRegionInitArgument; +use fw::GspArgumentsCached; =20 pub(crate) mod cmdq; =20 @@ -38,6 +39,7 @@ pub(crate) struct Gsp { pub logintr: CoherentAllocation, pub logrm: CoherentAllocation, pub cmdq: Cmdq, + rmargs: CoherentAllocation, } =20 #[repr(C)] @@ -94,12 +96,26 @@ pub(crate) fn new(pdev: &pci::Device) ->= Result::alloc_coh= erent( + dev, + 1, + GFP_KERNEL | __GFP_ZERO, + )?; + dma_write!(libos[3] =3D LibosMemoryRegionInitArgument::new("RMARGS= ", &rmargs))?; + + dma_write!( + rmargs[0] =3D fw::GspArgumentsCached::new( + fw::MessageQueueInitArguments::new(&cmdq), + fw::GspSrInitArguments::new() + ) + )?; =20 Ok(try_pin_init!(Self { libos, loginit, logintr, logrm, + rmargs, cmdq, })) } diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/= cmdq.rs index 07504d15bfbb..317767d8f521 100644 --- a/drivers/gpu/nova-core/gsp/cmdq.rs +++ b/drivers/gpu/nova-core/gsp/cmdq.rs @@ -6,7 +6,7 @@ =20 use kernel::alloc::flags::GFP_KERNEL; use kernel::device; -use kernel::dma::CoherentAllocation; +use kernel::dma::{CoherentAllocation, DmaAddress}; use kernel::dma_write; use kernel::io::poll::read_poll_timeout; use kernel::prelude::*; @@ -247,10 +247,25 @@ pub(crate) struct Cmdq { dev: ARef, seq: u32, gsp_mem: DmaGspMem, - pub _nr_ptes: u32, } =20 impl Cmdq { + /// Offset of the data after the PTEs. + const POST_PTE_OFFSET: usize =3D core::mem::offset_of!(GspMem, cpuq); + + /// Offset of command queue ring buffer. + pub(crate) const CMDQ_OFFSET: usize =3D core::mem::offset_of!(GspMem, = cpuq) + + core::mem::offset_of!(Msgq, msgq) + - Self::POST_PTE_OFFSET; + + /// Offset of message queue ring buffer. + pub(crate) const STATQ_OFFSET: usize =3D core::mem::offset_of!(GspMem,= gspq) + + core::mem::offset_of!(Msgq, msgq) + - Self::POST_PTE_OFFSET; + + /// Number of page table entries for the GSP shared region. + pub(crate) const NUM_PTES: usize =3D size_of::() >> GSP_PAGE_S= HIFT; + pub(crate) fn new(dev: &device::Device) -> Result= { let gsp_mem =3D DmaGspMem::new(dev)?; let nr_ptes =3D size_of::() >> GSP_PAGE_SHIFT; @@ -260,7 +275,6 @@ pub(crate) fn new(dev: &device::Device) = -> Result { dev: dev.into(), seq: 0, gsp_mem, - _nr_ptes: nr_ptes as u32, }) } =20 @@ -490,4 +504,8 @@ pub(crate) fn receive_msg_from_gsp( .advance_cpu_read_ptr(msg_header.length().div_ceil(GSP_PAGE_SI= ZE as u32)); result } + + pub(crate) fn dma_handle(&self) -> DmaAddress { + self.gsp_mem.0.dma_handle() + } } diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw= .rs index ca3a33ab21db..d2ba6f98d05d 100644 --- a/drivers/gpu/nova-core/gsp/fw.rs +++ b/drivers/gpu/nova-core/gsp/fw.rs @@ -17,6 +17,7 @@ use crate::firmware::gsp::GspFirmware; use crate::gpu::Chipset; use crate::gsp; +use crate::gsp::cmdq::Cmdq; use crate::gsp::FbLayout; use crate::gsp::GSP_PAGE_SIZE; =20 @@ -468,3 +469,62 @@ unsafe impl AsBytes for GspMsgElement {} // SAFETY: This struct only contains integer types for which all bit patte= rns // are valid. unsafe impl FromBytes for GspMsgElement {} + +#[repr(transparent)] +pub(crate) struct GspArgumentsCached(bindings::GSP_ARGUMENTS_CACHED); + +impl GspArgumentsCached { + pub(crate) fn new( + queue_arguments: MessageQueueInitArguments, + sr_arguments: GspSrInitArguments, + ) -> Self { + Self(bindings::GSP_ARGUMENTS_CACHED { + messageQueueInitArguments: queue_arguments.0, + srInitArguments: sr_arguments.0, + bDmemStack: 1, + ..Default::default() + }) + } +} + +impl From for bindings::GSP_ARGUMENTS_CACHED { + fn from(value: GspArgumentsCached) -> Self { + value.0 + } +} + +// SAFETY: Padding is explicit and will not contain uninitialized data. +unsafe impl AsBytes for GspArgumentsCached {} + +// SAFETY: This struct only contains integer types for which all bit patte= rns +// are valid. +unsafe impl FromBytes for GspArgumentsCached {} + +#[repr(transparent)] +pub(crate) struct MessageQueueInitArguments(bindings::MESSAGE_QUEUE_INIT_A= RGUMENTS); + +impl MessageQueueInitArguments { + pub(crate) fn new(cmdq: &Cmdq) -> Self { + Self(bindings::MESSAGE_QUEUE_INIT_ARGUMENTS { + sharedMemPhysAddr: cmdq.dma_handle(), + pageTableEntryCount: Cmdq::NUM_PTES as u32, + cmdQueueOffset: Cmdq::CMDQ_OFFSET as u64, + statQueueOffset: Cmdq::STATQ_OFFSET as u64, + ..Default::default() + }) + } +} + +#[repr(transparent)] +pub(crate) struct GspSrInitArguments(bindings::GSP_SR_INIT_ARGUMENTS); + +impl GspSrInitArguments { + pub(crate) fn new() -> Self { + Self(bindings::GSP_SR_INIT_ARGUMENTS { + oldLevel: 0, + flags: 0, + bInPMTransition: 0, + ..Default::default() + }) + } +} diff --git a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs b/drivers/gp= u/nova-core/gsp/fw/r570_144/bindings.rs index 3d96d91e5b12..b87c4e6cb857 100644 --- a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs +++ b/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs @@ -319,6 +319,39 @@ fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) ->= ::core::fmt::Result { pub const NV_VGPU_MSG_EVENT_NUM_EVENTS: _bindgen_ty_3 =3D 4131; pub type _bindgen_ty_3 =3D ffi::c_uint; #[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct MESSAGE_QUEUE_INIT_ARGUMENTS { + pub sharedMemPhysAddr: u64_, + pub pageTableEntryCount: u32_, + pub __bindgen_padding_0: [u8; 4usize], + pub cmdQueueOffset: u64_, + pub statQueueOffset: u64_, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct GSP_SR_INIT_ARGUMENTS { + pub oldLevel: u32_, + pub flags: u32_, + pub bInPMTransition: u8_, + pub __bindgen_padding_0: [u8; 3usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct GSP_ARGUMENTS_CACHED { + pub messageQueueInitArguments: MESSAGE_QUEUE_INIT_ARGUMENTS, + pub srInitArguments: GSP_SR_INIT_ARGUMENTS, + pub gpuInstance: u32_, + pub bDmemStack: u8_, + pub __bindgen_padding_0: [u8; 7usize], + pub profilerArgs: GSP_ARGUMENTS_CACHED__bindgen_ty_1, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct GSP_ARGUMENTS_CACHED__bindgen_ty_1 { + pub pa: u64_, + pub size: u64_, +} +#[repr(C)] #[derive(Copy, Clone)] pub union rpc_message_rpc_union_field_v03_00 { pub spare: u32_, --=20 2.50.1 From nobody Sat Feb 7 19:45:37 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011023.outbound.protection.outlook.com [52.101.52.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF62A211A14; Wed, 8 Oct 2025 00:13:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.23 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882434; cv=fail; b=YqeqnzL6gD1zYhgs568/xmH1ZfIQlTQ/yy97Xj2HUujedmtP2LUakZWq31j1+2jl7cEgnn4XHq2e/6HwjiDe7/vavJ/u4s7UxUEvo86ZgCkBVMX6wkAoweLkLMP3VMlQ/YvNXHhhhOzlTCm+cZaTnWpag4dKgqGnZTGdVU8SABo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882434; c=relaxed/simple; bh=RE0eCagVZ34TZp3U63x9QU/1BGEF4K1LvsHyPm/1G+Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=DryhEJSJkbcVlxiAbjzZJmGWQ03dijTZhz8qkMF1zv6PfYEjfCdtweG2GnpWqDKIVf5ab5gQ57hH05QaSCKBRhWXg4SirVvBqmZJRtEb0pNm4bOl/feUTMfn+RI7OaQjY9yxIgKhg/roFbHkHnJAy5OvIn/OXlTRxJzJfkQMSwI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=Dzvhe/eS; arc=fail smtp.client-ip=52.101.52.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="Dzvhe/eS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ypDeN+kwb5mjVGUvR1kU44GVho8nF3SXjXL51hDQ3ajUTGHRunIitmNbm8BItzobkUsPt8D4p8cRXzVjfxYbPZLJk1dW8OURAYeiFHCfaBhUqkNwR47xFmo2lCsZ8VSCGwvm7XhqiX7yZhUWrb+Uzb5qDn/WxCRvdf5fVDHhz6fs0VMtpTdE3zbnV/jCY/6EnajesVxNjtFxwaSnw3qLHVcpRYJ0WtVk4g+m9mu6xJZ4IXViaKYnXaB2cbjeaLcX/FZWSf0MXvVfFHRSV0Vo34RyJrj42izUX0WjBwsVuf69oJfbCs9VMCnU1lUpT99iVOICLUYZR6QuGTwNouCPqQ== 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=bgRWDmImk2Mjy2tpRlMNRlidNYvB5jZPO90zOI7kO7Y=; b=zRZ5Mh2GMkkmpjvYxRDFhtZNBk2ZEge9nzsQGKdDke3ovN1V2j29s7LpUbp8u+AzKlzzh8F82ngbXH5kt3zRww9Q5nDXryWEgLIGMbalt4+K4aey7RapvezF24n6gakmzTWZC1m1IdUV3nNdlu7lxDUy/HBNsGNSx6r+/jfkoRIgfPS9BKuzW3++2zBJuKkHw+Sjj+jqxLxYOEEN9eDMw2G2XqY1R8mH0MXODsM/OrEBCXeOwt987vZ5XQ48dPIORNO6K4F/I+JUHalUfDoPbXquO27rkJ03PiunZ4xuR58AgYuyFSC4A3VETIKYwq9+7PQ9K9tW+sQtYRm6DCStNg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bgRWDmImk2Mjy2tpRlMNRlidNYvB5jZPO90zOI7kO7Y=; b=Dzvhe/eShCHfDWkTscRmMK2Louj4y2Hxz7OvITEsIyh3iwsnFxm0c4Ejvo4LX6bUHwRp9BtJsYiz0hHqrSV9ooQIFDc59HH9vMcPkrPEQzCFNdJQWhvgz7hBflLD8bec1GYpG9Xpwu2giX59eVNHLIgzandzOYHtKnqFO/ku732PiCyZPydJt8w5lmiwj8UWA/ti+sFwuNfoLUYKIxS/2Ai7YzBzmbnV0p1/urGVxvFlxjoXM5kVJi+5up5aCti0uX9iSJyi899YhPI6K/1LEFEjCazTjjdQWE2mPFqmUsjJJ3/tSZ8KtCUNrpQFE5U+0/l2wyO/rGWNhMhnGgw9IA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:13:44 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:13:43 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org Subject: [PATCH v4 08/13] gpu: nova-core: Add bindings and accessors for GspSystemInfo Date: Wed, 8 Oct 2025 11:12:47 +1100 Message-ID: <20251008001253.437911-9-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SYCPR01CA0025.ausprd01.prod.outlook.com (2603:10c6:10:e::13) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: be5fe2e3-9bbc-4670-d18e-08de05ff8ab6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?PHTZ8oXpawI6i92gUAjC1/ta6g+r3Hqa53VSWO1gAA74oXxbIigSK+TeaPj1?= =?us-ascii?Q?wN0gw4MXzIX7X9OtP0Tp6aYnwe1b1MHhX0LCCnxAtKNlc5x3d9iIA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oArGWTYrlwM8X1vzM9IlShZZvX41cmggchY9Mj7V7?= =?us-ascii?Q?7QtEWJLQAWQ0mXVjeS0xr6NIjmGpIgmwQGtBjGB874z3tMwU8i4AFKZP9sq2?= =?us-ascii?Q?rtDk50WKd4+hPgF0lry03XAcr8F/BGunJl5uemc4QNSI8CiSOt4qeE4FUJ5U?= =?us-ascii?Q?ZcawwxMS+5dNEDq2xOrdGqZ1HR2bQEztW2bixJcSaGrNSqKi9JhZGgJkrXBG?= =?us-ascii?Q?CIA60U0XiJhv3Mu2RbLEuYVt0E31B7HLpafIDOH4zFKzM03r1DOFILDlBUVW?= =?us-ascii?Q?y6OTkeQoMzvEqGOA4kESE0rMNSrIqFKTv4XxCQjWwrZWS9ulKFgGT5kaANQL?= =?us-ascii?Q?F3M9q3Bdsn8Rqrm3SbojWJV5Lvewcp8gwzNMtxv2jNLSGb8L1x+6laynz6sR?= =?us-ascii?Q?D+6FD9j16y96Wydm4myE3amBdddpBSaHNHypiDxo0NIeF1+dKHIzZVFXU531?= =?us-ascii?Q?Dpr9eOPjcqtQWpxHlsJzU8i2+Y1iyEvk?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JC+tNZjlMqSf8lKB7IknQuT7u3QKEtvpF4+arJBMcXWSjI5Re7AqBTkEhbcU?= =?us-ascii?Q?Fjt9K5zRDtYB+N9MgD7vn7CuSbT2Hy/V84WDXEt9paWaZ7/kD+Y4KxwRins5?= =?us-ascii?Q?jniad3ZDmoMwaBtCCzUxhh05PdL/wgxmg/lw3btKU7TJ4w2JGSvaflV+lIpN?= =?us-ascii?Q?YMoXwoiNXjyvZOcwh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+msn6ruwJdQuV8oy?= =?us-ascii?Q?hWdR3E8ivZpUGBcqG/bGv/qQ3jmxjWtHq9FQwERmY5/O0XY+6M3ajopief3t?= =?us-ascii?Q?iUp+JL8ul+QpNhgKynyKHGC4DxWbsl7PQBHknSKGKBSnZSZvmjzgU3KDASVc?= =?us-ascii?Q?IKV8PduT0+ZTgWA7KGCxTZl4jhvqdLbjHPv48QmWlL1nj+wi+GOKIJazaUai?= =?us-ascii?Q?wbz06zSaC8KA95vLDh6d2JykhZnbWe6Vz3z5jWstm0eTeHzB3s6O9FDIAlDv?= =?us-ascii?Q?2uCgeA8Vt9OarWWw8tIG9VwFxSoz864UmpS5MesDvnb4wxd3jZPgZMzNU+Qk?= =?us-ascii?Q?XJZSdqR2TaQeCaUetltPA3seEqkzk07Zszda+8vyI9X5nlfXDTNhBzHByiwP?= =?us-ascii?Q?fUD/RsZd+vWJDMIQpqXE2NBYk5agycZN3R9ZPxNAlSwi+g0CF2Dmn+/qpNNf?= =?us-ascii?Q?7TX97KDQhllh33WpqvUdYZer7N4LNGlsQyjViCtuOg7GluHD/LnhL7EqxBJM?= =?us-ascii?Q?WwL+zshvLLMNnBfSqEPIcL63hPB+yE/tQd6/IijR?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: be5fe2e3-9bbc-4670-d18e-08de05ff8ab6 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:13:43.8777 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: F+WfkU+/tT9m39XYmGYduC2dG7UFZtm+5vou7OPbDxHOTa0vNSx2kYPlDTjvNKW0ycYN1b5ekYdjb+NAa25HoQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Content-Type: text/plain; charset="utf-8" Adds bindings and an in-place initialiser for the GspSystemInfo struct. Signed-off-by: Alistair Popple --- Changes for v4: - Use `init!` macros Changes for v3: - New for v3 --- drivers/gpu/nova-core/gsp/fw.rs | 1 + drivers/gpu/nova-core/gsp/fw/commands.rs | 55 ++++++++ .../gpu/nova-core/gsp/fw/r570_144/bindings.rs | 132 ++++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100644 drivers/gpu/nova-core/gsp/fw/commands.rs diff --git a/drivers/gpu/nova-core/gsp/fw.rs b/drivers/gpu/nova-core/gsp/fw= .rs index d2ba6f98d05d..fb309288ac40 100644 --- a/drivers/gpu/nova-core/gsp/fw.rs +++ b/drivers/gpu/nova-core/gsp/fw.rs @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 =20 +pub(crate) mod commands; mod r570_144; =20 // Alias to avoid repeating the version number with every use. diff --git a/drivers/gpu/nova-core/gsp/fw/commands.rs b/drivers/gpu/nova-co= re/gsp/fw/commands.rs new file mode 100644 index 000000000000..53e2c9098c48 --- /dev/null +++ b/drivers/gpu/nova-core/gsp/fw/commands.rs @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0 + +use super::bindings; + +use kernel::prelude::*; +use kernel::transmute::{AsBytes, FromBytes}; +use kernel::{device, pci}; + +#[repr(transparent)] +pub(crate) struct GspSystemInfo { + inner: bindings::GspSystemInfo, +} + +// TODO: Ideally we would derive this for all our bindings, using the same= technique as +// https://lore.kernel.org/rust-for-linux/20250814093046.2071971-3-lossin@= kernel.org/ +unsafe impl Zeroable for bindings::GspSystemInfo {} + +impl GspSystemInfo { + #[allow(non_snake_case)] + pub(crate) fn init<'a>(dev: &'a pci::Device) -> impl In= it + 'a { + type InnerGspSystemInfo =3D bindings::GspSystemInfo; + let init_inner =3D try_init!(InnerGspSystemInfo { + gpuPhysAddr: dev.resource_start(0)?, + gpuPhysFbAddr: dev.resource_start(1)?, + gpuPhysInstAddr: dev.resource_start(3)?, + nvDomainBusDeviceFunc: u64::from(dev.dev_id()), + + // Using TASK_SIZE in r535_gsp_rpc_set_system_info() seems wro= ng because + // TASK_SIZE is per-task. That's probably a design issue in GS= P-RM though. + maxUserVa: (1 << 47) - 4096, + pciConfigMirrorBase: 0x088000, + pciConfigMirrorSize: 0x001000, + + PCIDeviceID: (u32::from(dev.device_id()) << 16) | u32::from(de= v.vendor_id().as_raw()), + PCISubDeviceID: (u32::from(dev.subsystem_device_id()) << 16) + | u32::from(dev.subsystem_vendor_id()), + PCIRevisionID: u32::from(dev.revision_id()), + bIsPrimary: 0, + bPreserveVideoMemoryAllocations: 0, + ..Zeroable::init_zeroed() + }); + + try_init!(GspSystemInfo { + inner <- init_inner, + }) + } +} + +// SAFETY: These structs don't meet the no-padding requirements of AsBytes= but +// that is not a problem because they are not used outside the ker= nel. +unsafe impl AsBytes for GspSystemInfo {} + +// SAFETY: These structs don't meet the no-padding requirements of FromByt= es but +// that is not a problem because they are not used outside the ker= nel. +unsafe impl FromBytes for GspSystemInfo {} diff --git a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs b/drivers/gp= u/nova-core/gsp/fw/r570_144/bindings.rs index b87c4e6cb857..427fff82f7c1 100644 --- a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs +++ b/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs @@ -320,6 +320,138 @@ fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -= > ::core::fmt::Result { pub type _bindgen_ty_3 =3D ffi::c_uint; #[repr(C)] #[derive(Debug, Default, Copy, Clone)] +pub struct DOD_METHOD_DATA { + pub status: u32_, + pub acpiIdListLen: u32_, + pub acpiIdList: [u32_; 16usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct JT_METHOD_DATA { + pub status: u32_, + pub jtCaps: u32_, + pub jtRevId: u16_, + pub bSBIOSCaps: u8_, + pub __bindgen_padding_0: u8, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct MUX_METHOD_DATA_ELEMENT { + pub acpiId: u32_, + pub mode: u32_, + pub status: u32_, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct MUX_METHOD_DATA { + pub tableLen: u32_, + pub acpiIdMuxModeTable: [MUX_METHOD_DATA_ELEMENT; 16usize], + pub acpiIdMuxPartTable: [MUX_METHOD_DATA_ELEMENT; 16usize], + pub acpiIdMuxStateTable: [MUX_METHOD_DATA_ELEMENT; 16usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct CAPS_METHOD_DATA { + pub status: u32_, + pub optimusCaps: u32_, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct ACPI_METHOD_DATA { + pub bValid: u8_, + pub __bindgen_padding_0: [u8; 3usize], + pub dodMethodData: DOD_METHOD_DATA, + pub jtMethodData: JT_METHOD_DATA, + pub muxMethodData: MUX_METHOD_DATA, + pub capsMethodData: CAPS_METHOD_DATA, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct BUSINFO { + pub deviceID: u16_, + pub vendorID: u16_, + pub subdeviceID: u16_, + pub subvendorID: u16_, + pub revisionID: u8_, + pub __bindgen_padding_0: u8, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct GSP_VF_INFO { + pub totalVFs: u32_, + pub firstVFOffset: u32_, + pub FirstVFBar0Address: u64_, + pub FirstVFBar1Address: u64_, + pub FirstVFBar2Address: u64_, + pub b64bitBar0: u8_, + pub b64bitBar1: u8_, + pub b64bitBar2: u8_, + pub __bindgen_padding_0: [u8; 5usize], +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct GSP_PCIE_CONFIG_REG { + pub linkCap: u32_, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct GspSystemInfo { + pub gpuPhysAddr: u64_, + pub gpuPhysFbAddr: u64_, + pub gpuPhysInstAddr: u64_, + pub gpuPhysIoAddr: u64_, + pub nvDomainBusDeviceFunc: u64_, + pub simAccessBufPhysAddr: u64_, + pub notifyOpSharedSurfacePhysAddr: u64_, + pub pcieAtomicsOpMask: u64_, + pub consoleMemSize: u64_, + pub maxUserVa: u64_, + pub pciConfigMirrorBase: u32_, + pub pciConfigMirrorSize: u32_, + pub PCIDeviceID: u32_, + pub PCISubDeviceID: u32_, + pub PCIRevisionID: u32_, + pub pcieAtomicsCplDeviceCapMask: u32_, + pub oorArch: u8_, + pub __bindgen_padding_0: [u8; 7usize], + pub clPdbProperties: u64_, + pub Chipset: u32_, + pub bGpuBehindBridge: u8_, + pub bFlrSupported: u8_, + pub b64bBar0Supported: u8_, + pub bMnocAvailable: u8_, + pub chipsetL1ssEnable: u32_, + pub bUpstreamL0sUnsupported: u8_, + pub bUpstreamL1Unsupported: u8_, + pub bUpstreamL1PorSupported: u8_, + pub bUpstreamL1PorMobileOnly: u8_, + pub bSystemHasMux: u8_, + pub upstreamAddressValid: u8_, + pub FHBBusInfo: BUSINFO, + pub chipsetIDInfo: BUSINFO, + pub __bindgen_padding_1: [u8; 2usize], + pub acpiMethodData: ACPI_METHOD_DATA, + pub hypervisorType: u32_, + pub bIsPassthru: u8_, + pub __bindgen_padding_2: [u8; 7usize], + pub sysTimerOffsetNs: u64_, + pub gspVFInfo: GSP_VF_INFO, + pub bIsPrimary: u8_, + pub isGridBuild: u8_, + pub __bindgen_padding_3: [u8; 2usize], + pub pcieConfigReg: GSP_PCIE_CONFIG_REG, + pub gridBuildCsp: u32_, + pub bPreserveVideoMemoryAllocations: u8_, + pub bTdrEventSupported: u8_, + pub bFeatureStretchVblankCapable: u8_, + pub bEnableDynamicGranularityPageArrays: u8_, + pub bClockBoostSupported: u8_, + pub bRouteDispIntrsToCPU: u8_, + pub __bindgen_padding_4: [u8; 6usize], + pub hostPageSize: u64_, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] pub struct MESSAGE_QUEUE_INIT_ARGUMENTS { pub sharedMemPhysAddr: u64_, pub pageTableEntryCount: u32_, --=20 2.50.1 From nobody Sat Feb 7 19:45:37 2026 Received: from BL0PR03CU003.outbound.protection.outlook.com (mail-eastusazon11012012.outbound.protection.outlook.com [52.101.53.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C100522576E; Wed, 8 Oct 2025 00:13:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.53.12 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882437; cv=fail; b=HNqilWW6u5LzELjw0AraOOpk8W6Z4kZq4Mc6PNc+O/Wwpu/GkVaLZmHlNMl43OKtQBnyV1qb4azDXKUmTrd1XL9K1Ab2H+4brULnjgDMNOoO8vGQTMeKKtjMiIgIc1mZVWOVigSEfxy/4lIyYSAYXbp2AMQM8X8xzTvaY61IpW0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882437; c=relaxed/simple; bh=F20yCJNju6Px3kOxQa+gXi7Gxbq5WXv86PYjQB+SEt4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=IBIaA/yVMlH8F+colQ6oVSIgfN55SjQXEztLGjO66bnLRc9qkTw8dG9F4A8CD7Wytftdpoux7WSjHgYbp3e6yW8ATRV/MfPd6JZuXxtkLW5LtGisnaMyya+jVO2CTInQvnucjZLWytMRIt3eqdTcr8/UFCHGsrxpmPBQI7tlrXA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=AMuYmrz3; arc=fail smtp.client-ip=52.101.53.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="AMuYmrz3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XVPCZN4t00toua7pkIvlich5jlyMZuaVS+q4eP0jnnzicDjopsUXu5sLcPNi0Ugggl2Q2IT0HL0V00kryhjgAdv368akX9KdutHt5xdf/fuOJHkqmsH1Fv9sPTyA9YsxKA3h0aV4++izqDmUuOpGaH92KSF1+7/Rdts+ygqWIaz4wrYJv0P0SE+MdP9WW+O+fTiY56TJvwB4ItHY8Nu0XYbTaqRgWfxv596WnDf/FdEFSF45aMU/O8PwEGe8cYqjmZuSWa1DR8S94njlhi1i7rHzmyhvbseo8E0KowniW3FK9w3CT4+GjasPn9H1iXDu+weBeflbTE1H9Iqrs+vHWg== 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=0cffpN8hcpRRsdi58aTwANFiqddvxpjQxxOg+gpQsxs=; b=Z6Oal547ZKtgZ6Lx4zLT8cKkefAWBj90bltju+bx5NyNMZ13jb4CGKZkCnMDbfXFep14jQUoray+rXDXqQW/1y9aAgKr1CMisvZfweYZHtLDVM9x9zXlSTemvyf/JpMBKhuCQhRnokdcgWQezcsAMB5RhUE+0tMauw0WH29Qh9ElxdCG24BaGbAmuIk4Ehj4JAnjmgLbqGvNrJ3xlNl6YWbfOQgPkbQfleJpzShw/2zTplrScLjXFCTqhGozv+ia/66hPDJqJhz+Y7Zor0hDlQmWrJERG5qL75RasDV5zmaf4sx6mXWg3jBD4HmRstXtvPG32HCVjb28xqlzBRSyXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0cffpN8hcpRRsdi58aTwANFiqddvxpjQxxOg+gpQsxs=; b=AMuYmrz3O1Y+I+7NUWKgkX58eL+RSWRSY30xo2z84tYd88uYXfv8kbN2JgdLhYBd/oQmnrKqcgrA9GBUqJM+Sx8cIvkN2w6Qh9BChY9Qc4zkllAZ0pBg5JiEBqqsZKeFEuDtJ2JeBPcjdAdYB3Y+KMXgM8JEkUQdGN2U/ZrlU8MoD0qxjygF9WVKMZ1Q1W6S8LjcVf54zooJQ0fayWJmw8bXzDNUHE5sFn8HmgGOfz+KayqaiiGzbz4BgJJQxVR0LCtqSxXTDQAW5m4eppB/n3CW5Nthw+6of66XGuzVJUcL2RJ4ZHAnn024P+8P555Y/CxrIn+TsJxPDBIvo7c0wA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:13:49 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:13:49 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org Subject: [PATCH v4 09/13] gpu: nova-core: Add bindings for the GSP RM registry tables Date: Wed, 8 Oct 2025 11:12:48 +1100 Message-ID: <20251008001253.437911-10-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SYCPR01CA0036.ausprd01.prod.outlook.com (2603:10c6:10:e::24) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: 226bc0be-b305-477e-7b80-08de05ff8def X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?sG8AvhVxJai4Pt0cOCvhKilaN8L6y0DBul1WZvfmtDstHzFj+ZD70/+3if+8?= =?us-ascii?Q?eZq5oLCrRarnY3Nx89rgU1CUgVWwf5qgDPrxi4MPvhJf0MB/DhSFHbSYOtin?= =?us-ascii?Q?Lys/HncCXaudDLB0vh+yUsDJ3qDCg4pIWsOfQYamQChe/9QlqNazXdy7m6ap?= =?us-ascii?Q?tS5+NqzcHQiMSMvZsnynPQmCdCUUy+036EU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eb59NjpSGcJIuhgFsLCH+sa1uubKOdPW2co48ya55ydQ?= =?us-ascii?Q?iKMIimd3FOeIAoDOtXyiGe3oJEf3oLRudPd2guZp9JN1Z1wxVGbfrYYVqijG?= =?us-ascii?Q?Z+HJdQBlu0DcJtQbmZ1q9BhTWejgZTpkWWQY7R2E6HRsToGaoAMsHTe6P484?= =?us-ascii?Q?Ne0KthiNGbW4p1XIJAyqf70JmeKPAK1PHzDY8dcI0fUNZj8Zx5LX21a0pIwj?= =?us-ascii?Q?4v8H78QEE59TAhNDpwV5gR/8htolusa2Dqu4ElTOGbsMQBjYzdDU2VQHIufW?= =?us-ascii?Q?sH9l8vVxOK1LX5qxTbU0DWZGfB+mpTXDEiR+64vBLK7l5679RVwcJhh6erF6?= =?us-ascii?Q?1RHxPbDD+jmmMsSVB2sR1EARXlenhQGb?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?41NGDuqUSZemVgBLSJ4pgzH86uJrLs98Drki7E7BXlVwi8C7fE32efS3HXzF?= =?us-ascii?Q?R0GyEN2w451ZFM2EhpSOy6sG4qufvJ1Im5mK0b1MVswuiYR86pzEE3j3efms?= =?us-ascii?Q?BzTKRw3vpLt4nv1EpyOJRssVuNwuzYo4Pctsj0jy4mTgY3vygzJ/dceKG4Hc?= =?us-ascii?Q?DdIiDOnpid0dRGadha+lQtG/YgKAYF/IMs4aGSOIaz7bCM3stjdl91bqrM5P?= =?us-ascii?Q?3Tw5wDz0kgQ3ZABK+FcCDJYrV7y9AILEMxKpgh9XlPz4Jb6dKgZPLmiFkRzP?= =?us-ascii?Q?4uOrmEwZp9oTW6oAWqQiQS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?us-ascii?Q?+htNe1/e7J7iUAc/i79drCncPlbomTBrt762JP8mrfWLHCX6DIprCRP2eupo?= =?us-ascii?Q?YYK/bg3lZPS+fR44HJ9A5ucXLX6YBVG2SQVg6DkCyZ4rlD+BL/r/nJ2d+RnQ?= =?us-ascii?Q?KTLiuabI72+3orJ/IH/q3n6EP+McHeK+wiyIO+k7oNcELgxaWoWc4/e0pqWj?= =?us-ascii?Q?yC5hNwmi63Uu0eCWzxVB1pGRwk2GpbREqeZ5tWev14bNCOhGHS+BsCVxRMnw?= =?us-ascii?Q?4Dxlx8+juP4UmgvVX98s7AY6UpSzKqgfozS+EavOqdznqF7j1mstGheGKU14?= =?us-ascii?Q?YMslnvz2iknf50ZpRiUvk0uRqTkDAAQ+JLqvrp/666rmJvimFiXMN7pm6JTq?= =?us-ascii?Q?K1ymY2qw8xZxulm35ewSi3OD7OT+nD0WopAoaM/R?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 226bc0be-b305-477e-7b80-08de05ff8def X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:13:49.2729 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6FCq+DszBqUr6iRhEX+ybS15hY9Dch0uctYLRiPwnNEbSS6LwzKmuOrarWx1rq0LJfttuhDqDKA9hxtZYNfLPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Content-Type: text/plain; charset="utf-8" Adds bindings and constructors for PACKED_REGISTRY_TABLE and PACKED_REGISTRY_ENTRY structures. Signed-off-by: Alistair Popple --- Changes for v4: - Use `init!` macros - Add comments around only supporting DWORD entry types Changes for v3: - New for v3 --- drivers/gpu/nova-core/gsp/fw/commands.rs | 49 +++++++++++++++++++ .../gpu/nova-core/gsp/fw/r570_144/bindings.rs | 17 +++++++ 2 files changed, 66 insertions(+) diff --git a/drivers/gpu/nova-core/gsp/fw/commands.rs b/drivers/gpu/nova-co= re/gsp/fw/commands.rs index 53e2c9098c48..008c1331bb5a 100644 --- a/drivers/gpu/nova-core/gsp/fw/commands.rs +++ b/drivers/gpu/nova-core/gsp/fw/commands.rs @@ -53,3 +53,52 @@ unsafe impl AsBytes for GspSystemInfo {} // SAFETY: These structs don't meet the no-padding requirements of FromByt= es but // that is not a problem because they are not used outside the ker= nel. unsafe impl FromBytes for GspSystemInfo {} + +#[repr(transparent)] +pub(crate) struct PackedRegistryEntry(bindings::PACKED_REGISTRY_ENTRY); + +impl PackedRegistryEntry { + pub(crate) fn new(offset: u32, value: u32) -> Self { + Self({ + bindings::PACKED_REGISTRY_ENTRY { + nameOffset: offset, + + // We only support DWORD types for now. Support for other = types + // will come later if required. + type_: bindings::REGISTRY_TABLE_ENTRY_TYPE_DWORD as u8, + __bindgen_padding_0: Default::default(), + data: value, + length: 0, + } + }) + } +} + +// SAFETY: Padding is explicit and will not contain uninitialized data. +unsafe impl AsBytes for PackedRegistryEntry {} + +#[repr(transparent)] +pub(crate) struct PackedRegistryTable { + inner: bindings::PACKED_REGISTRY_TABLE, +} + +impl PackedRegistryTable { + #[allow(non_snake_case)] + pub(crate) fn init(num_entries: u32, size: u32) -> impl Init { + type InnerPackedRegistryTable =3D bindings::PACKED_REGISTRY_TABLE; + let init_inner =3D init!(InnerPackedRegistryTable { + numEntries: num_entries, + size, + entries: Default::default() + }); + + init!(PackedRegistryTable { inner <- init_inner }) + } +} + +// SAFETY: Padding is explicit and will not contain uninitialized data. +unsafe impl AsBytes for PackedRegistryTable {} + +// SAFETY: This struct only contains integer types for which all bit patte= rns +// are valid. +unsafe impl FromBytes for PackedRegistryTable {} diff --git a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs b/drivers/gp= u/nova-core/gsp/fw/r570_144/bindings.rs index 427fff82f7c1..7ad1981e471c 100644 --- a/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs +++ b/drivers/gpu/nova-core/gsp/fw/r570_144/bindings.rs @@ -42,6 +42,7 @@ fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::= core::fmt::Result { pub const GSP_FW_HEAP_SIZE_OVERRIDE_LIBOS3_BAREMETAL_MAX_MB: u32 =3D 280; pub const GSP_FW_WPR_META_REVISION: u32 =3D 1; pub const GSP_FW_WPR_META_MAGIC: i64 =3D -2577556379034558285; +pub const REGISTRY_TABLE_ENTRY_TYPE_DWORD: u32 =3D 1; pub type __u8 =3D ffi::c_uchar; pub type __u16 =3D ffi::c_ushort; pub type __u32 =3D ffi::c_uint; @@ -649,6 +650,22 @@ pub struct LibosMemoryRegionInitArgument { } #[repr(C)] #[derive(Debug, Default, Copy, Clone)] +pub struct PACKED_REGISTRY_ENTRY { + pub nameOffset: u32_, + pub type_: u8_, + pub __bindgen_padding_0: [u8; 3usize], + pub data: u32_, + pub length: u32_, +} +#[repr(C)] +#[derive(Debug, Default)] +pub struct PACKED_REGISTRY_TABLE { + pub size: u32_, + pub numEntries: u32_, + pub entries: __IncompleteArrayField, +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] pub struct msgqTxHeader { pub version: u32_, pub size: u32_, --=20 2.50.1 From nobody Sat Feb 7 19:45:37 2026 Received: from DM1PR04CU001.outbound.protection.outlook.com (mail-centralusazon11010005.outbound.protection.outlook.com [52.101.61.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEAD322B8B6; Wed, 8 Oct 2025 00:14:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.61.5 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882442; cv=fail; b=C3Wbc3tdtaeC8r5+O2+p8QUPSMwQqXDyW24d8VK10vaM3w+st2iJn+Nhz9hDSscOKI+P0Am2Vvnqdhl9wdiyIj44eP7/0mde0TOJXKCDHQBf2jBCJmBeLhMnjiL0HH94Lz6QoTrsgtz9PzlM6N9X2kj8hDf1wb4aI8ODYKfNjM4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882442; c=relaxed/simple; bh=Ics9J9LB7qPUSbbEXRp5PTxspvfiz6+YwUN2BgNDD80=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=tMTVrutrKav7YR+QZyY76Un++kGcADymFN2Ajeep4WgP3Rj8wPfBICq1J3SaOVeFIjjuMOHlabTf17RWwjURejqfF9t5yoJmTEg57Dk2MjxmB4EUaKrVt2CtOlv6SNXHixO1mpUWWnX1hla6c/Zsl7v4bimPTyMgplAnIyr4uKg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=tbqYaejy; arc=fail smtp.client-ip=52.101.61.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="tbqYaejy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nvLNr2MM0hByFiw4vl4JbfQC6n7N/VbmyG/Y6xAXuDHd8vQdiu7WsL/s/DXH1zQk6MsgBett4w/0CKogmjFfHvuH4H5dOo8WWI6MD3hdqDnsw1WIVTf6HZMsUl9lw8NTAVanyK2LTyuN31W8xht9W+1xdwybFWoaDeAwqSXYvneYxBfKoNEPcuDL5Uk/Fef/8BJJ+w2BQ1VZsgVbbGsRDXo6FVW/C+gVKfncuFEc0Io5Kh5bGEw5rfTgQoBxCom6NPmBDIjKMXCJpf4+k/gqclK31pB7eB6aQaIUcjPxO3Zg5lIFEdqkhiScOBLRVEqKnAOPNF+v+DVMks3aV9eqgA== 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=t2Yo8gtp0PUBYwRnmyV467u44C/wH9Ye2NzQEtfjuWw=; b=IQt/4pv8eN1WbVsD0zYqvXXiWxTTB8fsFdZ/ahAsEyupRqFFo8C6Zgk+EnAPPRyEiBP0TSDRiyoILOT5uHDrhG07j0DncKJU/0iNn2tI/fQgWoJnjM1NTK7kKbjBBqTbXQlkRVGRo0d4Nzjr9r8jV8LLwhAV8PafyyZfHiJyneAYS6bopM+BcbiaoiQtw2yakcMvdMZSz1BcHWk14yYhB7aPPyKW5YpgUAqfOj1uk64z81szUaHwsqiuss3WOgBLXjtHQE33c3TrObFg1C3x9qPrU90s6UuT/u/MUZdtbaS450hMJhYiGGEocrgFEGacIeDWB+wHBpc7iX0TW0WNtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t2Yo8gtp0PUBYwRnmyV467u44C/wH9Ye2NzQEtfjuWw=; b=tbqYaejyxv8E8pjt/auBm7VjdHB4vswXSvuq17bfNApykN04CbeqnMeTEQhlqpL4IwsetkoUcKpJgCHAHqPmcoA4PAkgJBX2uho7ylF46XAv2Z0yckHzsJm9/tIakDpOrZW+ZJqN9C/6tvetiBbOtb5zP9DF7JwKc39EUdT9DI4RtaR/4mdBIukHv8VCVZFzPjOnMoV5/eKAxtFym8aYxVN1xmvpL8wL01OuJg5Kjt3NKwbka+IuAamlrJuCQYsvzikDwZPL9AptzD7JiSpjjnmQ6rszW+7Y5aKjW65GlX663p4WXXQBRz5aB9Vv1QZhECX2a5KYMkLULdbjEKqRNw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:13:54 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:13:54 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, Lyude Paul Subject: [PATCH v4 10/13] gpu: nova-core: gsp: Create RM registry and sysinfo commands Date: Wed, 8 Oct 2025 11:12:49 +1100 Message-ID: <20251008001253.437911-11-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SY8PR01CA0011.ausprd01.prod.outlook.com (2603:10c6:10:29c::14) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b65dbaf-c517-47b4-2f0a-08de05ff90f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?MdLonnnIiTOk0wtCtsPDi9ST4YnJHuzsbKBG8uQJOyU6BbjTQI2dUqTWMquf?= =?us-ascii?Q?UtB8pwzDM7hGWamBqsyMHWpUzHJnUQ5SD+4th6CUbJXBIkxumukbm+0A3rsR?= =?us-ascii?Q?HEsZx0b69qVnYditrABltX3GrF7/lqXvz/960iDyGvv0QBIKjZiZVOJGWGEf?= =?us-ascii?Q?gu6L2bqdeOw+a8RkGEkZZSqv6Jt47sQkIeNZk2mUUnNmMaH3F9Rd6WXRjVp3?= =?us-ascii?Q?NSHzSBNvrXiD+oot6nyd9b8p4eN5aFrtpFBkP2pWQ7sCkBkFftMoBxx5hL2r?= =?us-ascii?Q?q519TtDBwGp+v8l2rS6ph8awyZuBLFt+EJzZhkFnPoQfmm6y21tEqmj94EDY?= =?us-ascii?Q?AcevSDil7GEAFEtDJZmRjrrqiui1a83XlfHyuIYchY+SQEELgE253w6RJ/fw?= =?us-ascii?Q?VUCeMFl5/tnFaTV4W9VVbvUGy8E3QXBM/a60tI23e8QSz6OLbldcfwK+9j4B?= =?us-ascii?Q?lg1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WSb7dfYodyBi?= =?us-ascii?Q?23hcBTEAoMyV1JS9J7SPyRi+V/pTF6GlR6kLBko1YAFQmXI6tY4pKfgI99af?= =?us-ascii?Q?VBzIaXBMBYsoyg7/EeClD6vUDti+XpeJ?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?EqQAc3oiFFZ90y8e4Lv8BCARN9t9EpQHVUuAkeVngEZoJPnTlX9dNj4ZeI6G?= =?us-ascii?Q?8uuyiRAcd6MtRt/bXRFgL+G3zv5q/OL2Fo8qQGZZigC3LshZv1EDosgLaj9T?= =?us-ascii?Q?3D2jZ9d29TGpzjFOBD2zNWqiSO9lWcYH5thSiPrsBJwSrgmAqImakSnd27cR?= =?us-ascii?Q?qRlOntkmRKTrl4e9N+CZSMSivZMZgs9sUvk8oDrhm2ge3iOwHdEs9ZDtMIM4?= =?us-ascii?Q?0hLRjg7+IP+FIjvybHfvlUVuPHQa/COk0Fd6d0wXHMZrCq+4To2aRqA2So0/?= =?us-ascii?Q?unjdIIt7NGojIzJyHc2Bqj7+HunjCJAX7nOawH/cGKfwLeoWhcf5yKRpCgb8?= =?us-ascii?Q?LVCUQ8IScfB2PolBEmjv0qloqdm8mBSLqtYe2aMp3IAxhCKJw050njet6IMW?= =?us-ascii?Q?Elyo2r2fAa6HOFYP0w1GtNWGiA81ojj0pw6OB0GpjXtU8DMQpezqoQ1Fc6LC?= =?us-ascii?Q?TyMKw87cktAAa2PpyIuH9pKtA3jg4T6aojkVAgm6rR2lyBzZPtlc2zvDj0iX?= =?us-ascii?Q?zVmyjRQ4hPm/wnJaSjzV/j0wlBzZDDlaifDxaw2HUaEuovV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dgUDOkzX1RnuHFsfnsZd2nA6dMoGP8eWklM8bJ4WxXGmL3HU3?= =?us-ascii?Q?niF4tSOkZj6zfaNhuHtm3sdcXUgIS81/dyNJ9TqxJS5Z1zeuOgchhX8jy4AI?= =?us-ascii?Q?a1lP1WZXn75OyTaF5kZ8IaRx0ctkW+ek4r46Kciu?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b65dbaf-c517-47b4-2f0a-08de05ff90f0 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:13:54.1990 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8mGueQSDIpeaXf+CzQHyfBZOWjEuhXxIiBeA4tZU3e6QJRyALVWL/B8u/0csTsgUtnAf5MxLaqeu22RqwZfmyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Content-Type: text/plain; charset="utf-8" Add the RM registry and system information commands that enable the host driver to configure GSP firmware parameters during initialization. The RM registry is serialized into a packed format and sent via the command queue. For now only two parameters which are required to boot GSP are hardcoded. In future a kernel module parameter will be added to enable other parameters to be added. Also add the system info command, which provides required hardware information to the GSP. These commands use the GSP command queue infrastructure to issue commands to the GSP which is read during GSP boot. Signed-off-by: Alistair Popple Reviewed-by: Lyude Paul --- Changes for v4: - Use `init!` macros - Update to use send_gsp_command_with_payload() for the registry - Add RMDevidCheckIgnore registry setting (thanks Timur) Changes for v3: - Use MsgFunction enum - Rename GspCmdq to Cmdq - Rename GspCommandToGsp to CommandToGsp - Rename GspMessageFromGsp to MessageFromGsp - Split bindings into separate patch Changes for v2: - Rebased on Alex's latest tree --- drivers/gpu/nova-core/gsp.rs | 1 + drivers/gpu/nova-core/gsp/boot.rs | 6 +- drivers/gpu/nova-core/gsp/cmdq.rs | 2 - drivers/gpu/nova-core/gsp/commands.rs | 115 ++++++++++++++++++++++++++ drivers/gpu/nova-core/sbuffer.rs | 1 - 5 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 drivers/gpu/nova-core/gsp/commands.rs diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs index ef48da6afacd..9b6abb9755ba 100644 --- a/drivers/gpu/nova-core/gsp.rs +++ b/drivers/gpu/nova-core/gsp.rs @@ -23,6 +23,7 @@ use fw::GspArgumentsCached; =20 pub(crate) mod cmdq; +pub(crate) mod commands; =20 pub(crate) const GSP_PAGE_SHIFT: usize =3D 12; pub(crate) const GSP_PAGE_SIZE: usize =3D 1 << GSP_PAGE_SHIFT; diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/= boot.rs index 1d2448331d7a..0b306313ec53 100644 --- a/drivers/gpu/nova-core/gsp/boot.rs +++ b/drivers/gpu/nova-core/gsp/boot.rs @@ -16,6 +16,7 @@ FIRMWARE_VERSION, }; use crate::gpu::Chipset; +use crate::gsp::commands::{build_registry, set_system_info}; use crate::gsp::GspFwWprMeta; use crate::regs; use crate::vbios::Vbios; @@ -105,7 +106,7 @@ fn run_fwsec_frts( /// /// Upon return, the GSP is up and running, and its runtime object giv= en as return value. pub(crate) fn boot( - self: Pin<&mut Self>, + mut self: Pin<&mut Self>, pdev: &pci::Device, bar: &Bar0, chipset: Chipset, @@ -139,6 +140,9 @@ pub(crate) fn boot( CoherentAllocation::::alloc_coherent(dev, 1, GFP= _KERNEL | __GFP_ZERO)?; dma_write!(wpr_meta[0] =3D GspFwWprMeta::new(&gsp_fw, &fb_layout))= ?; =20 + set_system_info(&mut self.cmdq, pdev, bar)?; + build_registry(&mut self.cmdq, bar)?; + Ok(()) } } diff --git a/drivers/gpu/nova-core/gsp/cmdq.rs b/drivers/gpu/nova-core/gsp/= cmdq.rs index 317767d8f521..389f78c7e6e1 100644 --- a/drivers/gpu/nova-core/gsp/cmdq.rs +++ b/drivers/gpu/nova-core/gsp/cmdq.rs @@ -292,7 +292,6 @@ fn notify_gsp(bar: &Bar0) { NV_PGSP_QUEUE_HEAD::default().set_address(0).write(bar); } =20 - #[expect(unused)] pub(crate) fn send_gsp_command(&mut self, bar: &Bar0, init: impl= Init) -> Result where M: CommandToGsp, @@ -345,7 +344,6 @@ struct FullCommand { Ok(()) } =20 - #[expect(unused)] pub(crate) fn send_gsp_command_with_payload( &mut self, bar: &Bar0, diff --git a/drivers/gpu/nova-core/gsp/commands.rs b/drivers/gpu/nova-core/= gsp/commands.rs new file mode 100644 index 000000000000..92fbafeaf69c --- /dev/null +++ b/drivers/gpu/nova-core/gsp/commands.rs @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0 + +use kernel::build_assert; +use kernel::device; +use kernel::pci; +use kernel::prelude::*; +use kernel::transmute::AsBytes; + +use super::fw::commands::*; +use super::fw::MsgFunction; +use crate::driver::Bar0; +use crate::gsp::cmdq::Cmdq; +use crate::gsp::cmdq::{CommandToGsp, CommandToGspWithPayload}; +use crate::gsp::GSP_PAGE_SIZE; +use crate::sbuffer::SBuffer; + +// For now we hard-code the registry entries. Future work will allow other= s to +// be added as module parameters. +const GSP_REGISTRY_NUM_ENTRIES: usize =3D 3; +pub(crate) struct RegistryEntry { + key: &'static str, + value: u32, +} + +pub(crate) struct RegistryTable { + entries: [RegistryEntry; GSP_REGISTRY_NUM_ENTRIES], +} + +impl CommandToGsp for PackedRegistryTable { + const FUNCTION: MsgFunction =3D MsgFunction::SetRegistry; +} +impl CommandToGspWithPayload for PackedRegistryTable {} + +impl RegistryTable { + fn write_payload<'a, I: Iterator>( + &self, + mut sbuffer: SBuffer, + ) -> Result { + let string_data_start_offset =3D size_of::() + + GSP_REGISTRY_NUM_ENTRIES * size_of::(); + + // Array for string data. + let mut string_data =3D KVec::new(); + + for entry in self.entries.iter().take(GSP_REGISTRY_NUM_ENTRIES) { + sbuffer.write_all( + PackedRegistryEntry::new( + (string_data_start_offset + string_data.len()) as u32, + entry.value, + ) + .as_bytes(), + )?; + + let key_bytes =3D entry.key.as_bytes(); + string_data.extend_from_slice(key_bytes, GFP_KERNEL)?; + string_data.push(0, GFP_KERNEL)?; + } + + sbuffer.write_all(string_data.as_slice()) + } + + fn size(&self) -> usize { + let mut key_size =3D 0; + for i in 0..GSP_REGISTRY_NUM_ENTRIES { + key_size +=3D self.entries[i].key.len() + 1; // +1 for NULL te= rminator + } + GSP_REGISTRY_NUM_ENTRIES * size_of::() + key_= size + } +} + +pub(crate) fn build_registry(cmdq: &mut Cmdq, bar: &Bar0) -> Result { + let registry =3D RegistryTable { + entries: [ + // RMSecBusResetEnable - enables PCI secondary bus reset + RegistryEntry { + key: "RMSecBusResetEnable", + value: 1, + }, + // RMForcePcieConfigSave - forces GSP-RM to preserve PCI + // configuration registers on any PCI reset. + RegistryEntry { + key: "RMForcePcieConfigSave", + value: 1, + }, + // RMDevidCheckIgnore - allows GSP-RM to boot even if the PCI = dev ID + // is not found in the internal product name database. + RegistryEntry { + key: "RMDevidCheckIgnore", + value: 1, + }, + ], + }; + + cmdq.send_gsp_command_with_payload( + bar, + registry.size(), + PackedRegistryTable::init(GSP_REGISTRY_NUM_ENTRIES as u32, registr= y.size() as u32), + |sbuffer| registry.write_payload(sbuffer), + ) +} + +impl CommandToGsp for GspSystemInfo { + const FUNCTION: MsgFunction =3D MsgFunction::GspSetSystemInfo; +} + +pub(crate) fn set_system_info( + cmdq: &mut Cmdq, + dev: &pci::Device, + bar: &Bar0, +) -> Result { + build_assert!(size_of::() < GSP_PAGE_SIZE); + cmdq.send_gsp_command(bar, GspSystemInfo::init(dev))?; + + Ok(()) +} diff --git a/drivers/gpu/nova-core/sbuffer.rs b/drivers/gpu/nova-core/sbuff= er.rs index bde80cc3fa63..5acfd005a86b 100644 --- a/drivers/gpu/nova-core/sbuffer.rs +++ b/drivers/gpu/nova-core/sbuffer.rs @@ -159,7 +159,6 @@ fn get_slice_mut(&mut self, len: usize) -> Option<&'a m= ut [u8]> { =20 /// Ideally we would implement `Write`, but it is not available in `co= re`. /// So mimic `std::io::Write::write_all`. - #[expect(unused)] pub(crate) fn write_all(&mut self, mut src: &[u8]) -> Result { while !src.is_empty() { match self.get_slice_mut(src.len()) { --=20 2.50.1 From nobody Sat Feb 7 19:45:37 2026 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010014.outbound.protection.outlook.com [52.101.46.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E85B22F77B; Wed, 8 Oct 2025 00:14:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.14 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882447; cv=fail; b=AfUU9oFR9sLCdwwcLArPIYLF4VJDA2o4FTghXPYIU5KgUsuDIxzFTSrVzbITOfv1IRVpiFzZLCOoLuRfLfFtznT2tqI7qTZ0SpqTOApXD+i/LTKfOw/Rt45q2sOlNeuelXanJZcRcAEbnkJ+YEUR9hBv4/uDUHk6uiLefWZ820k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882447; c=relaxed/simple; bh=5jXcxDu6j06Y7OA7bNNflyw6YueMYOkYPoYM/GBHzMM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=EIaiYwGburIbn47Qe6ZnY245GU5KaxzCQoRfEtuTAuYpvAvPeyAyiwG3XMgMO78O6V46wPt7ugOx9mYmRmKOrnQ6YKo0UGK0bywhZ1g9WC23R2dPKKTEeu9Jt/9rm70Z+Foyiz2grzVSktiWwyoYKJN1Lh1u6cdLa5UPy6usj90= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=NSLI6kZY; arc=fail smtp.client-ip=52.101.46.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="NSLI6kZY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mF3ZzYdJvblabtNscYVZI7biXPZKC+91AFN70bDy27kq1XUjNCsLLCg5jIkz9iNncQFgROLyn1jof4YQCJlfkv5VBB2CTkzbsAlBaj5/BEp5zLA1LaOdQXx9X6tp+OUv7BRQbgJgv1N+pN15dd/vZ9UQmW7MNHlBiUZT9OmU82i684rO1k9vAODQOYLwwz2iRKcGeOnw4Ht7feiZnY2gBzQ0DLOgjOGNyqigpKGpxVEvdlwIv0fYdvDSL6wVcvNiSF2hJTmIwgxKZdDDeq74TFB4d9DsHsq2cWLJODg51lT6oV7FEgPOPvBw6wI54rJ/NGj3OxxZFNUekj939rmq7A== 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=YH//zDOnPNDWjR55GYjV0YCDDW6AXQn837vFF70r+2k=; b=L4xUe2whXS/FwA6UfCwJzcrUsEZdFzKGvshjQuswBdtxOb6/FUQp81XQuTt29b2tFv75jwqzZ88isGjp6GHLsyAke3/6egJguxua5/QfrhYUvygVw9ed8WHE+UvNcCn3BdHw2cqQPYOwZSHHE8WpFdYJ/YGx8l47pr9zHbmKNauxpP79bsMCkYoQIY6LN+/IUc5s572npJ7/5v+6rVvmXzgh0DLuzPGHiKwVWuC0Sh2bEfHc2gRnn2oW7lon6J+LHoUf/Z2S7xIS6ajqOUpigk5F0yuA0LkWe0KoSeZ8rl+t2mk8rq1qkZKu+pydG7p2n0C99ssNcm14XIuXMpKLBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YH//zDOnPNDWjR55GYjV0YCDDW6AXQn837vFF70r+2k=; b=NSLI6kZYwbucWTCTJFdAAKmkI6i9OKw5Yb4odcBb25kCM3Rq7FJGlUePOiUpWJOl5ylH5US3+nHBp8TUTFFjxzdbQlIvB91WJhoMNn9nRwBoWSvbJHBm+cGjbPNUXxwT/kPOC9ocnPTs5M8Ia1uEhbZWZ2hNN30eq+8sQ41C97n9dfNLvtZd+nT76vr8wihZXDAFX/6roKluqflnxw4Z2zVXHafMy8aJgvkk4+rwSe/CT/hmVoBMoYzx4bpnoWsiS5C9MDYGhQxIfmI/niS4HdNxC+PjuC8XACoYn28L2HF5ovH/1DJ0ugJ7rHTpr3sUHCbwxIb7yLia1hmf7V4O0g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:13:59 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:13:59 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, Lyude Paul Subject: [PATCH v4 11/13] nova-core: falcon: Add support to check if RISC-V is active Date: Wed, 8 Oct 2025 11:12:50 +1100 Message-ID: <20251008001253.437911-12-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SY8PR01CA0006.ausprd01.prod.outlook.com (2603:10c6:10:29c::31) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: 6801b0a1-d79c-4dfd-bc76-08de05ff9411 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?uSV5eJa8WEVFzjJn0pEKyEJgXVCUoznCVuJWNhCUnCrNwACSJVmJp9l9Hvjk?= =?us-ascii?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VlQG/AJAuznzam?= =?us-ascii?Q?8Fcjc3FpldIcMPDsS0BhkSdb7SuV0Ki0XaGwWT01jhXtRJUGAUx2OZXUZkBH?= =?us-ascii?Q?4Q+sqyB497OnDwECXr/oFkzE6aSIXM0bWGSQmNVt88tVPlUtM4rbmIKs9ARM?= =?us-ascii?Q?eMYwt78w2rAO0/qcidkefiz4FTbeOiGYqtwkDpibGXKINrZNtS6Au6wiB+Sa?= =?us-ascii?Q?724jrap5BFAzfovDrUTC8kO/gfCD9ROH8JnICz0/YFM01Wwm3l6h6up4sWf+?= =?us-ascii?Q?F98qW/H1Fy1Tti3oxSqOLhWDK3B+wMuTNinb2urApTTZk9YGve99jeMhsgmE?= =?us-ascii?Q?BCZIu75J0jn01XwjhhwOrVo61oHoWUV56wRG3KRWk8b+aBSVdKu93bbRIUgm?= =?us-ascii?Q?iLPDnZywoAIi/4FXPwjlNCMSKCdiT8Ms1afSFHATNjhOqXCzHXBVUSsknT0C?= =?us-ascii?Q?+8zxXyfuOpEojVKCrwd+Cyjj9yAH925/nRnVax/88UMIk5cDT3scuRqXXbgY?= =?us-ascii?Q?+Js88yU9sTpMAXrX/rmsbhNrjikLATP2?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?2aMYUqNnYsb0P5AIQUzua584h3TSr1yQRxz3SVDPkLkRQxWHNey7NAWtnNuZ?= =?us-ascii?Q?clWyXCFcvIlrVVsLYfIK9OxDmKz4N/6zrwXuHv76K5Pcz9bfodPnatEJ+3mp?= =?us-ascii?Q?302r+kPcevC4vFTOcdPuSkOy7XCxCEYSI8yZOmtJZywqsDGowfj48kdGYyMh?= =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UaC92wnpXjfCw1hQQY/Is3EQ7GZz?= =?us-ascii?Q?NGl0PzOtFWcOuJOEz+smOuXQhGn+TMfbXxuC4NLwd26QBVZnWoq9WvOR4+5j?= =?us-ascii?Q?+1fBve1cMT5mUl53rSHvocN46uUyLt6EAyKnd530SN3ia6qUTwW+DZI+w1m7?= =?us-ascii?Q?C3sI8oDc9efJ+JrXgHkSoy/1Y/OT94m4b74B9X8q+3mLKBAeXe/ze+QJIFv0?= =?us-ascii?Q?z6kOSPDCeJZE36Ohp+trtv/lgRnbBhgs+xU36T0CaHNEwFcg52eLZRyGnvL4?= =?us-ascii?Q?C3Y+2NgNjubLszqMArFV7NVb7TU27e9GHZHJ8MRk9R97Oa2Fj0gNbqihgX2Q?= =?us-ascii?Q?7marcfVwI8T7gxdd6QHsWvwE5k85nV8tL0HCNxLHbTw9F2NvINWs1+M38nN1?= =?us-ascii?Q?aMJFy/clOwcAkzsI9T4lx0GHx5/6XLoAd1vCNbumOyTAPV6C3nvXn5fiAdG8?= =?us-ascii?Q?Qi8k4T2VHoZSQrGjZSeTv/zaW2TRk7CeXqODyUbKboy45Dsh9dQLYqEu3aOM?= =?us-ascii?Q?JyYaTcwI9Pfi5DOuMEVXSfugqNNipobMZMVvFnTp?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6801b0a1-d79c-4dfd-bc76-08de05ff9411 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:13:59.4213 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gArOTNPZAxF+5pvfMiGxaY11mUNy9IY5tK6WU7OZJzucUhQ1jgnQBGZxZnuELRKdTlvqFECCi7nU8siWlELZrg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Content-Type: text/plain; charset="utf-8" From: Joel Fernandes Add definition for RISCV_CPUCTL register and use it in a new falcon API to check if the RISC-V core of a Falcon is active. It is required by the sequencer to know if the GSP's RISCV processor is active. Signed-off-by: Joel Fernandes Reviewed-by: Lyude Paul --- Changes for v4: - Return bool instead of Result from is_riscv_active() as it can't fail (thanks Timur). - Update register definitions to correct Falcon - Switch register definition order --- drivers/gpu/nova-core/falcon.rs | 9 +++++++++ drivers/gpu/nova-core/regs.rs | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon= .rs index 734ac0fbfb49..185ed6d1cfb8 100644 --- a/drivers/gpu/nova-core/falcon.rs +++ b/drivers/gpu/nova-core/falcon.rs @@ -506,4 +506,13 @@ pub(crate) fn signature_reg_fuse_version( self.hal .signature_reg_fuse_version(self, bar, engine_id_mask, ucode_i= d) } + + /// Check if the RISC-V core is active. + /// + /// Returns `true` if the RISC-V core is active, `false` otherwise. + #[expect(unused)] + pub(crate) fn is_riscv_active(&self, bar: &Bar0) -> bool { + let cpuctl =3D regs::NV_PRISCV_RISCV_CPUCTL::read(bar, &E::ID); + cpuctl.active_stat() + } } diff --git a/drivers/gpu/nova-core/regs.rs b/drivers/gpu/nova-core/regs.rs index 0585699ae951..3bd1bddb16bb 100644 --- a/drivers/gpu/nova-core/regs.rs +++ b/drivers/gpu/nova-core/regs.rs @@ -324,7 +324,12 @@ pub(crate) fn mem_scrubbing_done(self) -> bool { =20 // PRISCV =20 -register!(NV_PRISCV_RISCV_BCR_CTRL @ PFalconBase[0x00001668] { +register!(NV_PRISCV_RISCV_CPUCTL @ PFalcon2Base[0x00000388] { + 0:0 halted as bool; + 7:7 active_stat as bool; +}); + +register!(NV_PRISCV_RISCV_BCR_CTRL @ PFalcon2Base[0x00000668] { 0:0 valid as bool; 4:4 core_select as bool =3D> PeregrineCoreSelect; 8:8 br_fetch as bool; --=20 2.50.1 From nobody Sat Feb 7 19:45:37 2026 Received: from SA9PR02CU001.outbound.protection.outlook.com (mail-southcentralusazon11013036.outbound.protection.outlook.com [40.93.196.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0CC723B615; Wed, 8 Oct 2025 00:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.93.196.36 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882453; cv=fail; b=ZxICrqPEQrcjgMjXQMuueNIHR3o5ntsyvmzaELZHVlBj56SuuDGXeAvy82lAjB4nRd/tWEGpVwaRqnFmBPsIE1L0ghtUzt0YbvUZA5W9mY2drpf6QhCeAH3TsCM1Ik+7ZRMeElSK28OOkmIssEEaHlhqyMr4bw5EtSBTZJ2RiVU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882453; c=relaxed/simple; bh=OU1gdF3AUCN1frLz5eSLrROgKDjp739HkYG+/nTBlQ0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=JxNnIUnHi3DN0Laji/pfZikU9HJGsG3gH5YW+uZ2WirJHwfXUK+qAUyR9oj0bm4RhIaq7jXrDJM42EumkFWVapPTAv9NhmyNBts5Y16xuYc1sCoPgzWsHJhgsAbwvJeKgX/SIzUiqaYYdK7srAnARBIclyXGSG/7etWh+EkjWgI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=K8uOotr/; arc=fail smtp.client-ip=40.93.196.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="K8uOotr/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r9rhDIGltxm4Ggiu1F7mCXEVsoEj47KMSxfTG8i5r4wiCMNoXgZ+DEeZ47tdzV7wihWsA9cIBoQLYR4Jpta1qZsOSReYwcbZCQzvrrgkuA1MBhH5fJSqbAfwCd5ZlOw3lmk9hwr2z+X66d+I9J+PtN4fzMogukTEYOvPl1OL2F5nfBiOd5yfii8swB9Ws44HV96kPdC3r2BvS3mtHxTFzerkhloeA1drDUibZmSVrc/D5AmtPJ29WiJSrula+1geDSVbTDowsQBdgc0Ht9R2I7Fo4FKtReIZjO0BeioDAYXT3NrfARhaP5hKuv162o3t/XtRTqK5Z5fMsUnTh8fCmA== 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=9PjBBS88kesQUItpxF3PEFBp3u3sENX38cl6NSTghgs=; b=NXuwndQ3T5xvalsw99gzYmRcSbCpOqAj8B7l8KtCzePscjBZ4ylF/iUB7jUi3hN5CA0cAt3Q4yjX+ul5MI1B9omotRwMusbqhf5uO0Csl4w4YwbNFJDzRB69xpXeerK0X10NoWweVzTyCZM7mgm5KqmM7SGrr9ZlbFMjmE0t5NxdL+tSkSCzZ5jHmpBGt9dJ5s4W8iGtezJyrtUKf07fo7fwW3aPfSGl8kGuMf7/4RUP0oBSBHcnz91sHYZtYzwHoZjs4fQpXBPU+pgHndHJ35GF0t16xHXEht7Nl3JDRP4/GLCOUIMTpD6HI/lhTTr8HHd2Wj9FHr6hkt2SoptgzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9PjBBS88kesQUItpxF3PEFBp3u3sENX38cl6NSTghgs=; b=K8uOotr/N2O5FGM4AF9dzLQyALC1h2UXhGi1uzTV+v1/SCqgnWdrAxfFmDGghkJRgHR7v5mbX7EFYqxX+DudB7Hb7UVP28uf9XF+C7klHb8lAj+16KiOeiVDMscz2wORlLlCcfDncX/V8yiikgFM1q1ADYohSKl1u4VZA4+8NDE4n3WQF9nkDTjmH7oIE5Kx+VA0ECSmrEyUzgLVPN6mH876MJCTfK2rNANwkIkq+5phH8ekUjBCGvuaJr/9QtBqqcG8/uGZUOGqW+zppYJYESY3CzfMTyXsqFVWcbAVzJWcsAO3o7wlVlhzSvV77tGesAbBpP6PGEMrf9DtaOq3/A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4071.namprd12.prod.outlook.com (2603:10b6:610:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:14:05 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:14:05 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, Lyude Paul Subject: [PATCH v4 12/13] nova-core: falcon: Add support to write firmware version Date: Wed, 8 Oct 2025 11:12:51 +1100 Message-ID: <20251008001253.437911-13-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SY6PR01CA0128.ausprd01.prod.outlook.com (2603:10c6:10:1b9::8) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4071:EE_ X-MS-Office365-Filtering-Correlation-Id: 39186b0b-b327-4332-84de-08de05ff975d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?4o3NcR2+h1xkBt42mnDSTNe6lqLVK2pQ9QKZpHiqsc7G/Xjb9JpM4EDUZj/M?= =?us-ascii?Q?1wfnaatRJSF+Rrgt0/06orYDLoe1LLmBhaiqPBU2uLzrpCnv9RrthVuQNJKu?= =?us-ascii?Q?Sf5efrBpbMrK7AxmAZ7/pxsj8Kv1mM6bdH8+FYdAEQm4Zv/mWaInniIgex8k?= =?us-ascii?Q?hscuT2xS+Io9lH60IzPUnIQ45eafydZb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?Q?BPoqtR18sachS54wVXo9E1gWAM25jlBit6xTWG+qLGtaV3yZSA4CmpT9K+3G?= =?us-ascii?Q?pRPSWNcIE/YxRacDIXTQTt7GnRdxguAsubCNmaCXROUKx8Dud+KPg2s2LAAI?= =?us-ascii?Q?sEbVWlrJYuwP7K6osnjaHMccUaPDkgX1PQi/HPp/tvbO/CcbNbXEtVHBqOUp?= =?us-ascii?Q?8NCcpkrydU7Lt/dz8vBl4/2C7lD/VPPmWLg4hL823QlDYWUS7pEG88idKYO4?= =?us-ascii?Q?IN963eutG/LmlitjRaayLNfhdR8PzTsMb6AHlEo1wtgimJMMEhbhssKkRb0Y?= =?us-ascii?Q?soJR7HZDueZEb7aQuC7d7Q/p0rk+HxVvaFebi6A+GKVJIJ9xMmBUypDrZaXI?= =?us-ascii?Q?3xrg8KxnAXaRv4W2QnTOQdZJlh0Fpb3O?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?M/NtYtdWlSVCbk2tj4a0pIxV77GbeSkZQeELenkvhzkx2qq6FTMQ5XCBRWN5?= =?us-ascii?Q?oPCPN43JIzmzcgRSrgoSNnPGmyxU73T5h2vMdeCWRAer7cQduKP2doBP0UxI?= =?us-ascii?Q?kulc/af97fc33vyuvnM2dZfMij3nN0jvlbrrwIn/FUcGSVJe88skUdM54JvK?= =?us-ascii?Q?TB3fO2m3KSeX1z7kRjlDWNcgKazSB9rz3yeg+sX1g5q4GmUon0HPNmZj9phj?= =?us-ascii?Q?yOFoYPcP+m1vkg4Mu+B9WwBdq8PZCFsHHIEbB0ddF6TyK9n5Qxr7S3Fy28E1?= =?us-ascii?Q?r+wQy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mkqdcN/7T4?= =?us-ascii?Q?nSG7fBLqsPr/a3fKQGQep4nuryKbVm36OknGVvhBSH1pRzCkRpedDRJ47p4X?= =?us-ascii?Q?N60r8i758GZ/BoAt7oYlBCbVE6IKha4mAVDEFAYQITAMI6jfRbdqV5g8zQ6o?= =?us-ascii?Q?dPCJ0R7tZJMvCnPJkcIPfv9mBM/mC6t1wjU2zrMRr+quxlK/lZjzsvfHL/QS?= =?us-ascii?Q?MKV1tdbeam2NAxiCAvJDP02LPYRVpNs6byU6k3GhbKVnozZYRKSCSrMmShjx?= =?us-ascii?Q?Myv5tYXLenBe/9+y4ZfdJiMhjxgAllvovZQpKOV/vDvR8llhr6wug/Qtpehl?= =?us-ascii?Q?fV252KOw6ACBx7QGjGhbddNPQ1h2uz3kVrt079Tc241cuQlohvZ3liF0QAPZ?= =?us-ascii?Q?8WWllH2GKC7OxcjWNeiCSlexuEW6akBszEpqMg1y?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 39186b0b-b327-4332-84de-08de05ff975d X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:14:04.9351 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZTHqNSa+nzdbo6BTNrqyomx3CYM3LelwYtib0XeY97a7pI1+AUdA+jAG/MHVjynzvZyW/iL3Oi1+8BzK9jbdsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4071 Content-Type: text/plain; charset="utf-8" From: Joel Fernandes This will be needed by both the GSP boot code as well as GSP resume code in the sequencer. Signed-off-by: Joel Fernandes Reviewed-by: Lyude Paul --- drivers/gpu/nova-core/falcon.rs | 9 +++++++++ drivers/gpu/nova-core/regs.rs | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon= .rs index 185ed6d1cfb8..01869b8deb8a 100644 --- a/drivers/gpu/nova-core/falcon.rs +++ b/drivers/gpu/nova-core/falcon.rs @@ -515,4 +515,13 @@ pub(crate) fn is_riscv_active(&self, bar: &Bar0) -> bo= ol { let cpuctl =3D regs::NV_PRISCV_RISCV_CPUCTL::read(bar, &E::ID); cpuctl.active_stat() } + + /// Write the application version to the OS register. + #[expect(dead_code)] + pub(crate) fn write_os_version(&self, bar: &Bar0, app_version: u32) ->= Result<()> { + regs::NV_PFALCON_FALCON_OS::default() + .set_value(app_version) + .write(bar, &E::ID); + Ok(()) + } } diff --git a/drivers/gpu/nova-core/regs.rs b/drivers/gpu/nova-core/regs.rs index 3bd1bddb16bb..6eda5c44c599 100644 --- a/drivers/gpu/nova-core/regs.rs +++ b/drivers/gpu/nova-core/regs.rs @@ -215,6 +215,12 @@ pub(crate) fn vga_workspace_addr(self) -> Option { 31:0 value as u32; }); =20 +// Used to store version information about the firmware running +// on the Falcon processor. +register!(NV_PFALCON_FALCON_OS @ PFalconBase[0x00000080] { + 31:0 value as u32; +}); + register!(NV_PFALCON_FALCON_RM @ PFalconBase[0x00000084] { 31:0 value as u32; }); --=20 2.50.1 From nobody Sat Feb 7 19:45:37 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011024.outbound.protection.outlook.com [52.101.52.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94FCE239E9E; Wed, 8 Oct 2025 00:14:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.24 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882455; cv=fail; b=l+AMKOd2cK10jbNlS4DFp03bt4sAIygUZCrz0b4ApH+LYVt+r5wN2uuWNsBhW4FEd4z8olal1P2TXGUS5eF/lb5FZzzayPA0TrzaqaAq+Zn87FabpwpH0k6J3rliKyLkDk1ePmKg01NBOXhhlaZgAcTt4Fdf2SGrDwSFezfTqFU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759882455; c=relaxed/simple; bh=K6jKliAK0ITvwZK2q2RuebaKQx+3wt9Qzd+8tK+VGv0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=Zc8mCNFYqNKGMevTk6v0/yGqnrL37JqkRAiFi8tEpduBOKcXg22e+uz9BRx/ElGz4uftPzbh+s7oo9cpAKZ209RzfnSAODTn0HBD8VtssoXJLZSWniclct6m9UzlRxwKfwH6IiPtQSpAfeIthK0n/Mp+l0tkno58EWkO1OVvrcI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=SetMIuje; arc=fail smtp.client-ip=52.101.52.24 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="SetMIuje" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Eb6+DyuAB57FKt8jFy5qgpU5jSYKAJT1i3ZuMdKidNB4RpcI0vdYtMI5iN5xc/KyPqADGTQoiBMp4L5bkUF9Gd1OKa6GHZ5rAYa+Pis6Mihsyr9V6M4d+1gfMisQRyaon6vEtQfyxwWp2U5jm1RdAPMufzlyKO72YkkoZ29EBoY0jQf39c0mTwcZo2rY+gzTxCKPHfo/QBk4skw9siSKkIeo+47B1uLvyAzjMVYcUuMSKa/wW6GjQPwoPxMv/gVgHx/w0J1aos19r/fdVg8ooEM0ZL8wA6ootByJpg77MEcAlenzKMuJ3jIrDBDC6BgMFPUsCa1ArtklkfRc+IJ1tQ== 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=VHaatapRNvMbAXgzB6/M6wcUhgrt3jsXdoWldNwUI54=; b=mJjTbrLWqDyawHfhPOMJ76PCvyfU3fqzMoRuethhZuRcp2OSO8j3q2abxn7OobddAylE3cuCej/Z61wgbex4P1WlVKGQQ7xOVBtp8l8goD74CuRnhyrXcs0kqQY8N3cuMP953JWfssvZ+KCMY4P51i6tC4dAr/T8pF/3uo4ftOjnqDAuyQBd7jDcKOuNzYCch/X+MsWx87Oj16P9Qpr46LYI4Sy+biBMODUsIYmmZ8wm/Eb7zVlOJlcZz/CjPTeZ7gN8rkYkBuyUZaMIu2xzuXmtcwcLgee4wgyfH27hM4YUAfLF5ES5YSkIJaQwgEuxMYeq7hQceuqzn8OSkJmihQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VHaatapRNvMbAXgzB6/M6wcUhgrt3jsXdoWldNwUI54=; b=SetMIujeFKaqCH5gEO39vZ01354XxDSmMihCs7z8mTdQsJjmSPtXBaAs8KC65n7elC3PIpyrIxy+mq5laAwmoXWVZpTk8B33jewpE15McWPm7r1nuNGRJRkSFEeNhAWG9DRI1tNEKvAsE8fs+yI5iFllkIEv27UnG1uHSR0zkxOqbE5qQj2514tF9Rb+BlL8Ki2z3INviOcizqBLRimTAhiyDogxmJeKuwXqcjhZZP/GYMNKvuJjUScFUmrjQS2SK/GVtAgO86ynknVv6BGZGckNVFWg0Om3h0W8wXMWaOaz9fUSFtTLzE4T3pw3tdt2Zhng6MyqHwiw7RMapHKdqQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) by CH2PR12MB4167.namprd12.prod.outlook.com (2603:10b6:610:7a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9203.9; Wed, 8 Oct 2025 00:14:10 +0000 Received: from DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe]) by DS0PR12MB7726.namprd12.prod.outlook.com ([fe80::953f:2f80:90c5:67fe%4]) with mapi id 15.20.9182.017; Wed, 8 Oct 2025 00:14:10 +0000 From: Alistair Popple To: rust-for-linux@vger.kernel.org, dri-devel@lists.freedesktop.org, dakr@kernel.org, acourbot@nvidia.com Cc: Alistair Popple , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , John Hubbard , Joel Fernandes , Timur Tabi , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, Lyude Paul Subject: [PATCH v4 13/13] nova-core: gsp: Boot GSP Date: Wed, 8 Oct 2025 11:12:52 +1100 Message-ID: <20251008001253.437911-14-apopple@nvidia.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251008001253.437911-1-apopple@nvidia.com> References: <20251008001253.437911-1-apopple@nvidia.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SY6PR01CA0016.ausprd01.prod.outlook.com (2603:10c6:10:e8::21) To DS0PR12MB7726.namprd12.prod.outlook.com (2603:10b6:8:130::6) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB7726:EE_|CH2PR12MB4167:EE_ X-MS-Office365-Filtering-Correlation-Id: cf05ad43-01b3-49e0-4a36-08de05ff9a85 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?ueRvtxEFWjhoSMCmhWoqsfTcCGCf+KOb/1fuECMVlTUqdJR6/0XQgk69f3zw?= =?us-ascii?Q?reFuovN6eqQBZqGenfEqSz7ACH6+iDb6yrDY208bhHZzUb5PuAppIJz3dK+J?= =?us-ascii?Q?Ke8crdODsXIIs6aXuVcZuPdrhoLX1N+Dax/hV2KtPSenAJJQ7T+I1XpY4NG5?= =?us-ascii?Q?gViVfTPH3X/ITRIony4g1EwRlOeHfzJOt/w0y8bcJgztADvbby9TVY0x6pP8?= =?us-ascii?Q?ct/0nWpuqAGGsjA9R31tajfcdvCblnhHY00ggLcz0TGBD5u5tB9696pcpn6Z?= =?us-ascii?Q?IE+4x18qJGsjIA5lQdz4g0dFcX6FVk0beaqAdq8RsPw8XKgTglBHXGtlfHTm?= =?us-ascii?Q?CIKdEtVPx3Vf5X4TS/vvVa2HFoUfY5Y8C0YZ2jiayoueosPVFEVbuaextz76?= =?us-ascii?Q?YfLWq/OKBJZgW/JPfcW01D6jeBp75qVepI/8R9sn4gH5N+YCkDbVtnORCXy1?= =?us-ascii?Q?PelE5EQj8LmGCqjnrcke4i2kp5b1MI/l5mXK5PEi0sUZx7x3kRmioD0myaJj?=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Vto/T8DS1WyDS0hgKnkdnOiV5BetDjrwQsd+7EtIeCm?= =?us-ascii?Q?zN+lkJr2Wd8DBSS+Ze1sov6iQ1KPhHg1?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB7726.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?/u/M3KlqKdWqkXd2DKrfw3nfP00QRX9QL9eLdjF5q6HU3dsZriECNVpkRe9V?= =?us-ascii?Q?q6Xls5iUEwcCoL0gRybUzLPYn8xBrwYxD6wpSEZ9byraCHzOhKgQHK/bwoC5?= =?us-ascii?Q?z1h2aT4TYD6ixOVYPoiUqinGXPpzD4UEXfet9o02XrFH+AdCJKOvZfxkX82k?= =?us-ascii?Q?fQcUO+YNJCayrhew6028YR81ZN7EEwbkRDHHNGNpt8rp+ydXNPlORua3p9Di?= =?us-ascii?Q?VL0zKJh1/i4QCuHs0jhEJJsOnIY0oYn705fvw3Rp09BgED7sLsNT6RlKCeWM?= =?us-ascii?Q?ArMEMg0Ku5+gbK4yXtRKjK5Cbr9Yudotn0OKK1n29j/jIaz5oJXwsVwKc9bS?= =?us-ascii?Q?ulVmXHeWZtsOnHFxHcArekkH0ifAKNxIk0HR+pC2wGQgmzc7ByM7ZNK/Nndq?= =?us-ascii?Q?c6rFysed26oiwLYm2r9enGhPyahH2la7owlmN1+u8//6/II++PJOqhJDrpNf?= =?us-ascii?Q?edRBXSDH47OFRnjB+iSFrKNzeVN7ZO9cB4eBGm1YqDIub2cRj134sPE+GL4Y?= =?us-ascii?Q?6f58pWJCrNrMxzw9TGAXzqj975NqAgllRjMNFEheNub0hO/mby54rAPlM008?= =?us-ascii?Q?Phph+UGVCLB/04GvTirEtrEANk77b9JXyf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uTNchJbVZH4rCPuIAqrA/0LJ61S25w1IgHq1qM76MidIeC?= =?us-ascii?Q?sYllxH0IRLh3ZV7SuyRSlumP44w7xmPdMvl0BSyu?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf05ad43-01b3-49e0-4a36-08de05ff9a85 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB7726.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2025 00:14:10.3999 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: V7CPo8cTigldr2IrqkFTJ9KgDHOGu7OGc+bareTDhdRYaxxgNWkhUFTY/pI2teWjaSUu6ifpzDJzG4bUVs9Y3w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4167 Content-Type: text/plain; charset="utf-8" Boot the GSP to the RISC-V active state. Completing the boot requires running the CPU sequencer which will be added in a future commit. Signed-off-by: Alistair Popple Reviewed-by: Lyude Paul --- Changes for v4: - Switch wait_on to read_poll_timeout Changes for v3: - Fixed minor nit from John - Added booter load error thanks to Timur's suggestion Changes for v2: - Rebased on Alex's latest tree --- drivers/gpu/nova-core/falcon.rs | 2 - drivers/gpu/nova-core/firmware/riscv.rs | 3 +- drivers/gpu/nova-core/gsp.rs | 2 +- drivers/gpu/nova-core/gsp/boot.rs | 63 ++++++++++++++++++++++++- 4 files changed, 64 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/nova-core/falcon.rs b/drivers/gpu/nova-core/falcon= .rs index 01869b8deb8a..3ee41aacf488 100644 --- a/drivers/gpu/nova-core/falcon.rs +++ b/drivers/gpu/nova-core/falcon.rs @@ -510,14 +510,12 @@ pub(crate) fn signature_reg_fuse_version( /// Check if the RISC-V core is active. /// /// Returns `true` if the RISC-V core is active, `false` otherwise. - #[expect(unused)] pub(crate) fn is_riscv_active(&self, bar: &Bar0) -> bool { let cpuctl =3D regs::NV_PRISCV_RISCV_CPUCTL::read(bar, &E::ID); cpuctl.active_stat() } =20 /// Write the application version to the OS register. - #[expect(dead_code)] pub(crate) fn write_os_version(&self, bar: &Bar0, app_version: u32) ->= Result<()> { regs::NV_PFALCON_FALCON_OS::default() .set_value(app_version) diff --git a/drivers/gpu/nova-core/firmware/riscv.rs b/drivers/gpu/nova-cor= e/firmware/riscv.rs index 76d0d36fee3e..87f2e16bc216 100644 --- a/drivers/gpu/nova-core/firmware/riscv.rs +++ b/drivers/gpu/nova-core/firmware/riscv.rs @@ -52,7 +52,6 @@ fn new(bin_fw: &BinFirmware<'_>) -> Result { } =20 /// A parsed firmware for a RISC-V core, ready to be loaded and run. -#[expect(unused)] pub(crate) struct RiscvFirmware { /// Offset at which the code starts in the firmware image. pub code_offset: u32, @@ -61,7 +60,7 @@ pub(crate) struct RiscvFirmware { /// Offset at which the manifest starts in the firmware image. pub manifest_offset: u32, /// Application version. - app_version: u32, + pub app_version: u32, /// Device-mapped firmware image. pub ucode: DmaObject, } diff --git a/drivers/gpu/nova-core/gsp.rs b/drivers/gpu/nova-core/gsp.rs index 9b6abb9755ba..0417da8525a8 100644 --- a/drivers/gpu/nova-core/gsp.rs +++ b/drivers/gpu/nova-core/gsp.rs @@ -35,7 +35,7 @@ /// GSP runtime data. #[pin_data] pub(crate) struct Gsp { - libos: CoherentAllocation, + pub libos: CoherentAllocation, pub loginit: CoherentAllocation, pub logintr: CoherentAllocation, pub logrm: CoherentAllocation, diff --git a/drivers/gpu/nova-core/gsp/boot.rs b/drivers/gpu/nova-core/gsp/= boot.rs index 0b306313ec53..7ba7932119e9 100644 --- a/drivers/gpu/nova-core/gsp/boot.rs +++ b/drivers/gpu/nova-core/gsp/boot.rs @@ -3,8 +3,10 @@ use kernel::device; use kernel::dma::CoherentAllocation; use kernel::dma_write; +use kernel::io::poll::read_poll_timeout; use kernel::pci; use kernel::prelude::*; +use kernel::time::Delta; =20 use crate::driver::Bar0; use crate::falcon::{gsp::Gsp, sec2::Sec2, Falcon}; @@ -127,7 +129,7 @@ pub(crate) fn boot( =20 Self::run_fwsec_frts(dev, gsp_falcon, bar, &bios, &fb_layout)?; =20 - let _booter_loader =3D BooterFirmware::new( + let booter_loader =3D BooterFirmware::new( dev, BooterKind::Loader, chipset, @@ -143,6 +145,65 @@ pub(crate) fn boot( set_system_info(&mut self.cmdq, pdev, bar)?; build_registry(&mut self.cmdq, bar)?; =20 + gsp_falcon.reset(bar)?; + let libos_handle =3D self.libos.dma_handle(); + let (mbox0, mbox1) =3D gsp_falcon.boot( + bar, + Some(libos_handle as u32), + Some((libos_handle >> 32) as u32), + )?; + dev_dbg!( + pdev.as_ref(), + "GSP MBOX0: {:#x}, MBOX1: {:#x}\n", + mbox0, + mbox1 + ); + + dev_dbg!( + pdev.as_ref(), + "Using SEC2 to load and run the booter_load firmware...\n" + ); + + sec2_falcon.reset(bar)?; + sec2_falcon.dma_load(bar, &booter_loader)?; + let wpr_handle =3D wpr_meta.dma_handle(); + let (mbox0, mbox1) =3D sec2_falcon.boot( + bar, + Some(wpr_handle as u32), + Some((wpr_handle >> 32) as u32), + )?; + dev_dbg!( + pdev.as_ref(), + "SEC2 MBOX0: {:#x}, MBOX1{:#x}\n", + mbox0, + mbox1 + ); + + if mbox0 !=3D 0 { + dev_err!( + pdev.as_ref(), + "Booter-load failed with error {:#x}\n", + mbox0 + ); + return Err(ENODEV); + } + + gsp_falcon.write_os_version(bar, gsp_fw.bootloader.app_version)?; + + // Poll for RISC-V to become active before running sequencer + read_poll_timeout( + || Ok(gsp_falcon.is_riscv_active(bar)), + |val: &bool| *val, + Delta::from_millis(10), + Delta::from_secs(5), + )?; + + dev_dbg!( + pdev.as_ref(), + "RISC-V active? {}\n", + gsp_falcon.is_riscv_active(bar), + ); + Ok(()) } } --=20 2.50.1