Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpu: nova-core: add initial documentation

Add the initial documentation of the Nova project.

The initial project documentation consists out of a brief introduction
of the project, as well as project guidelines both general and nova-core
specific and a task list for nova-core specifically.

The task list is divided into tasks for general Rust infrastructure
required by the project, tasks regarding GSP enablement and firmware
abstraction, general GPU driver tasks as well as tasks related to
external API design and test infrastructure.

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://lore.kernel.org/r/20250306222336.23482-6-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

+571
+1
Documentation/gpu/drivers.rst
··· 24 24 panfrost 25 25 panthor 26 26 zynqmp 27 + nova/index 27 28 28 29 .. only:: subproject and html 29 30
+24
Documentation/gpu/nova/core/guidelines.rst
··· 1 + .. SPDX-License-Identifier: (GPL-2.0+ OR MIT) 2 + 3 + ========== 4 + Guidelines 5 + ========== 6 + 7 + This documents contains the guidelines for nova-core. Additionally, all common 8 + guidelines of the Nova project do apply. 9 + 10 + Driver API 11 + ========== 12 + 13 + One main purpose of nova-core is to implement the abstraction around the 14 + firmware interface of GSP and provide a firmware (version) independent API for 15 + 2nd level drivers, such as nova-drm or the vGPU manager VFIO driver. 16 + 17 + Therefore, it is not permitted to leak firmware (version) specifics, through the 18 + driver API, to 2nd level drivers. 19 + 20 + Acceptance Criteria 21 + =================== 22 + 23 + - To the extend possible, patches submitted to nova-core must be tested for 24 + regressions with all 2nd level drivers.
+446
Documentation/gpu/nova/core/todo.rst
··· 1 + .. SPDX-License-Identifier: (GPL-2.0+ OR MIT) 2 + 3 + ========= 4 + Task List 5 + ========= 6 + 7 + Tasks may have the following fields: 8 + 9 + - ``Complexity``: Describes the required familiarity with Rust and / or the 10 + corresponding kernel APIs or subsystems. There are four different complexities, 11 + ``Beginner``, ``Intermediate``, ``Advanced`` and ``Expert``. 12 + - ``Reference``: References to other tasks. 13 + - ``Link``: Links to external resources. 14 + - ``Contact``: The person that can be contacted for further information about 15 + the task. 16 + 17 + Enablement (Rust) 18 + ================= 19 + 20 + Tasks that are not directly related to nova-core, but are preconditions in terms 21 + of required APIs. 22 + 23 + FromPrimitive API 24 + ----------------- 25 + 26 + Sometimes the need arises to convert a number to a value of an enum or a 27 + structure. 28 + 29 + A good example from nova-core would be the ``Chipset`` enum type, which defines 30 + the value ``AD102``. When probing the GPU the value ``0x192`` can be read from a 31 + certain register indication the chipset AD102. Hence, the enum value ``AD102`` 32 + should be derived from the number ``0x192``. Currently, nova-core uses a custom 33 + implementation (``Chipset::from_u32`` for this. 34 + 35 + Instead, it would be desirable to have something like the ``FromPrimitive`` 36 + trait [1] from the num crate. 37 + 38 + Having this generalization also helps with implementing a generic macro that 39 + automatically generates the corresponding mappings between a value and a number. 40 + 41 + | Complexity: Beginner 42 + | Link: https://docs.rs/num/latest/num/trait.FromPrimitive.html 43 + 44 + Generic register abstraction 45 + ---------------------------- 46 + 47 + Work out how register constants and structures can be automatically generated 48 + through generalized macros. 49 + 50 + Example: 51 + 52 + .. code-block:: rust 53 + 54 + register!(BOOT0, 0x0, u32, pci::Bar<SIZE>, Fields [ 55 + MINOR_REVISION(3:0, RO), 56 + MAJOR_REVISION(7:4, RO), 57 + REVISION(7:0, RO), // Virtual register combining major and minor rev. 58 + ]) 59 + 60 + This could expand to something like: 61 + 62 + .. code-block:: rust 63 + 64 + const BOOT0_OFFSET: usize = 0x00000000; 65 + const BOOT0_MINOR_REVISION_SHIFT: u8 = 0; 66 + const BOOT0_MINOR_REVISION_MASK: u32 = 0x0000000f; 67 + const BOOT0_MAJOR_REVISION_SHIFT: u8 = 4; 68 + const BOOT0_MAJOR_REVISION_MASK: u32 = 0x000000f0; 69 + const BOOT0_REVISION_SHIFT: u8 = BOOT0_MINOR_REVISION_SHIFT; 70 + const BOOT0_REVISION_MASK: u32 = BOOT0_MINOR_REVISION_MASK | BOOT0_MAJOR_REVISION_MASK; 71 + 72 + struct Boot0(u32); 73 + 74 + impl Boot0 { 75 + #[inline] 76 + fn read(bar: &RevocableGuard<'_, pci::Bar<SIZE>>) -> Self { 77 + Self(bar.readl(BOOT0_OFFSET)) 78 + } 79 + 80 + #[inline] 81 + fn minor_revision(&self) -> u32 { 82 + (self.0 & BOOT0_MINOR_REVISION_MASK) >> BOOT0_MINOR_REVISION_SHIFT 83 + } 84 + 85 + #[inline] 86 + fn major_revision(&self) -> u32 { 87 + (self.0 & BOOT0_MAJOR_REVISION_MASK) >> BOOT0_MAJOR_REVISION_SHIFT 88 + } 89 + 90 + #[inline] 91 + fn revision(&self) -> u32 { 92 + (self.0 & BOOT0_REVISION_MASK) >> BOOT0_REVISION_SHIFT 93 + } 94 + } 95 + 96 + Usage: 97 + 98 + .. code-block:: rust 99 + 100 + let bar = bar.try_access().ok_or(ENXIO)?; 101 + 102 + let boot0 = Boot0::read(&bar); 103 + pr_info!("Revision: {}\n", boot0.revision()); 104 + 105 + | Complexity: Advanced 106 + 107 + Delay / Sleep abstractions 108 + -------------------------- 109 + 110 + Rust abstractions for the kernel's delay() and sleep() functions. 111 + 112 + FUJITA Tomonori plans to work on abstractions for read_poll_timeout_atomic() 113 + (and friends) [1]. 114 + 115 + | Complexity: Beginner 116 + | Link: https://lore.kernel.org/netdev/20250228.080550.354359820929821928.fujita.tomonori@gmail.com/ [1] 117 + 118 + IRQ abstractions 119 + ---------------- 120 + 121 + Rust abstractions for IRQ handling. 122 + 123 + There is active ongoing work from Daniel Almeida [1] for the "core" abstractions 124 + to request IRQs. 125 + 126 + Besides optional review and testing work, the required ``pci::Device`` code 127 + around those core abstractions needs to be worked out. 128 + 129 + | Complexity: Intermediate 130 + | Link: https://lore.kernel.org/lkml/20250122163932.46697-1-daniel.almeida@collabora.com/ [1] 131 + | Contact: Daniel Almeida 132 + 133 + Page abstraction for foreign pages 134 + ---------------------------------- 135 + 136 + Rust abstractions for pages not created by the Rust page abstraction without 137 + direct ownership. 138 + 139 + There is active onging work from Abdiel Janulgue [1] and Lina [2]. 140 + 141 + | Complexity: Advanced 142 + | Link: https://lore.kernel.org/linux-mm/20241119112408.779243-1-abdiel.janulgue@gmail.com/ [1] 143 + | Link: https://lore.kernel.org/rust-for-linux/20250202-rust-page-v1-0-e3170d7fe55e@asahilina.net/ [2] 144 + 145 + Scatterlist / sg_table abstractions 146 + ----------------------------------- 147 + 148 + Rust abstractions for scatterlist / sg_table. 149 + 150 + There is preceding work from Abdiel Janulgue, which hasn't made it to the 151 + mailing list yet. 152 + 153 + | Complexity: Intermediate 154 + | Contact: Abdiel Janulgue 155 + 156 + ELF utils 157 + --------- 158 + 159 + Rust implementation of ELF header representation to retrieve section header 160 + tables, names, and data from an ELF-formatted images. 161 + 162 + There is preceding work from Abdiel Janulgue, which hasn't made it to the 163 + mailing list yet. 164 + 165 + | Complexity: Beginner 166 + | Contact: Abdiel Janulgue 167 + 168 + PCI MISC APIs 169 + ------------- 170 + 171 + Extend the existing PCI device / driver abstractions by SR-IOV, config space, 172 + capability, MSI API abstractions. 173 + 174 + | Complexity: Beginner 175 + 176 + Auxiliary bus abstractions 177 + -------------------------- 178 + 179 + Rust abstraction for the auxiliary bus APIs. 180 + 181 + This is needed to connect nova-core to the nova-drm driver. 182 + 183 + | Complexity: Intermediate 184 + 185 + Debugfs abstractions 186 + -------------------- 187 + 188 + Rust abstraction for debugfs APIs. 189 + 190 + | Reference: Export GSP log buffers 191 + | Complexity: Intermediate 192 + 193 + Vec extensions 194 + -------------- 195 + 196 + Implement ``Vec::truncate`` and ``Vec::resize``. 197 + 198 + Currently this is used for some experimental code to parse the vBIOS. 199 + 200 + | Reference vBIOS support 201 + | Complexity: Beginner 202 + 203 + GPU (general) 204 + ============= 205 + 206 + Parse firmware headers 207 + ---------------------- 208 + 209 + Parse ELF headers from the firmware files loaded from the filesystem. 210 + 211 + | Reference: ELF utils 212 + | Complexity: Beginner 213 + | Contact: Abdiel Janulgue 214 + 215 + Build radix3 page table 216 + ----------------------- 217 + 218 + Build the radix3 page table to map the firmware. 219 + 220 + | Complexity: Intermediate 221 + | Contact: Abdiel Janulgue 222 + 223 + vBIOS support 224 + ------------- 225 + 226 + Parse the vBIOS and probe the structures required for driver initialization. 227 + 228 + | Contact: Dave Airlie 229 + | Reference: Vec extensions 230 + | Complexity: Intermediate 231 + 232 + Initial Devinit support 233 + ----------------------- 234 + 235 + Implement BIOS Device Initialization, i.e. memory sizing, waiting, PLL 236 + configuration. 237 + 238 + | Contact: Dave Airlie 239 + | Complexity: Beginner 240 + 241 + Boot Falcon controller 242 + ---------------------- 243 + 244 + Infrastructure to load and execute falcon (sec2) firmware images; handle the 245 + GSP falcon processor and fwsec loading. 246 + 247 + | Complexity: Advanced 248 + | Contact: Dave Airlie 249 + 250 + GPU Timer support 251 + ----------------- 252 + 253 + Support for the GPU's internal timer peripheral. 254 + 255 + | Complexity: Beginner 256 + | Contact: Dave Airlie 257 + 258 + MMU / PT management 259 + ------------------- 260 + 261 + Work out the architecture for MMU / page table management. 262 + 263 + We need to consider that nova-drm will need rather fine-grained control, 264 + especially in terms of locking, in order to be able to implement asynchronous 265 + Vulkan queues. 266 + 267 + While generally sharing the corresponding code is desirable, it needs to be 268 + evaluated how (and if at all) sharing the corresponding code is expedient. 269 + 270 + | Complexity: Expert 271 + 272 + VRAM memory allocator 273 + --------------------- 274 + 275 + Investigate options for a VRAM memory allocator. 276 + 277 + Some possible options: 278 + - Rust abstractions for 279 + - RB tree (interval tree) / drm_mm 280 + - maple_tree 281 + - native Rust collections 282 + 283 + | Complexity: Advanced 284 + 285 + Instance Memory 286 + --------------- 287 + 288 + Implement support for instmem (bar2) used to store page tables. 289 + 290 + | Complexity: Intermediate 291 + | Contact: Dave Airlie 292 + 293 + GPU System Processor (GSP) 294 + ========================== 295 + 296 + Export GSP log buffers 297 + ---------------------- 298 + 299 + Recent patches from Timur Tabi [1] added support to expose GSP-RM log buffers 300 + (even after failure to probe the driver) through debugfs. 301 + 302 + This is also an interesting feature for nova-core, especially in the early days. 303 + 304 + | Link: https://lore.kernel.org/nouveau/20241030202952.694055-2-ttabi@nvidia.com/ [1] 305 + | Reference: Debugfs abstractions 306 + | Complexity: Intermediate 307 + 308 + GSP firmware abstraction 309 + ------------------------ 310 + 311 + The GSP-RM firmware API is unstable and may incompatibly change from version to 312 + version, in terms of data structures and semantics. 313 + 314 + This problem is one of the big motivations for using Rust for nova-core, since 315 + it turns out that Rust's procedural macro feature provides a rather elegant way 316 + to address this issue: 317 + 318 + 1. generate Rust structures from the C headers in a separate namespace per version 319 + 2. build abstraction structures (within a generic namespace) that implement the 320 + firmware interfaces; annotate the differences in implementation with version 321 + identifiers 322 + 3. use a procedural macro to generate the actual per version implementation out 323 + of this abstraction 324 + 4. instantiate the correct version type one on runtime (can be sure that all 325 + have the same interface because it's defined by a common trait) 326 + 327 + There is a PoC implementation of this pattern, in the context of the nova-core 328 + PoC driver. 329 + 330 + This task aims at refining the feature and ideally generalize it, to be usable 331 + by other drivers as well. 332 + 333 + | Complexity: Expert 334 + 335 + GSP message queue 336 + ----------------- 337 + 338 + Implement low level GSP message queue (command, status) for communication 339 + between the kernel driver and GSP. 340 + 341 + | Complexity: Advanced 342 + | Contact: Dave Airlie 343 + 344 + Bootstrap GSP 345 + ------------- 346 + 347 + Call the boot firmware to boot the GSP processor; execute initial control 348 + messages. 349 + 350 + | Complexity: Intermediate 351 + | Contact: Dave Airlie 352 + 353 + Client / Device APIs 354 + -------------------- 355 + 356 + Implement the GSP message interface for client / device allocation and the 357 + corresponding client and device allocation APIs. 358 + 359 + | Complexity: Intermediate 360 + | Contact: Dave Airlie 361 + 362 + Bar PDE handling 363 + ---------------- 364 + 365 + Synchronize page table handling for BARs between the kernel driver and GSP. 366 + 367 + | Complexity: Beginner 368 + | Contact: Dave Airlie 369 + 370 + FIFO engine 371 + ----------- 372 + 373 + Implement support for the FIFO engine, i.e. the corresponding GSP message 374 + interface and provide an API for chid allocation and channel handling. 375 + 376 + | Complexity: Advanced 377 + | Contact: Dave Airlie 378 + 379 + GR engine 380 + --------- 381 + 382 + Implement support for the graphics engine, i.e. the corresponding GSP message 383 + interface and provide an API for (golden) context creation and promotion. 384 + 385 + | Complexity: Advanced 386 + | Contact: Dave Airlie 387 + 388 + CE engine 389 + --------- 390 + 391 + Implement support for the copy engine, i.e. the corresponding GSP message 392 + interface. 393 + 394 + | Complexity: Intermediate 395 + | Contact: Dave Airlie 396 + 397 + VFN IRQ controller 398 + ------------------ 399 + 400 + Support for the VFN interrupt controller. 401 + 402 + | Complexity: Intermediate 403 + | Contact: Dave Airlie 404 + 405 + External APIs 406 + ============= 407 + 408 + nova-core base API 409 + ------------------ 410 + 411 + Work out the common pieces of the API to connect 2nd level drivers, i.e. vGPU 412 + manager and nova-drm. 413 + 414 + | Complexity: Advanced 415 + 416 + vGPU manager API 417 + ---------------- 418 + 419 + Work out the API parts required by the vGPU manager, which are not covered by 420 + the base API. 421 + 422 + | Complexity: Advanced 423 + 424 + nova-core C API 425 + --------------- 426 + 427 + Implement a C wrapper for the APIs required by the vGPU manager driver. 428 + 429 + | Complexity: Intermediate 430 + 431 + Testing 432 + ======= 433 + 434 + CI pipeline 435 + ----------- 436 + 437 + Investigate option for continuous integration testing. 438 + 439 + This can go from as simple as running KUnit tests over running (graphics) CTS to 440 + booting up (multiple) guest VMs to test VFIO use-cases. 441 + 442 + It might also be worth to consider the introduction of a new test suite directly 443 + sitting on top of the uAPI for more targeted testing and debugging. There may be 444 + options for collaboration / shared code with the Mesa project. 445 + 446 + | Complexity: Advanced
+69
Documentation/gpu/nova/guidelines.rst
··· 1 + .. SPDX-License-Identifier: (GPL-2.0+ OR MIT) 2 + 3 + ========== 4 + Guidelines 5 + ========== 6 + 7 + This document describes the general project guidelines that apply to nova-core 8 + and nova-drm. 9 + 10 + Language 11 + ======== 12 + 13 + The Nova project uses the Rust programming language. In this context, all rules 14 + of the Rust for Linux project as documented in 15 + :doc:`../../rust/general-information` apply. Additionally, the following rules 16 + apply. 17 + 18 + - Unless technically necessary otherwise (e.g. uAPI), any driver code is written 19 + in Rust. 20 + 21 + - Unless technically necessary, unsafe Rust code must be avoided. In case of 22 + technical necessity, unsafe code should be isolated in a separate component 23 + providing a safe API for other driver code to use. 24 + 25 + Style 26 + ----- 27 + 28 + All rules of the Rust for Linux project as documented in 29 + :doc:`../../rust/coding-guidelines` apply. 30 + 31 + For a submit checklist, please also see the `Rust for Linux Submit checklist 32 + addendum <https://rust-for-linux.com/contributing#submit-checklist-addendum>`_. 33 + 34 + Documentation 35 + ============= 36 + 37 + The availability of proper documentation is essential in terms of scalability, 38 + accessibility for new contributors and maintainability of a project in general, 39 + but especially for a driver running as complex hardware as Nova is targeting. 40 + 41 + Hence, adding documentation of any kind is very much encouraged by the project. 42 + 43 + Besides that, there are some minimum requirements. 44 + 45 + - Every non-private structure needs at least a brief doc comment explaining the 46 + semantical sense of the structure, as well as potential locking and lifetime 47 + requirements. It is encouraged to have the same minimum documentation for 48 + non-trivial private structures. 49 + 50 + - uAPIs must be fully documented with kernel-doc comments; additionally, the 51 + semantical behavior must be explained including potential special or corner 52 + cases. 53 + 54 + - The APIs connecting the 1st level driver (nova-core) with 2nd level drivers 55 + must be fully documented. This includes doc comments, potential locking and 56 + lifetime requirements, as well as example code if applicable. 57 + 58 + - Abbreviations must be explained when introduced; terminology must be uniquely 59 + defined. 60 + 61 + - Register addresses, layouts, shift values and masks must be defined properly; 62 + unless obvious, the semantical sense must be documented. This only applies if 63 + the author is able to obtain the corresponding information. 64 + 65 + Acceptance Criteria 66 + =================== 67 + 68 + - Patches must only be applied if reviewed by at least one other person on the 69 + mailing list; this also applies for maintainers.
+30
Documentation/gpu/nova/index.rst
··· 1 + .. SPDX-License-Identifier: (GPL-2.0+ OR MIT) 2 + 3 + ======================= 4 + nova NVIDIA GPU drivers 5 + ======================= 6 + 7 + The nova driver project consists out of two separate drivers nova-core and 8 + nova-drm and intends to supersede the nouveau driver for NVIDIA GPUs based on 9 + the GPU System Processor (GSP). 10 + 11 + The following documents apply to both nova-core and nova-drm. 12 + 13 + .. toctree:: 14 + :titlesonly: 15 + 16 + guidelines 17 + 18 + nova-core 19 + ========= 20 + 21 + The nova-core driver is the core driver for NVIDIA GPUs based on GSP. nova-core, 22 + as the 1st level driver, provides an abstraction around the GPUs hard- and 23 + firmware interfaces providing a common base for 2nd level drivers, such as the 24 + vGPU manager VFIO driver and the nova-drm driver. 25 + 26 + .. toctree:: 27 + :titlesonly: 28 + 29 + core/guidelines 30 + core/todo
+1
MAINTAINERS
··· 7457 7457 B: https://gitlab.freedesktop.org/drm/nova/-/issues 7458 7458 C: irc://irc.oftc.net/nouveau 7459 7459 T: git https://gitlab.freedesktop.org/drm/nova.git nova-next 7460 + F: Documentation/gpu/nova/ 7460 7461 F: drivers/gpu/nova-core/ 7461 7462 7462 7463 DRM DRIVER FOR OLIMEX LCD-OLINUXINO PANELS