From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E3BD370D52 for ; Thu, 11 Jun 2026 08:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781165023; cv=none; b=nob5g1JzOKwqaKhbQ9VgeUlJe8s+fQCQVTXO48+ZswNER0qd95MsBZm+os6UonUoJDr0T5FY75Nqh978TsLGFVwVRXUWUPgssSH5cpeaRKKp7sxWskqZfq/8otIAvLSE29qmaarukqAxaum7vGKVjaU2uQsCtIUZ+JO06LCcDxM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781165023; c=relaxed/simple; bh=LWyr+rdQinIp8FqIbGsaQbKMxNF65P8QliTxrl9xuoU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rIJ1xi4BA1CXUKC+hKOrk+ObI6cEzm0jKC3dJfNvqOf1Yt+QITmYtfWoLBkohPgrAGgkwuW5vfEiibxntMn2wbGh+41OGbP+2zwf1XZSWdrgapNGURAVLChqudB/zZhvox9sBN46y8pkNBBfGkv8grmmB1c7RIGeQOgk7JEZ9sc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=EunLrFy/; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EunLrFy/" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-490ace40f13so33094555e9.3 for ; Thu, 11 Jun 2026 01:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781165021; x=1781769821; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=4Zn3bOdZdUuKhUFaYqBi4NI8K8WLwOEN+61v6c7A6xo=; b=EunLrFy/Ciezgu3s1SEPiqjiTDePflZ6Wkaul6ZdjJ86iRsL4DvWcapD/lvS+0hWq3 ADlBwzHzr37YeqVsSqHa4m+5P1jXDc3c8Pj3w0X3BdE8jscOA4IInMN7op7WKGknqRJn aFcwGHA1zMoHQJj+XqZKMiRstwuF7i+CLPuY2Ct622DvatqMTIUEiOWv8IJqlrow9ied OHOP3u8C5WAmXY9bsgtq59vEqDj/wDHTt9gYeS9pCvTNveoXVjg2lOhE28w7r2Bkhw0Q 3ZFsEy/R9xsEqboLQccKfA3MZnw7q+Lh5ZZFd5xtPow/KBMGqbKJulYsOt8S+qu9goKD 9KEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781165021; x=1781769821; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4Zn3bOdZdUuKhUFaYqBi4NI8K8WLwOEN+61v6c7A6xo=; b=r+nNpjvojuCAzt9fqEh/rQ5zT6xZOaXLJFT5LDu6nFCXMp/7su34jWZP/CPbV5FNpE xL0sHkjwVbYDa22qGmbBmN+FPcMXZGf0ud7jhcpm1ReGrFxj8+gXzPswp5g+2JkOLVi7 i0wSPCygPZ0eSAi7Qg2yE9uzQ5evGdiQ4EM6whatTwZKs0DrbejwQsPToJUsZFbgc7zp ewaR5DtOGswBD+m1qjiN2aZSOtUN9iT/zyas6M4FVCpt7fh6cE8Ivj9nOcyc02Dw+baE KwdDbEpRMJ2I7ENyf0YFlx+Jipi+qSvmSWvsjUDejNFMKnTOZF6VxXYgHKi1gu7DbS7H 36aQ== X-Forwarded-Encrypted: i=1; AFNElJ8tqXckAwgubzzXyQhyoAcRRbTFi1I+rYr5M0AVDjDb1xWPMMj1IqQDbbxlgaJDzmG/0D65N6SQgBwSfuU=@vger.kernel.org X-Gm-Message-State: AOJu0YwOdGq2nt4V/aOHEeYlBfPe9AohjOnZIvxF9YGB2bFPJC2TdJN+ 7e2XgJopNd5eUjwQUrxkaRvoHaF7ZVKs2ao2+c3CHqM4e1mLWWmMMwnZKDP3th2CmE2LNRfp6sc TPDOevVr6hC2+FM0lAg== X-Received: from wmgf12.prod.google.com ([2002:a05:600c:154c:b0:490:adcb:7374]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:e555:20b0:490:bd66:e523 with SMTP id 5b1f17b1804b1-490e560b322mr11403345e9.20.1781165020957; Thu, 11 Jun 2026 01:03:40 -0700 (PDT) Date: Thu, 11 Jun 2026 08:03:39 +0000 In-Reply-To: <20260610-gpuvm_smcontext_lifetime_bound_v1-v1-1-531e7d2ee7b4@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260610-gpuvm_smcontext_lifetime_bound_v1-v1-1-531e7d2ee7b4@collabora.com> Message-ID: Subject: Re: [PATCH] rust: drm: gpuvm: add SmContext lifetime bound From: Alice Ryhl To: Deborah Brouwer Cc: Danilo Krummrich , Matthew Brost , "Thomas =?utf-8?Q?Hellstr=C3=B6m?=" , David Airlie , Simona Vetter , Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Trevor Gross , 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 Content-Type: text/plain; charset="utf-8" On Wed, Jun 10, 2026 at 05:04:31PM -0700, Deborah Brouwer wrote: > From: Boris Brezillon > > 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 > Signed-off-by: Deborah Brouwer > --- > 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