mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mikko Perttunen <mperttunen@nvidia.com>
To: "Thierry Reding" <thierry.reding@kernel.org>,
	"Uwe Kleine-König" <ukleinek@kernel.org>,
	"Jonathan Hunter" <jonathanh@nvidia.com>,
	"Myeonghun Pak" <mhun512@gmail.com>
Cc: Dmitry Osipenko <digetx@gmail.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	linux-pwm@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Ijae Kim <ae878000@gmail.com>
Subject: Re: [PATCH] pwm: tegra: Disable runtime PM on cleanup errors
Date: Mon, 14 Sep 2026 15:20:51 +0900	[thread overview]
Message-ID: <RjVH6lTrT_KugcUQV9puWA@nvidia.com> (raw)
In-Reply-To: <20260913040606.23272-1-mhun512@gmail.com>

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@vger.kernel.org
> Assisted-by: OpenAI:GPT-5.6
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
>  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




  reply	other threads:[~2026-09-14  6:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-13  4:06 Myeonghun Pak
2026-09-14  6:20 ` Mikko Perttunen [this message]
2026-09-14 22:32   ` Myeonghun Pak

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=RjVH6lTrT_KugcUQV9puWA@nvidia.com \
    --to=mperttunen@nvidia.com \
    --cc=ae878000@gmail.com \
    --cc=digetx@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mhun512@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=thierry.reding@kernel.org \
    --cc=ukleinek@kernel.org \
    --cc=ulf.hansson@linaro.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

all inboxes | Powered by JetHome®