From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CO1PR03CU002.outbound.protection.outlook.com (mail-westus2azon11010000.outbound.protection.outlook.com [52.101.46.0]) (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 3079F35DA60; Tue, 31 Mar 2026 21:21:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.46.0 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774992069; cv=fail; b=ENP0tCYFuOxQM6dtRIQ5wGZsbIj+W8NEg3neklpfbSM1zggdYdfIFt0MXjV7jcpmgQjz2FubhWy7EcOgcHD6bnA9Mh2+h15x2JY+Db1OY+AgDaxnLkqYokCMj2ktXdlDuEXr8cKCavdTRprkODb0KnrEzKyIZPrQYwmB57CYxBw= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774992069; c=relaxed/simple; bh=YM0IjSFf8dzQ3mLhgccnzapDJXRTUiotT/5ChxHn5wA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=QFnTrlyZlxQvbSelVYwWFPpCHo3nv85zgWrbpH62U55L/NzzPJMRXgygEl1t8FSIj/VWaqe8q1bLz2oKAHNWVgiL2pahxTv/CXAHa2TTDP+jGoKNrMOgNJ4fAwZ7b9dXyA2WX7nTL2djcEBob+fwsoLNvOKJ7+mCyoqgk355Hb0= 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=PUhP+3uE; arc=fail smtp.client-ip=52.101.46.0 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="PUhP+3uE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VLGO0+lxgEkJo7mHdMEKMGQ4CoeqiZmvJfYVNdcmLm8j98BYY5ID/Ui10dlcfdVYXEpwas5nu5JL4VxpDKW1EmuYNxSpMcmO4aiLNnjEus5XRAvP0tSpt0HORu2kG+iBRs1cAWjawFEKNDowisdVgP8cKUAEM2kkLb6ku9D0xL2nVuRdqC88ZFJtka0eapG4FdWjY9haPsWhr5WdpShOA66SmERuVCvJ2/QSHN+fLmtHsxXxKEZVYUlLpLGZdGLz0gR9lC4tL3a6Zg+eA/XKPuyDc3RWCFjJlItGqaP91owwLHut/4UpzRu3exeo5izbKv/sF4CDh7vdquhvIDnWjg== 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=/4Ewwtq1i0RH2pVXx0MBFLaxvDIV74lF3X4sQRMdsBQ=; b=GYKPTHWgCncj5HAzx5zYQ7Fti/OawSkpYyrspKaWDUwzD8Smj2hU0NZbIND03wbL5YujyCN6vFlmZM8729uDk+9g+sfneECs1abtd9amUMcSbrSf22p2V4vB5dzvr41/1eUaRjyyMJ8s0vZUTKCw52S/zKmlzFtiGOraTm6ZtjUIFtYjql/yho8+XDZvsHG90QxfrLKDN8AAIvckf5PNtvxn710FhLyZy0wZJvXjrSCHaYep2w3RXPueiR/1WkV1QF4IyyN5v90UhC8yToNDWJgdjiZc3rgua+8jkmMBGpAdhEC/DgBxs7eB6IS3oZeztq/Unf9Blx5sWPnQCXVOBg== 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=/4Ewwtq1i0RH2pVXx0MBFLaxvDIV74lF3X4sQRMdsBQ=; b=PUhP+3uEOEjPYQIq9O4jXgeoIY3Duj3SXqqO1wXN2Yxm6nTbEBXEIl9Q00D79y1ioC6cZTmuMcgiHnzQqbEfMatAlZ/RGTRJ9Y28pgu3KCDuqIi9re3fT+oz9LS+84seFc+yp5CK7F2tYZ7mg7ioS21BApepWTfbC7s7C2vHfrDGbckMgybByhGO34kqzDfGmj/bj2L6HA/jYS5CUun7yYfwcNzzJzKJDc4xL2oI3geY2LaKIwW1apnwxUwEHCdR/4ooZE08SyuR+/EgZ4TtdUKAFMD1NaYxOVYskRVUWknl1734B5jsD9032982Eze/7qV6S1BRxcwEYM682dSq8Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DS0PR12MB6486.namprd12.prod.outlook.com (2603:10b6:8:c5::21) by BL1PR12MB5849.namprd12.prod.outlook.com (2603:10b6:208:384::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.8; Tue, 31 Mar 2026 21:21:02 +0000 Received: from DS0PR12MB6486.namprd12.prod.outlook.com ([fe80::88a9:f314:c95f:8b33]) by DS0PR12MB6486.namprd12.prod.outlook.com ([fe80::88a9:f314:c95f:8b33%4]) with mapi id 15.20.9769.014; Tue, 31 Mar 2026 21:21:02 +0000 From: Joel Fernandes To: linux-kernel@vger.kernel.org Cc: Miguel Ojeda , Boqun Feng , Gary Guo , Bjorn Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Dave Airlie , Daniel Almeida , Koen Koning , dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org, Nikola Djukic , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Jonathan Corbet , Alex Deucher , Christian Koenig , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Huang Rui , Matthew Auld , Matthew Brost , Lucas De Marchi , Thomas Hellstrom , Helge Deller , Alex Gaynor , Boqun Feng , John Hubbard , Alistair Popple , Timur Tabi , Edwin Peer , Alexandre Courbot , Andrea Righi , Andy Ritger , Zhi Wang , Balbir Singh , Philipp Stanner , Elle Rhumsaa , alexeyi@nvidia.com, Eliot Courtney , joel@joelfernandes.org, linux-doc@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, linux-fbdev@vger.kernel.org, Joel Fernandes Subject: [PATCH v10 00/21] gpu: nova-core: Add memory management support Date: Tue, 31 Mar 2026 17:20:27 -0400 Message-Id: <20260331212048.2229260-1-joelagnelf@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260311004008.2208806-1-joelagnelf@nvidia.com> References: <20260311004008.2208806-1-joelagnelf@nvidia.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MN2PR15CA0056.namprd15.prod.outlook.com (2603:10b6:208:237::25) To DS0PR12MB6486.namprd12.prod.outlook.com (2603:10b6:8:c5::21) Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR12MB6486:EE_|BL1PR12MB5849:EE_ X-MS-Office365-Filtering-Correlation-Id: c61c8a9b-95a0-4114-33bf-08de8f6b6924 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|366016|22082099003|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: l26iC7kUBWbAKYzDHcz1EdZOtjO0woVDZLZ/VsyLkIJEK2YAugtxvfgV1z8t76WnOgjp7najQ1j+9D4Zm5xSVHJ3iK4IiEztdZ8+FVN6SLjLaLZaByxrZTGXr1BKlAcnGI9Jcfb4V3DfHmFl6KNXD0V9qTGNLZ2wZnJFfFU2tY9XGX1Fbe+10mIvSCyY8r0du7pynUy+GzPyLgyzJlDHKj57m4w0IjoDuKt4L4Wg3FZFhogkVsAR205IbpnJAf+RsTH8ypQakbXAkXmZCFaW3QTbl59KSdeB9JdeEWMTl8655NP1092Hqys2PXs1raUUGZRQ/3mfgdRNzlFaBAkj7wlBz2v0Xk4eB//DrQChWBK0dICd4inS/zETPz+iuFamTttjbGCT65UYRXVda86rSSbHiyhGW0U4FQOAKszsNn1RkngHQbLFgNkklTaiAjPIM9NPW5LIuH9XfEH5uvrnTkX36aYbf5pDaqKBmCDLTIekFuEVBf+ABO7YjnsC+UvSRYVX3JsFzNrN60Lk81FPwWN8n7h1Mjg7D8HLqzXd64imjcy9Ts6Rng1diU1imzwUivJZgNVpE8ZzG+qwcg3dhzWMQ6PzlZe4ZL7ocjvctc48ra//6EHRoS3KMQuyXCCaQYKK/Y21b0mblp4FAItc+Wl/Ty9GJRv4TISyYuOp8iSlC6cQK20rQmAB9aE4s5YQPrfQqGAsgzWXR6Gd8At0ptczqpbi0ZJEPEnAYAU8YFQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR12MB6486.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(366016)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?idrftnFxfpj+ycGoW/ToTfHESrR8jV3RyEzy40A6O9ZZuMBR7YvPt/G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avg4NMQTgoSsdr62q4DgG?= =?us-ascii?Q?6VXhULEGmFch28zkKehEz9836u4sTjtdihZRGcX2cCMlI4MFPU6CgL+OtPQk?= =?us-ascii?Q?m97Bewt/UKw981dXkbo05s/k43sqVKwpHiWQSgCez9ddTJxtT6NmX9L0kMpS?= =?us-ascii?Q?HI848IQDs4zQjEBPrZ9+K0DeqxNOGXzMZs3nhHbdk/LjjPu7O0Rk4TUd8Bhs?= =?us-ascii?Q?g27zYeznR0kLTIor7Arl7uKfiu6jFrqgRc6Gyna0uma2WEGjVi8dMCESq04a?= =?us-ascii?Q?fJKcDumKxZHWV3VaNW6+PV0l2WmTlAKu46RJyxWriTcXiY2ODJZFPXvw51qA?= =?us-ascii?Q?6MzaZMZtKMKJrzVnS0mSzYR1aZd/9T2upBdAXe8F4Fz4tTAPGn1d/LphTIxC?= =?us-ascii?Q?YG7LhIG2wHlqTa0j8KzPJs/eayHRHnH7Wj88KGXuANOKjtYliV7bKrckHJ/M?= =?us-ascii?Q?CBF6ETBE5oSzsiL7hCfn/zmlIFNgsd+obDNFYJVJzm4jR0k+q9U4+Qn8VLfS?= =?us-ascii?Q?nqkTiZtsz6pNQU9xCZDosuQjqPEFkspSGfEZxgsAG70KxrgsaB2I1JXBQyTN?= =?us-ascii?Q?1Xbmbiefwd331Ym3RAzXQ+LfDawPJoL72dbVeX6tFZE59lpoWnyjBVo7w0LQ?= =?us-ascii?Q?cGtPodw54MZMNVuE3NXiqRrEZ/EXj4eZX+MFcKKcnDKk4w+SyE65ASZWa8Nj?= =?us-ascii?Q?weC7wKOAE2oZ6m/YCMNaXgcwGz4VbRakSmcbmsppHfzXgOzVR2wSy6eiFv/H?= =?us-ascii?Q?hKkanJyoILGfM8OtMdx7mbmzwFL0HrTdhqmifd7IYQXHlBtiHKStbGL1MCJw?= =?us-ascii?Q?eCePT4KXzQ=3D=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c61c8a9b-95a0-4114-33bf-08de8f6b6924 X-MS-Exchange-CrossTenant-AuthSource: DS0PR12MB6486.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2026 21:21:02.2923 (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: CYjk+sDQLty4LFVdE8PP80kKlvt1EUwzhHZ6NZYew3pgCgwNYRqONCzVnJ3gWxW2QMD38qoQOLOPq9drIARZag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5849 This series adds support for nova-core memory management, including VRAM allocation, PRAMIN, VMM, page table walking, and BAR 1 read/writes. These are critical for channel management, vGPU, and all other memory management uses of nova-core. The patches are based on drm-rust-next and work on Ampere, and should "just work on Blackwell" once John's Blackwell patches are merged, however it does not depend on those patches and can independently go in. Change log: Changes from v9 to v10: - Rebased and dropped patches already merged in to drm-rust-next. - GPU_BUDDY select folded into GpuMm patch. - updated code with new register macro API. - Refactored fb_regions() to use iterator (Alex Courbot). - Renamed Pramin::window() to get_window() to make it more clear it is 'acquiring a resource'. - Converted Bar0WindowTarget to bounded_enum! macro, replacing TryFrom. Allows to use `with_*` instead of `try_with_*`. Changes from v8 to v9: - Added fixes from Zhi Wang for bitfield position changes in virtual address and larger BAR1 size on some platforms. Tested and working for vGPU usecase! - Refactored gsp: boot() to return only GspStaticInfo, removing FbLayout (Alex). - bar1_pde_base and bar2_pde_base are now accessed via GspStaticInfo directly (Alex). - Added new patch "gsp: Expose total physical VRAM end from FB region info" introducing total_fb_end() to expose VRAM extent (Alex). - Consolidated usable VRAM and BarUser setup; removed dedicated "fb: Add usable_vram field to FbLayout", "mm: Use usable VRAM region for buddy allocator", and "mm: Add BarUser to struct Gpu and create at boot". Changes from v7 to v8: - Incorporated "Select GPU_BUDDY for VRAM allocation" patch from the dependency series (Alex). - Significant patch reordering for better logical flow (GSP/FB patches moved earlier, page table patches, Vmm, Bar1, tests) (Alex). - Replaced several 'as' usages with into_safe_cast() (Danilo, Alex). - Updated BAR 1 test cases to include exercising the block size API (Eliot, Danilo). Changes from v6 to v7: - Addressed DMA fence signalling usecase per Danilo's feedback. Pre v6: - Simplified PRAMIN code (John Hubbard, Alex Courbot). - Handled different MMU versions: ver2 versus ver3 (John Hubbard). - Added BAR1 usecase so we have user of DRM Buddy / VMM (John Hubbard). - Iterating over clist/buddy bindings. Link to v9: https://lore.kernel.org/all/20260311004008.2208806-1-joelagnelf@nvidia.com/ Link to v8: https://lore.kernel.org/all/20260224225323.3312204-1-joelagnelf@nvidia.com/ Link to v7: https://lore.kernel.org/all/20260218212020.800836-1-joelagnelf@nvidia.com/ Joel Fernandes (20): gpu: nova-core: gsp: Return GspStaticInfo from boot() gpu: nova-core: gsp: Extract usable FB region from GSP gpu: nova-core: gsp: Expose total physical VRAM end from FB region info gpu: nova-core: mm: Add support to use PRAMIN windows to write to VRAM docs: gpu: nova-core: Document the PRAMIN aperture mechanism gpu: nova-core: mm: Add common memory management types gpu: nova-core: mm: Add TLB flush support gpu: nova-core: mm: Add GpuMm centralized memory manager gpu: nova-core: mm: Add common types for all page table formats gpu: nova-core: mm: Add MMU v2 page table types gpu: nova-core: mm: Add MMU v3 page table types gpu: nova-core: mm: Add unified page table entry wrapper enums gpu: nova-core: mm: Add page table walker for MMU v2/v3 gpu: nova-core: mm: Add Virtual Memory Manager gpu: nova-core: mm: Add virtual address range tracking to VMM gpu: nova-core: mm: Add multi-page mapping API to VMM gpu: nova-core: Add BAR1 aperture type and size constant gpu: nova-core: mm: Add BAR1 user interface gpu: nova-core: mm: Add BAR1 memory management self-tests gpu: nova-core: mm: Add PRAMIN aperture self-tests Zhi Wang (1): gpu: nova-core: Use runtime BAR1 size instead of hardcoded 256MB Documentation/gpu/nova/core/pramin.rst | 123 +++++ Documentation/gpu/nova/index.rst | 1 + drivers/gpu/nova-core/Kconfig | 11 + drivers/gpu/nova-core/driver.rs | 3 + drivers/gpu/nova-core/gpu.rs | 94 +++- drivers/gpu/nova-core/gsp/boot.rs | 9 +- drivers/gpu/nova-core/gsp/commands.rs | 18 +- drivers/gpu/nova-core/gsp/fw/commands.rs | 59 ++- drivers/gpu/nova-core/mm.rs | 234 ++++++++++ drivers/gpu/nova-core/mm/bar_user.rs | 388 ++++++++++++++++ drivers/gpu/nova-core/mm/pagetable.rs | 489 ++++++++++++++++++++ drivers/gpu/nova-core/mm/pagetable/ver2.rs | 232 ++++++++++ drivers/gpu/nova-core/mm/pagetable/ver3.rs | 337 ++++++++++++++ drivers/gpu/nova-core/mm/pagetable/walk.rs | 218 +++++++++ drivers/gpu/nova-core/mm/pramin.rs | 489 ++++++++++++++++++++ drivers/gpu/nova-core/mm/tlb.rs | 95 ++++ drivers/gpu/nova-core/mm/vmm.rs | 499 +++++++++++++++++++++ drivers/gpu/nova-core/nova_core.rs | 1 + drivers/gpu/nova-core/regs.rs | 52 +++ 19 files changed, 3344 insertions(+), 8 deletions(-) create mode 100644 Documentation/gpu/nova/core/pramin.rst create mode 100644 drivers/gpu/nova-core/mm.rs create mode 100644 drivers/gpu/nova-core/mm/bar_user.rs create mode 100644 drivers/gpu/nova-core/mm/pagetable.rs create mode 100644 drivers/gpu/nova-core/mm/pagetable/ver2.rs create mode 100644 drivers/gpu/nova-core/mm/pagetable/ver3.rs create mode 100644 drivers/gpu/nova-core/mm/pagetable/walk.rs create mode 100644 drivers/gpu/nova-core/mm/pramin.rs create mode 100644 drivers/gpu/nova-core/mm/tlb.rs create mode 100644 drivers/gpu/nova-core/mm/vmm.rs base-commit: 76bce7ac51673640a4a46236ea723cf5543268d7 -- 2.34.1