summaryrefslogtreecommitdiff
path: root/rust/kernel/drm
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@collabora.com>2026-06-10 17:04:31 -0700
committerDanilo Krummrich <dakr@kernel.org>2026-06-12 22:28:36 +0200
commit5f7410aa26524101d34b627fbe16670b1514962c (patch)
treec2468837a90651e66f096a1dd3ccdc93ed3d4e69 /rust/kernel/drm
parent20003c1a1fd80ae1b1742ff54297b67f7f21b77f (diff)
rust: drm: gpuvm: add SmContext lifetime bound
If a DriverGpuVm implementation is lifetime-parameterized, its SmContext<'ctx> type may depend on lifetimes carried by that driver implementation. In this case, SmContext<'ctx> is only valid if the driver implementation outlives 'ctx. Add a Self: 'ctx bound to DriverGpuVm::SmContext<'ctx> to express that requirement. Then propagate the corresponding T: 'ctx bound to the GPUVM state machine helper types that store T::SmContext<'ctx>. This allows drivers to provide lifetime-parameterized implementations of DriverGpuVm. Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260610-gpuvm_smcontext_lifetime_bound_v1-v1-1-531e7d2ee7b4@collabora.com Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/kernel/drm')
-rw-r--r--rust/kernel/drm/gpuvm/mod.rs4
-rw-r--r--rust/kernel/drm/gpuvm/sm_ops.rs4
2 files changed, 5 insertions, 3 deletions
diff --git a/rust/kernel/drm/gpuvm/mod.rs b/rust/kernel/drm/gpuvm/mod.rs
index a625fcd9b5f2..20a08b3defeb 100644
--- a/rust/kernel/drm/gpuvm/mod.rs
+++ b/rust/kernel/drm/gpuvm/mod.rs
@@ -264,7 +264,9 @@ pub trait DriverGpuVm: Sized + Send {
type VmBoData;
/// The private data passed to callbacks.
- type SmContext<'ctx>;
+ type SmContext<'ctx>
+ where
+ Self: 'ctx;
/// Indicates that a new mapping should be created.
fn sm_step_map<'op, 'ctx>(
diff --git a/rust/kernel/drm/gpuvm/sm_ops.rs b/rust/kernel/drm/gpuvm/sm_ops.rs
index 69a8e5ab2821..742c151b2540 100644
--- a/rust/kernel/drm/gpuvm/sm_ops.rs
+++ b/rust/kernel/drm/gpuvm/sm_ops.rs
@@ -3,7 +3,7 @@
use super::*;
/// The actual data that gets threaded through the callbacks.
-struct SmData<'a, 'ctx, T: DriverGpuVm> {
+struct SmData<'a, 'ctx, T: DriverGpuVm + 'ctx> {
gpuvm: &'a mut UniqueRefGpuVm<T>,
user_context: &'a mut T::SmContext<'ctx>,
}
@@ -20,7 +20,7 @@ struct SmMapData<'a, 'ctx, T: DriverGpuVm> {
}
/// The argument for [`UniqueRefGpuVm::sm_map`].
-pub struct OpMapRequest<'a, 'ctx, T: DriverGpuVm> {
+pub struct OpMapRequest<'a, 'ctx, T: DriverGpuVm + 'ctx> {
/// Address in GPU virtual address space.
pub addr: u64,
/// Length of mapping to create.