Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Varun Gupta" <varun.gupta@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH] drm/xe/guc: Skip CLEANUP message when GuC is stopped
Date: Tue, 18 Aug 2026 04:26:20 +0000	[thread overview]
Message-ID: <20260818042621.024E11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260818040733.135964-1-varun.gupta@intel.com>

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

New issues:
- [High] An unprotected Time-of-Check to Time-of-Use (TOCTOU) race condition exists between checking the GuC stopped state and adding the CLEANUP message, leading to suspended hardware access.

Pre-existing issues:
- [High] Bypassing the CLEANUP message abandons pending messages in the scheduler queue, causing memory and runtime PM reference leaks.
--

--- Patch [1]: [PATCH] drm/xe/guc: Skip CLEANUP message when GuC is stopped ---
commit 3774f2ff22deecb1f1aaf595a02f4bc19900b790
Author: Varun Gupta <varun.gupta@intel.com>

drm/xe/guc: Skip CLEANUP message when GuC is stopped

Attempting to enqueue a CLEANUP message while the GuC is stopped
(during a device reset or suspend) triggers a missing outer runtime
PM protection warning in xe_pm_runtime_get_noresume().

Since the GuC cannot service Command Transport (CT) requests while
stopped, skip the message and route directly to local teardown.

Cc: stable@vger.kernel.org

> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -2180,12 +2180,14 @@ static bool guc_exec_queue_try_add_msg(struct xe_exec_queue *q,
>  #define STATIC_MSG_CGP_SYNC	3
>  static void guc_exec_queue_destroy(struct xe_exec_queue *q)
>  {
> +	struct xe_guc *guc = exec_queue_to_guc(q);
>  	struct xe_sched_msg *msg = q->guc->static_msgs + STATIC_MSG_CLEANUP;
>  
> -	if (!(q->flags & EXEC_QUEUE_FLAG_PERMANENT) && !exec_queue_wedged(q))
> +	if (!(q->flags & EXEC_QUEUE_FLAG_PERMANENT) && !exec_queue_wedged(q) &&
> +	    !xe_guc_read_stopped(guc))

[Severity: High]
Could this regression introduce a race condition between checking the GuC
stopped state and adding the CLEANUP message?

The lockless check of xe_guc_read_stopped(guc) creates a window before
xe_pm_runtime_get_noresume() is called inside guc_exec_queue_add_msg().
If a thread evaluates the check as true, but concurrently the device performs
a runtime PM suspend and reaches RPM_SUSPENDED, the thread will still proceed
to add the CLEANUP message.

This would increment the PM reference without waking the device, leading
to the worker executing hardware instructions against powered-down registers
when it processes the message.

>  		guc_exec_queue_add_msg(q, msg, CLEANUP);
>  	else
> -		__guc_exec_queue_destroy(exec_queue_to_guc(q), q);
> +		__guc_exec_queue_destroy(guc, q);
>  }

[Severity: High]
This is a pre-existing issue, but does bypassing the CLEANUP message abandon
pending messages in the scheduler queue?

By moving straight to local teardown without draining pending messages,
the queue is destroyed immediately. Later, xe_sched_fini() unconditionally
cancels the work_process_msg worker:

drivers/gpu/drm/xe/xe_gpu_scheduler.c:xe_sched_submission_stop() {
    ...
    drm_sched_wqueue_stop(&sched->base);
    cancel_work_sync(&sched->work_process_msg);
}

Any prior messages (like SUSPEND or SET_SCHED_PROPS) still pending in
sched->msgs would be stranded and never processed. This permanently leaks
the dynamically allocated messages and their associated runtime PM
references. 

A leaked PM reference permanently prevents the GPU from entering runtime
suspend (D3 states), resulting in continuous power drain until the system
is rebooted.

Will the CLEANUP message still be needed to act as a barrier to ensure
the queue is drained properly?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260818040733.135964-1-varun.gupta@intel.com?part=1

  parent reply	other threads:[~2026-08-18  4:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18  4:07 [PATCH] drm/xe/guc: Skip CLEANUP message when GuC is stopped Varun Gupta
2026-08-18  4:14 ` ✓ CI.KUnit: success for " Patchwork
2026-08-18  4:26 ` sashiko-bot [this message]
2026-08-18  5:05 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-18  6:40 ` ✗ 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=20260818042621.024E11F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=varun.gupta@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