This patch series introduces a number of improvements to nova-core's register!() macro in order to make it more useful to Nova itself, and to bring it closer to graduation into the wider kernel crate.
The first half is trivial fixes and code reorganization to let the following patches apply more cleanly. The interesting stuff begins with the introduction of proper `Debug` and `Default` implementations leveraging the field information that is made available by the first half of the patchset. `Debug` now displays the interpreted values of all the fields on top of the hexadecimal representation of the register; and `Default` now initializes all the fields to their declared default value instead of just zeroes. Then goes a complete redesign of the way relative registers work. The previous way was very unsafe as it accepted any literal value as the base. Now, valid bases can (and must) be explicitly defined for specific group of relative registers. All these bases are belong to us, and thus can be validated at build-time. Next come arrays of registers, a useful feature to represent contiguous groups of registers that are interpreted identically. For these we have both build-time and runtime checked accessors. We immediately make use of them to clean up the FUSE registers code, which was a bit unsightly due to the lack of this feature. Finally, combining the two features: arrays of relative registers, which we don't really need at the moment, but will become needed for GSP booting. There are still features that need to be implemented before this macro can be considered ready for other drivers: - Make I/O accessors optional, - Support other sizes than `u32`, - Allow visibility control for registers and individual fields, - Convert the range syntax to inclusive slices instead of NVIDIA's OpenRM format, - ... and proper suitability assessment by other driver contributors. These should be trivial compared to the work that is done in this series. Signed-off-by: Alexandre Courbot <acour...@nvidia.com> --- Alexandre Courbot (17): gpu: nova-core: register: fix typo gpu: nova-core: register: fix alias documentation gpu: nova-core: register: simplify @leaf_accessor rule gpu: nova-core: register: remove `try_` accessors for relative registers gpu: nova-core: register: move OFFSET declaration to I/O impl block gpu: nova-core: register: fix documentation and indentation gpu: nova-core: register: add missing doccomments for fixed registers I/O accessors gpu: nova-core: register: add fields dispatcher internal rule gpu: nova-core: register: improve `Debug` implementation gpu: nova-core: register: generate correct `Default` implementation gpu: nova-core: register: split @io rule into fixed and relative versions gpu: nova-core: register: use #[inline(always)] for all methods gpu: nova-core: register: redesign relative registers gpu: nova-core: falcon: add distinct base address for PFALCON2 gpu: nova-core: register: add support for register arrays gpu: nova-core: falcon: use register arrays for FUSE registers gpu: nova-core: registers: add support for relative array registers John Hubbard (1): gpu: nova-core: register: minor grammar and spelling fixes Documentation/gpu/nova/core/todo.rst | 2 - drivers/gpu/nova-core/falcon.rs | 72 +-- drivers/gpu/nova-core/falcon/gsp.rs | 16 +- drivers/gpu/nova-core/falcon/hal/ga102.rs | 47 +- drivers/gpu/nova-core/falcon/sec2.rs | 13 +- drivers/gpu/nova-core/gpu.rs | 2 +- drivers/gpu/nova-core/regs.rs | 79 ++-- drivers/gpu/nova-core/regs/macros.rs | 736 +++++++++++++++++++++++++----- 8 files changed, 749 insertions(+), 218 deletions(-) --- base-commit: 4092e1b41202ff39aad75a40a03ac1d318443670 change-id: 20250703-nova-regs-24dddef5fba3 Best regards, -- Alexandre Courbot <acour...@nvidia.com>