rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] gpu: nova-core: various bitfield fixes
@ 2025-10-22 10:50 Alexandre Courbot
  2025-10-22 10:50 ` [PATCH 1/3] gpu: nova-core: bitfield: simplify condition Alexandre Courbot
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Alexandre Courbot @ 2025-10-22 10:50 UTC (permalink / raw)
  To: Danilo Krummrich, Alice Ryhl, Edwin Peer
  Cc: John Hubbard, Alistair Popple, Joel Fernandes, Timur Tabi,
	nouveau, dri-devel, linux-kernel, rust-for-linux,
	Alexandre Courbot

These trivial patches fix a few issues reported by Edwin in [1].

[1] https://lore.kernel.org/rust-for-linux/F3853912-2C1C-4F9B-89B0-3168689F35B3@nvidia.com/

To: Danilo Krummrich <dakr@kernel.org>
To: Alice Ryhl <aliceryhl@google.com>
To: Edwin Peer <epeer@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Joel Fernandes <joelagnelf@nvidia.com>
Cc: Timur Tabi <ttabi@nvidia.com>
Cc: nouveau@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Cc: rust-for-linux@vger.kernel.org

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
Alexandre Courbot (3):
      gpu: nova-core: bitfield: simplify condition
      gpu: nova-core: bitfield: simplify expression
      gpu: nova-core: bitfield: remove BitOr implementation

 drivers/gpu/nova-core/bitfield.rs | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)
---
base-commit: 5ae65bdcb867555540169ef57876658262a67d87
change-id: 20251022-nova-bitfield-2846201b6544

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


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

* [PATCH 1/3] gpu: nova-core: bitfield: simplify condition
  2025-10-22 10:50 [PATCH 0/3] gpu: nova-core: various bitfield fixes Alexandre Courbot
@ 2025-10-22 10:50 ` Alexandre Courbot
  2025-10-22 16:12   ` Joel Fernandes
  2025-10-22 10:50 ` [PATCH 2/3] gpu: nova-core: bitfield: simplify expression Alexandre Courbot
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Alexandre Courbot @ 2025-10-22 10:50 UTC (permalink / raw)
  To: Danilo Krummrich, Alice Ryhl, Edwin Peer
  Cc: John Hubbard, Alistair Popple, Joel Fernandes, Timur Tabi,
	nouveau, dri-devel, linux-kernel, rust-for-linux,
	Alexandre Courbot

This condition was uselessly convoluted.

Reported-by: Edwin Peer <epeer@nvidia.com>
Link: https://lore.kernel.org/rust-for-linux/F3853912-2C1C-4F9B-89B0-3168689F35B3@nvidia.com/
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/nova-core/bitfield.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/nova-core/bitfield.rs b/drivers/gpu/nova-core/bitfield.rs
index 25579b4c328f..136de7289162 100644
--- a/drivers/gpu/nova-core/bitfield.rs
+++ b/drivers/gpu/nova-core/bitfield.rs
@@ -203,7 +203,7 @@ impl $name {
     ) => {
         bitfield!(
             @leaf_accessor $vis $name $storage, $hi:$lo $field
-            { |f| <$into_type>::from(if f != 0 { true } else { false }) }
+            { |f| <$into_type>::from(f != 0) }
             bool $into_type => $into_type $(, $comment)?;
         );
     };

-- 
2.51.0


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

* [PATCH 2/3] gpu: nova-core: bitfield: simplify expression
  2025-10-22 10:50 [PATCH 0/3] gpu: nova-core: various bitfield fixes Alexandre Courbot
  2025-10-22 10:50 ` [PATCH 1/3] gpu: nova-core: bitfield: simplify condition Alexandre Courbot
@ 2025-10-22 10:50 ` Alexandre Courbot
  2025-10-22 16:12   ` Joel Fernandes
  2025-10-22 10:50 ` [PATCH 3/3] gpu: nova-core: bitfield: remove BitOr implementation Alexandre Courbot
  2025-10-22 16:19 ` [PATCH 0/3] gpu: nova-core: various bitfield fixes Danilo Krummrich
  3 siblings, 1 reply; 9+ messages in thread
From: Alexandre Courbot @ 2025-10-22 10:50 UTC (permalink / raw)
  To: Danilo Krummrich, Alice Ryhl, Edwin Peer
  Cc: John Hubbard, Alistair Popple, Joel Fernandes, Timur Tabi,
	nouveau, dri-devel, linux-kernel, rust-for-linux,
	Alexandre Courbot

The shift is more easily expressed by the index of the lowest bit of the
field.

Reported-by: Edwin Peer <epeer@nvidia.com>
Link: https://lore.kernel.org/rust-for-linux/F3853912-2C1C-4F9B-89B0-3168689F35B3@nvidia.com/
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/nova-core/bitfield.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/nova-core/bitfield.rs b/drivers/gpu/nova-core/bitfield.rs
index 136de7289162..f113439c6501 100644
--- a/drivers/gpu/nova-core/bitfield.rs
+++ b/drivers/gpu/nova-core/bitfield.rs
@@ -268,7 +268,7 @@ impl $name {
                 _ => ::kernel::build_error!("Unsupported storage type size")
             }
         };
-        const [<$field:upper _SHIFT>]: u32 = Self::[<$field:upper _MASK>].trailing_zeros();
+        const [<$field:upper _SHIFT>]: u32 = $lo;
         );
 
         $(

-- 
2.51.0


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

* [PATCH 3/3] gpu: nova-core: bitfield: remove BitOr implementation
  2025-10-22 10:50 [PATCH 0/3] gpu: nova-core: various bitfield fixes Alexandre Courbot
  2025-10-22 10:50 ` [PATCH 1/3] gpu: nova-core: bitfield: simplify condition Alexandre Courbot
  2025-10-22 10:50 ` [PATCH 2/3] gpu: nova-core: bitfield: simplify expression Alexandre Courbot
@ 2025-10-22 10:50 ` Alexandre Courbot
  2025-10-22 16:11   ` Joel Fernandes
  2025-10-22 16:19 ` [PATCH 0/3] gpu: nova-core: various bitfield fixes Danilo Krummrich
  3 siblings, 1 reply; 9+ messages in thread
From: Alexandre Courbot @ 2025-10-22 10:50 UTC (permalink / raw)
  To: Danilo Krummrich, Alice Ryhl, Edwin Peer
  Cc: John Hubbard, Alistair Popple, Joel Fernandes, Timur Tabi,
	nouveau, dri-devel, linux-kernel, rust-for-linux,
	Alexandre Courbot

Using this operand can produce invalid values. It also doesn't bring
any benefit as one can use the builder pattern to assemble a new value.

Reported-by: Edwin Peer <epeer@nvidia.com>
Link: https://lore.kernel.org/rust-for-linux/F3853912-2C1C-4F9B-89B0-3168689F35B3@nvidia.com/
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/nova-core/bitfield.rs | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/gpu/nova-core/bitfield.rs b/drivers/gpu/nova-core/bitfield.rs
index f113439c6501..16e143658c51 100644
--- a/drivers/gpu/nova-core/bitfield.rs
+++ b/drivers/gpu/nova-core/bitfield.rs
@@ -94,7 +94,7 @@ macro_rules! bitfield {
     // All rules below are helpers.
 
     // Defines the wrapper `$name` type, as well as its relevant implementations (`Debug`,
-    // `Default`, `BitOr`, and conversion to the value type) and field accessor methods.
+    // `Default`, and conversion to the value type) and field accessor methods.
     (@core $vis:vis $name:ident $storage:ty $(, $comment:literal)? { $($fields:tt)* }) => {
         $(
         #[doc=$comment]
@@ -103,14 +103,6 @@ macro_rules! bitfield {
         #[derive(Clone, Copy)]
         $vis struct $name($storage);
 
-        impl ::core::ops::BitOr for $name {
-            type Output = Self;
-
-            fn bitor(self, rhs: Self) -> Self::Output {
-                Self(self.0 | rhs.0)
-            }
-        }
-
         impl ::core::convert::From<$name> for $storage {
             fn from(val: $name) -> $storage {
                 val.0

-- 
2.51.0


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

* Re: [PATCH 3/3] gpu: nova-core: bitfield: remove BitOr implementation
  2025-10-22 10:50 ` [PATCH 3/3] gpu: nova-core: bitfield: remove BitOr implementation Alexandre Courbot
@ 2025-10-22 16:11   ` Joel Fernandes
  0 siblings, 0 replies; 9+ messages in thread
From: Joel Fernandes @ 2025-10-22 16:11 UTC (permalink / raw)
  To: Alexandre Courbot, Danilo Krummrich, Alice Ryhl, Edwin Peer
  Cc: John Hubbard, Alistair Popple, Timur Tabi, nouveau, dri-devel,
	linux-kernel, rust-for-linux



On 10/22/2025 6:50 AM, Alexandre Courbot wrote:
> Using this operand can produce invalid values. It also doesn't bring
> any benefit as one can use the builder pattern to assemble a new value.>> Reported-by: Edwin Peer <epeer@nvidia.com>
> Link: https://lore.kernel.org/rust-for-linux/F3853912-2C1C-4F9B-89B0-3168689F35B3@nvidia.com/
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Yeah, we should get rid of BitOr.

Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>

Thanks.


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

* Re: [PATCH 2/3] gpu: nova-core: bitfield: simplify expression
  2025-10-22 10:50 ` [PATCH 2/3] gpu: nova-core: bitfield: simplify expression Alexandre Courbot
@ 2025-10-22 16:12   ` Joel Fernandes
  0 siblings, 0 replies; 9+ messages in thread
From: Joel Fernandes @ 2025-10-22 16:12 UTC (permalink / raw)
  To: Alexandre Courbot, Danilo Krummrich, Alice Ryhl, Edwin Peer
  Cc: John Hubbard, Alistair Popple, Timur Tabi, nouveau, dri-devel,
	linux-kernel, rust-for-linux



On 10/22/2025 6:50 AM, Alexandre Courbot wrote:
> The shift is more easily expressed by the index of the lowest bit of the
> field.
> 
> Reported-by: Edwin Peer <epeer@nvidia.com>
> Link: https://lore.kernel.org/rust-for-linux/F3853912-2C1C-4F9B-89B0-3168689F35B3@nvidia.com/
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>

Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>

Thanks.

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

* Re: [PATCH 1/3] gpu: nova-core: bitfield: simplify condition
  2025-10-22 10:50 ` [PATCH 1/3] gpu: nova-core: bitfield: simplify condition Alexandre Courbot
@ 2025-10-22 16:12   ` Joel Fernandes
  0 siblings, 0 replies; 9+ messages in thread
From: Joel Fernandes @ 2025-10-22 16:12 UTC (permalink / raw)
  To: Alexandre Courbot, Danilo Krummrich, Alice Ryhl, Edwin Peer
  Cc: John Hubbard, Alistair Popple, Timur Tabi, nouveau, dri-devel,
	linux-kernel, rust-for-linux



On 10/22/2025 6:50 AM, Alexandre Courbot wrote:
> This condition was uselessly convoluted.
> 
> Reported-by: Edwin Peer <epeer@nvidia.com>
> Link: https://lore.kernel.org/rust-for-linux/F3853912-2C1C-4F9B-89B0-3168689F35B3@nvidia.com/
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>


Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>

Thanks.



> ---
>  drivers/gpu/nova-core/bitfield.rs | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/nova-core/bitfield.rs b/drivers/gpu/nova-core/bitfield.rs
> index 25579b4c328f..136de7289162 100644
> --- a/drivers/gpu/nova-core/bitfield.rs
> +++ b/drivers/gpu/nova-core/bitfield.rs
> @@ -203,7 +203,7 @@ impl $name {
>      ) => {
>          bitfield!(
>              @leaf_accessor $vis $name $storage, $hi:$lo $field
> -            { |f| <$into_type>::from(if f != 0 { true } else { false }) }
> +            { |f| <$into_type>::from(f != 0) }
>              bool $into_type => $into_type $(, $comment)?;
>          );
>      };
> 


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

* Re: [PATCH 0/3] gpu: nova-core: various bitfield fixes
  2025-10-22 10:50 [PATCH 0/3] gpu: nova-core: various bitfield fixes Alexandre Courbot
                   ` (2 preceding siblings ...)
  2025-10-22 10:50 ` [PATCH 3/3] gpu: nova-core: bitfield: remove BitOr implementation Alexandre Courbot
@ 2025-10-22 16:19 ` Danilo Krummrich
  2025-10-27  0:55   ` Alexandre Courbot
  3 siblings, 1 reply; 9+ messages in thread
From: Danilo Krummrich @ 2025-10-22 16:19 UTC (permalink / raw)
  To: Alexandre Courbot
  Cc: Alice Ryhl, Edwin Peer, John Hubbard, Alistair Popple,
	Joel Fernandes, Timur Tabi, nouveau, dri-devel, linux-kernel,
	rust-for-linux

On 10/22/25 12:50 PM, Alexandre Courbot wrote:
> These trivial patches fix a few issues reported by Edwin in [1].
> 
> [1] https://lore.kernel.org/rust-for-linux/F3853912-2C1C-4F9B-89B0-3168689F35B3@nvidia.com/
> 
> To: Danilo Krummrich <dakr@kernel.org>
> To: Alice Ryhl <aliceryhl@google.com>
> To: Edwin Peer <epeer@nvidia.com>
> Cc: John Hubbard <jhubbard@nvidia.com>
> Cc: Alistair Popple <apopple@nvidia.com>
> Cc: Joel Fernandes <joelagnelf@nvidia.com>
> Cc: Timur Tabi <ttabi@nvidia.com>
> Cc: nouveau@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-kernel@vger.kernel.org
> Cc: rust-for-linux@vger.kernel.org
> 
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>

Reviewed-by: Danilo Krummrich <dakr@kernel.org>

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

* Re: [PATCH 0/3] gpu: nova-core: various bitfield fixes
  2025-10-22 16:19 ` [PATCH 0/3] gpu: nova-core: various bitfield fixes Danilo Krummrich
@ 2025-10-27  0:55   ` Alexandre Courbot
  0 siblings, 0 replies; 9+ messages in thread
From: Alexandre Courbot @ 2025-10-27  0:55 UTC (permalink / raw)
  To: Danilo Krummrich, Alexandre Courbot
  Cc: Alice Ryhl, Edwin Peer, John Hubbard, Alistair Popple,
	Joel Fernandes, Timur Tabi, nouveau, dri-devel, linux-kernel,
	rust-for-linux, Nouveau

On Thu Oct 23, 2025 at 1:19 AM JST, Danilo Krummrich wrote:
> On 10/22/25 12:50 PM, Alexandre Courbot wrote:
>> These trivial patches fix a few issues reported by Edwin in [1].
>> 
>> [1] https://lore.kernel.org/rust-for-linux/F3853912-2C1C-4F9B-89B0-3168689F35B3@nvidia.com/
>> 
>> To: Danilo Krummrich <dakr@kernel.org>
>> To: Alice Ryhl <aliceryhl@google.com>
>> To: Edwin Peer <epeer@nvidia.com>
>> Cc: John Hubbard <jhubbard@nvidia.com>
>> Cc: Alistair Popple <apopple@nvidia.com>
>> Cc: Joel Fernandes <joelagnelf@nvidia.com>
>> Cc: Timur Tabi <ttabi@nvidia.com>
>> Cc: nouveau@lists.freedesktop.org
>> Cc: dri-devel@lists.freedesktop.org
>> Cc: linux-kernel@vger.kernel.org
>> Cc: rust-for-linux@vger.kernel.org
>> 
>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>
> Reviewed-by: Danilo Krummrich <dakr@kernel.org>

Pushed to drm-rust-next, thanks for the reviews!

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

end of thread, other threads:[~2025-10-27  0:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 10:50 [PATCH 0/3] gpu: nova-core: various bitfield fixes Alexandre Courbot
2025-10-22 10:50 ` [PATCH 1/3] gpu: nova-core: bitfield: simplify condition Alexandre Courbot
2025-10-22 16:12   ` Joel Fernandes
2025-10-22 10:50 ` [PATCH 2/3] gpu: nova-core: bitfield: simplify expression Alexandre Courbot
2025-10-22 16:12   ` Joel Fernandes
2025-10-22 10:50 ` [PATCH 3/3] gpu: nova-core: bitfield: remove BitOr implementation Alexandre Courbot
2025-10-22 16:11   ` Joel Fernandes
2025-10-22 16:19 ` [PATCH 0/3] gpu: nova-core: various bitfield fixes Danilo Krummrich
2025-10-27  0:55   ` Alexandre Courbot

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).