Re: [WIP RFC v2 05/35] rust: drm/kms: Add bindings for drm_connector

From: Simona Vetter
Date: Thu Dec 12 2024 - 05:04:11 EST


On Wed, Dec 11, 2024 at 07:34:10PM -0500, Lyude Paul wrote:
> On Wed, 2024-12-11 at 09:43 +0100, Simona Vetter wrote:
> > On Tue, Dec 10, 2024 at 06:41:52PM -0500, Lyude Paul wrote:
> > > On Tue, 2024-11-26 at 18:25 -0300, Daniel Almeida wrote:
> > > > Hi Lyude,
> > > >
> > > > > On 30 Sep 2024, at 20:09, Lyude Paul <lyude@xxxxxxxxxx> wrote:
> > > > >
> > > > > +
> > > > > +impl<T: DriverConnector> Connector<T> {
> > > > > + /// Construct a new [`Connector`].
> > > > > + ///
> > > > > + /// A driver may use this to create new [`Connector`] objects.
> > > > > + ///
> > > > > + /// TODO: Add a way to handle creating connectors after device registration. Also, that's why we
> > > > > + /// don't ask for a UnregisteredKms device here.
> > > >
> > > > Can you elaborate? We can try to help if you describe this a bit better :)
> > >
> > > oh - totally forgot to respond to this!
> > >
> > > So: out of all of the mode objects, Connectors are a bit special. They can
> > > actually be created and destroyed after registration (hence why they have a
> > > refcount). This is not terribly difficult to handle before registration, the
> > > complication comes after registration - where we'll likely need to split
> > > Connector into two different types:
> > >
> > > UnregisteredConnector
> > >
> > > Connector
> > >
> > > Where you have to sacrifice the UnregisteredConnector to get to the Connector
> > > object. I don't think this will actually be too difficult to implement, I just
> > > didn't get around to it yet because there were so many other open questions I
> > > had about the design here in general.
> >
> > For connnnector lifetime fun please also see Imre's patches for fixing
> > some races around mst hotplug. At least on the C side I think we will
> > split connectors into dynamic and static ones, to be able to handle things
> > correctly. It's a bit a mess unfortuantely.
>
> Thanks for letting me know! Honestly I think this actually should make things
> easier to handle in rust, since I can just push off dynamic connectors for the
> time being and simplify things a bit.

Yeah it definitely clarifies the lifetime rules on the C side, which tends
to help Rust a lot since yolo lifetime is just not a real option for rust
bindings.
-Sima
--
Simona Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch