Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Charles" <daniel.charles@intel.com>,
	intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v6 2/4] drm/xe: Notify scheduling-state waiters per exec queue
Date: Thu, 19 Nov 2026 18:06:47 +0000	[thread overview]
Message-ID: <sashiko-outbox-223756@kernel.org> (raw)
In-Reply-To: <20261119174621.1311154-3-daniel.charles@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/xe: IRQ deadlock on exec_queue_lookup in
  xe_guc_submit_wake_state_waiters()
--

commit 82584d6c0991b25ef45bbf198d37096f89c4db89
Author: Daniel Charles <daniel.charles@intel.com>

drm/xe: Notify scheduling-state waiters per exec queue

This commit adds a per-exec-queue waitqueue for GuC scheduling state
changes and wakes waiters upon SCHED_DONE, submission stop, wedge, and VF
migration recovery.

> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index 1f24e248acb97..4087a38ad3d66 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -559,6 +559,30 @@ static bool vf_recovery(struct xe_guc *guc)
>  	return xe_gt_recovery_pending(guc_to_gt(guc));
>  }
>  
> +/**
> + * xe_guc_submit_wake_state_waiters() - Wake all scheduling-state waiters
> + * @guc: the &xe_guc
> + *
> + * Notify per-queue waiters when a GuC-wide stop or recovery changes their
> + * wait conditions. May be called from interrupt context.
> + */
> +void xe_guc_submit_wake_state_waiters(struct xe_guc *guc)
> +{
> +	struct xarray *lookup = &guc->submission_state.exec_queue_lookup;
> +	struct xe_exec_queue *q;
> +	unsigned long index, flags;
> +
> +	if (!guc->submission_state.initialized)
> +		return;
> +
> +	/* Prevent removal and freeing of queues while waking their waiters. */
> +	xa_lock_irqsave(lookup, flags);
> +	xa_for_each(lookup, index, q)
> +		if (q->guc->id == index)
> +			wake_up_all(&q->guc->state_wq);
> +	xa_unlock_irqrestore(lookup, flags);
> +}

[Severity: High]
Can taking exec_queue_lookup's xa_lock from hardirq context self-deadlock
against process-context mutators?

vf_start_migration_recovery() calls xe_guc_submit_wake_state_waiters()
from hardirq context via xe_guc_irq_handler() ->
xe_guc_sw_0_irq_handler() -> xe_gt_sriov_vf_migrated_event_handler().
However, exec_queue_lookup is initialized with xa_init() without
XA_FLAGS_LOCK_IRQ, and alloc_guc_id(), publish_guc_id(), and
__release_guc_id() mutate it using xa_insert(), xa_store(), and
xa_erase(), which take xa_lock with interrupts enabled:

alloc_guc_id()
  xa_insert(&guc->submission_state.exec_queue_lookup, ...)
    xa_lock(...)
    <hardirq>
      xe_guc_irq_handler()
        ...
          vf_start_migration_recovery()
            xe_guc_submit_wake_state_waiters()
              xa_lock_irqsave(lookup, flags)  <-- spins forever

Initializing exec_queue_lookup with xa_init_flags(..., XA_FLAGS_LOCK_IRQ)
and using the _irq variants for xa_insert(), xa_store(), and xa_erase()
would avoid this lock inversion.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119174621.1311154-1-daniel.charles@intel.com?part=2

  reply	other threads:[~2026-11-19 18:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 17:46 [PATCH v6 0/4] FD close cleanup for XE Daniel Charles
2026-11-19 17:46 ` [PATCH v6 1/4] drm/xe: Read scheduler message opcode under lock Daniel Charles
2026-11-19 17:46 ` [PATCH v6 2/4] drm/xe: Notify scheduling-state waiters per exec queue Daniel Charles
2026-11-19 18:06   ` sashiko-bot [this message]
2026-11-19 19:16     ` Cavitt, Jonathan
2026-11-19 17:46 ` [PATCH v6 3/4] drm/xe: Disable scheduling early on FD close to avoid CAT error cascade Daniel Charles
2026-11-19 18:18   ` sashiko-bot
2026-11-19 19:26     ` Cavitt, Jonathan
2026-11-19 17:46 ` [PATCH v6 4/4] drm/xe: Synchronously wait for queue kill on FD close Daniel Charles
2026-11-19 18:21   ` sashiko-bot
2026-11-19 19:44   ` Cavitt, Jonathan
2026-11-20  0:16 ` ✗ CI.checkpatch: warning for FD close cleanup for XE (rev6) Patchwork
2026-11-20  0:18 ` ✓ CI.KUnit: success " Patchwork
2026-11-20  0:58 ` ✓ Xe.CI.BAT: " 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-223756@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=daniel.charles@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --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