From: Daniel Charles <daniel.charles@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: x.wang@intel.com, jia.yao@intel.com, jonathan.cavitt@intel.com,
matthew.brost@intel.com, stable <stable@kernel.org>
Subject: [PATCH v2 1/3] drm/xe: Read scheduler message opcode under lock
Date: Tue, 13 Oct 2026 13:15:06 -0700 [thread overview]
Message-ID: <20261013201508.514480-2-daniel.charles@intel.com> (raw)
In-Reply-To: <20261013201508.514480-1-daniel.charles@intel.com>
From: Matthew Brost <matthew.brost@intel.com>
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 9c8004d5dd915..d656db758cb3c 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 78ef2e8ded4f3..163a0d85e3cb9 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 7ce73489c35fc..c4ef3e9bf7a18 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -2056,16 +2056,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.43.0
next prev parent reply other threads:[~2026-10-13 20:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 20:15 [PATCH v2 0/3] FD close cleanup for XE Daniel Charles
2026-10-13 20:15 ` Daniel Charles [this message]
2026-10-13 20:32 ` [PATCH v2 1/3] drm/xe: Read scheduler message opcode under lock sashiko-bot
2026-10-13 20:15 ` [PATCH v2 2/3] drm/xe: Disable scheduling early on FD close to avoid CAT error cascade Daniel Charles
2026-10-13 20:15 ` [PATCH v2 3/3] drm/xe: Synchronously wait for queue kill on FD close Daniel Charles
2026-10-13 21:03 ` sashiko-bot
2026-10-13 20:40 ` ✗ CI.checkpatch: warning for FD close cleanup for XE (rev2) Patchwork
2026-10-13 20:43 ` ✓ CI.KUnit: success " 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=20261013201508.514480-2-daniel.charles@intel.com \
--to=daniel.charles@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=jia.yao@intel.com \
--cc=jonathan.cavitt@intel.com \
--cc=matthew.brost@intel.com \
--cc=stable@kernel.org \
--cc=x.wang@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