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: <5C141885-C8D3-4CD9-8919-683D1DFE4AB3@collabora.com>
Date: Wed, 27 Nov 2024 11:43:18 -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 09/35] WIP: rust: drm/kms: Add
 Connector.attach_encoder()

Hi Lyude

> On 30 Sep 2024, at 20:09, Lyude Paul <lyude@...hat.com> wrote:
> 
> This adds a simple binding for completing the last step of creating a DRM
> connector - attaching its encoder. This function should only be called
> before the connector is registered, and DRM should enforce this itself by
> returning an error if a driver tries to add an encoder to an
> already-registered DRM connector.
> 
> Note that unlike most of the methods we'll be adding to DRM mode objects,
> this is directly implemented on the Connector<T> type since I don't really
> think it would make sense for us to allow this operation on an
> OpaqueConnector (a DRM connector without a known DriverConnector
> implementation, something we'll be adding in the next few commits).
> 
> Signed-off-by: Lyude Paul <lyude@...hat.com>
> 
> ---
> 
> TODO:
> * Figure out a solution for making sure that this can only be called when a
>  Connector is unregistered, probably via an UnregisteredConnector type.
> 

Either that, or via the typestate pattern. But I think a UnregisteredConnector type
will work fine based on your previous UnregisteredKmsDevice.

> Signed-off-by: Lyude Paul <lyude@...hat.com>
> ---
> rust/kernel/drm/kms/connector.rs | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
> 
> diff --git a/rust/kernel/drm/kms/connector.rs b/rust/kernel/drm/kms/connector.rs
> index 0fa927a3743b2..54457b327c365 100644
> --- a/rust/kernel/drm/kms/connector.rs
> +++ b/rust/kernel/drm/kms/connector.rs
> @@ -28,6 +28,7 @@
> use super::{
>     ModeObject,
>     RcModeObject,
> +    encoder::*,
>     KmsDriver,
> };
> use macros::pin_data;
> @@ -227,6 +228,20 @@ pub fn new(
>             ARef::from_raw(NonNull::new_unchecked(Box::into_raw(Pin::into_inner_unchecked(new))))
>         })
>     }
> +
> +    /// Attach an encoder to this [`Connector`].
> +    ///
> +    /// TODO: Move this to an `UnregisteredConnector` interface somehow…
> +    #[must_use]
> +    pub fn attach_encoder<E>(&self, encoder: &Encoder<E>) -> Result
> +    where
> +        E: DriverEncoder<Driver = T::Driver>
> +    {
> +        // SAFETY: FFI call with no special requirements
> +        to_result(unsafe {
> +            bindings::drm_connector_attach_encoder(self.as_raw(), encoder.as_raw())
> +        })
> +    }
> }
> 
> /// A trait implemented by any type that acts as a [`struct drm_connector`] interface.
> -- 
> 2.46.1
> 
> 

LGTM.

— Daniel


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ