Rust for Linux List
 help / color / mirror / Atom feed
From: Alice Ryhl <aliceryhl@google.com>
To: Deborah Brouwer <deborah.brouwer@collabora.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org,
	linux-kernel@vger.kernel.org, laura.nao@collabora.com,
	samitolvanen@google.com, boris.brezillon@collabora.com
Subject: Re: [PATCH] rust: drm: gpuvm: add SmContext lifetime bound
Date: Thu, 11 Jun 2026 08:03:39 +0000	[thread overview]
Message-ID: <aipr26YVZZMVKIt_@google.com> (raw)
In-Reply-To: <20260610-gpuvm_smcontext_lifetime_bound_v1-v1-1-531e7d2ee7b4@collabora.com>

On Wed, Jun 10, 2026 at 05:04:31PM -0700, Deborah Brouwer wrote:
> From: Boris Brezillon <boris.brezillon@collabora.com>
> 
> 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>
> ---
>  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 <aliceryhl@google.com>

      reply	other threads:[~2026-06-11  8:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11  0:04 [PATCH] rust: drm: gpuvm: add SmContext lifetime bound Deborah Brouwer
2026-06-11  8:03 ` Alice Ryhl [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aipr26YVZZMVKIt_@google.com \
    --to=aliceryhl@google.com \
    --cc=a.hindborg@kernel.org \
    --cc=airlied@gmail.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=boris.brezillon@collabora.com \
    --cc=dakr@kernel.org \
    --cc=deborah.brouwer@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary@garyguo.net \
    --cc=laura.nao@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=samitolvanen@google.com \
    --cc=simona@ffwll.ch \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=tmgross@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox