linux/rust/kernel/drm
Lyude Paul 5ae65bdcb8 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 38cb08c3fc.

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
2025-10-21 14:15:20 -04:00
..
gem Partially revert "rust: drm: gem: Implement AlwaysRefCounted for all gem objects automatically" 2025-10-21 14:15:20 -04:00
device.rs drm next for 6.18-rc1 2025-10-02 12:47:25 -07:00
driver.rs drm next for 6.18-rc1 2025-10-02 12:47:25 -07:00
file.rs rust: drm: fix srctree/ links 2025-09-08 00:11:19 +02:00
ioctl.rs drm next for 6.18-rc1 2025-10-02 12:47:25 -07:00
mod.rs rust: drm: gem: Add GEM object abstraction 2025-04-28 10:08:23 +02:00