lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <FC63978F-BAC0-4294-999E-9BA31FA39490@collabora.com>
Date: Wed, 27 Nov 2024 16:30:49 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Lyude Paul <lyude@...hat.com>
Cc: dri-devel@...ts.freedesktop.org,
 rust-for-linux@...r.kernel.org,
 Asahi Lina <lina@...hilina.net>,
 Danilo Krummrich <dakr@...nel.org>,
 mcanal@...lia.com,
 airlied@...hat.com,
 zhiw@...dia.com,
 cjia@...dia.com,
 jhubbard@...dia.com,
 Miguel Ojeda <ojeda@...nel.org>,
 Alex Gaynor <alex.gaynor@...il.com>,
 Wedson Almeida Filho <wedsonaf@...il.com>,
 Boqun Feng <boqun.feng@...il.com>,
 Gary Guo <gary@...yguo.net>,
 Björn Roy Baron <bjorn3_gh@...tonmail.com>,
 Benno Lossin <benno.lossin@...ton.me>,
 Andreas Hindborg <a.hindborg@...sung.com>,
 Alice Ryhl <aliceryhl@...gle.com>,
 Trevor Gross <tmgross@...ch.edu>,
 open list <linux-kernel@...r.kernel.org>
Subject: Re: [WIP RFC v2 18/35] rust: drm/kms: Add RawPlane and RawPlaneState

Hi Lyude

> On 30 Sep 2024, at 20:10, Lyude Paul <lyude@...hat.com> wrote:
> 
> Same thing as RawCrtc and RawCrtcState, but for DRM planes now
> 
> Signed-off-by: Lyude Paul <lyude@...hat.com>
> ---
> rust/kernel/drm/kms/plane.rs | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
> 
> diff --git a/rust/kernel/drm/kms/plane.rs b/rust/kernel/drm/kms/plane.rs
> index 3ace487316d46..1c151ae3b3dcc 100644
> --- a/rust/kernel/drm/kms/plane.rs
> +++ b/rust/kernel/drm/kms/plane.rs
> @@ -312,6 +312,27 @@ unsafe impl<T: DriverPlane> Send for Plane<T> {}
> // SAFETY: Our interface is thread-safe.
> unsafe impl<T: DriverPlane> Sync for Plane<T> {}
> 
> +/// Common methods available on any type which implements [`AsRawPlane`].
> +///
> +/// This is implemented internally by DRM, and provides many of the basic methods for working with
> +/// planes.
> +pub trait RawPlane: AsRawPlane {
> +    /// Return the index of this DRM plane
> +    #[inline]
> +    fn index(&self) -> u32 {
> +        // SAFETY: The index is initialized by the time we expose `Plane` objects to users, and is
> +        // invariant throughout the lifetime of the `Plane`
> +        unsafe { (*self.as_raw()).index }
> +    }
> +
> +    /// Return the index of this DRM plane in the form of a bitmask
> +    #[inline]
> +    fn mask(&self) -> u32 {
> +        1 << self.index()
> +    }
> +}
> +impl<T: AsRawPlane> RawPlane for T {}
> +
> /// A [`struct drm_plane`] without a known [`DriverPlane`] implementation.
> ///
> /// This is mainly for situations where our bindings can't infer the [`DriverPlane`] implementation
> @@ -426,6 +447,20 @@ pub trait FromRawPlaneState: AsRawPlaneState {
>     unsafe fn from_raw_mut<'a>(ptr: *mut bindings::drm_plane_state) -> &'a mut Self;
> }
> 
> +/// Common methods available on any type which implements [`AsRawPlane`].
> +///
> +/// This is implemented internally by DRM, and provides many of the basic methods for working with
> +/// the atomic state of [`Plane`]s.
> +pub trait RawPlaneState: AsRawPlaneState {
> +    /// Return the plane that this plane state belongs to.
> +    fn plane(&self) -> &Self::Plane {
> +        // SAFETY: The index is initialized by the time we expose Plane objects to users, and is
> +        // invariant throughout the lifetime of the Plane
> +        unsafe { Self::Plane::from_raw(self.as_raw().plane) }
> +    }
> +}
> +impl<T: AsRawPlaneState + ?Sized> RawPlaneState for T {}
> +
> /// The main interface for a [`struct drm_plane_state`].
> ///
> /// This type is the main interface for dealing with the atomic state of DRM planes. In addition, it
> -- 
> 2.46.1
> 

LGTM

— Daniel


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ