[PATCH v4 0/2] rust, nova-core: add DeviceSize trait for SZ_* constants

John Hubbard posted 2 patches 3 days, 14 hours ago
drivers/gpu/nova-core/fb.rs     |  21 ++--
drivers/gpu/nova-core/gsp/fw.rs |  15 ++-
drivers/gpu/nova-core/regs.rs   |   7 +-
rust/kernel/sizes.rs            | 167 +++++++++++++++++++++++---------
4 files changed, 142 insertions(+), 68 deletions(-)
[PATCH v4 0/2] rust, nova-core: add DeviceSize trait for SZ_* constants
Posted by John Hubbard 3 days, 14 hours ago
Changes in v4:
  * Renamed the trait from DeviceSize to SizeConstants.

  * Added backticks and trailing periods to all hex-value doc comments
    on the SZ_* constants.

  * Removed redundant type annotations from doc-test examples.

  * Used a `use` import for PAGE_SIZE in the module-level doc-test
    instead of a fully qualified path.

  * Rewrote doc-test comments to clarify the distinction between
    module-level constants (no type qualifier) and trait associated
    constants (type qualifier required).

  * Added Reviewed-by from Eliot Courtney.

Changes in v3:
  * Dropped the Alignment::from_u64() patch.

  * Reworked define_sizes! macro to accept target types as arguments
    (define_sizes!(u32, u64, usize)) using recursive macro arms,
    instead of hardcoding impls for u32 and u64. Overflow checking
    uses u128 casts so the same assert works for any ("reasonable")
    target type.

  * Added usize to the DeviceSize implementations, so the trait
    covers u32, u64, and usize.

  * Hex values for each constant are now proper doc-comments
    (forwarded via macro meta), instead of inline comments.

  * Rebased onto latest drm-rust-next.

Changes in v2:
  * Replaced flat SZ_*_U64 constants with a DeviceSize trait that
    provides SZ_* as associated constants on u32 and u64.

  * A define_sizes! macro generates everything from one list of names.

  * Added Alignment::from_u64() so alignment values can be constructed
    from DeviceSize constants without falling back to usize variants.

  * Rebased onto drm-rust-next. No longer depends on the Blackwell
    patchset.

v1 is here:
    https://lore.kernel.org/20260310023145.120037-1-jhubbard@nvidia.com

John Hubbard (2):
  rust: sizes: add SizeConstants trait for device address space
    constants
  gpu: nova-core: use SizeConstants trait for u64 size constants

 drivers/gpu/nova-core/fb.rs     |  21 ++--
 drivers/gpu/nova-core/gsp/fw.rs |  15 ++-
 drivers/gpu/nova-core/regs.rs   |   7 +-
 rust/kernel/sizes.rs            | 167 +++++++++++++++++++++++---------
 4 files changed, 142 insertions(+), 68 deletions(-)


base-commit: 7c50d748b4a635bc39802ea3f6b120e66b1b9067
-- 
2.53.0
Re: [PATCH v4 0/2] rust, nova-core: add DeviceSize trait for SZ_* constants
Posted by Gary Guo 2 days, 22 hours ago
On Wed Apr 1, 2026 at 11:27 PM BST, John Hubbard wrote:
>
> John Hubbard (2):
>   rust: sizes: add SizeConstants trait for device address space
>     constants
>   gpu: nova-core: use SizeConstants trait for u64 size constants

Acked-by: Gary Guo <gary@garyguo.net>

>
>  drivers/gpu/nova-core/fb.rs     |  21 ++--
>  drivers/gpu/nova-core/gsp/fw.rs |  15 ++-
>  drivers/gpu/nova-core/regs.rs   |   7 +-
>  rust/kernel/sizes.rs            | 167 +++++++++++++++++++++++---------
>  4 files changed, 142 insertions(+), 68 deletions(-)
>
>
> base-commit: 7c50d748b4a635bc39802ea3f6b120e66b1b9067