dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org,
	"Abhinav Kumar" <abhinav.kumar@linux.dev>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Anna Maniscalco" <anna.maniscalco2000@gmail.com>,
	"Antonino Maniscalco" <antomani103@gmail.com>,
	"Boris Brezillon" <boris.brezillon@collabora.com>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"David Airlie" <airlied@gmail.com>,
	"Dmitry Baryshkov" <lumag@kernel.org>,
	"Jessica Zhang" <jesszhan0024@gmail.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Liviu Dudau" <liviu.dudau@arm.com>,
	"Lyude Paul" <lyude@redhat.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Marijn Suijten" <marijn.suijten@somainline.org>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Randy Dunlap" <rdunlap@infradead.org>,
	"Rob Clark" <robin.clark@oss.qualcomm.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Sean Paul" <sean@poorly.run>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Steven Price" <steven.price@arm.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Thomas Zimmermann" <tzimmermann@suse.de>
Subject: [PATCH v3 8/8] drm/nouveau: lock the resident BOs of an exec last
Date: Thu,  1 Oct 2026 15:06:32 -0700	[thread overview]
Message-ID: <20261001220632.3190896-9-matthew.brost@intel.com> (raw)
In-Reply-To: <20261001220632.3190896-1-matthew.brost@intel.com>

nouveau_exec_job_submit() locks every BO mapped in the VM, then
validates the evicted ones while holding all of those locks. A client
paging a large working set back in therefore keeps the dma-resv of every
BO it shares, e.g. with the compositor it presents to, locked for as
long as that takes, stalling the other side for no reason.

Use the two-pass locking drm_gpuvm now provides. Validation moves from
after drm_gpuvm_exec_lock() into its per-pass extra.fn callback, so the
early pass validates the evicted BOs while the resident external ones
are still unlocked, and the late pass locks those and validates
anything that was evicted in the meantime. drm_gpuvm_exec_lock() falls
back to a single pass when nothing is evicted.

Validation now runs under the uvmm mutex, like it already does for bind
jobs in bind_lock_validate().

Cc: Abhinav Kumar <abhinav.kumar@linux.dev>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Anna Maniscalco <anna.maniscalco2000@gmail.com>
Cc: Antonino Maniscalco <antomani103@gmail.com>
Cc: Boris Brezillon <boris.brezillon@collabora.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: David Airlie <airlied@gmail.com>
Cc: Dmitry Baryshkov <lumag@kernel.org>
Cc: Jessica Zhang <jesszhan0024@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Marijn Suijten <marijn.suijten@somainline.org>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Rob Clark <robin.clark@oss.qualcomm.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Sean Paul <sean@poorly.run>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Simona Vetter <simona@ffwll.ch>
Cc: Steven Price <steven.price@arm.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Assisted-by: LLM
---
v3:
 - New patch (Danilo)
---
 drivers/gpu/drm/nouveau/nouveau_exec.c | 27 +++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_exec.c b/drivers/gpu/drm/nouveau/nouveau_exec.c
index eea6619cffaa..b9ab7da125b1 100644
--- a/drivers/gpu/drm/nouveau/nouveau_exec.c
+++ b/drivers/gpu/drm/nouveau/nouveau_exec.c
@@ -85,6 +85,18 @@
  * the corresponding VM_BIND jobs they depend on - attached to them.
  */
 
+/*
+ * Called once per pass of drm_gpuvm_exec_lock(), validating whatever that pass
+ * locked. The early pass validates the evicted BOs before the resident ones
+ * are locked, so that a BO shared with another client, e.g. a compositor, is
+ * not held locked while this job's evicted BOs are moved back in.
+ */
+static int
+nouveau_exec_job_validate(struct drm_gpuvm_exec *vme)
+{
+	return drm_gpuvm_exec_validate(vme);
+}
+
 static int
 nouveau_exec_job_submit(struct nouveau_job *job,
 			struct drm_gpuvm_exec *vme)
@@ -99,21 +111,14 @@ nouveau_exec_job_submit(struct nouveau_job *job,
 	if (ret)
 		return ret;
 
+	vme->two_pass = true;
+	vme->extra.fn = nouveau_exec_job_validate;
+
 	nouveau_uvmm_lock(uvmm);
 	ret = drm_gpuvm_exec_lock(vme);
-	if (ret) {
-		nouveau_uvmm_unlock(uvmm);
-		return ret;
-	}
 	nouveau_uvmm_unlock(uvmm);
 
-	ret = drm_gpuvm_exec_validate(vme);
-	if (ret) {
-		drm_gpuvm_exec_unlock(vme);
-		return ret;
-	}
-
-	return 0;
+	return ret;
 }
 
 static void
-- 
2.34.1


      parent reply	other threads:[~2026-10-01 22:06 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 22:06 [PATCH v3 0/8] drm/gpuvm: two pass locking for exec Matthew Brost
2026-10-01 22:06 ` [PATCH v3 1/8] drm/gpuvm: allow locking external objects in two passes Matthew Brost
2026-10-04 19:56   ` Anna Maniscalco
2026-10-01 22:06 ` [PATCH v3 2/8] drm/xe: lock the resident BOs of an exec last Matthew Brost
2026-10-01 22:06 ` [PATCH v3 3/8] drm/panthor: lock the resident BOs of a submit last Matthew Brost
2026-10-05  9:39   ` Boris Brezillon
2026-10-01 22:06 ` [PATCH v3 4/8] drm/msm: reject a submit_bo table on VM_BIND contexts Matthew Brost
2026-10-01 22:06 ` [PATCH v3 5/8] drm/msm: use DRM_GPUVM_RESV_PROTECTED for VM_BIND VMs Matthew Brost
2026-10-01 22:06 ` [PATCH v3 6/8] drm/msm: lock the resident BOs of a VM_BIND submit last Matthew Brost
2026-10-04 20:29   ` Anna Maniscalco
2026-10-01 22:06 ` [PATCH v3 7/8] drm/nouveau: use DRM_GPUVM_RESV_PROTECTED Matthew Brost
2026-10-02  0:06   ` Matthew Brost
2026-10-02 20:17     ` Matthew Brost
2026-10-02  9:13   ` sashiko-bot
2026-10-06 16:50   ` Liviu Dudau
2026-10-01 22:06 ` Matthew Brost [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=20261001220632.3190896-9-matthew.brost@intel.com \
    --to=matthew.brost@intel.com \
    --cc=abhinav.kumar@linux.dev \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=anna.maniscalco2000@gmail.com \
    --cc=antomani103@gmail.com \
    --cc=boris.brezillon@collabora.com \
    --cc=corbet@lwn.net \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jesszhan0024@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=liviu.dudau@arm.com \
    --cc=lumag@kernel.org \
    --cc=lyude@redhat.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=marijn.suijten@somainline.org \
    --cc=mripard@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=sean@poorly.run \
    --cc=simona@ffwll.ch \
    --cc=skhan@linuxfoundation.org \
    --cc=steven.price@arm.com \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=tzimmermann@suse.de \
    /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