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 v3 3/5] drm/xe/guc: Add suspend refcount to exec queue ops
Date: Mon, 25 May 2026 15:30:49 +0200 [thread overview]
Message-ID: <20260525133051.91636-4-thomas.hellstrom@linux.intel.com> (raw)
In-Reply-To: <20260525133051.91636-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 a reference count to exec queue suspend operations. A queue remains
suspended as long as any caller holds a suspend; it resumes only when
the last caller releases it. Each caller simply pairs its own suspend
with a resume without needing to know about others.
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..1207d51cf770 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: Reference count of active suspend requests. The
+ * exec_queue remains suspended while this is non-zero, allowing
+ * multiple concurrent callers to independently hold a suspend without
+ * prematurely re-enabling the queue. Protected by @sched.msg_lock.
+ */
+ 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 f1a6f13011b5..7800a9d1d377 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-25 13:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 13:30 [PATCH v3 0/5] drm/xe: Fix LR exec queue suspend/resume for S3/S4 Thomas Hellström
2026-05-25 13:30 ` [PATCH v3 1/5] drm/xe/guc: Defer user exec queue scheduler start until after page table restore Thomas Hellström
2026-05-26 15:27 ` Matthew Auld
2026-05-27 10:15 ` Thomas Hellström
2026-05-25 13:30 ` [PATCH v3 2/5] drm/xe/guc: Don't ban LR VM exec queues on PM suspend Thomas Hellström
2026-05-26 15:38 ` Matthew Auld
2026-05-27 10:19 ` Thomas Hellström
2026-05-27 16:35 ` Matthew Auld
2026-05-25 13:30 ` Thomas Hellström [this message]
2026-05-25 13:30 ` [PATCH v3 4/5] drm/xe: Rename EXEC_MODE_LR to EXEC_MODE_FAULT in hw engine group Thomas Hellström
2026-05-28 17:06 ` Rodrigo Vivi
2026-05-28 17:33 ` Francois Dugast
2026-05-25 13:30 ` [PATCH v3 5/5] drm/xe: Suspend fault-mode LR jobs before VRAM eviction on S3/S4 Thomas Hellström
2026-05-25 15:56 ` ✓ CI.KUnit: success for drm/xe: Fix LR exec queue suspend/resume for S3/S4 (rev3) Patchwork
2026-05-25 16:35 ` ✓ Xe.CI.BAT: " Patchwork
2026-05-25 20:38 ` ✗ Xe.CI.FULL: failure " 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=20260525133051.91636-4-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 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.