dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Laura Nao" <laura.nao@collabora.com>
Cc: dri-devel@lists.freedesktop.org, ojeda@kernel.org
Subject: Re: [PATCH v6 1/2] drm/tyr: add TyrIrq threaded IRQ wrapper
Date: Thu, 27 Aug 2026 08:15:12 +0000	[thread overview]
Message-ID: <20260827081512.EF6B21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260728-tyr-irq-v2-v6-1-15c90baed949@collabora.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The IRQ wrapper requests the threaded IRQ before clearing the device's pending interrupt status, creating an initialization race condition that can drop valid interrupts or cause IRQ storms.
--

commit e2f89c4d0d12a403d87f79e5dbf89539040c84df
Author: Laura Nao <laura.nao@collabora.com>

drm/tyr: add TyrIrq threaded IRQ wrapper

Introduce a generic TyrIrq threaded IRQ wrapper along with the
TyrIrqTrait trait describing the operations required to handle a
Tyr interrupt source.

> diff --git a/drivers/gpu/drm/tyr/irq.rs b/drivers/gpu/drm/tyr/irq.rs
> new file mode 100644
> index 0000000000000..e6a739532daa2
> --- /dev/null
> +++ b/drivers/gpu/drm/tyr/irq.rs

[ ... ]

> +impl<T: TyrIrqTrait> TyrIrq<T> {
> +    /// Requests a threaded IRQ registration for irq, using name to look up the interrupt.
> +    ///
> +    /// # Safety
> +    ///
> +    /// Callers must not mem::forget() the resulting registration or otherwise prevent its
> +    /// [Drop] implementation from running.
> +    pub(crate) unsafe fn request<'a>(
> +        pdev: &'a platform::Device<Bound>,
> +        name: &'static CStr,
> +        irq: T,
> +    ) -> Result<impl PinInit<ThreadedRegistration<'a, Self>, Error> + 'a>
> +    where
> +        T: 'a,
> +    {
> +        let handler = try_pin_init!(Self {
> +            irq,
> +            _pin: PhantomPinned,
> +        });
> +
> +        // SAFETY: The caller guarantees the resulting registration will not be leaked.
> +        let registration =
> +            unsafe { pdev.request_threaded_irq_by_name(Flags::SHARED, name, name, handler) };
> +
> +        // Clear the status and unmask once the handler has been
> +        // successfully registered.
> +        Ok(registration.pin_chain(|reg| {
> +            let irq = &reg.handler().irq;
> +            irq.clear_status(irq.mask());

[Severity: High]
Does this code request the threaded IRQ before clearing the device's pending
interrupt status?

Calling pdev.request_threaded_irq_by_name() immediately registers the
handler and enables the IRQ at the interrupt controller. However, the
hardware status is only cleared later when the .pin_chain closure executes.

If the device line is shared and level-triggered, could a pending stale
interrupt cause the hardirq handler to fire immediately? If masked, it
returns None, leading the kernel to see an unhandled level interrupt, which
could trigger an IRQ storm and permanently disable the line.

Furthermore, if a valid hardware interrupt arrives after registration but
before the .pin_chain closure runs, does irq.clear_status(irq.mask())
unconditionally wipe it out, permanently losing the event?

Should the device be quiesced (clearing status and masking) before
registering the IRQ?

> +            irq.reenable_mask();
> +            Ok(())
> +        }))
> +    }
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260728-tyr-irq-v2-v6-0-15c90baed949@collabora.com?part=1

  reply	other threads:[~2026-08-27  8:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27  8:01 [PATCH v6 0/2] drm/tyr: add Job IRQ handling Laura Nao
2026-08-27  8:01 ` [PATCH v6 1/2] drm/tyr: add TyrIrq threaded IRQ wrapper Laura Nao
2026-08-27  8:15   ` sashiko-bot [this message]
2026-08-27  8:01 ` [PATCH v6 2/2] drm/tyr: add Job IRQ handling Laura Nao
2026-08-27  8:14   ` sashiko-bot
2026-09-23  8:37   ` Alice Ryhl
2026-10-05 13:40     ` Laura Nao
2026-09-25 19:29 ` [PATCH v6 0/2] " Daniel Almeida
2026-10-05 13:54   ` Laura Nao

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=20260827081512.EF6B21F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=laura.nao@collabora.com \
    --cc=ojeda@kernel.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