[PATCH 0/2] rust: add functions and traits for lossless integer conversions

From: Alexandre Courbot

Date: Mon Jul 27 2026 - 06:19:15 EST


This series introduces a copy of the lossless integer conversion
functions/traits of `nova-core` into the `kernel` crate, and makes
`nova-core` use them.

It is way overdue since its RFC [1]; recent dicussions [2] that have
suggested that it might become useful have triggered this posting.

This series is based on `rust-next`.

[1] https://lore.kernel.org/r/20251104-as_casts-v1-1-0a0e95bd2a9f@xxxxxxxxxx
[2] https://lore.kernel.org/all/DK82VNBOLWA7.1RFTZQWWNHIEH@xxxxxxxxxx/

Signed-off-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
---
Changes in v1:
- Update to latest version in `nova-core`.
- Make `nova-core` use the kernel crate implementation and remove its
own.
- Link to RFC: https://lore.kernel.org/r/20251104-as_casts-v1-1-0a0e95bd2a9f@xxxxxxxxxx

To: Alexandre Courbot <acourbot@xxxxxxxxxx>
To: Yury Norov <yury.norov@xxxxxxxxx>
To: Miguel Ojeda <ojeda@xxxxxxxxxx>
To: Boqun Feng <boqun@xxxxxxxxxx>
To: Gary Guo <gary@xxxxxxxxxxx>
To: Björn Roy Baron <bjorn3_gh@xxxxxxxxxxxxxx>
To: Benno Lossin <lossin@xxxxxxxxxx>
To: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
To: Alice Ryhl <aliceryhl@xxxxxxxxxx>
To: Trevor Gross <tmgross@xxxxxxxxx>
To: Danilo Krummrich <dakr@xxxxxxxxxx>
To: Daniel Almeida <daniel.almeida@xxxxxxxxxxxxx>
To: Tamir Duberstein <tamird@xxxxxxxxxx>
To: Onur Özkan <work@xxxxxxxxxxxxx>
To: David Airlie <airlied@xxxxxxxxx>
To: Simona Vetter <simona@xxxxxxxx>
Cc: John Hubbard <jhubbard@xxxxxxxxxx>
Cc: Alistair Popple <apopple@xxxxxxxxxx>
Cc: Timur Tabi <ttabi@xxxxxxxxxx>
Cc: Eliot Courtney <ecourtney@xxxxxxxxxx>
Cc: Zhi Wang <zhiw@xxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: rust-for-linux@xxxxxxxxxxxxxxx
Cc: nova-gpu@xxxxxxxxxxxxxxx
Cc: dri-devel@xxxxxxxxxxxxxxxxxxxxx

---
Alexandre Courbot (2):
rust: add functions and traits for lossless integer conversions
gpu: nova-core: use kernel lossless integer conversion module

drivers/gpu/nova-core/falcon.rs | 10 +-
drivers/gpu/nova-core/falcon/fsp.rs | 2 +-
drivers/gpu/nova-core/fb.rs | 2 +-
drivers/gpu/nova-core/fb/hal/gb100.rs | 6 +-
drivers/gpu/nova-core/firmware.rs | 8 +-
drivers/gpu/nova-core/firmware/booter.rs | 10 +-
drivers/gpu/nova-core/firmware/fwsec.rs | 2 +-
drivers/gpu/nova-core/firmware/fwsec/bootloader.rs | 2 +-
drivers/gpu/nova-core/firmware/gsp.rs | 2 +-
drivers/gpu/nova-core/firmware/riscv.rs | 6 +-
drivers/gpu/nova-core/fsp.rs | 2 +-
drivers/gpu/nova-core/gsp.rs | 2 +-
drivers/gpu/nova-core/gsp/cmdq.rs | 4 +-
drivers/gpu/nova-core/gsp/fw.rs | 8 +-
drivers/gpu/nova-core/gsp/sequencer.rs | 2 +-
drivers/gpu/nova-core/num.rs | 211 ------------------
drivers/gpu/nova-core/vbios.rs | 2 +-
rust/kernel/num.rs | 3 +
rust/kernel/num/casts.rs | 248 +++++++++++++++++++++
19 files changed, 286 insertions(+), 246 deletions(-)
---
base-commit: 3dab139d4795f688e4f243e40c7474df00d329d9
change-id: 20251104-as_casts-6a8882ac0192

Best regards,
--
Alexandre Courbot <acourbot@xxxxxxxxxx>