All of lore.kernel.org
 help / color / mirror / Atom feed
From: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
To: intel-xe@lists.freedesktop.org, daniele.ceraolospurio@intel.com,
	alan.previn.teres.alexis@intel.com, julia.filipchuk@intel.com
Subject: [PATCH 1/2] drm/xe/guc: Reject a duplicate deregister-done G2H
Date: Tue,  8 Sep 2026 16:18:56 -0700	[thread overview]
Message-ID: <20260908231854.1218934-5-umesh.nerlige.ramappa@intel.com> (raw)
In-Reply-To: <20260908231854.1218934-4-umesh.nerlige.ramappa@intel.com>

The registered bit is cleared by the first deregister-done, but the
guc_id is only freed once the deferred destroy work has run, so there is
a small window of time where a duplicate deregister can go through
before the guc id is freed. Add an additional check to block a duplicate
deregister.

Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
Reported-by: Martin Hodo <martin.hodo@intel.com>
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Assisted-by: Claude:claude-opus-5
---
 drivers/gpu/drm/xe/xe_guc_submit.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
index f3ba8abfc228..7339c3cecdc0 100644
--- a/drivers/gpu/drm/xe/xe_guc_submit.c
+++ b/drivers/gpu/drm/xe/xe_guc_submit.c
@@ -3350,8 +3350,15 @@ int xe_guc_deregister_done_handler(struct xe_guc *guc, u32 *msg, u32 len)
 	if (unlikely(!q))
 		return -EPROTO;
 
-	if (!exec_queue_destroyed(q) || exec_queue_pending_disable(q) ||
-	    exec_queue_pending_enable(q) || exec_queue_enabled(q)) {
+	/*
+	 * The registered bit is cleared by the first deregister-done, but the
+	 * guc_id is only freed once the deferred destroy work has run, so the
+	 * lookup above still resolves in between. Checking it here makes a
+	 * duplicate notification an error rather than a second destroy.
+	 */
+	if (!exec_queue_registered(q) || !exec_queue_destroyed(q) ||
+	    exec_queue_pending_disable(q) || exec_queue_pending_enable(q) ||
+	    exec_queue_enabled(q)) {
 		xe_gt_err(guc_to_gt(guc),
 			  "DEREGISTER_DONE: Unexpected engine state 0x%04x, guc_id=%d",
 			  atomic_read(&q->guc->state), q->guc->id);
-- 
2.53.0


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

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 23:18 [PATCH 0/2] Some error handling improvements in GuC Umesh Nerlige Ramappa
2026-09-08 23:18 ` Umesh Nerlige Ramappa [this message]
2026-09-08 23:32   ` [PATCH 1/2] drm/xe/guc: Reject a duplicate deregister-done G2H sashiko-bot
2026-09-08 23:18 ` [PATCH 2/2] drm/xe/guc: Sanity check GuC-reported hwconfig table size Umesh Nerlige Ramappa
2026-09-08 23:26   ` sashiko-bot
2026-09-08 23:26 ` ✗ CI.checkpatch: warning for Some error handling improvements in GuC Patchwork
2026-09-08 23:28 ` ✓ CI.KUnit: success " Patchwork
2026-09-09  0:14 ` ✓ Xe.CI.BAT: " Patchwork
2026-09-09  8:17 ` ✗ 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=20260908231854.1218934-5-umesh.nerlige.ramappa@intel.com \
    --to=umesh.nerlige.ramappa@intel.com \
    --cc=alan.previn.teres.alexis@intel.com \
    --cc=daniele.ceraolospurio@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=julia.filipchuk@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.