From: Matthew Brost <matthew.brost@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: stable <stable@kernel.org>
Subject: [PATCH 1/2] drm/xe: Read scheduler message opcode under lock
Date: Mon, 31 Aug 2026 18:17:11 -0700 [thread overview]
Message-ID: <20260901011712.2617466-1-matthew.brost@intel.com> (raw)
For static scheduler messages, the opcode is only guaranteed to remain
stable while the message is on the pending message list. Read the opcode
under the message lock before removing the message from the pending list,
and pass it through the processing pipeline.
Fixes: ff796870f5dd ("drm/xe/guc: rework exec queue teardown PM/unplug handling")
Cc: stable <stable@kernel.org>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
drivers/gpu/drm/xe/xe_gpu_scheduler.c | 13 +++++++++----
drivers/gpu/drm/xe/xe_gpu_scheduler_types.h | 2 +-
drivers/gpu/drm/xe/xe_guc_submit.c | 7 ++++---
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_gpu_scheduler.c b/drivers/gpu/drm/xe/xe_gpu_scheduler.c
index 9c8004d5dd91..d656db758cb3 100644
--- a/drivers/gpu/drm/xe/xe_gpu_scheduler.c
+++ b/drivers/gpu/drm/xe/xe_gpu_scheduler.c
@@ -23,15 +23,19 @@ static void xe_sched_process_msg_queue_if_ready(struct xe_gpu_scheduler *sched)
}
static struct xe_sched_msg *
-xe_sched_get_msg(struct xe_gpu_scheduler *sched)
+xe_sched_get_msg(struct xe_gpu_scheduler *sched, unsigned int *opcode)
{
struct xe_sched_msg *msg;
xe_sched_msg_lock(sched);
msg = list_first_entry_or_null(&sched->msgs,
struct xe_sched_msg, link);
- if (msg)
+ if (msg) {
+ /* The opcode is only stable under lock for static messages */
+ *opcode = msg->opcode;
+
list_del_init(&msg->link);
+ }
xe_sched_msg_unlock(sched);
return msg;
@@ -42,13 +46,14 @@ static void xe_sched_process_msg_work(struct work_struct *w)
struct xe_gpu_scheduler *sched =
container_of(w, struct xe_gpu_scheduler, work_process_msg);
struct xe_sched_msg *msg;
+ unsigned int opcode;
if (drm_sched_is_stopped(&sched->base))
return;
- msg = xe_sched_get_msg(sched);
+ msg = xe_sched_get_msg(sched, &opcode);
if (msg) {
- sched->ops->process_msg(msg);
+ sched->ops->process_msg(msg, opcode);
xe_sched_process_msg_queue_if_ready(sched);
}
diff --git a/drivers/gpu/drm/xe/xe_gpu_scheduler_types.h b/drivers/gpu/drm/xe/xe_gpu_scheduler_types.h
index 63d9bf92583c..ea8b0d703d12 100644
--- a/drivers/gpu/drm/xe/xe_gpu_scheduler_types.h
+++ b/drivers/gpu/drm/xe/xe_gpu_scheduler_types.h
@@ -34,7 +34,7 @@ struct xe_sched_backend_ops {
* @process_msg: Process a message. Allowed to block, it is this
* function's responsibility to free message if dynamically allocated.
*/
- void (*process_msg)(struct xe_sched_msg *msg);
+ void (*process_msg)(struct xe_sched_msg *msg, unsigned int opcode);
};
/**
diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index 99d8c807ff05..5223f2782503 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -1980,16 +1980,17 @@ static void __guc_exec_queue_process_msg_cgp_sync(struct xe_sched_msg *msg,
#define MSG_HEAD BIT(9)
#define MSG_PM_REF BIT(10)
-static void guc_exec_queue_process_msg(struct xe_sched_msg *msg)
+static void guc_exec_queue_process_msg(struct xe_sched_msg *msg,
+ unsigned int opcode)
{
struct xe_device *xe = guc_to_xe(exec_queue_to_guc(msg->private_data));
int idx;
- bool pm_ref = !!(msg->opcode & MSG_PM_REF);
+ bool pm_ref = !!(opcode & MSG_PM_REF);
bool bound = drm_dev_enter(&xe->drm, &idx);
trace_xe_sched_msg_recv(msg);
- switch (msg->opcode & OPCODE_MASK) {
+ switch (opcode & OPCODE_MASK) {
case CLEANUP:
__guc_exec_queue_process_msg_cleanup(msg, bound);
break;
--
2.34.1
next reply other threads:[~2026-09-01 1:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 1:17 Matthew Brost [this message]
2026-09-01 1:17 ` [PATCH 2/2] drm/xe: Disable scheduling early on FD close to avoid CAT error cascade Matthew Brost
2026-09-01 1:39 ` sashiko-bot
2026-09-01 1:23 ` ✗ CI.checkpatch: warning for series starting with [1/2] drm/xe: Read scheduler message opcode under lock Patchwork
2026-09-01 1:25 ` ✓ CI.KUnit: success " Patchwork
2026-09-01 1:36 ` [PATCH 1/2] " sashiko-bot
2026-09-01 2:06 ` ✓ Xe.CI.BAT: success for series starting with [1/2] " Patchwork
2026-09-01 3:14 ` ✗ 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=20260901011712.2617466-1-matthew.brost@intel.com \
--to=matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=stable@kernel.org \
/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