38cb08c3 | 14-May-2025 |
Lyude Paul <lyude@redhat.com> |
rust: drm: gem: Implement AlwaysRefCounted for all gem objects automatically
Currently we are requiring AlwaysRefCounted in most trait bounds for gem objects, and implementing it by hand for our onl
rust: drm: gem: Implement AlwaysRefCounted for all gem objects automatically
Currently we are requiring AlwaysRefCounted in most trait bounds for gem objects, and implementing it by hand for our only current type of gem object. However, all gem objects use the same functions for reference counting - and all gem objects support reference counting.
We're planning on adding support for shmem gem objects, let's move this around a bit by instead making IntoGEMObject require AlwaysRefCounted as a trait bound, and then provide a blanket AlwaysRefCounted implementation for any object that implements IntoGEMObject so all gem object types can use the same AlwaysRefCounted implementation. This also makes things less verbose by making the AlwaysRefCounted trait bound implicit for any IntoGEMObject bound.
Signed-off-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Link: https://lore.kernel.org/r/20250513221046.903358-5-lyude@redhat.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
b36ff40b | 14-May-2025 |
Lyude Paul <lyude@redhat.com> |
rust: drm: gem: s/into_gem_obj()/as_raw()/
There's a few changes here: * The rename, of course (this should also let us drop the clippy annotation here) * Return *mut bindings::drm_gem_object inst
rust: drm: gem: s/into_gem_obj()/as_raw()/
There's a few changes here: * The rename, of course (this should also let us drop the clippy annotation here) * Return *mut bindings::drm_gem_object instead of &Opaque<bindings::drm_gem_object> - the latter doesn't really have any benefit and just results in conversion from the rust type to the C type having to be more verbose than necessary.
Signed-off-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Link: https://lore.kernel.org/r/20250513221046.903358-4-lyude@redhat.com [ Fixup s/into_gem_obj()/as_raw()/ in safety comment. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|
36b1ccbf | 14-May-2025 |
Lyude Paul <lyude@redhat.com> |
rust: drm: gem: Refactor IntoGEMObject::from_gem_obj() to as_ref()
There's a few issues with this function, mainly:
* This function -probably- should have been unsafe from the start. Pointers are
rust: drm: gem: Refactor IntoGEMObject::from_gem_obj() to as_ref()
There's a few issues with this function, mainly:
* This function -probably- should have been unsafe from the start. Pointers are not always necessarily valid, but you want a function that does field-projection for a pointer that can travel outside of the original struct to be unsafe, at least if I understand properly. * *mut Self is not terribly useful in this context, the majority of uses of from_gem_obj() grab a *mut Self and then immediately convert it into a &'a Self. It also goes against the ffi conventions we've set in the rest of the kernel thus far. * from_gem_obj() also doesn't follow the naming conventions in the rest of the DRM bindings at the moment, as_ref() would be a better name.
So, let's:
* Make from_gem_obj() unsafe * Convert it to return &'a Self * Rename it to as_ref() * Update all call locations
Signed-off-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Link: https://lore.kernel.org/r/20250513221046.903358-3-lyude@redhat.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
show more ...
|