Re: [PATCH v5 6/9] rust: bitfield: Add KUNIT tests for bitfield

2025-10-01 Thread Elle Rhumsaa
On 10/2/25 2:51 AM, Alexandre Courbot wrote: On Thu Oct 2, 2025 at 11:16 AM JST, Elle Rhumsaa wrote: On 10/2/25 1:41 AM, Alexandre Courbot wrote: On Tue Sep 30, 2025 at 11:45 PM JST, Joel Fernandes wrote: Add KUNIT tests to make sure the macro is working correctly. Signed-off-by: Joel

Re: [PATCH v5 6/9] rust: bitfield: Add KUNIT tests for bitfield

2025-10-01 Thread Elle Rhumsaa
On 10/2/25 1:41 AM, Alexandre Courbot wrote: On Tue Sep 30, 2025 at 11:45 PM JST, Joel Fernandes wrote: Add KUNIT tests to make sure the macro is working correctly. Signed-off-by: Joel Fernandes --- rust/kernel/bitfield.rs | 321 1 file changed, 321

Re: [PATCH v4 1/6] nova-core: bitfield: Move bitfield-specific code from register! into new macro

2025-09-25 Thread Elle Rhumsaa
On 9/24/2025 4:38 PM, Yury Norov wrote: On Wed, Sep 24, 2025 at 12:52:41PM +0200, Greg KH wrote: On Sun, Sep 21, 2025 at 03:47:55PM +0200, Danilo Krummrich wrote: On Sun Sep 21, 2025 at 2:45 PM CEST, Greg KH wrote: Again, regmap handles this all just fine, why not just make bindings to tha

Re: [PATCH v2 3/4] nova-core: bitstruct: Add support for custom visiblity

2025-09-07 Thread Elle Rhumsaa
> ) => { > static_assert!(::core::mem::size_of::() <= $stride); > -bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); > +bitstruct!(pub(crate) struct $name: u32 $(, $comment)? { $($fields)* > } ); > register!(@io_relative_array $name @ $base [ $offset [ $size ; > $stride ] ]); > }; > > @@ -356,7 +356,7 @@ macro_rules! register { > } > ) => { > static_assert!($idx < $alias::SIZE); > -bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); > +bitstruct!(pub(crate) struct $name: u32 $(, $comment)? { $($fields)* > } ); > register!(@io_relative $name @ $base [ $alias::OFFSET + $idx * > $alias::STRIDE ] ); > }; > > @@ -365,7 +365,7 @@ macro_rules! register { > // to avoid it being interpreted in place of the relative register array > alias rule. > ($name:ident => $alias:ident [ $idx:expr ] $(, $comment:literal)? { > $($fields:tt)* }) => { > static_assert!($idx < $alias::SIZE); > -bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); > +bitstruct!(pub(crate) struct $name: u32 $(, $comment)? { $($fields)* > } ); > register!(@io_fixed $name @ $alias::OFFSET + $idx * $alias::STRIDE ); > }; > > -- > 2.34.1 > > Reviewed-by: Elle Rhumsaa

Re: [PATCH v2 2/4] nova-core: bitstruct: Add support for different storage widths

2025-09-06 Thread Elle Rhumsaa
fset [ $size ; $stride ]); > }; > > @@ -334,7 +334,7 @@ macro_rules! register { > $(, $comment:literal)? { $($fields:tt)* } > ) => { > static_assert!(::core::mem::size_of::() <= $stride); > -bitstruct!(struct $name $(, $comment)? { $($fields)* } ); > +bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); > register!(@io_relative_array $name @ $base [ $offset [ $size ; > $stride ] ]); > }; > > @@ -356,7 +356,7 @@ macro_rules! register { > } > ) => { > static_assert!($idx < $alias::SIZE); > -bitstruct!(struct $name $(, $comment)? { $($fields)* } ); > +bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); > register!(@io_relative $name @ $base [ $alias::OFFSET + $idx * > $alias::STRIDE ] ); > }; > > @@ -365,7 +365,7 @@ macro_rules! register { > // to avoid it being interpreted in place of the relative register array > alias rule. > ($name:ident => $alias:ident [ $idx:expr ] $(, $comment:literal)? { > $($fields:tt)* }) => { > static_assert!($idx < $alias::SIZE); > -bitstruct!(struct $name $(, $comment)? { $($fields)* } ); > +bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); > register!(@io_fixed $name @ $alias::OFFSET + $idx * $alias::STRIDE ); > }; > > -- > 2.34.1 > > Reviewed-by: Elle Rhumsaa

Re: [PATCH v2 4/4] rust: Move register and bitstruct macros out of Nova

2025-09-06 Thread Elle Rhumsaa
ult where > -T: ::core::ops::Deref>, > -B: crate::regs::macros::RegisterBase<$base>, > + ) -> $crate::error::Result where > +T: ::core::ops::Deref>, > +B: $crate::register::RegisterBase<$base>, > { > if idx < Self::SIZE { > Ok(Self::read(io, base, idx)) > } else { > -Err(EINVAL) > +Err($crate::error::code::EINVAL) > } > } > > @@ -690,14 +692,14 @@ pub(crate) fn try_write( > io: &T, > base: &B, > idx: usize, > -) -> ::kernel::error::Result where > -T: ::core::ops::Deref>, > -B: crate::regs::macros::RegisterBase<$base>, > +) -> $crate::error::Result where > +T: ::core::ops::Deref>, > +B: $crate::register::RegisterBase<$base>, > { > if idx < Self::SIZE { > Ok(self.write(io, base, idx)) > } else { > -Err(EINVAL) > +Err($crate::error::code::EINVAL) > } > } > > @@ -713,17 +715,19 @@ pub(crate) fn try_alter( > base: &B, > idx: usize, > f: F, > -) -> ::kernel::error::Result where > -T: ::core::ops::Deref>, > -B: crate::regs::macros::RegisterBase<$base>, > +) -> $crate::error::Result where > +T: ::core::ops::Deref>, > +B: $crate::register::RegisterBase<$base>, > F: ::core::ops::FnOnce(Self) -> Self, > { > if idx < Self::SIZE { > Ok(Self::alter(io, base, idx, f)) > } else { > -Err(EINVAL) > +Err($crate::error::code::EINVAL) > } > } > } > }; > } > + > +pub use register; > -- > 2.34.1 > > Reviewed-by: Elle Rhumsaa

Re: [PATCH v2 3/4] nova-core: bitstruct: Add support for custom visiblity

2025-09-06 Thread Elle Rhumsaa
> ) => { > static_assert!(::core::mem::size_of::() <= $stride); > -bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); > +bitstruct!(pub(crate) struct $name: u32 $(, $comment)? { $($fields)* > } ); > register!(@io_relative_array $name @ $base [ $offset [ $size ; > $stride ] ]); > }; > > @@ -356,7 +356,7 @@ macro_rules! register { > } > ) => { > static_assert!($idx < $alias::SIZE); > -bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); > +bitstruct!(pub(crate) struct $name: u32 $(, $comment)? { $($fields)* > } ); > register!(@io_relative $name @ $base [ $alias::OFFSET + $idx * > $alias::STRIDE ] ); > }; > > @@ -365,7 +365,7 @@ macro_rules! register { > // to avoid it being interpreted in place of the relative register array > alias rule. > ($name:ident => $alias:ident [ $idx:expr ] $(, $comment:literal)? { > $($fields:tt)* }) => { > static_assert!($idx < $alias::SIZE); > -bitstruct!(struct $name: u32 $(, $comment)? { $($fields)* } ); > +bitstruct!(pub(crate) struct $name: u32 $(, $comment)? { $($fields)* > } ); > register!(@io_fixed $name @ $alias::OFFSET + $idx * $alias::STRIDE ); > }; > > -- > 2.34.1 > > Reviewed-by: Elle Rhumsaa

Re: [PATCH 1/2] nova-core: Add a library for bitfields in Rust structs

2025-08-26 Thread Elle Rhumsaa
t; +} > + > +#[inline(always)] > +#[allow(dead_code)] > +$vis const fn [](mut self, val: $field_type) > -> Self { > +self.0 = bitstruct_write_bits!(self.0, $hi, $lo, val, > $storage); > + self > +} > +} > +} > +}; > +} This is awesome. Is there a place for this to live outside of `nova-core`? I would think this would be extremely useful as a general helper for bitfield struct definitions. > diff --git a/drivers/gpu/nova-core/nova_core.rs > b/drivers/gpu/nova-core/nova_core.rs > index cb2bbb30cba1..54505cad4a73 100644 > --- a/drivers/gpu/nova-core/nova_core.rs > +++ b/drivers/gpu/nova-core/nova_core.rs > @@ -2,6 +2,7 @@ > > //! Nova Core GPU Driver > > +mod bitstruct; > mod dma; > mod driver; > mod falcon; > -- > 2.34.1 Reviewed-by: Elle Rhumsaa