Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matthew Brost" <matthew.brost@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/xe: Read scheduler message opcode under lock
Date: Tue, 01 Sep 2026 01:36:51 +0000	[thread overview]
Message-ID: <20260901013651.886601F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260901011712.2617466-1-matthew.brost@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Unprocessed STATIC_MSG_CLEANUP messages leak the entire xe_exec_queue and drm_device reference when the device is wedged.
--

commit 1cf668d3355bee8d104370398164a7bf010492ee
Author: Matthew Brost <matthew.brost@intel.com>

drm/xe: Read scheduler message opcode under lock

This commit modifies the DRM Xe scheduler to read the message opcode
under the message lock, as the opcode is only guaranteed to remain
stable while the message is on the pending list for static messages.

> 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
[ ... ]
> @@ -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;

[Severity: High]
This isn't a bug introduced by this patch, but this early return appears
to leak the xe_exec_queue memory and a reference to drm_device when the
device is wedged.

When the device is wedged, xe_sched_submission_stop() sets sched->pause_submit
to true and cancels the message processing worker. 

Later, when queues are destroyed (for example via FD close or
guc_submit_fini()), guc_exec_queue_destroy() adds a STATIC_MSG_CLEANUP message
to the scheduler's message list:

drivers/gpu/drm/xe/xe_guc_submit.c:guc_exec_queue_destroy() {
    ...
    struct xe_sched_msg *msg = q->guc->static_msgs + STATIC_MSG_CLEANUP;

    guc_exec_queue_add_msg(q, msg, CLEANUP);
    ...
}

Because the scheduler is stopped, xe_sched_process_msg_work() immediately
returns without processing the cleanup message.

As a result, the queue's async destruction
(__guc_exec_queue_process_msg_cleanup() -> guc_exec_queue_do_destroy()) is
never invoked.

This can be reached by any user that opens the DRM FD, runs a workload that
causes a GPU hang (triggering a wedge), and then closes the FD.

Could this be modified to allow processing of cleanup messages even when the
scheduler is stopped, or handled in an alternate teardown path, so we don't
permanently leak the xe_exec_queue and prevent the DRM module from being
cleanly unloaded?

>  
> -	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);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901011712.2617466-1-matthew.brost@intel.com?part=1

  parent reply	other threads:[~2026-09-01  1:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01  1:17 [PATCH 1/2] drm/xe: Read scheduler message opcode under lock Matthew Brost
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 ` sashiko-bot [this message]
2026-09-01  2:06 ` ✓ Xe.CI.BAT: " 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=20260901013651.886601F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@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