* [PATCH] media: renesas: rzv2h-ivc: manage runtime PM with devres
@ 2026-08-04 14:11 Myeonghun Pak
2026-08-06 9:52 ` Jacopo Mondi
0 siblings, 1 reply; 2+ messages in thread
From: Myeonghun Pak @ 2026-08-04 14:11 UTC (permalink / raw)
To: Daniel Scally, Jacopo Mondi
Cc: Mauro Carvalho Chehab, Hans Verkuil, linux-media, linux-kernel
Runtime PM is enabled before the IRQ is looked up. If that lookup
fails, probe returns without disabling runtime PM. The subdevice
initialization error path disables runtime PM but leaves autosuspend
enabled, while the remove path does neither.
Use devm_pm_runtime_enable() so the driver core disables autosuspend and
runtime PM on every failed probe and after remove. This also makes the
manual subdevice error unwind unnecessary.
This issue was identified during our ongoing static-analysis research while
reviewing kernel code.
Fixes: f0b3984d821b ("media: platform: Add Renesas Input Video Control block driver")
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
.../media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
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 355842abb24b..48f9fd818bff 100644
--- a/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c
+++ b/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c
@@ -202,7 +202,9 @@ static int rzv2h_ivc_probe(struct platform_device *pdev)
pm_runtime_set_autosuspend_delay(dev, 2000);
pm_runtime_use_autosuspend(dev);
- pm_runtime_enable(dev);
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return ret;
ivc->irqnum = platform_get_irq(pdev, 0);
if (ivc->irqnum < 0)
@@ -210,14 +212,9 @@ static int rzv2h_ivc_probe(struct platform_device *pdev)
ret = rzv2h_ivc_initialise_subdevice(ivc);
if (ret)
- goto err_disable_pm_runtime;
+ return ret;
return 0;
-
-err_disable_pm_runtime:
- pm_runtime_disable(dev);
-
- return ret;
}
static void rzv2h_ivc_remove(struct platform_device *pdev)
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] media: renesas: rzv2h-ivc: manage runtime PM with devres
2026-08-04 14:11 [PATCH] media: renesas: rzv2h-ivc: manage runtime PM with devres Myeonghun Pak
@ 2026-08-06 9:52 ` Jacopo Mondi
0 siblings, 0 replies; 2+ messages in thread
From: Jacopo Mondi @ 2026-08-06 9:52 UTC (permalink / raw)
To: Myeonghun Pak
Cc: Daniel Scally, Jacopo Mondi, Mauro Carvalho Chehab, Hans Verkuil,
linux-media, linux-kernel
Hello Myeonghun
On Tue, Aug 04, 2026 at 11:11:04PM +0900, Myeonghun Pak wrote:
> Runtime PM is enabled before the IRQ is looked up. If that lookup
> fails, probe returns without disabling runtime PM. The subdevice
> initialization error path disables runtime PM but leaves autosuspend
> enabled, while the remove path does neither.
>
> Use devm_pm_runtime_enable() so the driver core disables autosuspend and
> runtime PM on every failed probe and after remove. This also makes the
> manual subdevice error unwind unnecessary.
>
> This issue was identified during our ongoing static-analysis research while
> reviewing kernel code.
>
> Fixes: f0b3984d821b ("media: platform: Add Renesas Input Video Control block driver")
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
> .../media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> 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 355842abb24b..48f9fd818bff 100644
> --- a/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c
> +++ b/drivers/media/platform/renesas/rzv2h-ivc/rzv2h-ivc-dev.c
> @@ -202,7 +202,9 @@ static int rzv2h_ivc_probe(struct platform_device *pdev)
>
> pm_runtime_set_autosuspend_delay(dev, 2000);
> pm_runtime_use_autosuspend(dev);
> - pm_runtime_enable(dev);
> + ret = devm_pm_runtime_enable(dev);
> + if (ret)
> + return ret;
>
> ivc->irqnum = platform_get_irq(pdev, 0);
> if (ivc->irqnum < 0)
> @@ -210,14 +212,9 @@ static int rzv2h_ivc_probe(struct platform_device *pdev)
>
> ret = rzv2h_ivc_initialise_subdevice(ivc);
> if (ret)
> - goto err_disable_pm_runtime;
> + return ret;
>
> return 0;
> -
> -err_disable_pm_runtime:
> - pm_runtime_disable(dev);
> -
> - return ret;
> }
>
> static void rzv2h_ivc_remove(struct platform_device *pdev)
The deveres managed version of pm_runtime_enable() calls
pm_runtime_dont_use_autosuspend(data);
pm_runtime_disable(data);
So this version is already better than what we have here.
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
We don't seem to forcefully suspend the device at remove time. The
device is only active during streaming and I don't think the driver can
be removed (or unbind) while it's actively streaming ?
> --
> 2.47.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-06 9:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-04 14:11 [PATCH] media: renesas: rzv2h-ivc: manage runtime PM with devres Myeonghun Pak
2026-08-06 9:52 ` Jacopo Mondi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox