From: Laura Nao <laura.nao@collabora.com>
To: gary@garyguo.net
Cc: a.hindborg@kernel.org, airlied@gmail.com, aliceryhl@google.com,
bjorn3_gh@protonmail.com, boqun.feng@gmail.com,
boris.brezillon@collabora.com, dakr@kernel.org,
daniel.almeida@collabora.com, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, lossin@kernel.org,
nouveau@lists.freedesktop.org, ojeda@kernel.org,
rust-for-linux@vger.kernel.org, simona@ffwll.ch,
tmgross@umich.edu
Subject: Re: [PATCH 1/2] rust: drm: add support for driver features
Date: Tue, 5 May 2026 12:13:45 +0200 [thread overview]
Message-ID: <20260505101345.112368-1-laura.nao@collabora.com> (raw)
In-Reply-To: <DFUG2U4PVVTN.1DVPXGJK735F8@garyguo.net>
Hi Gary,
I just submitted a v2 [1] with DRIVER_RENDER modeled as a single
constant bool flag, as using a trait for this specific feature seemed
unnecessary.
This doesn't prevent us from modeling other features such as
FEAT_MODESET differently later, possibly with a trait and a constant
type that can only be constructed when the relevant trait is
implemented.
One thing probably worth noting about your previous suggestion, in case
it's useful for future feature implementations:
> On 21 Jan 2026, at 14:31, Gary Guo <gary@garyguo.net> wrote:
>
> When building, you can use `TypeId` to check if it's actually implemented, and
> set bits in the feature flags automatically.
>
Taking FEAT_MODESET as example, I believe this would translate to:
const fn compute_features() -> u32 {
let mut features = drm::driver::FEAT_GEM;
if TypeId::of::<T::Modeset>() != TypeId::of::<drm::driver::NoFeature>() {
features |= drm::driver::FEAT_MODESET;
}
features
}
However, this results in a compiler error as PartialEq is not yet
const-stable:
error[E0658]: cannot call conditionally-const operator in constant functions
--> rust/kernel/drm/device.rs:87:12
|
87 | if TypeId::of::<T::Render>() != TypeId::of::<drm::driver::NoFeature>() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information
= help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
= note: this compiler was built on 2026-03-25; consider upgrading it if it is out of date
error: `PartialEq` is not yet stable as a const trait
--> rust/kernel/drm/device.rs:87:12
|
87 | if TypeId::of::<T::Render>() != TypeId::of::<drm::driver::NoFeature>() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: add `#![feature(const_cmp)]` to the crate attributes to enable
--> rust/kernel/lib.rs:68:1
|
68 + #![feature(const_cmp)]
|
error: aborting due to 2 previous errors
As TypeId comparison is currently unstable, I think a different approach
would be needed if this pattern is adopted for other features.
Best,
Laura
[1] v2: https://lore.kernel.org/all/20260505092304.108262-1-laura.nao@collabora.com/
next prev parent reply other threads:[~2026-05-05 10:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-19 23:34 [PATCH 0/2] DRM 'feature' support for DRM drivers Daniel Almeida
2026-01-19 23:34 ` [PATCH 1/2] rust: drm: add support for driver features Daniel Almeida
2026-01-21 17:31 ` Gary Guo
2026-01-21 19:05 ` Daniel Almeida
2026-05-05 10:13 ` Laura Nao [this message]
2026-01-19 23:34 ` [PATCH 2/2] rust: drm: add FeatureRender Daniel Almeida
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260505101345.112368-1-laura.nao@collabora.com \
--to=laura.nao@collabora.com \
--cc=a.hindborg@kernel.org \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox