[PATCH] media: renesas: rzv2h-ivc: stop interrupt before disabling clocks on suspend
From: Yaohan Li
Date: Thu Dec 03 2026 - 03:53:29 EST
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@xxxxxxxxxxxxxxx
Signed-off-by: Yaohan Li <shunsheng1218@xxxxxxxxx>
---
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