intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Legowski <jakub.legowski@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: matthew.brost@intel.com, maciej.patelczyk@intel.com,
	Jakub Legowski <jakub.legowski@intel.com>
Subject: [PATCH v2 1/1] drm/xe/guc: Fix wake_up race in handle_sched_done
Date: Wed,  9 Sep 2026 09:08:25 +0200	[thread overview]
Message-ID: <20260909070825.228551-1-jakub.legowski@intel.com> (raw)

Move wake_up_all() after clear_exec_queue_pending_disable()

When a SCHED_DONE G2H arrives for a banned exec queue,
handle_sched_done() calls wake_up_all() before
clear_exec_queue_pending_disable(). This creates a race with the
wait_event_timeout() in guc_exec_queue_timedout_job() that waits
for pending_disable to be cleared:

    smp_rmb();
    ret = wait_event_timeout(guc->ct.wq,
                 ...
                 ...);

This was observed as:
[drm:guc_exec_queue_timedout_job [xe]] Tile0: GT0: Check job timeout: seqno=4294967169, lrc_seqno=4294967169, guc_id=4, running_time_ms=0, timeout_ms=5000, diff=0x00000001

Moving the wake_up_all() (along with its smp_wmb())
after all paths that clear pending_disable, ensuring that waiters
always observe the updated state when woken.

Same as for runnable_state == 1 in the beginning of
handle_sched_done().

Signed-off-by: Jakub Legowski <jakub.legowski@intel.com>
---
 drivers/gpu/drm/xe/xe_guc_submit.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index 99d8c807ff05..a181b5042293 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -3239,25 +3239,27 @@ static void handle_sched_done(struct xe_guc *guc, struct xe_exec_queue *q,
 			clear_exec_queue_pending_disable(q);
 			suspend_fence_signal(q);
 		} else {
+			bool destroyed = exec_queue_destroyed(q);
+
+			/*
+			 * Make sure to clear the pending_disable only
+			 * after sampling the destroyed state. We want
+			 * to ensure we don't trigger the unregister too
+			 * early with something intending to only
+			 * disable scheduling. The caller doing the
+			 * destroy must wait for an ongoing
+			 * pending_disable before marking as destroyed.
+			 */
+			clear_exec_queue_pending_disable(q);
+
 			if (exec_queue_banned(q)) {
+				/* Pairs with smp_rmb in guc_exec_queue_timedout_job */
 				smp_wmb();
 				wake_up_all(&guc->ct.wq);
 			}
-			if (exec_queue_destroyed(q)) {
-				/*
-				 * Make sure to clear the pending_disable only
-				 * after sampling the destroyed state. We want
-				 * to ensure we don't trigger the unregister too
-				 * early with something intending to only
-				 * disable scheduling. The caller doing the
-				 * destroy must wait for an ongoing
-				 * pending_disable before marking as destroyed.
-				 */
-				clear_exec_queue_pending_disable(q);
+
+			if (destroyed)
 				deregister_exec_queue(guc, q);
-			} else {
-				clear_exec_queue_pending_disable(q);
-			}
 		}
 	}
 }
-- 
2.48.1

---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych.

Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.


             reply	other threads:[~2026-09-09  7:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09  7:08 Jakub Legowski [this message]
2026-09-09  7:30 ` [PATCH v2 1/1] drm/xe/guc: Fix wake_up race in handle_sched_done sashiko-bot
2026-09-09  7:42 ` ✗ CI.checkpatch: warning for series starting with [v2,1/1] " Patchwork
2026-09-09  7:44 ` ✓ CI.KUnit: success " Patchwork
2026-09-09  8:23 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-09 12:57 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-09-10  0:00 ` [PATCH v2 1/1] " Matthew Brost
2026-09-10 10:20 ` Maciej Patelczyk

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=20260909070825.228551-1-jakub.legowski@intel.com \
    --to=jakub.legowski@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=maciej.patelczyk@intel.com \
    --cc=matthew.brost@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;
as well as URLs for NNTP newsgroup(s).