Re: [PATCH] pwm: tegra: Disable runtime PM on cleanup errors
From: Mikko Perttunen
Date: Mon Sep 14 2026 - 02:21:09 EST
On Sunday, September 13, 2026 1:06 PM Myeonghun Pak wrote:
> tegra_pwm_probe() enables runtime PM before requesting the initial resume.
> If pm_runtime_resume_and_get() fails, probe returns with runtime PM still
> enabled as the managed driver resources are released.
>
> The later probe unwind and remove paths use pm_runtime_force_suspend(),
> which disables runtime PM on success but enables it again if the suspend
> callback fails. Ignoring that error can therefore also leave runtime PM
> enabled during resource cleanup.
>
> Disable runtime PM on the initial resume failure and when force-suspend
> fails. Do not disable it a second time after successful force-suspend, and
> preserve the original probe error. The failed resume_and_get call has
> already balanced its usage count, so it needs no additional put.
>
> This issue was identified during our ongoing static-analysis research while
> reviewing kernel code.
>
> Fixes: 3da9b0feaa16 ("pwm: tegra: Add runtime PM and OPP support")
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: OpenAI:GPT-5.6
> Co-developed-by: Ijae Kim <ae878000@xxxxxxxxx>
> Signed-off-by: Ijae Kim <ae878000@xxxxxxxxx>
> Signed-off-by: Myeonghun Pak <mhun512@xxxxxxxxx>
> ---
> drivers/pwm/pwm-tegra.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
> index 5cdbe120b..55287afcb 100644
> --- a/drivers/pwm/pwm-tegra.c
> +++ b/drivers/pwm/pwm-tegra.c
> @@ -346,8 +346,10 @@ static int tegra_pwm_probe(struct platform_device *pdev)
>
> pm_runtime_enable(&pdev->dev);
> ret = pm_runtime_resume_and_get(&pdev->dev);
> - if (ret)
> + if (ret) {
> + pm_runtime_disable(&pdev->dev);
> return ret;
> + }
>
> /* Set maximum frequency of the IP */
> ret = dev_pm_opp_set_rate(&pdev->dev, ULONG_MAX);
> @@ -395,7 +397,8 @@ static int tegra_pwm_probe(struct platform_device *pdev)
> return 0;
> put_pm:
> pm_runtime_put_sync_suspend(&pdev->dev);
> - pm_runtime_force_suspend(&pdev->dev);
> + if (pm_runtime_force_suspend(&pdev->dev))
> + pm_runtime_disable(&pdev->dev);
> return ret;
> }
>
> @@ -408,7 +411,8 @@ static void tegra_pwm_remove(struct platform_device *pdev)
>
> reset_control_assert(pc->rst);
>
> - pm_runtime_force_suspend(&pdev->dev);
> + if (pm_runtime_force_suspend(&pdev->dev))
> + pm_runtime_disable(&pdev->dev);
> }
>
> static int __maybe_unused tegra_pwm_runtime_suspend(struct device *dev)
>
This driver seems to be good candidate for devm_pm_runtime_enable. Using
that, I think we can avoid any calls to pm_runtime_disable or
pm_runtime_force_suspend.
Thanks
Mikko