* [PATCH v3 0/1] DRM 'feature' support for DRM drivers
@ 2026-05-07 8:09 Laura Nao
2026-05-07 8:09 ` [PATCH v3 1/1] rust: drm: add FEAT_RENDER flag for render node support Laura Nao
0 siblings, 1 reply; 2+ messages in thread
From: Laura Nao @ 2026-05-07 8:09 UTC (permalink / raw)
To: dakr, aliceryhl, airlied, simona, ojeda, boqun, gary, bjorn3_gh,
lossin, a.hindborg, tmgross, boris.brezillon
Cc: dri-devel, nouveau, linux-kernel, rust-for-linux, kernel,
Laura Nao
This is a follow up to [1], which introduces feature support for DRM
drivers, as will soon be needed by Tyr and rvkms.
Based on feedback and discussion on the first iteration, render node
support has been reworked.
Support for render nodes was initially modeled as an unsafe trait, to
require drivers to comply with any safety requirements tied to enabling
a given feature. For DRIVER_RENDER specifically, the intent was to force
implementors to ensure that any ioctl declared with DRM_RENDER_ALLOW
does not call KMS/modesetting APIs or require DRM_MASTER.
However, the C DRM core already enforces render node access control at
the ioctl dispatch level: if a client opens a render node, any ioctl
without the DRM_RENDER_ALLOW flag will fail. So the C DRM framework
already ensures the rules are respected for core ioctls, and the
unsafe trait doesn't add any meaningful protection beyond this.
For these reasons and since enabling DRIVER_RENDER doesn't require any
particular method to be implemented, there's no real need to model this
as a trait, and a boolean flag is sufficient.
This does not prevent other driver features to be modeled differently
based on their requirements. Features that require additional ops (e.g.
FEAT_MODESET) could instead be modeled as a trait, and some other
constant type that can only be constructed when the relevant trait is
implemented.
Introducing the FEAT_RENDER bool flag here leaves room for
implementing other features differently at a later stage.
Changes since v2[2]:
- Renamed RENDER_CAPABILITY const to FEAT_RENDER
- Expanded documentation for FEAT_RENDER
[1] v1: https://lore.kernel.org/rust-for-linux/20260119-drm-render-v1-0-8326e4d5cb44@collabora.com/
[2] v2: https://lore.kernel.org/rust-for-linux/20260505092304.108262-1-laura.nao@collabora.com/
Laura Nao (1):
rust: drm: add FEAT_RENDER flag for render node support
drivers/gpu/drm/tyr/driver.rs | 1 +
rust/kernel/drm/device.rs | 12 +++++++++++-
rust/kernel/drm/driver.rs | 12 ++++++++++++
3 files changed, 24 insertions(+), 1 deletion(-)
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v3 1/1] rust: drm: add FEAT_RENDER flag for render node support
2026-05-07 8:09 [PATCH v3 0/1] DRM 'feature' support for DRM drivers Laura Nao
@ 2026-05-07 8:09 ` Laura Nao
0 siblings, 0 replies; 2+ messages in thread
From: Laura Nao @ 2026-05-07 8:09 UTC (permalink / raw)
To: dakr, aliceryhl, airlied, simona, ojeda, boqun, gary, bjorn3_gh,
lossin, a.hindborg, tmgross, boris.brezillon
Cc: dri-devel, nouveau, linux-kernel, rust-for-linux, kernel,
Laura Nao, Daniel Almeida
Add FEAT_RENDER bool constant to the Driver trait to control
render node support. When enabled, the driver exposes /dev/dri/renderDXX
render nodes to userspace. The flag defaults to false, drivers can opt
in by setting it to true in their Driver implementation.
This is then enabled in the Tyr driver, while it's left disabled for
Nova for the time being.
Co-developed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Laura Nao <laura.nao@collabora.com>
---
drivers/gpu/drm/tyr/driver.rs | 1 +
rust/kernel/drm/device.rs | 12 +++++++++++-
rust/kernel/drm/driver.rs | 12 ++++++++++++
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs
index e20a5978eed6..f0c2d6e4db3a 100644
--- a/drivers/gpu/drm/tyr/driver.rs
+++ b/drivers/gpu/drm/tyr/driver.rs
@@ -186,6 +186,7 @@ impl drm::Driver for TyrDrmDriver {
type Object = drm::gem::shmem::Object<BoData>;
const INFO: drm::DriverInfo = INFO;
+ const FEAT_RENDER: bool = true;
kernel::declare_drm_ioctls! {
(PANTHOR_DEV_QUERY, drm_panthor_dev_query, ioctl::RENDER_ALLOW, TyrDrmFileData::dev_query),
diff --git a/rust/kernel/drm/device.rs b/rust/kernel/drm/device.rs
index adbafe8db54d..abb51ae98a41 100644
--- a/rust/kernel/drm/device.rs
+++ b/rust/kernel/drm/device.rs
@@ -80,6 +80,16 @@ pub struct Device<T: drm::Driver> {
}
impl<T: drm::Driver> Device<T> {
+ const fn compute_features() -> u32 {
+ let mut features = drm::driver::FEAT_GEM;
+
+ if T::FEAT_RENDER {
+ features |= drm::driver::FEAT_RENDER;
+ }
+
+ features
+ }
+
const VTABLE: bindings::drm_driver = drm_legacy_fields! {
load: None,
open: Some(drm::File::<T::File>::open_callback),
@@ -105,7 +115,7 @@ impl<T: drm::Driver> Device<T> {
name: crate::str::as_char_ptr_in_const_context(T::INFO.name).cast_mut(),
desc: crate::str::as_char_ptr_in_const_context(T::INFO.desc).cast_mut(),
- driver_features: drm::driver::FEAT_GEM,
+ driver_features: Self::compute_features(),
ioctls: T::IOCTLS.as_ptr(),
num_ioctls: T::IOCTLS.len() as i32,
fops: &Self::GEM_FOPS,
diff --git a/rust/kernel/drm/driver.rs b/rust/kernel/drm/driver.rs
index 5233bdebc9fc..6886396c8fa7 100644
--- a/rust/kernel/drm/driver.rs
+++ b/rust/kernel/drm/driver.rs
@@ -16,6 +16,8 @@
/// Driver use the GEM memory manager. This should be set for all modern drivers.
pub(crate) const FEAT_GEM: u32 = bindings::drm_driver_feature_DRIVER_GEM;
+/// Driver supports render nodes, i.e.: /dev/dri/renderDXX devices.
+pub(crate) const FEAT_RENDER: u32 = bindings::drm_driver_feature_DRIVER_RENDER;
/// Information data for a DRM Driver.
pub struct DriverInfo {
@@ -115,6 +117,16 @@ pub trait Driver {
/// IOCTL list. See `kernel::drm::ioctl::declare_drm_ioctls!{}`.
const IOCTLS: &'static [drm::ioctl::DrmIoctlDescriptor];
+
+ /// Sets the `DRIVER_RENDER` feature for this driver.
+ ///
+ /// When enabled, the driver exposes `/dev/dri/renderDXX` render nodes to
+ /// userspace. The render node is an alternate low-priviledge way to access
+ /// the driver, which is enforced on a per-ioctl level. Userspace processes
+ /// that open the render node can only invoke ioctls explicitly listed as
+ /// usable from the render node (i.e. marked DRM_RENDER_ALLOW), whereas
+ /// userspace processes using the master node can invoke any ioctl.
+ const FEAT_RENDER: bool = false;
}
/// The registration type of a `drm::Device`.
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-07 8:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 8:09 [PATCH v3 0/1] DRM 'feature' support for DRM drivers Laura Nao
2026-05-07 8:09 ` [PATCH v3 1/1] rust: drm: add FEAT_RENDER flag for render node support Laura Nao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox