[PATCH v2 0/3] rust: add `bitfield!` macro

Alexandre Courbot
2026-04-09T14:59:04Z

This is the continuation of the `bitfield!` macro which started
alongside the `register!` one before being temporarily integrated into
it [1].

There were still ongoing discussions in [1], notably about improving the
ergonomics of setting bitfield values. This revision doesn't try to
address them yet (although the `with_const` setters partially solve the
issue); it just extracts the `bitfield!` macro and makes it available,
for the following reasons:

- To get the ball rolling again after several months of hiatus,
- Because it is already useful as-is, and ergonomics will be improved
with macros built on top of the existing code,
- To allow dependencies over this series, notably the Nova MM series.

Thus, the discussions about ergonomics could take place as part of this
series, or as a follow-up - after all, bitfields are just registers
without I/O, so the present proposal does not introduce anything that is
not already in the kernel.

[1] https://lore.kernel.org/all/20260120-register-v1-0-723a1743b557@nvidia.com/

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
Alexandre Courbot (2):
rust: extract `bitfield!` macro from `register!`
gpu: nova-core: switch to kernel bitfield macro

Joel Fernandes (1):
rust: bitfield: Add KUNIT tests for bitfield

MAINTAINERS | 8 +
drivers/gpu/nova-core/bitfield.rs | 329 ---------------
drivers/gpu/nova-core/gsp/fw.rs | 15 +-
drivers/gpu/nova-core/nova_core.rs | 3 -
rust/kernel/bitfield.rs | 809 +++++++++++++++++++++++++++++++++++++
rust/kernel/io/register.rs | 246 +----------
rust/kernel/lib.rs | 1 +
7 files changed, 828 insertions(+), 583 deletions(-)
---
base-commit: a7a080bb4236ebe577b6776d940d1717912ff6dd
change-id: 20260408-bitfield-6e18254f4fdc

Best regards,
--
Alexandre Courbot <acourbot@nvidia.com>