Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
To: intel-gfx@lists.freedesktop.org, daniele.ceraolospurio@intel.com,
	alan.previn.teres.alexis@intel.com, julia.filipchuk@intel.com
Subject: [PATCH 2/2] drm/i915/guc: Reject unsolicited deregister-done G2H
Date: Tue,  8 Sep 2026 16:23:26 -0700	[thread overview]
Message-ID: <20260908232323.1220407-6-umesh.nerlige.ramappa@intel.com> (raw)
In-Reply-To: <20260908232323.1220407-4-umesh.nerlige.ramappa@intel.com>

intel_guc_deregister_done_process_msg() takes the ctx_id straight out of
the G2H payload, resolves it via g2h_context_lookup() and then calls
decr_outstanding_submission_g2h() unconditionally. Ensure that we are
expecting a DEREGISTER_DONE G2H for that context before changing
outstanding_submission state. Return EPROTO on error.

Fixes: b97060a99b01 ("drm/i915/guc: Update intel_gt_wait_for_idle to work with GuC")
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/i915/gt/uc/intel_guc_submission.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index 9d3bd16adf40..85fbef30dbec 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -5065,6 +5065,18 @@ int intel_guc_deregister_done_process_msg(struct intel_guc *guc,
 	if (unlikely(!ce))
 		return -EPROTO;
 
+	/*
+	 * A deregister H2G is only ever sent for a context that has been put in
+	 * one of these two states first, so anything else means this G2H does
+	 * not correspond to an outstanding request of ours.
+	 */
+	if (unlikely(!context_wait_for_deregister_to_register(ce) &&
+		     !context_destroyed(ce))) {
+		guc_err(guc, "Unexpected deregister done, ctx_id %u sched_state 0x%x\n",
+			ctx_id, ce->guc_state.sched_state);
+		return -EPROTO;
+	}
+
 	trace_intel_context_deregister_done(ce);
 
 #ifdef CONFIG_DRM_I915_SELFTEST
-- 
2.53.0


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

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 23:23 [PATCH 0/2] Some error handling improvements in GuC Umesh Nerlige Ramappa
2026-09-08 23:23 ` [PATCH 1/2] drm/i915/guc: Range check GuC-provided engine class and instance Umesh Nerlige Ramappa
2026-09-08 23:23 ` Umesh Nerlige Ramappa [this message]
2026-09-08 23:39   ` [PATCH 2/2] drm/i915/guc: Reject unsolicited deregister-done G2H sashiko-bot
2026-09-09  0:47 ` ✓ i915.CI.BAT: success for Some error handling improvements in GuC Patchwork
2026-09-09 18:00 ` ✗ i915.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=20260908232323.1220407-6-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-gfx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox