From: sashiko-bot@kernel.org
To: "Bommu Krishnaiah" <krishnaiah.bommu@intel.com>,
intel-xe@lists.freedesktop.org
Subject: Re: [PATCH] drm/xe/hw_engine_group: Fix resume racing a pending suspend
Date: Thu, 03 Dec 2026 08:18:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-247346@kernel.org> (raw)
In-Reply-To: <20261203080016.3093097-1-krishnaiah.bommu@intel.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [High] drm/xe: queuing RESUME while stopped breaks GuC scheduling
state machine
- [High] drm/xe: repeated suspend/resume while stopped collides static
msg slots
- [High] drm/xe: stale lr.suspended on skipped resume stalls future mode
switches
- [Medium] drm/xe: TOCTOU race across xe_guc_submit_start() still trips
resume assert
- [Medium] drm/xe: skipping resume() on banned secondary leaks primary
suspend_count
--
commit 7adb9851ce0a8492837d8f79554f2c25836d3de5
Author: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
drm/xe/hw_engine_group: Fix resume racing a pending suspend
This commit drains pending queue suspends in
hw_engine_group_resume_lr_jobs_func() before resuming faulting LR queues, and
relaxes the suspend_pending assertion in __guc_exec_queue_resume() while GuC
submission is stopped.
> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index fce39dd4e1177..7421731d912c2 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -2463,10 +2463,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));
[Severity: High]
Can queuing STATIC_MSG_RESUME behind a pending STATIC_MSG_SUSPEND while
submission is stopped corrupt the GuC scheduling state machine?
When xe_guc_submit_start() runs guc_exec_queue_start(),
xe_sched_resubmit_jobs() runs before work_process_msg and can register and
enable the queue. When work_process_msg then processes STATIC_MSG_SUSPEND,
disable_scheduling() sends GUC_CONTEXT_DISABLE asynchronously and returns
with EXEC_QUEUE_STATE_PENDING_DISABLE set.
work_process_msg GuC
__guc_exec_queue_process_msg_suspend()
set_exec_queue_suspended(q)
disable_scheduling(q, false)
send GUC_CONTEXT_DISABLE (async)
__guc_exec_queue_process_msg_resume()
clear_exec_queue_suspended(q)
enable_scheduling(q) <-- asserts !pending_disable
SCHED_DONE(0) arrives
handle_sched_done() sees
!exec_queue_suspended(q)
__guc_exec_queue_process_msg_resume() does not wait for
!exec_queue_pending_disable(q), so it trips the enable_scheduling() assert,
sends an overlapping GUC_CONTEXT_ENABLE, and makes handle_sched_done() skip
suspend_fence_signal(), leaving suspend_pending stuck true.
In the pre-stop reset window (after xe_uc_reset_prepare() sets stopped and
before guc_exec_queue_stop() stops the scheduler), STATIC_MSG_SUSPEND skips
disable_scheduling() and STATIC_MSG_RESUME is consumed immediately.
guc_exec_queue_stop() then still sees suspend_pending set and preserves
EXEC_QUEUE_STATE_SUSPENDED across reset with no resume left to clear it, so
submit_exec_queue() silently drops all future submissions on the queue.
> xe_gt_assert(guc_to_gt(guc), ge->suspend_count > 0);
> last = (--ge->suspend_count == 0);
> if (last) {
[Severity: High]
What happens if another suspend/resume cycle runs before
xe_guc_submit_start() drains sched->msgs?
Allowing __guc_exec_queue_resume() to decrement ge->suspend_count to 0 while
stopped leaves both STATIC_MSG_SUSPEND and STATIC_MSG_RESUME linked on
sched->msgs. A second DMA-fence mode switch before restart then hits
guc_exec_queue_try_add_msg() for STATIC_MSG_SUSPEND with !list_empty(),
tripping xe_gt_assert(..., added) in __guc_exec_queue_suspend().
On non-debug builds the second suspend is silently dropped, so restart runs
SUSPEND followed by RESUME and re-enables the faulting LR queue while the
engine group is in EXEC_MODE_DMA_FENCE. A second resume before drain
similarly drops STATIC_MSG_RESUME.
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine_group.c b/drivers/gpu/drm/xe/xe_hw_engine_group.c
> index 418ff427ae308..4113ee52e8405 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);
> }
[Severity: High]
Does skipping WRITE_ONCE(q->lr.suspended, false) on a failed wait or non-zero
reset_status() stall every future DMA-fence mode switch on the group?
When suspend_wait_blocking() times out, guc_exec_queue_suspend_timeout_ban()
bans the queue and leaves suspend_pending set until teardown. The queue
stays on group->exec_queue_list with q->lr.suspended set until closed.
On the next DMA-fence mode switch,
xe_hw_engine_group_suspend_faulting_lr_jobs() skips the banned queue in its
first loop without clearing q->lr.suspended, then waits on it in the second
loop.
Because guc_exec_queue_wait_suspend_done() does not wake on
EXEC_QUEUE_STATE_BANNED or EXEC_QUEUE_STATE_WEDGED, every mode switch sleeps
5 seconds in suspend_wait() holding group->mode_sem write-locked, fails with
-ETIME, and sleeps another 5 seconds in err_resume.
Also, if reset_status() is non-zero only due to EXEC_QUEUE_STATE_RESET,
skipping resume() while guc_exec_queue_suspend() still succeeds on the next
switch leaks an unbalanced ge->suspend_count increment.
[Severity: Medium]
Can xe_guc_submit_start() still race between suspend_wait_blocking() and
resume() and trip the __guc_exec_queue_resume() assertion?
hw_engine_group_resume_lr_jobs_func() only holds group->mode_sem for reading
and does not serialize against xe_guc_submit_start(), which clears
guc->submission_state.stopped before work_process_msg clears suspend_pending:
CPU0 (resume worker) CPU1 (GT reset)
suspend_wait_blocking(q)
xe_guc_read_stopped() != 0
returns 0 (suspend_pending=1)
xe_guc_submit_start()
atomic_dec(&stopped) -> 0
q->ops->resume(q)
__guc_exec_queue_resume(q) <-- assert fails: stopped=0, pending=1
Once stopped drops to 0 before STATIC_MSG_SUSPEND finishes, all three clauses
of the xe_gt_assert() in __guc_exec_queue_resume() evaluate to false.
[Severity: Medium]
If reset_status() skips resume() on a banned multi-queue secondary, does this
leak the secondary's forwarded suspend reference on the primary queue?
guc_exec_queue_suspend() increments primary->guc->suspend_count on a
secondary's 0->1 transition, and that reference is only dropped by
guc_exec_queue_resume() or on teardown in guc_exec_queue_fini().
During a GT reset, a secondary can be banned individually without banning its
primary (for example in guc_exec_queue_stop() when a completed job hits
xe_sched_invalidate_job(), so TDR exits early without banning the group).
Skipping q->ops->resume(q) then leaves primary->guc->suspend_count pinned at
1 until userspace closes the secondary, either leaving the healthy primary
permanently suspended or preventing later DMA-fence mode switches from
suspending the group (incrementing suspend_count 1->2 instead of 0->1).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203080016.3093097-1-krishnaiah.bommu@intel.com?part=1
prev parent reply other threads:[~2026-12-03 8:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` sashiko-bot [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=sashiko-outbox-247346@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=krishnaiah.bommu@intel.com \
--cc=sashiko-reviews@lists.linux.dev \
/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