From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 73AC73AFD0B; Sun, 28 Jun 2026 14:54:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782658475; cv=none; b=nGqMwwvY2UVIN6UGjNOUOjm3CCUrzWkgW7Fp7XCTPusLhSJ2/Hd88y+sDZiEJjQyUTFRoc5F5fbpa2YvAT3BqP4LohYWsXdE+4o6zKVkoZVgrD7EY05rA+O583WqeDnIXBP8xUmlSaZ6K0JhkZ+KojRzjrGrF5jOc2K2zpaas1I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782658475; c=relaxed/simple; bh=AMAf4zUwcR3TqnEr6ejdrLIc+MRmLhzF8yuf6RlkMgI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UP8oUHhhZ6LvKa8n4zrXdOOCryue532Ifub5MVh14O+k0sFedezuxjuSivZsMR568c0NmRbLgqdNjL+YPI1xovzTx29u3sg2D5B+J9sXFSgz6qH/TJ31hw7aLP6qFJKWMzERzg6Xdu4FH+Vdjo3vg73EvWkYP2lryADSnaOEbcA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VNA5ErI/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VNA5ErI/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F4A61F00A3A; Sun, 28 Jun 2026 14:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782658474; bh=odWfVzmackCp2ldw7ZGnJrCgCPIWuRfkhQ182Xj2G7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VNA5ErI/5DunX4S5ziuxzz4LOBYi883DdTBotBiM2ExNeZlB7YCjAzi46Uxad+fA+ fVnwPje32D9TxSH2KAxzrVbKIw38bSLQyqk765S7qL0WvpyD8imCaj5STgP0xLkJfE qw+cxQ8cOIxfDiILsNIiIZbrutRkEk2vhAykZ+RWffiibwv8ZcdCCAES1z9L3+y6Jf ZtUhZFdJaRjJaekDrlY/yLtWCXWGsXgXrVSZ0QUP2saaM4V/WEdBN1eo5poYJ7VckJ rmw/cI+tLYW4CltHsJQA22GuD7CweVQ4u4OpMMILE4FM8euxO98jW9uygq4NyPMoYl ODGcDmZgV9dDQ== From: Danilo Krummrich To: dakr@kernel.org, aliceryhl@google.com, daniel.almeida@collabora.com, acourbot@nvidia.com, ecourtney@nvidia.com, ojeda@kernel.org, boqun@kernel.org, gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org, a.hindborg@kernel.org, tmgross@umich.edu, deborah.brouwer@collabora.com, boris.brezillon@collabora.com, lyude@redhat.com Cc: driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org Subject: [PATCH v5 05/19] rust: drm: change default DeviceContext to Normal Date: Sun, 28 Jun 2026 16:53:25 +0200 Message-ID: <20260628145406.2107056-6-dakr@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260628145406.2107056-1-dakr@kernel.org> References: <20260628145406.2107056-1-dakr@kernel.org> Precedence: bulk X-Mailing-List: nova-gpu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Change the default DeviceContext from Registered to Normal for drm::Device, gem::Object, gem::shmem::Object and gem::shmem::ObjectConfig. Normal is the general-purpose, reference-counted context suitable for most uses; Registered represents a device that was registered with userspace and will become a non-owning context obtained through a RegistrationGuard. Update the create_handle/lookup_handle bounds from Object to Object to match the new default context of GEM objects, and update the driver device type aliases (NovaDevice, TyrDrmDevice) to default to Normal. Reviewed-by: Lyude Paul Signed-off-by: Danilo Krummrich --- drivers/gpu/drm/nova/driver.rs | 2 +- drivers/gpu/drm/tyr/driver.rs | 2 +- rust/kernel/drm/device.rs | 2 +- rust/kernel/drm/gem/mod.rs | 7 ++++--- rust/kernel/drm/gem/shmem.rs | 10 +++++----- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/nova/driver.rs b/drivers/gpu/drm/nova/driver.rs index c5b0313006bd..8ddb81fd0c87 100644 --- a/drivers/gpu/drm/nova/driver.rs +++ b/drivers/gpu/drm/nova/driver.rs @@ -26,7 +26,7 @@ pub(crate) struct Nova { } /// Convienence type alias for the DRM device type for this driver -pub(crate) type NovaDevice = drm::Device; +pub(crate) type NovaDevice = drm::Device; #[pin_data] pub(crate) struct NovaData { diff --git a/drivers/gpu/drm/tyr/driver.rs b/drivers/gpu/drm/tyr/driver.rs index 338c25ccc151..180631daff02 100644 --- a/drivers/gpu/drm/tyr/driver.rs +++ b/drivers/gpu/drm/tyr/driver.rs @@ -47,7 +47,7 @@ pub(crate) struct TyrDrmDriver; /// Convenience type alias for the DRM device type for this driver. -pub(crate) type TyrDrmDevice = drm::Device; +pub(crate) type TyrDrmDevice = drm::Device; pub(crate) struct TyrPlatformDriver; diff --git a/rust/kernel/drm/device.rs b/rust/kernel/drm/device.rs index 23eb4c0a65ef..d712387707d2 100644 --- a/rust/kernel/drm/device.rs +++ b/rust/kernel/drm/device.rs @@ -246,7 +246,7 @@ pub fn new( /// * The data layout of `Self` remains the same across all implementations of `C`. /// * Any invariants for `C` also apply. #[repr(C)] -pub struct Device { +pub struct Device { dev: Opaque, data: T::Data, _ctx: PhantomData, diff --git a/rust/kernel/drm/gem/mod.rs b/rust/kernel/drm/gem/mod.rs index c8b66d816871..1023ddccd785 100644 --- a/rust/kernel/drm/gem/mod.rs +++ b/rust/kernel/drm/gem/mod.rs @@ -10,6 +10,7 @@ self, device::{ DeviceContext, + Normal, Registered, // }, driver::{ @@ -183,7 +184,7 @@ fn size(&self) -> usize { fn create_handle(&self, file: &drm::File) -> Result where Self: AllocImpl, - D: drm::Driver = Self, File = F>, + D: drm::Driver = Self, File = F>, F: drm::file::DriverFile, { let mut handle: u32 = 0; @@ -198,7 +199,7 @@ fn create_handle(&self, file: &drm::File) -> Result fn lookup_handle(file: &drm::File, handle: u32) -> Result> where Self: AllocImpl, - D: drm::Driver = Self, File = F>, + D: drm::Driver = Self, File = F>, F: drm::file::DriverFile, { // SAFETY: The arguments are all valid per the type invariants. @@ -254,7 +255,7 @@ impl BaseObjectPrivate for T {} /// * Any type invariants of `Ctx` apply to the parent DRM device for this GEM object. #[repr(C)] #[pin_data] -pub struct Object { +pub struct Object { obj: Opaque, #[pin] data: T, diff --git a/rust/kernel/drm/gem/shmem.rs b/rust/kernel/drm/gem/shmem.rs index cbcfc7e4edb6..5ffa1355ecf2 100644 --- a/rust/kernel/drm/gem/shmem.rs +++ b/rust/kernel/drm/gem/shmem.rs @@ -22,7 +22,7 @@ private::Sealed, Device, DeviceContext, - Registered, // + Normal, // }, error::{ from_err_ptr, @@ -73,7 +73,7 @@ /// /// This is used with [`Object::new()`] to control various properties that can only be set when /// initially creating a shmem-backed GEM object. -pub struct ObjectConfig<'a, T: DriverObject, C: DeviceContext = Registered> { +pub struct ObjectConfig<'a, T: DriverObject, C: DeviceContext = Normal> { /// Whether to set the write-combine map flag. pub map_wc: bool, @@ -102,7 +102,7 @@ fn default() -> Self { /// - Any type invariants of `C` apply to the parent DRM device for this GEM object. #[repr(C)] #[pin_data] -pub struct Object { +pub struct Object { #[pin] obj: Opaque, /// Parent object that owns this object's DMA reservation object. @@ -409,7 +409,7 @@ impl driver::AllocImpl for Object { /// When this is dropped, the `dma_resv` lock is dropped as well. /// // TODO: This should be replace with a WwMutex equivalent once we have such bindings in the kernel. -struct DmaResvGuard<'a, T: DriverObject, C: DeviceContext = Registered>( +struct DmaResvGuard<'a, T: DriverObject, C: DeviceContext = Normal>( &'a Object, NotThreadSafe, ); @@ -438,7 +438,7 @@ fn drop(&mut self) { /// /// - The size of `owner` is >= SIZE. /// - The memory pointed to by `addr` remains valid at least until this object is dropped. -pub struct VMap +pub struct VMap where D: DriverObject, C: DeviceContext, -- 2.54.0