From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Francois Dugast" <francois.dugast@intel.com>,
"Matthew Auld" <matthew.auld@intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>
Subject: [PATCH 1/4] drm/xe/guc: Add suspend refcount to exec queue ops
Date: Thu, 21 May 2026 16:48:34 +0200 [thread overview]
Message-ID: <20260521144837.7363-2-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20260521144837.7363-1-thomas.hellstrom@linux.intel.com>
Concurrent call sites that suspend exec queues (PM, mode switching,
preempt fences) each need to pair their own suspend/resume without
caring about other callers. Without coordination, a resume from one
path can prematurely re-enable a queue still suspended by another.
Add suspend_count to xe_guc_exec_queue. The SUSPEND message is only
sent on the 0->1 transition; the RESUME message is only sent on the
1->0 transition. Callers simply pair suspend and resume. The existing
sched.msg_lock spinlock serialises concurrent calls so neither side
needs to know about the other.
Assisted-by: GitHub_Copilot:claude-sonnet-4.6
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
drivers/gpu/drm/xe/xe_guc_exec_queue_types.h | 7 ++++++
drivers/gpu/drm/xe/xe_guc_submit.c | 24 ++++++++++++--------
2 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_guc_exec_queue_types.h b/drivers/gpu/drm/xe/xe_guc_exec_queue_types.h
index e5e53b421f29..8ee76f958dc2 100644
--- a/drivers/gpu/drm/xe/xe_guc_exec_queue_types.h
+++ b/drivers/gpu/drm/xe/xe_guc_exec_queue_types.h
@@ -49,6 +49,13 @@ struct xe_guc_exec_queue {
wait_queue_head_t suspend_wait;
/** @suspend_pending: a suspend of the exec_queue is pending */
bool suspend_pending;
+ /**
+ * @suspend_count: number of active suspend requests, protected by
+ * @sched.msg_lock. The exec_queue is kept suspended as long as this
+ * is non-zero. Transitions 0->1 send the SUSPEND message; transitions
+ * 1->0 send the RESUME message.
+ */
+ int suspend_count;
/**
* @needs_cleanup: Needs a cleanup message during VF post migration
* recovery.
diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index 4d32b430bc15..50b622cf0c30 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -2131,15 +2131,18 @@ static int guc_exec_queue_set_multi_queue_priority(struct xe_exec_queue *q,
static int guc_exec_queue_suspend(struct xe_exec_queue *q)
{
- struct xe_gpu_scheduler *sched = &q->guc->sched;
- struct xe_sched_msg *msg = q->guc->static_msgs + STATIC_MSG_SUSPEND;
+ struct xe_guc_exec_queue *ge = q->guc;
+ struct xe_gpu_scheduler *sched = &ge->sched;
+ struct xe_sched_msg *msg = ge->static_msgs + STATIC_MSG_SUSPEND;
if (exec_queue_killed_or_banned_or_wedged(q))
return -EINVAL;
xe_sched_msg_lock(sched);
- if (guc_exec_queue_try_add_msg(q, msg, SUSPEND))
- q->guc->suspend_pending = true;
+ if (++ge->suspend_count == 1) {
+ if (guc_exec_queue_try_add_msg(q, msg, SUSPEND))
+ ge->suspend_pending = true;
+ }
xe_sched_msg_unlock(sched);
return 0;
@@ -2190,14 +2193,17 @@ static int guc_exec_queue_suspend_wait(struct xe_exec_queue *q)
static void guc_exec_queue_resume(struct xe_exec_queue *q)
{
- struct xe_gpu_scheduler *sched = &q->guc->sched;
- struct xe_sched_msg *msg = q->guc->static_msgs + STATIC_MSG_RESUME;
+ struct xe_guc_exec_queue *ge = q->guc;
+ struct xe_gpu_scheduler *sched = &ge->sched;
+ struct xe_sched_msg *msg = ge->static_msgs + STATIC_MSG_RESUME;
struct xe_guc *guc = exec_queue_to_guc(q);
- xe_gt_assert(guc_to_gt(guc), !q->guc->suspend_pending);
-
xe_sched_msg_lock(sched);
- guc_exec_queue_try_add_msg(q, msg, RESUME);
+ xe_gt_assert(guc_to_gt(guc), ge->suspend_count > 0);
+ if (--ge->suspend_count == 0) {
+ xe_gt_assert(guc_to_gt(guc), !ge->suspend_pending);
+ guc_exec_queue_try_add_msg(q, msg, RESUME);
+ }
xe_sched_msg_unlock(sched);
}
--
2.54.0
next prev parent reply other threads:[~2026-05-21 14:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 14:48 [PATCH 0/4] drm/xe: Fix LR exec queue suspend/resume for S3/S4 Thomas Hellström
2026-05-21 14:48 ` Thomas Hellström [this message]
2026-05-21 14:48 ` [PATCH 2/4] drm/xe/guc: Don't ban LR VM exec queues on PM suspend Thomas Hellström
2026-05-21 14:48 ` [PATCH 3/4] drm/xe: Restore userspace LRC BOs early on resume Thomas Hellström
2026-05-21 16:09 ` Matthew Auld
2026-05-21 16:31 ` Thomas Hellström
2026-05-22 9:51 ` Thomas Hellström
2026-05-22 10:05 ` Matthew Auld
2026-05-21 14:48 ` [PATCH 4/4] drm/xe: Suspend fault-mode LR jobs before VRAM eviction on S3/S4 Thomas Hellström
2026-05-21 14:56 ` ✓ CI.KUnit: success for drm/xe: Fix LR exec queue suspend/resume for S3/S4 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=20260521144837.7363-2-thomas.hellstrom@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=francois.dugast@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=rodrigo.vivi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox