[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <FBB3C949-5568-4F26-95C8-8873F6DF1530@collabora.com>
Date: Wed, 21 Jan 2026 16:05:22 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Gary Guo <gary@...yguo.net>
Cc: Danilo Krummrich <dakr@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>,
David Airlie <airlied@...il.com>,
Simona Vetter <simona@...ll.ch>,
Miguel Ojeda <ojeda@...nel.org>,
Boqun Feng <boqun.feng@...il.com>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>,
Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>,
Boris Brezillon <boris.brezillon@...labora.com>,
nouveau@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org
Subject: Re: [PATCH 1/2] rust: drm: add support for driver features
Hi Gary,
> On 21 Jan 2026, at 14:31, Gary Guo <gary@...yguo.net> wrote:
>
> On Mon Jan 19, 2026 at 11:34 PM GMT, Daniel Almeida wrote:
>> Add initial support for drm driver features via the DriverFeatures trait.
>> This trait is unsafe, requiring the implementer to comply with the safety
>> requirements of each feature individually if the feature is enabled.
>
> I think such unsafe requirement is quite vague and also very non-local.
>
> Maybe we can use a single trait (the `ModesetOps` that you described) to do
> this:
>
> Something like:
>
> pub unsafe trait ModesetOps<D> { ... }
>
> // Maybe the never type in the future...
> pub enum NoFeature {}
>
> impl<D> ModesetOps<D> for NoFeature {
> fn foo(&self, ...) { unimplemented!() }
> }
>
> impl Driver {
> /// Reference the modeset implementation (typically Self),
> /// or `NoFeature` to indicate that the feature is not implemented.
> type Modeset: ModesetOps<Self>;
Yeah, this looks better indeed. I assume we can have multiple features by
having multiple traits, right?
> }
>
> When building, you can use `TypeId` to check if it's actually implemented, and
> set bits in the feature flags automatically.
>
> Best,
> Gary
I assume we would enable FeatureFoo if typeid(Foo) != typeid(NoFeatureFoo)?
Where Foo is “type Foo: FooOps” in the Driver trait.
Powered by blists - more mailing lists