All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maarten Lankhorst" <dev@lankhorst.se>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 7/7] drm/i915/gt: Add a spinlock to prevent starvation of irq_work.
Date: Thu, 02 Jul 2026 08:24:50 +0000	[thread overview]
Message-ID: <20260702082451.021A11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260702080913.434121-8-dev@lankhorst.se>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Acquiring `b->signaler_active_sync` with `spin_lock()` in `intel_context_remove_breadcrumbs()` without disabling interrupts creates a deadlock vulnerability and Lockdep splat on non-RT kernels.
--

commit b2f8f390d7421e899486c8f32c2c91c29a783338
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

drm/i915/gt: Add a spinlock to prevent starvation of irq_work.

This commit introduces a new spinlock, signaler_active_sync, to prevent
starvation of irq-work. It acquires this lock in both signal_irq_work()
and intel_context_remove_breadcrumbs() to force completion and synchronize
signaler state.

> diff --git a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
> --- a/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
> +++ b/drivers/gpu/drm/i915/gt/intel_breadcrumbs.c
> @@ -209,6 +209,7 @@ static void signal_irq_work(struct irq_work *work)
>  		intel_breadcrumbs_disarm_irq(b);
>  
>  	rcu_read_lock();
> +	spin_lock(&b->signaler_active_sync);
>  	atomic_inc(&b->signaler_active);
>  	list_for_each_entry_rcu(ce, &b->signalers, signal_link) {

[ ... ]

> @@ -487,8 +490,11 @@ void intel_context_remove_breadcrumbs(struct intel_context *ce,
>  	if (release)
>  		intel_context_put(ce);
>  
> -	while (atomic_read(&b->signaler_active))
> +	while (atomic_read(&b->signaler_active)) {
> +		spin_lock(&b->signaler_active_sync);
> +		spin_unlock(&b->signaler_active_sync);

[Severity: High]
Can this cause a deadlock on non-RT kernels?

Because signal_irq_work() runs in hardirq context as an irq_work callback,
acquiring signaler_active_sync here in intel_context_remove_breadcrumbs() 
without disabling interrupts creates a window for a self-deadlock.

If a hardware interrupt occurs on the same CPU while this spinlock is 
momentarily held, the local irq_work will trigger and signal_irq_work() 
will try to acquire the already-held lock. Lockdep will also flag this as 
an inconsistent lock state (HARDIRQ-ON-W vs IN-HARDIRQ-W) on its first 
execution.

Does this need to use spin_lock_irq() or spin_lock_irqsave() to safely 
synchronize against the irq_work?

>  		cpu_relax();
> +	}
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260702080913.434121-1-dev@lankhorst.se?part=7

  reply	other threads:[~2026-07-02  8:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  8:09 [PATCH 0/7] drm/i915: All fixes to make i915 work well with PREEMPT_RT Maarten Lankhorst
2026-07-02  8:09 ` [PATCH 1/7] drm/i915/gt: Use spin_lock_irq() instead of local_irq_disable() + spin_lock() Maarten Lankhorst
2026-07-02  8:27   ` sashiko-bot
2026-07-02  8:09 ` [PATCH 2/7] drm/i915: Drop the irqs_disabled() check Maarten Lankhorst
2026-07-02  8:09 ` [PATCH 3/7] drm/i915/guc: Consider also RCU depth in busy loop Maarten Lankhorst
2026-07-02  8:09 ` [PATCH 4/7] drm/i915/gt: Fix selftests on PREEMPT_RT Maarten Lankhorst
2026-07-02  8:09 ` [PATCH 5/7] drm/i915/gt: Set stop_timeout() correctly on PREEMPT-RT Maarten Lankhorst
2026-07-02  8:09 ` [PATCH 6/7] drm/i915: Use sleeping selftests for igt_atomic on PREEMPT_RT Maarten Lankhorst
2026-07-02  8:09 ` [PATCH 7/7] drm/i915/gt: Add a spinlock to prevent starvation of irq_work Maarten Lankhorst
2026-07-02  8:24   ` sashiko-bot [this message]
2026-07-02 12:42 ` ✗ i915.CI.BAT: failure for drm/i915: All fixes to make i915 work well with PREEMPT_RT 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=20260702082451.021A11F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dev@lankhorst.se \
    --cc=dri-devel@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 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.