rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/6] Introduce bitfield and move register macro to rust/kernel/
@ 2025-09-20 18:22 Joel Fernandes
  2025-09-20 18:22 ` [PATCH v4 1/6] nova-core: bitfield: Move bitfield-specific code from register! into new macro Joel Fernandes
                   ` (5 more replies)
  0 siblings, 6 replies; 44+ messages in thread
From: Joel Fernandes @ 2025-09-20 18:22 UTC (permalink / raw)
  To: linux-kernel, rust-for-linux, dri-devel, dakr, acourbot
  Cc: Alistair Popple, Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
	bjorn3_gh, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, David Airlie, Simona Vetter, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, John Hubbard, Joel Fernandes,
	Timur Tabi, joel, Elle Rhumsaa, Yury Norov, Daniel Almeida,
	nouveau

Hello!

These patches extract and enhance the bitfield support in the register macro in
nova to define Rust structures with bitfields. This is extremely useful as it
allows clean Rust structure definitions without requiring explicit masks and
shifts.

See [1] example code using it.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git/patch/?id=76797b31facae8f1a1be139412c78568df1da9f3

v3 of the patches is at:
https://lore.kernel.org/all/20250909212039.227221-1-joelagnelf@nvidia.com/

v2 of the patches is at:
https://lore.kernel.org/all/20250903215428.1296517-1-joelagnelf@nvidia.com/

v1 of the patches is at:
https://lore.kernel.org/all/20250824135954.2243774-1-joelagnelf@nvidia.com/

v3->v4:
* Rebased on -next.
* Added more test cases.
* Added support for fields larger than the struct
  (ex, using 'as u32' for a u8 struct.)

v2->v3:
* Renamed bitstruct to bitfield.
* Various suggestions to improve code (Alex, Yury, Miguel).
* Added reviewed-by tags from Elle Rhumsaa.
* Added KUNIT tests including tests for overlap.
* Added F: maintainers file entry for new files under BITOPS.

v1->v2:
* Use build_assert in bitstruct
* Split move and enhance patches for easier review
* Move out of Nova into kernel crate for other drivers like Tyr which will use.
* Miscellaneous cosmetic improvements.

Joel Fernandes (6):
  nova-core: bitfield: Move bitfield-specific code from register! into
    new macro
  nova-core: bitfield: Add support for different storage widths
  nova-core: bitfield: Add support for custom visiblity
  rust: Move register and bitfield macros out of Nova
  rust: Add KUNIT tests for bitfield
  rust: bitfield: Use 'as' operator for setter type conversion

 MAINTAINERS                                   |   1 +
 drivers/gpu/nova-core/falcon.rs               |   2 +-
 drivers/gpu/nova-core/falcon/gsp.rs           |   4 +-
 drivers/gpu/nova-core/falcon/sec2.rs          |   2 +-
 drivers/gpu/nova-core/regs.rs                 |   6 +-
 rust/kernel/bits.rs                           |   2 +
 rust/kernel/bits/bitfield.rs                  | 736 ++++++++++++++++++
 rust/kernel/io.rs                             |   1 +
 .../macros.rs => rust/kernel/io/register.rs   | 289 +------
 9 files changed, 774 insertions(+), 269 deletions(-)
 create mode 100644 rust/kernel/bits/bitfield.rs
 rename drivers/gpu/nova-core/regs/macros.rs => rust/kernel/io/register.rs (73%)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2025-09-30 12:04 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-20 18:22 [PATCH v4 0/6] Introduce bitfield and move register macro to rust/kernel/ Joel Fernandes
2025-09-20 18:22 ` [PATCH v4 1/6] nova-core: bitfield: Move bitfield-specific code from register! into new macro Joel Fernandes
2025-09-21  9:36   ` Greg KH
2025-09-21  9:59     ` Miguel Ojeda
2025-09-21 11:23       ` Greg KH
2025-09-21 12:33     ` Benno Lossin
2025-09-21 12:45       ` Greg KH
2025-09-21 13:47         ` Danilo Krummrich
2025-09-23  6:38           ` Behme Dirk (XC-CP/ESD1)
2025-09-24 10:52           ` Greg KH
2025-09-24 11:28             ` Danilo Krummrich
2025-09-24 12:04               ` Greg KH
2025-09-24 14:38             ` Yury Norov
2025-09-24 15:53               ` Danilo Krummrich
2025-09-24 17:46               ` Joel Fernandes
2025-09-24 20:01                 ` Elle Rhumsaa
2025-09-25  7:05                   ` Joel Fernandes
2025-09-23 22:24         ` Joel Fernandes
2025-09-24 10:40           ` Greg KH
2025-09-29 19:26             ` Joel Fernandes
2025-09-29 19:37               ` Greg KH
2025-09-29 19:45                 ` Joel Fernandes
2025-09-29 20:25               ` Danilo Krummrich
2025-09-21 13:49     ` Danilo Krummrich
2025-09-29  6:16   ` Alexandre Courbot
2025-09-29 19:36     ` Joel Fernandes
2025-09-20 18:22 ` [PATCH v4 2/6] nova-core: bitfield: Add support for different storage widths Joel Fernandes
2025-09-29  6:22   ` Alexandre Courbot
2025-09-29 19:47     ` Joel Fernandes
2025-09-20 18:22 ` [PATCH v4 3/6] nova-core: bitfield: Add support for custom visiblity Joel Fernandes
2025-09-29  6:28   ` Alexandre Courbot
2025-09-29 20:20     ` Joel Fernandes
2025-09-20 18:22 ` [PATCH v4 4/6] rust: Move register and bitfield macros out of Nova Joel Fernandes
2025-09-29  6:30   ` Alexandre Courbot
2025-09-20 18:22 ` [PATCH v4 5/6] rust: Add KUNIT tests for bitfield Joel Fernandes
2025-09-20 18:22 ` [PATCH v4 6/6] rust: bitfield: Use 'as' operator for setter type conversion Joel Fernandes
2025-09-29  6:47   ` Alexandre Courbot
2025-09-29 20:32     ` Joel Fernandes
2025-09-29 13:59   ` Miguel Ojeda
2025-09-29 14:44     ` Alexandre Courbot
2025-09-29 15:17       ` Miguel Ojeda
2025-09-30 12:03       ` Joel Fernandes
2025-09-29 15:26     ` Yury Norov
2025-09-29 20:46     ` Joel Fernandes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).