All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Bommu Krishnaiah <krishnaiah.bommu@intel.com>,
	Matthew Brost <matthew.brost@intel.com>
Subject: [PATCH 1/2] drm/xe: Hold a fence reference while waiting for migration
Date: Fri, 20 Nov 2026 12:38:21 +0530	[thread overview]
Message-ID: <20261120070822.3834209-2-krishnaiah.bommu@intel.com> (raw)
In-Reply-To: <20261120070822.3834209-1-krishnaiah.bommu@intel.com>

xe_migrate_wait() reads m->fence without job_mutex, while migration
submissions replace the pointer and drop the previous reference under
that mutex. A concurrent replacement could leave the waiter accessing
a fence whose reference has been released.

Take a fence reference under job_mutex, then wait and release
the reference outside the lock. This protects the snapshot without holding
the submission mutex throughout the wait. Callers must still quiesce
submissions when they require the migration context to be idle.

Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")

Cc: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
---
 drivers/gpu/drm/xe/xe_migrate.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
index d7a8d8ecffe6..57a81eda2088 100644
--- a/drivers/gpu/drm/xe/xe_migrate.c
+++ b/drivers/gpu/drm/xe/xe_migrate.c
@@ -2150,8 +2150,16 @@ struct migrate_test_params {
  */
 void xe_migrate_wait(struct xe_migrate *m)
 {
-	if (m->fence)
-		dma_fence_wait(m->fence, false);
+	struct dma_fence *fence;
+
+	mutex_lock(&m->job_mutex);
+	fence = dma_fence_get(m->fence);
+	mutex_unlock(&m->job_mutex);
+
+	if (fence) {
+		dma_fence_wait(fence, false);
+		dma_fence_put(fence);
+	}
 }
 
 static u32 pte_update_cmd_size(u64 size)
-- 
2.43.0


  reply	other threads:[~2026-11-20  6:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  7:08 [PATCH 0/2] drm/xe: Hold a fence reference while waiting for migration Bommu Krishnaiah
2026-11-20  7:08 ` Bommu Krishnaiah [this message]
2026-11-24 21:55   ` [PATCH 1/2] " Matthew Brost
2026-11-20  7:08 ` [PATCH 2/2] drm/xe: Centralize migration fence updates Bommu Krishnaiah
2026-11-24 21:56   ` Matthew Brost
2026-11-20  8:10 ` ✓ CI.KUnit: success for drm/xe: Hold a fence reference while waiting for migration (rev2) Patchwork
2026-11-20  9:01 ` ✓ Xe.CI.BAT: " Patchwork

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=20261120070822.3834209-2-krishnaiah.bommu@intel.com \
    --to=krishnaiah.bommu@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.