* [PATCH] media: renesas: rzv2h-ivc: stop interrupt before disabling clocks on suspend
@ 2026-12-03 8:53 Yaohan Li
2026-12-03 9:19 ` Jacopo Mondi
0 siblings, 1 reply; 3+ messages in thread
From: Yaohan Li @ 2026-12-03 8:53 UTC (permalink / raw)
To: Daniel Scally, Jacopo Mondi, Mauro Carvalho Chehab
Cc: Hans Verkuil, linux-media, linux-kernel
rzv2h_ivc_runtime_resume() enables the clocks, deasserts resets, unmasks
RZV2H_IVC_REG_FM_INT_EN, and finally requests ivc->irqnum.
rzv2h_ivc_runtime_suspend() tears these down in the wrong order: it
asserts resets and disables all three clocks while RZV2H_IVC_REG_FM_INT_EN
is still enabled and before calling free_irq(). If an interrupt arrives
or is still running during that window, rzv2h_ivc_isr() can call
rzv2h_ivc_transfer_buffer() and write MMIO registers while the block is
held in reset with its clocks gated.
Mask RZV2H_IVC_REG_FM_INT_EN and free ivc->irqnum before asserting resets
and disabling the clocks, matching the resume path in reverse.
Fixes: f0b3984d821b ("media: platform: Add Renesas Input Video Control block driver")
Cc: stable@vger.kernel.org
Signed-off-by: Yaohan Li <shunsheng1218@gmail.com>
---
Based on v7.4-rc5 (fe6ff8d5d675); applies cleanly on media-committers fixes
and next. Scoped strictly to the rzv2h_ivc_runtime_suspend() teardown
order; active-remove / V4L2 lifetime is left untouched.
I don't have physical Renesas RZ/V2H hardware, so I tested this in QEMU
(x86_64, KASAN + PROVE_LOCKING) with the in-tree rzv2h-ivc.ko bound to a
platform device backed by reserved MMIO, three CCF clk_hw clocks, and a
virtual IRQ across 5 runtime suspend/resume and system force-suspend/resume
cycles (unmodified driver disables all three clocks while FM_INT_EN is still
set and ivc->irqnum is still bound; patched clears FM_INT_EN and frees the
IRQ first with 0 KASAN or lockdep warnings). Also build-tested on x86_64
and arm64 with W=1 (0 warnings).
AI assistance: Claude and Gemini helped check the runtime PM ordering, write
the QEMU test module, and draft the changelog. I reviewed the driver code,
test logs, and final patch myself.
drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c b/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c
index e2a14ebeb1141..937891e45e38b 100644
--- a/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c
+++ b/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c
@@ -164,9 +164,10 @@ static int rzv2h_ivc_runtime_suspend(struct device *dev)
{
struct rzv2h_ivc *ivc = dev_get_drvdata(dev);
+ rzv2h_ivc_write(ivc, RZV2H_IVC_REG_FM_INT_EN, 0x0);
+ free_irq(ivc->irqnum, dev);
reset_control_bulk_assert(ARRAY_SIZE(ivc->resets), ivc->resets);
clk_bulk_disable_unprepare(ARRAY_SIZE(ivc->clks), ivc->clks);
- free_irq(ivc->irqnum, dev);
return 0;
}
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: renesas: rzv2h-ivc: stop interrupt before disabling clocks on suspend
2026-12-03 8:53 [PATCH] media: renesas: rzv2h-ivc: stop interrupt before disabling clocks on suspend Yaohan Li
@ 2026-12-03 9:19 ` Jacopo Mondi
2026-12-04 4:21 ` Yaohan Li
0 siblings, 1 reply; 3+ messages in thread
From: Jacopo Mondi @ 2026-12-03 9:19 UTC (permalink / raw)
To: Yaohan Li
Cc: Daniel Scally, Jacopo Mondi, Mauro Carvalho Chehab, Hans Verkuil,
linux-media, linux-kernel
On Thu, Dec 03, 2026 at 04:53:19PM +0800, Yaohan Li wrote:
> rzv2h_ivc_runtime_resume() enables the clocks, deasserts resets, unmasks
> RZV2H_IVC_REG_FM_INT_EN, and finally requests ivc->irqnum.
>
> rzv2h_ivc_runtime_suspend() tears these down in the wrong order: it
> asserts resets and disables all three clocks while RZV2H_IVC_REG_FM_INT_EN
> is still enabled and before calling free_irq(). If an interrupt arrives
How can an interrupt arrive ater the reset signal has been asserted ?
> or is still running during that window, rzv2h_ivc_isr() can call
> rzv2h_ivc_transfer_buffer() and write MMIO registers while the block is
> held in reset with its clocks gated.
>
> Mask RZV2H_IVC_REG_FM_INT_EN and free ivc->irqnum before asserting resets
> and disabling the clocks, matching the resume path in reverse.
>
> Fixes: f0b3984d821b ("media: platform: Add Renesas Input Video Control block driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yaohan Li <shunsheng1218@gmail.com>
> ---
> Based on v7.4-rc5 (fe6ff8d5d675); applies cleanly on media-committers fixes
> and next. Scoped strictly to the rzv2h_ivc_runtime_suspend() teardown
> order; active-remove / V4L2 lifetime is left untouched.
>
> I don't have physical Renesas RZ/V2H hardware, so I tested this in QEMU
> (x86_64, KASAN + PROVE_LOCKING) with the in-tree rzv2h-ivc.ko bound to a
> platform device backed by reserved MMIO, three CCF clk_hw clocks, and a
> virtual IRQ across 5 runtime suspend/resume and system force-suspend/resume
> cycles (unmodified driver disables all three clocks while FM_INT_EN is still
> set and ivc->irqnum is still bound; patched clears FM_INT_EN and frees the
> IRQ first with 0 KASAN or lockdep warnings). Also build-tested on x86_64
> and arm64 with W=1 (0 warnings).
>
> AI assistance: Claude and Gemini helped check the runtime PM ordering, write
> the QEMU test module, and draft the changelog. I reviewed the driver code,
> test logs, and final patch myself.
>
> drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c b/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c
> index e2a14ebeb1141..937891e45e38b 100644
> --- a/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c
> +++ b/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c
> @@ -164,9 +164,10 @@ static int rzv2h_ivc_runtime_suspend(struct device *dev)
> {
> struct rzv2h_ivc *ivc = dev_get_drvdata(dev);
>
> + rzv2h_ivc_write(ivc, RZV2H_IVC_REG_FM_INT_EN, 0x0);
> + free_irq(ivc->irqnum, dev);
> reset_control_bulk_assert(ARRAY_SIZE(ivc->resets), ivc->resets);
> clk_bulk_disable_unprepare(ARRAY_SIZE(ivc->clks), ivc->clks);
> - free_irq(ivc->irqnum, dev);
>
> return 0;
> }
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] media: renesas: rzv2h-ivc: stop interrupt before disabling clocks on suspend
2026-12-03 9:19 ` Jacopo Mondi
@ 2026-12-04 4:21 ` Yaohan Li
0 siblings, 0 replies; 3+ messages in thread
From: Yaohan Li @ 2026-12-04 4:21 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Daniel Scally, Mauro Carvalho Chehab, Hans Verkuil, linux-media,
linux-kernel
Hi Jacopo,
On Thu, Dec 03, 2026 at 10:19:22AM +0100, Jacopo Mondi wrote:
> On Thu, Dec 03, 2026 at 04:53:19PM +0800, Yaohan Li wrote:
> > rzv2h_ivc_runtime_suspend() tears these down in the wrong order: it
> > asserts resets and disables all three clocks while RZV2H_IVC_REG_FM_INT_EN
> > is still enabled and before calling free_irq(). If an interrupt arrives
>
> How can an interrupt arrive ater the reset signal has been asserted ?
You're right -- saying a new interrupt could arrive after reset was
imprecise.
My concern is an interrupt handler that is already running on another CPU
when runtime_suspend() asserts the resets and disables the clocks. Since
free_irq() currently runs after both, nothing waits for an in-flight
handler before the clocks are gated.
Also, the driver gets shared resets via
devm_reset_control_bulk_get_optional_shared(), so asserting them does not
necessarily assert the physical reset line if another consumer still holds
it deasserted.
My QEMU test only checks the teardown order, not real RZ/V2H interrupt
behavior. Does the streaming stop path already guarantee that no handler
can still be running when runtime_suspend() is entered?
Thanks,
Yaohan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-04 4:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-03 8:53 [PATCH] media: renesas: rzv2h-ivc: stop interrupt before disabling clocks on suspend Yaohan Li
2026-12-03 9:19 ` Jacopo Mondi
2026-12-04 4:21 ` Yaohan Li
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®