Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/guc: Do not trigger TDR from the memory CAT error handler
@ 2026-11-16 10:20 Arvind Yadav
  2026-11-16 10:49 ` sashiko-bot
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Arvind Yadav @ 2026-11-16 10:20 UTC (permalink / raw)
  To: intel-xe, dri-devel
  Cc: rodrigo.vivi, matthew.brost, himal.prasad.ghimiray,
	thomas.hellstrom, tejas.upadhyay

The memory CAT error handler uses the same cleanup path as the
context-reset handler. This immediately triggers the TDR, which can
send a scheduling-disable request before the context-reset notification
arrives.

On a BMG dGPU, an early disable after a CCS memory CAT error is
associated with subsequent contexts being enabled but never starting
work. Recovery occurs later when a scheduling-disable timeout triggers
a GT reset.

Separate waking user-fence waiters from triggering the TDR. On a memory
CAT notification, mark the queue reset and wake waiters without starting
the TDR. Keep the existing cleanup triggered by the context-reset
notification.

Leave the uncorrectable-error and CGP context-error paths unchanged.

Tested on a BMG dGPU using a standalone SYCL reproducer with two
separate processes.

The first process submits a kernel that reads an unmapped GPU address,
causing a page fault followed by a memory CAT error. It then calls
abort() without waiting for the kernel to finish.

After that process exits, a second process, called "victim", starts.
It submits a simple kernel that writes 7 to a device allocation,
copies the value back to the CPU and checks the result.

Without the patch, the victim can hang and reach its 60-second
userspace timeout. With the patch, the victim completed and returned
the expected value in all tested rounds where the first process triggered
the fault.

Recovery without a context-reset notification still needs confirmation,
particularly for LR queues, which have no normal finite job timeout.
Independent queue-kill and cleanup paths are unchanged.

Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
Assisted-by: LLM
Signed-off-by: Arvind Yadav <arvind.yadav@intel.com>
---
 drivers/gpu/drm/xe/xe_guc_submit.c | 50 ++++++++++++++++++++++--------
 1 file changed, 37 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index d76f125f9c3a..aa382634a235 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -557,17 +557,39 @@ static bool vf_recovery(struct xe_guc *guc)
 	return xe_gt_recovery_pending(guc_to_gt(guc));
 }
 
-static void xe_guc_exec_queue_trigger_cleanup(struct xe_exec_queue *q)
+static void xe_guc_exec_queue_wake_ufence(struct xe_exec_queue *q)
 {
 	struct xe_guc *guc = exec_queue_to_guc(q);
 	struct xe_device *xe = guc_to_xe(guc);
 
 	/** to wakeup xe_wait_user_fence ioctl if exec queue is reset */
 	wake_up_all(&xe->ufence_wq);
+}
+
+static void xe_guc_exec_queue_trigger_cleanup(struct xe_exec_queue *q)
+{
+	xe_guc_exec_queue_wake_ufence(q);
 
 	xe_sched_tdr_queue_imm(&q->guc->sched);
 }
 
+/*
+ * Allow callers to wake user-fence waiters without triggering the TDR.
+ * The memory CAT handler uses this to avoid starting cleanup before
+ * the context-reset notification arrives.
+ */
+static void xe_queue_trigger_cleanup_for_reset(struct xe_exec_queue *q,
+					       bool trigger_tdr)
+{
+	if (exec_queue_banned(q))
+		return;
+
+	if (trigger_tdr)
+		xe_guc_exec_queue_trigger_cleanup(q);
+	else
+		xe_guc_exec_queue_wake_ufence(q);
+}
+
 static void xe_guc_exec_queue_group_stop(struct xe_exec_queue *q)
 {
 	struct xe_exec_queue *primary = xe_exec_queue_multi_queue_primary(q);
@@ -653,7 +675,8 @@ static void xe_guc_exec_queue_group_trigger_cleanup(struct xe_exec_queue *q)
 	mutex_unlock(&group->list_lock);
 }
 
-static void xe_guc_exec_queue_reset_trigger_cleanup(struct xe_exec_queue *q)
+static void xe_guc_exec_queue_reset_trigger_cleanup(struct xe_exec_queue *q,
+						    bool trigger_tdr)
 {
 	if (xe_exec_queue_is_multi_queue(q)) {
 		struct xe_exec_queue *primary = xe_exec_queue_multi_queue_primary(q);
@@ -664,20 +687,17 @@ static void xe_guc_exec_queue_reset_trigger_cleanup(struct xe_exec_queue *q)
 		WRITE_ONCE(group->banned, true);
 
 		set_exec_queue_reset(primary);
-		if (!exec_queue_banned(primary))
-			xe_guc_exec_queue_trigger_cleanup(primary);
+		xe_queue_trigger_cleanup_for_reset(primary, trigger_tdr);
 
 		mutex_lock(&group->list_lock);
 		list_for_each_entry(eq, &group->list, multi_queue.link) {
 			set_exec_queue_reset(eq);
-			if (!exec_queue_banned(eq))
-				xe_guc_exec_queue_trigger_cleanup(eq);
+			xe_queue_trigger_cleanup_for_reset(eq, trigger_tdr);
 		}
 		mutex_unlock(&group->list_lock);
 	} else {
 		set_exec_queue_reset(q);
-		if (!exec_queue_banned(q))
-			xe_guc_exec_queue_trigger_cleanup(q);
+		xe_queue_trigger_cleanup_for_reset(q, trigger_tdr);
 	}
 }
 
@@ -3523,7 +3543,7 @@ int xe_guc_exec_queue_reset_handler(struct xe_guc *guc, u32 *msg, u32 len)
 	 * jobs by setting timeout of the job to the minimum value kicking
 	 * guc_exec_queue_timedout_job.
 	 */
-	xe_guc_exec_queue_reset_trigger_cleanup(q);
+	xe_guc_exec_queue_reset_trigger_cleanup(q, true);
 
 	return 0;
 }
@@ -3601,8 +3621,12 @@ int xe_guc_exec_queue_memory_cat_error_handler(struct xe_guc *guc, u32 *msg,
 
 	trace_xe_exec_queue_memory_cat_error(q);
 
-	/* Treat the same as engine reset */
-	xe_guc_exec_queue_reset_trigger_cleanup(q);
+	/*
+	 * Starting the TDR here can send a scheduling-disable request before
+	 * the context-reset notification arrives. Mark the queue reset and
+	 * wake user-fence waiters, leaving that notification to trigger cleanup.
+	 */
+	xe_guc_exec_queue_reset_trigger_cleanup(q, false);
 
 	return 0;
 }
@@ -3644,7 +3668,7 @@ int xe_guc_uncorrectable_error_handler(struct xe_guc *guc, u32 *msg, u32 len)
 	trace_xe_guc_uncorrectable_error(q);
 
 	/* Treat the same as engine reset */
-	xe_guc_exec_queue_reset_trigger_cleanup(q);
+	xe_guc_exec_queue_reset_trigger_cleanup(q, true);
 
 	return 0;
 }
@@ -3696,7 +3720,7 @@ int xe_guc_exec_queue_cgp_context_error_handler(struct xe_guc *guc, u32 *msg,
 	trace_xe_exec_queue_cgp_context_error(q);
 
 	/* Treat the same as engine reset */
-	xe_guc_exec_queue_reset_trigger_cleanup(q);
+	xe_guc_exec_queue_reset_trigger_cleanup(q, true);
 
 	return 0;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-16 13:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 10:20 [PATCH] drm/xe/guc: Do not trigger TDR from the memory CAT error handler Arvind Yadav
2026-11-16 10:49 ` sashiko-bot
2026-11-16 12:49 ` ✗ CI.checkpatch: warning for " Patchwork
2026-11-16 12:52 ` ✓ CI.KUnit: success " Patchwork
2026-11-16 13:25 ` ✓ Xe.CI.BAT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox