Hi everyone, New revision addressing the feedback received on v3, and then some.
Notably the `register!` macro gets a few new features that add clarity to the code (like register aliases), and the `vbios` module has also been reworked according to feedback. We also now have a HAL in the fb module. The newly-introduced `num` module provides some very common operations (i.e. `align_down`, `align_up`), so it might make sense to consider merging it early. As previously, this series only successfully probes Ampere GPUs, but support for other generations is on the way. Upon successful probe, the driver will display the range of the WPR2 region constructed by FWSEC-FRTS with debug priority: [ 95.436000] NovaCore 0000:01:00.0: WPR2: 0xffc00000-0xffce0000 [ 95.436002] NovaCore 0000:01:00.0: GPU instance built This series is based on nova-next with no other dependencies. There are bits of documentation still missing, these are addressed by Joel in his own documentation patch series [1]. I'll also double-check and send follow-up patches if anything is still missing after that. [1] https://lore.kernel.org/rust-for-linux/20250503040802.1411285-1-joelagn...@nvidia.com/ Signed-off-by: Alexandre Courbot <acour...@nvidia.com> --- Changes in v4: - Improve documentation of falcon security modes (thanks Joel!) - Add the definition of the size of CoherentAllocation as one of its invariants. - Better document GFW boot progress, registers and use wait_on() helper, and move it to `gfw` module instead of `devinit`. - Add missing TODOs for workarounds waiting to be replaced by in-flight R4L features. - Register macro: add the offset of the register as a type constant, and allow register aliases for registers which can be interpreted differently depending on context. - Rework the `num` module using only macros (to allow use of overflowing ops), and add align_down() and fls() ops. - Add a proper HAL to the `fb` module. - Move HAL builders to impl blocks of Chipset. - Add proper types and traits for signatures. - Proactively split FalconFirmware into distinct traits to ease management of v2 vs v3 FWSEC headers that will be needed for Turing support. - Link to v3: https://lore.kernel.org/r/20250507-nova-frts-v3-0-fcb027497...@nvidia.com Changes in v3: - Rebased on top of latest nova-next. - Use the new Devres::access() and remove the now unneeded with_bar!() macro. - Dropped `rust: devres: allow to borrow a reference to the resource's Device` as it is not needed anymore. - Fixed more erroneous uses of `ERANGE` error. - Optimized alignment computations of the FB layout a bit. - Link to v2: https://lore.kernel.org/r/20250501-nova-frts-v2-0-b4a137175...@nvidia.com Changes in v2: - Rebased on latest nova-next. - Fixed all clippy warnings. - Added `count` and `size` methods to `CoherentAllocation`. - Added method to obtain a reference to the `Device` from a `Devres` (this is super convenient). - Split `DmaObject` into its own patch and added `Deref` implementation. - Squashed field names from [3] into "extract FWSEC from BIOS". - Fixed erroneous use of `ERANGE` error. - Reworked `register!()` macro towards a more intuitive syntax, moved its helper macros into internal rules to avoid polluting the macro namespace. - Renamed all registers to capital snake case to better match OpenRM. - Removed declarations for registers that are not used yet. - Added more documentation for items not covered by Joel's documentation patches. - Removed timer device and replaced it with a helper function using `Ktime`. This also made [4] unneeded so it is dropped. - Unregister the sysmem flush page upon device destruction. - ... probably more that I forgot. >_< - Link to v1: https://lore.kernel.org/r/20250420-nova-frts-v1-0-ecd1cca23...@nvidia.com [3] https://lore.kernel.org/all/20250423225405.139613-6-joelagn...@nvidia.com/ [4] https://lore.kernel.org/lkml/20250420-nova-frts-v1-1-ecd1cca23...@nvidia.com/ --- Alexandre Courbot (19): rust: dma: expose the count and size of CoherentAllocation rust: make ETIMEDOUT error available rust: sizes: add constants up to SZ_2G rust: add new `num` module with useful integer operations gpu: nova-core: use absolute paths in register!() macro gpu: nova-core: add delimiter for helper rules in register!() macro gpu: nova-core: expose the offset of each register as a type constant gpu: nova-core: allow register aliases gpu: nova-core: increase BAR0 size to 16MB gpu: nova-core: add helper function to wait on condition gpu: nova-core: wait for GFW_BOOT completion gpu: nova-core: add DMA object struct gpu: nova-core: register sysmem flush page gpu: nova-core: add falcon register definitions and base code gpu: nova-core: firmware: add ucode descriptor used by FWSEC-FRTS gpu: nova-core: compute layout of the FRTS region gpu: nova-core: add types for patching firmware binaries gpu: nova-core: extract FWSEC from BIOS and patch it to run FWSEC-FRTS gpu: nova-core: load and run FWSEC-FRTS Joel Fernandes (1): nova-core: Add support for VBIOS ucode extraction for boot drivers/gpu/nova-core/dma.rs | 58 ++ drivers/gpu/nova-core/driver.rs | 2 +- drivers/gpu/nova-core/falcon.rs | 557 ++++++++++++++ drivers/gpu/nova-core/falcon/gsp.rs | 22 + drivers/gpu/nova-core/falcon/hal.rs | 60 ++ drivers/gpu/nova-core/falcon/hal/ga102.rs | 122 +++ drivers/gpu/nova-core/falcon/sec2.rs | 8 + drivers/gpu/nova-core/firmware.rs | 86 +++ drivers/gpu/nova-core/firmware/fwsec.rs | 394 ++++++++++ drivers/gpu/nova-core/gfw.rs | 37 + drivers/gpu/nova-core/gpu.rs | 135 +++- drivers/gpu/nova-core/gsp.rs | 3 + drivers/gpu/nova-core/gsp/fb.rs | 77 ++ drivers/gpu/nova-core/gsp/fb/hal.rs | 30 + drivers/gpu/nova-core/gsp/fb/hal/ga100.rs | 24 + drivers/gpu/nova-core/gsp/fb/hal/ga102.rs | 24 + drivers/gpu/nova-core/gsp/fb/hal/tu102.rs | 28 + drivers/gpu/nova-core/nova_core.rs | 5 + drivers/gpu/nova-core/regs.rs | 265 +++++++ drivers/gpu/nova-core/regs/macros.rs | 63 +- drivers/gpu/nova-core/util.rs | 29 + drivers/gpu/nova-core/vbios.rs | 1173 +++++++++++++++++++++++++++++ rust/kernel/dma.rs | 18 + rust/kernel/error.rs | 1 + rust/kernel/lib.rs | 1 + rust/kernel/num.rs | 82 ++ rust/kernel/sizes.rs | 24 + 27 files changed, 3315 insertions(+), 13 deletions(-) --- base-commit: 276c53c66e032c8e7cc0da63555f2742eb1afd69 change-id: 20250417-nova-frts-96ef299abe2c Best regards, -- Alexandre Courbot <acour...@nvidia.com>