From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from CWXP265CU009.outbound.protection.outlook.com (mail-ukwestazon11021076.outbound.protection.outlook.com [52.101.100.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 80AC933B961; Wed, 21 Jan 2026 17:31:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.100.76 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769016691; cv=fail; b=OQsolA1/LHqvtjgBedD6trrSGSSR5zcMlxa/qvOg72GSBtUQGSBi/gbhdSXQPGAewlXzDOisVZVHjVon5XUlcGYPj4GQFGz+c4VDi5VxcwXK/xBzvdmqYpwM0oil3yi8yiAMmygyUt3eIiLXGgTxv4qOYJKoVsKpFJmsGxIVCKw= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769016691; c=relaxed/simple; bh=L8AyVxkWDBCCBmaCVH4ONh+ioMHOBiYhJg6g+hhwgT4=; h=Content-Type:Date:Message-Id:Cc:Subject:From:To:References: In-Reply-To:MIME-Version; b=KY2tPK24MWCf4ad5UQDI2uLfEOdpj7Yovfxo2IRHOQnl9lW9SVJnUqCbLND9U+20LFIcxASZhTivV8EN6T4BfdexfOIFjFQLRD/qGENm9/XeheACEHJBmF2w4klp3LZsr90JllOUQlpt9fjUlxAt9YQsYEQirlJpdyp5dHEXNMk= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=garyguo.net; spf=pass smtp.mailfrom=garyguo.net; dkim=pass (1024-bit key) header.d=garyguo.net header.i=@garyguo.net header.b=XPGR8wDy; arc=fail smtp.client-ip=52.101.100.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=garyguo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=garyguo.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=garyguo.net header.i=@garyguo.net header.b="XPGR8wDy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=u8vyKhBevr4Qmr8ZBYpj+Sjl3+oOCdEOw3SSi+GFGJZsis5vAh01toFku/u+Qqr3zqyNSKl8mM4Ihe4MTzdXYUmhY+ICbCOcHn1UHdpkFClgle3OZQ18Mvf1aRPO6bQik+5Mi6Kugw7MzV5DNcYjeS7BXji1WZLnlKwpt/vEdP6Sle1UM700l3vyZqCuh8YuygefAqziFSRWQeGivP1QDN+nCc9ZjJIC6n+f5f/vsMjMOoQjZtHkKL/hCL+z0RtpoUT5E/o4Bt+vpgBLHCkGMqsAp842+FOPn0uAIh7EuAu5ABqMUN8yBkmVuM6s6b8jOVcLoHfxCcZSgS1E1WtEqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K9P+pqLPSK/Q9brJpDt2S6JHm3SrThmYtk+/fl8qiQw=; b=Eh4bjB3WpQuryFLYf8tRLF3Aqwge4Mfi5PA9Bypdi9fZ/V6mHDjOSo62e7XFzTKaiFaygihr6WDGHW6qH8gnJs864ignS5H2vGZ92OHynnehI07Lzmfq/TRN/TM/RWcXj2xXpqRtwrWEFh5NshWCALILqWx9VjazYc3XL3EdYHlsf9xnZYUkHsOeIhF1lRU9Zl1GhzqsOObObMz9DvtCxhjfq2zXJTE6B62g2vyNDkrRfy3advYL/uye8R7rU5Kc9bpvUtsg9JyA4JZ9ujp7sfnOhCwtnTFq2etPXoFFL6ftVIZSm7FmokuRt/aBVtLSwvVDF6//WtHyIwOIOxD6Bw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=garyguo.net; dmarc=pass action=none header.from=garyguo.net; dkim=pass header.d=garyguo.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garyguo.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K9P+pqLPSK/Q9brJpDt2S6JHm3SrThmYtk+/fl8qiQw=; b=XPGR8wDyRlzBRsb4VFGviQ3kxQ385ljrlD0xXLPfUbfs8sfMGCSUzdI4+vReHadkizxa+lGCTo2jbmPcyLfBb99wf+cDaFzKBl09hluuJZc7k86X3yuEryEGUqE8Fa+ugqcqG/SATKuAKeobyz8f3CvtZ1CRFURT+q+5+mr8PFA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=garyguo.net; Received: from LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:488::16) by LOYP265MB2206.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:114::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.10; Wed, 21 Jan 2026 17:31:26 +0000 Received: from LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM ([fe80::1c3:ceba:21b4:9986]) by LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM ([fe80::1c3:ceba:21b4:9986%5]) with mapi id 15.20.9542.008; Wed, 21 Jan 2026 17:31:25 +0000 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 21 Jan 2026 17:31:25 +0000 Message-Id: Cc: , , , Subject: Re: [PATCH 1/2] rust: drm: add support for driver features From: "Gary Guo" To: "Daniel Almeida" , "Danilo Krummrich" , "Alice Ryhl" , "David Airlie" , "Simona Vetter" , "Miguel Ojeda" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , "Boris Brezillon" X-Mailer: aerc 0.21.0 References: <20260119-drm-render-v1-0-8326e4d5cb44@collabora.com> <20260119-drm-render-v1-1-8326e4d5cb44@collabora.com> In-Reply-To: <20260119-drm-render-v1-1-8326e4d5cb44@collabora.com> X-ClientProxiedBy: LO2P265CA0229.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:b::25) To LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:488::16) Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LOVP265MB8871:EE_|LOYP265MB2206:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d86216a-ce32-4f04-6453-08de5912e747 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?B?ODk5YU80NjJPZWNxOWtRS0JBT25DM3AvSDF3VmxrNENWNEFZbThHTytOYWFs?= =?utf-8?B?anhsWnBZSTAySHJQd3k1T1ViajRncTNxRzF1bWVDOXQwNnMxbFJOMzhVZnRV?= =?utf-8?B?d2lPWU1vTHJxOFZqVEhaRmFOVlJ6VnJ2Zi9aVExBeFRyZGxhRGRHVUdPWEhW?= =?utf-8?B?NnlhampVekZpYm9Sb1hET3BPK0VOcjFpZHBJd2RoWEVBVjBkL1BmczhiMnFM?= =?utf-8?B?ZkZQTmQ3RGRMWnMybjhKMEtpeFFKQlBETXhGNGcvWUJ3bHZDZ3BUUkZKRUs0?= =?utf-8?B?MGFpVzhaMlE5WTNHb1JJWTVIbUpPUVgyVlB1Sk5SR2svSGcxOXVoZnFHREhq?= =?utf-8?B?SXJEYnRRRWVPQU1ibnQ2RnZVZmx3bitHa0FwWTJNTTRSdnhyMXhGNDBlbDMz?= =?utf-8?B?Mmxidkg0emdXWF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IPV:NLI;SFV:NSPM;H:LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014)(921020);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TU9jVzB2dmlsSHk3QjhCN2FVZ1B6VVpYTmxMeG1TbnlJeWdIeUhtNm96SEZG?= =?utf-8?B?TmJMdTRCQk9teEpiSmNsYUpvY0kzL1MvbUx5bEVuRi80Tkl2RHpONUo0aEVr?= =?utf-8?B?SWQ1cEpyb25iQ25KQ1NJMDZQRk5yNWhtejFMbUo1R2UwamhKVmJ6TEcySXVB?= =?utf-8?B?V2xISEo5dVhkeFNIaWREWFhrNGJCcXVZNjZTdVVuSm5aaTE5enFMZ1d5Wnoz?= =?utf-8?B?MDkvV0pSdGJJM3JSMm5FM2xwU2pUcWEzbHNGSmN4dTdHeitOa0E4V1FjeXVH?= =?utf-8?B?cnBPTUZnN1U0MmZGSnFDZHI5Vk9sUW1hdnc1TUpVbXBLcVVmL2RFUWFhckF1?= =?utf-8?B?OXJpUDJXN1NJWjQ4T3FDWmdWZmIreS84cm1ZYkpPejBSWWl6Z1p1bCtCUmMw?= =?utf-8?B?K211OEN3VEcxZzhoRFNxZjZWdjIyVmw4clI4QVI2WWtaL3ZKZ0pNWThEN2Vw?= =?utf-8?B?a0RVRWdmNkFFL0JTQUMrckQ2V3Jla2ZTM3Y2STZueUZCOTRtd2lTczZ0Ny80?= =?utf-8?B?OGR5eU13bDRESzdaVERHMkhRMEdFRml3dFNyOWxJNGFBRHE4YlVDYjRmUGYz?= =?utf-8?B?TkR4TjBOdjk3ZC8wYXU4a29TY1dUUnpiUWRWeThybEkyeVFNOXUzWHU4dm15?= =?utf-8?B?MGJRTWZtdW9LTXE1QTh1RTh5OTVXOTB2SkRyc0M0R1VKRTBWWTl0N3BvNjVR?= =?utf-8?B?eHpOMGxneG91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8?B?RlQ2M2pOamUvK2VIRE9BejhQaUNCSFkrWHNiU0tab21Pa3ZTZHJHenYzc0Vw?= =?utf-8?B?eTZwMWNKOUhtZ0JocDNIZG0ya0lFMWxxbGxJdXNPMEhqK1BPVFJibG1ScGxn?= =?utf-8?B?Q0xTWTNKOEgydlNFVExXRUxlV29GRUF4K29KNmp5SWNtaUFkZWQ3VTNpd081?= =?utf-8?B?Z0hhMzB1VFN4KzlNTmVIem1rS3JvYTdXeno2U0R4dU14OWF0OStNUG5OY2Nu?= =?utf-8?B?cUxhOUZtYk1laHhLZzRES1B1RkI2WnJ4QkNOdUxpNUVpZ0xoVmFaMzUzeEpX?= =?utf-8?B?RlBSeWJaRDZJYmNZRWZ2ZjBobThOdlNCcnpaWjd4RlRlMDVlbUUvUVVYeHdj?= =?utf-8?B?bnhkcjE5dmxvS3BMa3JCUHRvcDVNK2hDTHl3NjdaUks2WUd1SHRXR3NYNWN6?= =?utf-8?B?M0UxUmI1VXRWUHozRWJXdG4wMWtURVZYNEFzUTZkSGxXMzA0czYxcVRyM3pi?= =?utf-8?B?M3NWQWxtTEEzUFc4SGdpSVF1MlM5bzEwVC9QWnlRRWg2MzJ0cnJxdmgxbzZw?= =?utf-8?B?dXZQN0NuU2V6TERNalliMlNBOWRTMi9FRHExQ3dkNi9malYxbHM2VFkzc292?= =?utf-8?B?dERJNGFja2xOdEh4ZmRTMEttalU1dlZ1ZXRUYVgyTUkzanFualQvZ1BQdmV4?= =?utf-8?B?Q041NGFIMitzTVZzRENjOWtSeUxxa3c5WTkxL0ZOM2RHcmdPcG0yQT09?= X-OriginatorOrg: garyguo.net X-MS-Exchange-CrossTenant-Network-Message-Id: 8d86216a-ce32-4f04-6453-08de5912e747 X-MS-Exchange-CrossTenant-AuthSource: LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2026 17:31:25.8332 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bbc898ad-b10f-4e10-8552-d9377b823d45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Zm52v0ama9sEkpaj6Dotrr/WVOTA9K3bkJcRIxDrbucsqytMfpNXTCcIEnqf3ST0nOJOzLbod9gVcBV64s8/iQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LOYP265MB2206 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 { ... } // Maybe the never type in the future... pub enum NoFeature {} impl ModesetOps 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; } When building, you can use `TypeId` to check if it's actually implemented, = and set bits in the feature flags automatically. Best, Gary > > New features can be described by adding separate ZSTs to encode them. The > current design assumes two types, for example: FeatureFooSupported and > NoFoo. As said above, this will require implementors to observe more safe= ty > requirements in their DriverFeatures trait implementation. > > A subsequent commit will build on this one to add support for FEAT_RENDER= . > This is required by Tyr and other drivers. > > Additionally, features can also require additional traits to be implement= ed > when enabled. These traits can add their own safety requirements. > > This is roughly described below, with some boilerplate omitted: > > pub struct ModesetSupported; > pub struct NoModeset; > > pub unsafe trait ModesetOps: Driver { > fn set_mode(&self, ...); > } > > pub trait ModesetRequirement {} > impl ModesetRequirement for T {} > impl ModesetRequirement for T {} > > pub trait Driver: > DriverFeatures > + ModesetRequirement > { > // ... > } > > // `driver::compute_features` is augmented to include the feature flag. > const fn compute_features() -> u32 { > if T::Modeset::ENABLED { > features |=3D FEAT_MODESET; > } > > features > } > > // In driver code, `DriverFeatures` can enable the feature via > // `ModesetSupported`. > unsafe impl DriverFeatures for MyDriver { > type Modeset =3D ModesetSupported; > } > > // Required because `Modeset =3D ModesetSupported`. > unsafe impl ModesetOps for MyDriver {...} > > Feature support will soon be required by upcoming DRM drivers. This > extensible model lets us describe them in terms of either additional safe= ty > requirements and/or traits. > > Signed-off-by: Daniel Almeida > --- > drivers/gpu/drm/nova/driver.rs | 5 +++++ > drivers/gpu/drm/tyr/driver.rs | 5 +++++ > rust/kernel/drm/device.rs | 6 +++++- > rust/kernel/drm/driver.rs | 17 ++++++++++++++++- > 4 files changed, 31 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/nova/driver.rs b/drivers/gpu/drm/nova/driver= .rs > index 2246d8e104e0..247a05f7b3a7 100644 > --- a/drivers/gpu/drm/nova/driver.rs > +++ b/drivers/gpu/drm/nova/driver.rs > @@ -69,3 +69,8 @@ impl drm::Driver for NovaDriver { > (NOVA_GEM_INFO, drm_nova_gem_info, ioctl::AUTH | ioctl::RENDER_A= LLOW, File::gem_info), > } > } > + > +// SAFETY: This trait requires implementers to observe the safety requir= ements > +// of each enabled feature. There are no features enabled, so this is sa= fe by > +// definition. > +unsafe impl drm::driver::DriverFeatures for NovaDriver {} > diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.r= s > index 0389c558c036..ec2aa30515a1 100644 > --- a/drivers/gpu/drm/tyr/driver.rs > +++ b/drivers/gpu/drm/tyr/driver.rs > @@ -191,6 +191,11 @@ impl drm::Driver for TyrDriver { > } > } > =20 > +// SAFETY: This trait requires implementers to observe the safety requir= ements > +// of each enabled feature. There are no features enabled, so this is sa= fe by > +// definition. > +unsafe impl drm::driver::DriverFeatures for TyrDriver {} > + > #[pin_data] > struct Clocks { > core: Clk, > diff --git a/rust/kernel/drm/device.rs b/rust/kernel/drm/device.rs > index 3ce8f62a0056..cfc2f34e8cc2 100644 > --- a/rust/kernel/drm/device.rs > +++ b/rust/kernel/drm/device.rs > @@ -61,6 +61,10 @@ pub struct Device { > } > =20 > impl Device { > + const fn compute_features() -> u32 { > + drm::driver::FEAT_GEM > + } > + > const VTABLE: bindings::drm_driver =3D drm_legacy_fields! { > load: None, > open: Some(drm::File::::open_callback), > @@ -86,7 +90,7 @@ impl Device { > name: crate::str::as_char_ptr_in_const_context(T::INFO.name).cas= t_mut(), > desc: crate::str::as_char_ptr_in_const_context(T::INFO.desc).cas= t_mut(), > =20 > - 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 f30ee4c6245c..fdfd083ba2b6 100644 > --- a/rust/kernel/drm/driver.rs > +++ b/rust/kernel/drm/driver.rs > @@ -98,7 +98,7 @@ pub trait AllocImpl: super::private::Sealed + drm::gem:= :IntoGEMObject { > /// This trait must be implemented by drivers in order to create a `stru= ct drm_device` and `struct > /// drm_driver` to be registered in the DRM subsystem. > #[vtable] > -pub trait Driver { > +pub trait Driver: DriverFeatures { > /// Context data associated with the DRM driver > type Data: Sync + Send; > =20 > @@ -168,3 +168,18 @@ fn drop(&mut self) { > unsafe { bindings::drm_dev_unregister(self.0.as_raw()) }; > } > } > + > +/// Marker trait for drivers supporting specific features. > +/// > +/// This trait is unsafe, and each feature might add its own safety > +/// requirements. The safety requirements for this trait requires the ca= ller to > +/// comply with the safety requirements of each supported feature. > +/// > +/// Features might also require additional trait implementations to be p= resent. > +/// These additional traits may also be unsafe. > +/// > +/// # Safety > +/// > +/// Drivers implementing this trait must ensure they comply with the saf= ety > +/// requirements of each supported feature. > +pub unsafe trait DriverFeatures {}