Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Javier MV" <javiermv@gmail.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v3 1/2] drm/i915/guc: Complete all requests of a non-schedulable context
Date: Mon, 16 Nov 2026 12:40:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-217016@kernel.org> (raw)
In-Reply-To: <20261116115958.9499-2-javiermv@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/i915/guc: out-of-order completion and missed cancel in
  __guc_add_request()
--

commit 8c211d88b3b41f45abe7f135b95dfbf93ce1feef
Author: Javier MV <javiermv@duck.com>

drm/i915/guc: Complete all requests of a non-schedulable context

This commit completes all queued requests on ce->guc_state.requests in
__guc_add_request() when a non-schedulable context is off the hardware.

Link: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/15301

> 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 788e59cdfac9b..229fa0fd3714b 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> @@ -709,7 +709,22 @@ static int __guc_add_request(struct intel_guc *guc, struct i915_request *rq)
>  	 * request resubmitted after the context was banned.
>  	 */
>  	if (unlikely(!intel_context_is_schedulable(ce))) {
> -		i915_request_put(i915_request_mark_eio(rq));
> +		struct i915_request *pos;
> +
> +		/*
> +		 * Only the last merged request is passed in. Once the context
> +		 * is off the HW, complete all of them (rq included).
> +		 */
> +		spin_lock(&ce->guc_state.lock);
> +		if (!context_enabled(ce) && !context_pending_enable(ce) &&
> +		    !context_pending_disable(ce)) {
> +			list_for_each_entry(pos, &ce->guc_state.requests, sched.link)
> +				i915_request_put(i915_request_mark_eio(pos));
> +		} else {
> +			i915_request_put(i915_request_mark_eio(rq));
> +		}
> +		spin_unlock(&ce->guc_state.lock);
> +
>  		intel_engine_signal_breadcrumbs(ce->engine);
>  		return 0;
>  	}

[Severity: High]
Does the else branch complete rq out of order while earlier merged or
in-flight requests on the same context are still incomplete?

Both guc_dequeue_one_context() and guc_bypass_tasklet_submit() call
__i915_request_submit() -> add_to_context() on every merged request before
calling guc_add_request(), placing them in sequence order on
ce->guc_state.requests and ce->timeline->requests.  When the context is
still enabled or pending disable, those earlier requests remain incomplete
until the schedule-disable G2H calls guc_cancel_context_requests().
Marking only the tail request rq complete here violates timeline ordering:
i915_request_retire_upto() hits GEM_BUG_ON(!i915_request_completed(tmp)) on
the older requests, and __i915_active_fence_set() retires vma->active and
ce->active callbacks attached to rq while earlier requests are still
running on the GPU.

Checking !context_pending_enable(ce) can also leave the earlier merged
requests uncompleted forever.  If __guc_reset_context() clears
SCHED_STATE_ENABLED while SCHED_STATE_PENDING_ENABLE is still set,
guc_context_revoke() sees !context_enabled(ce) && !context_pending_disable(ce)
and does not send a schedule-disable H2G, while intel_guc_sched_done_process_msg()
only clears SCHED_STATE_PENDING_ENABLE when the pending-enable G2H arrives
without calling guc_cancel_context_requests().

Matching guc_context_revoke() by checking !context_enabled(ce) &&
!context_pending_disable(ce) and dropping the else branch would avoid both
issues, since rq is already on ce->guc_state.requests and will be completed
in order by guc_cancel_context_requests() once the schedule-disable
completes.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116115958.9499-1-javiermv@gmail.com?part=1

  reply	other threads:[~2026-11-16 12:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 11:59 [PATCH v3 0/2] drm/i915/guc: Fix requests of a banned context never completing Javier MV
2026-11-16 11:59 ` [PATCH v3 1/2] drm/i915/guc: Complete all requests of a non-schedulable context Javier MV
2026-11-16 12:40   ` sashiko-bot [this message]
2026-11-16 11:59 ` [PATCH v3 2/2] drm/i915/guc: Don't unblock " Javier MV
2026-11-16 14:18 ` ✗ LGCI.VerificationFailed: failure for drm/i915/guc: Fix requests of a banned context never completing (rev3) 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=sashiko-outbox-217016@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=javiermv@gmail.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