From: Laura Nao <laura.nao@collabora.com>
To: aliceryhl@google.com
Cc: a.hindborg@kernel.org, acourbot@nvidia.com, airlied@gmail.com,
bjorn3_gh@protonmail.com, boqun@kernel.org, dakr@kernel.org,
daniel.almeida@collabora.com, deborah.brouwer@collabora.com,
dri-devel@lists.freedesktop.org, gary@garyguo.net,
kernel@collabora.com, laura.nao@collabora.com,
linux-kernel@vger.kernel.org, lossin@kernel.org,
ojeda@kernel.org, rust-for-linux@vger.kernel.org,
simona@ffwll.ch, tamird@kernel.org, tmgross@umich.edu,
work@onurozkan.dev
Subject: Re: [PATCH v6 2/2] drm/tyr: add Job IRQ handling
Date: Mon, 5 Oct 2026 15:40:10 +0200 [thread overview]
Message-ID: <20261005134010.302208-1-laura.nao@collabora.com> (raw)
In-Reply-To: <arOP5iuLuj1aTiLl@google.com>
Hi Alice,
On 9/23/26 10:37, Alice Ryhl wrote:
> I agree with sashiko's review here.
>
> This needs to happen after the free_irq() call in the destructor of
> TyrIrq.
Thanks for the feedback.
In v5, I was masking the interrupts in TyrIrq's PinnedDrop impl which
resulted in clear_mask() being called after free_irq(). However, sashiko
warned the device could then assert irqs after free_irq() completes
but before clear_mask() runs, potentially leading to an IRQ storm that
could result in the shared line being permanently disabled.
So calling clear_mask() before free_irq() should avoid this, but we
still have to deal with threaded handlers potentially re-enabling the
mask after clear_mask() has run (as per sashiko's review on this current
revision). Adding the atomic state should help with that though, as you
suggested:
> And most likely, we need an atomic along the lines of ACTIVE /
> PROCESSING / SUSPENDING in panthor_irq.
>
So I'm thinking something like this for the state:
#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(i32)]
enum IrqState {
Active = 0,
Processing,
Unregistering,
}
unsafe impl AtomicType for IrqState {
type Repr = i32;
}
This could then be stored in TyrIrq:
#[pin_data]
pub(crate) struct TyrIrq<T: TyrIrqTrait> {
irq: T,
state: Arc<Atomic<IrqState>>,
#[pin]
_pin: PhantomPinned,
}
Then TyrIrq::handle() proceeds only when the state is active and
TyrIrq::handle_threaded() re-enables the mask only if the state is not
`Unregistering`.
Does this make sense to you?
As for masking before free_irq() runs, I'm thinking of possible
alternatives to JobIrqMaskGuard and its ordering convention (i.e. must
be stored in a field declared before the corresponding
`ThreadedRegistration` in the struct that owns both). Would it make
sense to define a TyrIrqRegistration struct that wraps
ThreadedRegistration instead? and then clear the mask in
TyrIrqRegistration's drop impl.
Something like:
#[pin_data(PinnedDrop)]
pub(crate) struct TyrIrqRegistration<'a, T: TyrIrqTrait> {
#[pin]
registration: ThreadedRegistration<'a, TyrIrq<T>>,
}
#[pinned_drop]
impl<T: TyrIrqTrait> PinnedDrop for TyrIrqRegistration<'_, T> {
fn drop(self: Pin<&mut Self>) {
let handler = self.registration.handler();
handler.state.store(IrqState::Unregistering, Release);
handler.irq.clear_mask();
}
}
This should make sure teardown order is still respected without relying
on the user correctly putting the guard before `ThreadedRegistration`.
Any thoughts on this approach? In case it helps as a reference, I've
drafted both IrqState and TyrIrqRegistration in [1].
[1] https://gitlab.freedesktop.org/laura.nao/linux/-/commit/c78e296690e643b790fb3195660f1229e3cdb5ca
Best,
Laura
next prev parent reply other threads:[~2026-10-05 13:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 8:01 [PATCH v6 0/2] " Laura Nao
2026-08-27 8:01 ` [PATCH v6 1/2] drm/tyr: add TyrIrq threaded IRQ wrapper Laura Nao
2026-08-27 8:01 ` [PATCH v6 2/2] drm/tyr: add Job IRQ handling Laura Nao
2026-09-23 8:37 ` Alice Ryhl
2026-10-05 13:40 ` Laura Nao [this message]
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=20261005134010.302208-1-laura.nao@collabora.com \
--to=laura.nao@collabora.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=deborah.brouwer@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.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
all inboxes | Powered by JetHome®