Skip to contentSkip to conversation

gpu: nova-core: bitfield: fix broken Default implementation

PATCH Applied Eliot Courtney 4 participants 7 messages Apr 1 – Apr 4

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gpu: nova-core: bitfield: fix broken Default implementation

The current implementation does not actually set the default values for the fields in the bitfield.

Fixes 3fa145bef533 ("gpu: nova-core: register: generate correct `Default` implementation")

---
It doesn't actually set the default values for each field. I know that bitfields are being moved soon, so maybe this fix is unnecessary but I
saw it and it's a simple fix.
---
Changes in v2:
- add "Fixes"
- remove test
- Link to v1: https://patch.msgid.link/[email protected]

---
 drivers/gpu/nova-core/bitfield.rs | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/nova-core/bitfield.rs +2 -3
index 16e143658c51..02efdcf78d89 100644
@@ -314,12 +314,11 @@ fn fmt(&self, f: &mut ::kernel::fmt::Formatter<'_>) -> ::kernel::fmt::Result {
         /// Returns a value for the bitfield where all fields are set to their default value.
         impl ::core::default::Default for $name {
             fn default() -> Self {
-                #[allow(unused_mut)]
-                let mut value = Self(Default::default());
+                let value = Self(Default::default());
 
                 ::kernel::macros::paste!(
                 $(
-                value.[<set_ $field>](Default::default());
+                let value = value.[<set_ $field>](Default::default());
                 )*
                 );
 

---
base-commit: 7c50d748b4a635bc39802ea3f6b120e66b1b9067
change-id: 20260331-fix-bitfield-a03f6d1b9e00

Best regards,

Signature · 1 line
Eliot Courtney <[email protected]>
#1 lore raw
Quoted 5 lines · Eliot Courtney

The current implementation does not actually set the default values for the fields in the bitfield.

Fixes 3fa145bef533 ("gpu: nova-core: register: generate correct `Default` implementation")

Don't forget to collect the tags you received on v1 (I use b4 which will do it anyway so no biggie, but not everybody does).

Quoted 4 lines

---
It doesn't actually set the default values for each field. I know that bitfields are being moved soon, so maybe this fix is unnecessary but I saw it and it's a simple fix.

Fixing it is the correct course imho - the common bitfield macro still needs to undergo extensive review, and we might hit some hard-to-debug issue in Nova because of this bug. I'll apply it as soon as drm-rust-next reopens, thanks!

reviewer
#2 lore raw
Quoted 15 lines · Alexandre Courbot
Quoted 5 lines · Eliot Courtney

The current implementation does not actually set the default values for the fields in the bitfield.

Fixes 3fa145bef533 ("gpu: nova-core: register: generate correct `Default` implementation")

Don't forget to collect the tags you received on v1 (I use b4 which will do it anyway so no biggie, but not everybody does).

Quoted 4 lines

---
It doesn't actually set the default values for each field. I know that bitfields are being moved soon, so maybe this fix is unnecessary but I saw it and it's a simple fix.

Quoted 4 lines

Fixing it is the correct course imho - the common bitfield macro still needs to undergo extensive review, and we might hit some hard-to-debug issue in Nova because of this bug. I'll apply it as soon as drm-rust-next reopens, thanks!

This could go via drm-rust-fixes?

Best,
Gary

maintainer
#3 lore raw
Quoted 1 line · Gary Guo

This could go via drm-rust-fixes?

It seems there's nothing actually broken due to that, so no need to take it through -fixes. But we can pick it up before drm-rust-next opens for new features as I will send another -next PR for the unsoundness fix anyways.

#4 lore raw
Quoted 6 lines · Danilo Krummrich
Quoted 1 line · Gary Guo

This could go via drm-rust-fixes?

It seems there's nothing actually broken due to that, so no need to take it through -fixes. But we can pick it up before drm-rust-next opens for new features as I will send another -next PR for the unsoundness fix anyways.

Yes, nothing actually broken from this right now.

Thanks all

maintainer
#6 lore raw
In reply to Eliot Courtney
Quoted 5 lines · Eliot Courtney

The current implementation does not actually set the default values for the fields in the bitfield.

Fixes 3fa145bef533 ("gpu: nova-core: register: generate correct `Default` implementation")

Due to [1] I dropped this one as well for now; I will pick it up once -rc1 is out.

Thanks,
Danilo

[1] https://lore.kernel.org/all/[email protected]/