Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/xe/hw_engine_group: Fix resume racing a pending suspend
@ 2026-12-03  8:00 Bommu Krishnaiah
  2026-12-03  7:55 ` ✗ CI.checkpatch: warning for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Bommu Krishnaiah @ 2026-12-03  8:00 UTC (permalink / raw)
  To: intel-xe; +Cc: Bommu Krishnaiah, Matthew Brost, Niranjana Vishwanathapura

hw_engine_group_resume_lr_jobs_func() calls resume() on every queue with
lr.suspended set without checking that the queue's suspend has
completed. resume() asserts that suspend_pending is clear unless the
queue is killed, banned or wedged, so a queue that still has a suspend
in flight when the worker runs trips it:

  Assertion `!ge->suspend_pending || exec_queue_killed_or_banned_or_wedged(q)' failed!
  WARNING: drivers/gpu/drm/xe/xe_guc_submit.c at __guc_exec_queue_resume
  Workqueue: xe-resume-lr-jobs-wq hw_engine_group_resume_lr_jobs_func

This is hit around a GT reset, in two windows:

1) The GuC is running but the suspend has not completed yet. Drain it
   with suspend_wait_blocking() before resuming, and skip queues whose
   wait failed or that are reset/killed/banned/wedged, in the same way
   the err_resume path of xe_hw_engine_group_suspend_faulting_lr_jobs()
   already does. The blocking variant is used because the queue may
   belong to a different process than the one that triggered the mode
   switch, so an interruptible wait could leave it suspended forever.

2) GuC submission is stopped. A queued SUSPEND message cannot run, so
   suspend_pending stays set, and guc_exec_queue_wait_suspend_done()
   returns success because its wait condition includes
   xe_guc_read_stopped(). The RESUME message is queued behind the
   pending SUSPEND and both are processed in order once submission
   restarts, so resuming is valid. Allow it in the assertion in
   __guc_exec_queue_resume(), as is already done for killed, banned and
   wedged queues.

Fixes: d16ef1a18e39 ("drm/xe/exec: Switch hw engine group execution mode upon job submission")
Assisted-by: LLM
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
---
 drivers/gpu/drm/xe/xe_guc_submit.c      | 7 +++++--
 drivers/gpu/drm/xe/xe_hw_engine_group.c | 4 ++++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index 2eb2e9ca3464..872ba426ae47 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -2466,10 +2466,13 @@ static bool __guc_exec_queue_resume(struct xe_exec_queue *q)
 	xe_sched_msg_lock(sched);
 	/*
 	 * A killed, banned or wedged queue keeps suspend_pending set until it
-	 * is torn down, so only assert the flag is clear otherwise.
+	 * is torn down. While submission is stopped (GT reset) a queued SUSPEND
+	 * cannot run, so the flag stays set; it is processed before this RESUME
+	 * once submission restarts. Only assert the flag is clear otherwise.
 	 */
 	xe_gt_assert(guc_to_gt(guc), !ge->suspend_pending ||
-		     exec_queue_killed_or_banned_or_wedged(q));
+		     exec_queue_killed_or_banned_or_wedged(q) ||
+		     xe_guc_read_stopped(guc));
 	xe_gt_assert(guc_to_gt(guc), ge->suspend_count > 0);
 	last = (--ge->suspend_count == 0);
 	if (last) {
diff --git a/drivers/gpu/drm/xe/xe_hw_engine_group.c b/drivers/gpu/drm/xe/xe_hw_engine_group.c
index 418ff427ae30..4113ee52e840 100644
--- a/drivers/gpu/drm/xe/xe_hw_engine_group.c
+++ b/drivers/gpu/drm/xe/xe_hw_engine_group.c
@@ -44,6 +44,10 @@ hw_engine_group_resume_lr_jobs_func(struct work_struct *w)
 		if (!READ_ONCE(q->lr.suspended))
 			continue;
 
+		/* resume() asserts the suspend fence has signalled, so drain it first. */
+		if (q->ops->suspend_wait_blocking(q) || q->ops->reset_status(q))
+			continue;
+
 		WRITE_ONCE(q->lr.suspended, false);
 		q->ops->resume(q);
 	}
-- 
2.43.0


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

end of thread, other threads:[~2026-12-03  8:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03  8:00 [PATCH] drm/xe/hw_engine_group: Fix resume racing a pending suspend Bommu Krishnaiah
2026-12-03  7:55 ` ✗ CI.checkpatch: warning for " Patchwork
2026-12-03  7:58 ` ✓ CI.KUnit: success " Patchwork
2026-12-03  8:18 ` [PATCH] " sashiko-bot
2026-12-03  8:28 ` ✓ Xe.CI.BAT: success for " Patchwork

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