On Wed, Jun 10, 2026 at 05:04:31PM -0700, Deborah Brouwer wrote: > From: Boris Brezillon <[email protected]> > > 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 <[email protected]> > Signed-off-by: Deborah Brouwer <[email protected]> > --- > rust/kernel/drm/gpuvm/mod.rs | 4 +++- > rust/kernel/drm/gpuvm/sm_ops.rs | 4 ++-- > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/rust/kernel/drm/gpuvm/mod.rs b/rust/kernel/drm/gpuvm/mod.rs > index ae58f6f667c1..1ec649fa50ea 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;
This imposes the requirement that the GpuVm private data cannot contain any references that expire during 'ctx. Since 'ctx represents the duration of a call to sm_map() or sm_unmap(), this seems reasonable. Reviewed-by: Alice Ryhl <[email protected]>
