[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aXM-Fc0NeY6Acdqz@google.com>
Date: Fri, 23 Jan 2026 09:23:33 +0000
From: Alice Ryhl <aliceryhl@...gle.com>
To: Daniel Almeida <daniel.almeida@...labora.com>
Cc: Danilo Krummrich <dakr@...nel.org>, Boris Brezillon <boris.brezillon@...labora.com>,
Janne Grunau <j@...nau.net>, Matthew Brost <matthew.brost@...el.com>,
"Thomas Hellström" <thomas.hellstrom@...ux.intel.com>, Lyude Paul <lyude@...hat.com>,
Asahi Lina <lina+kernel@...hilina.net>, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v3 6/6] rust: gpuvm: add GpuVmCore::sm_map()
On Thu, Jan 22, 2026 at 07:58:34PM -0300, Daniel Almeida wrote:
> Hi Alice,
>
> > On 21 Jan 2026, at 08:31, Alice Ryhl <aliceryhl@...gle.com> wrote:
> >
> > Finally also add the operation for creating new mappings. Mapping
> > operations need extra data in the context since they involve a vm_bo
> > coming from the outside.
> >
> > Co-developed-by: Asahi Lina <lina+kernel@...hilina.net>
> > Signed-off-by: Asahi Lina <lina+kernel@...hilina.net>
> > Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
> > ---
> > rust/kernel/drm/gpuvm/mod.rs | 9 ++-
> > rust/kernel/drm/gpuvm/sm_ops.rs | 154 ++++++++++++++++++++++++++++++++++++++--
> > 2 files changed, 157 insertions(+), 6 deletions(-)
> >
> > diff --git a/rust/kernel/drm/gpuvm/mod.rs b/rust/kernel/drm/gpuvm/mod.rs
> > index 165a25666ccc3d62e59b73483d4eedff044423e9..557c0d629eec912a97fc4ef18495d5bf0807db0a 100644
> > --- a/rust/kernel/drm/gpuvm/mod.rs
> > +++ b/rust/kernel/drm/gpuvm/mod.rs
> > @@ -93,7 +93,7 @@ const fn vtable() -> &'static bindings::drm_gpuvm_ops {
> > vm_bo_alloc: GpuVmBo::<T>::ALLOC_FN,
> > vm_bo_free: GpuVmBo::<T>::FREE_FN,
> > vm_bo_validate: None,
> > - sm_step_map: None,
> > + sm_step_map: Some(Self::sm_step_map),
> > sm_step_unmap: Some(Self::sm_step_unmap),
> > sm_step_remap: Some(Self::sm_step_remap),
> > }
> > @@ -248,6 +248,13 @@ pub trait DriverGpuVm: Sized {
> > /// The private data passed to callbacks.
> > type SmContext<'ctx>;
> >
> > + /// Indicates that a new mapping should be created.
> > + fn sm_step_map<'op, 'ctx>(
> > + &mut self,
> > + op: OpMap<'op, Self>,
> > + context: &mut Self::SmContext<'ctx>,
> > + ) -> Result<OpMapped<'op, Self>, Error>;
> > +
> > /// Indicates that an existing mapping should be removed.
> > fn sm_step_unmap<'op, 'ctx>(
> > &mut self,
> > diff --git a/rust/kernel/drm/gpuvm/sm_ops.rs b/rust/kernel/drm/gpuvm/sm_ops.rs
> > index 3c29d10d63f0b0a1976c714a86d486948ba81a15..5f3c5d3918147a6962e5658443c343835baa10b8 100644
> > --- a/rust/kernel/drm/gpuvm/sm_ops.rs
> > +++ b/rust/kernel/drm/gpuvm/sm_ops.rs
> > @@ -8,6 +8,100 @@ struct SmData<'a, 'ctx, T: DriverGpuVm> {
> > user_context: &'a mut T::SmContext<'ctx>,
> > }
> >
> > +#[repr(C)]
> > +struct SmMapData<'a, 'ctx, T: DriverGpuVm> {
> > + sm_data: SmData<'a, 'ctx, T>,
> > + vm_bo: GpuVmBoResident<T>,
> > +}
> > +
> > +/// The argument for [`GpuVmCore::sm_map`].
> > +pub struct OpMapRequest<'a, 'ctx, T: DriverGpuVm> {
> > + /// Address in GPU virtual address space.
> > + pub addr: u64,
> > + /// Length of mapping to create.
> > + pub range: u64,
> > + /// Offset in GEM object.
> > + pub offset: u64,
>
> I’d rename this gem_offset. A bit vague/confusing otherwise.
Sure. I'll rename.
Alice
Powered by blists - more mailing lists