]> Gentwo Git Trees - linux/.git/commit
Partially revert "rust: drm: gem: Implement AlwaysRefCounted for all gem objects...
authorLyude Paul <lyude@redhat.com>
Thu, 16 Oct 2025 21:08:14 +0000 (17:08 -0400)
committerLyude Paul <lyude@redhat.com>
Tue, 21 Oct 2025 18:15:20 +0000 (14:15 -0400)
commit5ae65bdcb867555540169ef57876658262a67d87
tree941f16eb66619b072b9d60d50dc34d37b5d18441
parent77ed4376d7c5de8be1f2612d6b4777077fb5fdb2
Partially revert "rust: drm: gem: Implement AlwaysRefCounted for all gem objects automatically"

Currently in order to implement AlwaysRefCounted for gem objects, we use a
blanket implementation:

  unsafe impl<T: IntoGEMObject> AlwaysRefCounted for T { … }

While this technically works, it comes with the rather unfortunate downside
that attempting to create a similar blanket implementation in any other
kernel crate will now fail in a rather confusing way.

Using an example from the (not yet upstream) rust DRM KMS bindings, if we
were to add:

  unsafe impl<T: RcModeObject> AlwaysRefCounted for T { … }

Then the moment that both blanket implementations are present in the same
kernel tree, compilation fails with the following:

   error[E0119]: conflicting implementations of trait `types::AlwaysRefCounted`
      --> rust/kernel/drm/kms.rs:504:1
       |
   504 | unsafe impl<T: RcModeObject> AlwaysRefCounted for T {
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
       |
      ::: rust/kernel/drm/gem/mod.rs:97:1
       |
   97  | unsafe impl<T: IntoGEMObject> AlwaysRefCounted for T {
       | ---------------------------------------------------- first implementation here

So, revert these changes for now. The proper fix for this is to introduce a
macro for copy/pasting the same implementation of AlwaysRefCounted around.

This reverts commit 38cb08c3fcd3f3b1d0225dcec8ae50fab5751549.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20251016210955.2813186-2-lyude@redhat.com
rust/kernel/drm/gem/mod.rs