Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
To: Linus Walleij <linusw@kernel.org>
Cc: Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
	 Li Youhong <dayou5941@163.com>,
	Daniel Scally <dan.scally@ideasonboard.com>,
	 Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil+cisco@kernel.org>,
	 Nayden Kanchev <nayden.kanchev@arm.com>,
	linux-media@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v2] media: mali-c55: Keep IRQ requested during suspend
Date: Mon, 23 Nov 2026 09:28:28 +0100	[thread overview]
Message-ID: <awP0mKeNtrJj8zh6@zed> (raw)
In-Reply-To: <CAD++jLnuS9ZE8mRwkCizsqo3f40s5etqOJAUqLJNsCtE5eEkDg@mail.gmail.com>

Hi Linus

On Mon, Nov 23, 2026 at 01:29:05AM +0100, Linus Walleij wrote:
> Hi Jacopo,
>
> On Tue, Nov 10, 2026 at 1:51 PM Jacopo Mondi
> <jacopo.mondi@ideasonboard.com> wrote:
>
> > >  static const struct dev_pm_ops mali_c55_pm_ops = {
> > > @@ -825,27 +813,42 @@ static int mali_c55_probe(struct platform_device *pdev)
> > >       pm_runtime_set_autosuspend_delay(&pdev->dev, 2000);
> > >       pm_runtime_use_autosuspend(&pdev->dev);
> > >       pm_runtime_set_active(&pdev->dev);
> > > +     pm_runtime_get_noresume(dev);
> >
> > Why is it relevant to hold a PM reference during the installation of
> > the IRQ handler ?
>
> Probe enables runtime PM before registering the media devices.
> Once those devices are visible, a streaming path can take and drop a

This seems veeery theoretical. To have the v4l2 device and subdevice
nodes appear to userspace we have to wait the ivc to probe (see the
.complete() notifier callback handler) and to operate the pipeline we
need the CSI-2 receiver and the sensor to have probed as well. This in
m2m mode. With an inline path to have the devnodes registered you have
to have the whole chain to probe up to the sensor.

So yeah, maybe Sashiko would tell you this is possible but I hardly
believe it is.

Anyway, there is a remote possibility for a window here, so let's
increase the pm runtime counter.

> PM reference. The probe reference keeps the ISP active until the IRQ is
> installed, so runtime suspend cannot call disable_irq() on an IRQ we
> haven’t requested yet. I’ll add a comment.

A suspend will always follow a resume, and if a resume tries to enable
an irq before it is installed we'll have problems as well.

If that's a real concern to you, shouldn't we install the irq handler
before enabling pm runtime and powering the device up ?

>
> > > +     /*
> > > +      * The driver needs to transfer large amounts of register settings to
> > > +      * the ISP each frame, using either a DMA transfer or memcpy. We use a
> > > +      * threaded IRQ to avoid disabling interrupts the entire time that's
> > > +      * happening.
> >
> > Does this comment still apply in your opinion ? I mean, thread_irq are
> > pretty regular stuff, do we need to justify its usage ?
>
> Nah I'll drop it.
>
> > > +     pm_runtime_disable(&pdev->dev);
> >
> > It amazes me how, after so many years, I still can't find a clear, firm
> > indication of what is the intended call order for pm_runtime_disable()
> > and the other pm_runtime calls is during a driver's remove.
> >
> > Media drivers seem to do different things with some disabling pm
> > before setting the state to suspended, other doing the other way
> > around.
> >
> > In the end, I think this doesn't make any difference, but in this
> > specific occurance:
> >
> > 1) Is this re-ordering required to support the new interrupt handling?
> > or
> > 2) Is it a change that is worth doing anyway ? (and I should say "should
> > go in a different patch on its own")
> >
> > > +     free_irq(mali_c55->irqnum, &pdev->dev);
> > >       mali_c55_media_frameworks_deinit(mali_c55);
> > > -     if (!pm_runtime_suspended(&pdev->dev)) {
> > > +     if (!pm_runtime_status_suspended(&pdev->dev)) {
> >
> > I guess this is required because you moved pm_runtime_disable() up
>
> The remove ordering is part of the IRQ lifetime change. Both runtime
> PM callbacks now assume the IRQ is installed, so we need to drain
> them befor free_irq(). Then free_irq() waits for the threaded handler
> before we unregister the media entities it uses.

I'm sorry, this is certainly me missing some pm_runtime internals,
but where is this happening ?

>
> That’s also why I switched to pm_runtime_status_suspended().
> It reports the actual status after pm_runtime_disable(), so we only
> power off the ISP if it’s still active.

It seems to me pm_runtime_status_suspended() ignores the runtime
counter and is only there because you pm_runtime_disable() earlier ?


>
> I'll resend a touched-up version.
>
> Yours,
> Linus Walleij

      reply	other threads:[~2026-11-23  8:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 14:08 [PATCH v2] media: mali-c55: Keep IRQ requested during suspend Linus Walleij
2026-11-05  8:07 ` Linus Walleij
2026-11-10 12:51 ` Jacopo Mondi
2026-11-23  0:29   ` Linus Walleij
2026-11-23  8:28     ` Jacopo Mondi [this message]

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=awP0mKeNtrJj8zh6@zed \
    --to=jacopo.mondi@ideasonboard.com \
    --cc=dan.scally@ideasonboard.com \
    --cc=dayou5941@163.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nayden.kanchev@arm.com \
    --cc=stable@vger.kernel.org \
    /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