Skip to content

Commit 5233171

Browse files
committed
gpu: nova-core: bindings: derive MaybeZeroable
Commit 4846300 ("rust: derive `Zeroable` for all structs & unions generated by bindgen where possible") automatically derives `MaybeZeroable` for all bindings. This is better than selectively deriving `Zeroable` as it ensures all types that can implement `Zeroable` do. Regenerate the nova-core bindings so they benefit from this, and remove a now unneeded implementation of `Zeroable`. Fixes: 75f6b1d ("gpu: nova-core: gsp: Add GSP command queue bindings and handling") Reviewed-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20251216-nova-fixes-v3-3-c7469a71f7c4@nvidia.com Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
1 parent 9d250ab commit 5233171

3 files changed

Lines changed: 54 additions & 57 deletions

File tree

drivers/gpu/nova-core/gsp/fw.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -797,13 +797,6 @@ impl bindings::rpc_message_header_v {
797797
}
798798
}
799799

800-
// SAFETY: We can't derive the Zeroable trait for this binding because the
801-
// procedural macro doesn't support the syntax used by bindgen to create the
802-
// __IncompleteArrayField types. So instead we implement it here, which is safe
803-
// because these are explicitly padded structures only containing types for
804-
// which any bit pattern, including all zeros, is valid.
805-
unsafe impl Zeroable for bindings::rpc_message_header_v {}
806-
807800
/// GSP Message Element.
808801
///
809802
/// This is essentially a message header expected to be followed by the message data.

drivers/gpu/nova-core/gsp/fw/r570_144.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@
2424
unreachable_pub,
2525
unsafe_op_in_unsafe_fn
2626
)]
27-
use kernel::{
28-
ffi,
29-
prelude::Zeroable, //
30-
};
27+
use kernel::ffi;
28+
use pin_init::MaybeZeroable;
29+
3130
include!("r570_144/bindings.rs");
31+
32+
// SAFETY: This type has a size of zero, so its inclusion into another type should not affect their
33+
// ability to implement `Zeroable`.
34+
unsafe impl<T> kernel::prelude::Zeroable for __IncompleteArrayField<T> {}

0 commit comments

Comments
 (0)