All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: ti: Fix runtime PM imbalance on error
@ 2022-01-16 11:31 Yongzhi Liu
  2022-01-22  8:09 ` Péter Ujfalusi
  0 siblings, 1 reply; 3+ messages in thread
From: Yongzhi Liu @ 2022-01-16 11:31 UTC (permalink / raw)
  To: peter.ujfalusi, vkoul; +Cc: dmaengine, linux-kernel, Yongzhi Liu

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code, thus a matching decrement is needed on
the error handling path to keep the counter balanced.

Signed-off-by: Yongzhi Liu <lyz_cs@pku.edu.cn>
---
 drivers/dma/ti/edma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c
index 08e47f4..a73f779 100644
--- a/drivers/dma/ti/edma.c
+++ b/drivers/dma/ti/edma.c
@@ -2398,9 +2398,9 @@ static int edma_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, ecc);
 
 	pm_runtime_enable(dev);
-	ret = pm_runtime_get_sync(dev);
+	ret = pm_runtime_resume_and_get(dev);
 	if (ret < 0) {
-		dev_err(dev, "pm_runtime_get_sync() failed\n");
+		dev_err(dev, "pm_runtime_resume_and_get() failed\n");
 		pm_runtime_disable(dev);
 		return ret;
 	}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: ti: Fix runtime PM imbalance on error
  2022-01-16 11:31 [PATCH] dmaengine: ti: Fix runtime PM imbalance on error Yongzhi Liu
@ 2022-01-22  8:09 ` Péter Ujfalusi
  2022-01-22  8:47   ` 刘永志
  0 siblings, 1 reply; 3+ messages in thread
From: Péter Ujfalusi @ 2022-01-22  8:09 UTC (permalink / raw)
  To: Yongzhi Liu, vkoul; +Cc: dmaengine, linux-kernel



On 1/16/22 13:31, Yongzhi Liu wrote:
> pm_runtime_get_sync() increments the runtime PM usage counter even
> when it returns an error code, thus a matching decrement is needed on
> the error handling path to keep the counter balanced.

The patch is correct, however the commit message is a bit incorrect.

We are not adding any visible matching decrement, we are switching to
pm_runtime_resume_and_get() which only increments the usage counter if
pm_runtime_resume() is successful.
Granted internally it does a pm_runtime_put_noidle() if resume call fails.

Switch to pm_runtime_resume_and_get() to keep the device's use caunt
balanced?

> 
> Signed-off-by: Yongzhi Liu <lyz_cs@pku.edu.cn>
> ---
>  drivers/dma/ti/edma.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c
> index 08e47f4..a73f779 100644
> --- a/drivers/dma/ti/edma.c
> +++ b/drivers/dma/ti/edma.c
> @@ -2398,9 +2398,9 @@ static int edma_probe(struct platform_device *pdev)
>  	platform_set_drvdata(pdev, ecc);
>  
>  	pm_runtime_enable(dev);
> -	ret = pm_runtime_get_sync(dev);
> +	ret = pm_runtime_resume_and_get(dev);
>  	if (ret < 0) {
> -		dev_err(dev, "pm_runtime_get_sync() failed\n");
> +		dev_err(dev, "pm_runtime_resume_and_get() failed\n");
>  		pm_runtime_disable(dev);
>  		return ret;
>  	}

-- 
Péter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dmaengine: ti: Fix runtime PM imbalance on error
  2022-01-22  8:09 ` Péter Ujfalusi
@ 2022-01-22  8:47   ` 刘永志
  0 siblings, 0 replies; 3+ messages in thread
From: 刘永志 @ 2022-01-22  8:47 UTC (permalink / raw)
  To: péter ujfalusi; +Cc: vkoul, dmaengine, linux-kernel

> -----原始邮件-----
> 发件人: "Péter Ujfalusi" <peter.ujfalusi@gmail.com>
> 发送时间: 2022-01-22 16:09:53 (星期六)
> 收件人: "Yongzhi Liu" <lyz_cs@pku.edu.cn>, vkoul@kernel.org
> 抄送: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
> 主题: Re: [PATCH] dmaengine: ti: Fix runtime PM imbalance on error
> 
> 
> 
> On 1/16/22 13:31, Yongzhi Liu wrote:
> > pm_runtime_get_sync() increments the runtime PM usage counter even
> > when it returns an error code, thus a matching decrement is needed on
> > the error handling path to keep the counter balanced.
> 
> The patch is correct, however the commit message is a bit incorrect.
> 
> We are not adding any visible matching decrement, we are switching to
> pm_runtime_resume_and_get() which only increments the usage counter if
> pm_runtime_resume() is successful.
> Granted internally it does a pm_runtime_put_noidle() if resume call fails.
> 
> Switch to pm_runtime_resume_and_get() to keep the device's use caunt
> balanced?
> 

Thanks for your reply. I agree with your change and rewrite the commit message as follows.

[why]
pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code, however pm_runtime_resume_and_get() 
only increments the usage counter if pm_runtime_resume() is successful,
which granted internally does a pm_runtime_put_noidle() if resume call fails.

[how]
Fix this by switching to pm_runtime_resume_and_get() to keep the device's use count
balanced.


> > 
> > Signed-off-by: Yongzhi Liu <lyz_cs@pku.edu.cn>
> > ---
> >  drivers/dma/ti/edma.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c
> > index 08e47f4..a73f779 100644
> > --- a/drivers/dma/ti/edma.c
> > +++ b/drivers/dma/ti/edma.c
> > @@ -2398,9 +2398,9 @@ static int edma_probe(struct platform_device *pdev)
> >  	platform_set_drvdata(pdev, ecc);
> >  
> >  	pm_runtime_enable(dev);
> > -	ret = pm_runtime_get_sync(dev);
> > +	ret = pm_runtime_resume_and_get(dev);
> >  	if (ret < 0) {
> > -		dev_err(dev, "pm_runtime_get_sync() failed\n");
> > +		dev_err(dev, "pm_runtime_resume_and_get() failed\n");
> >  		pm_runtime_disable(dev);
> >  		return ret;
> >  	}
> 
> -- 
> Péter

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-22  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-16 11:31 [PATCH] dmaengine: ti: Fix runtime PM imbalance on error Yongzhi Liu
2022-01-22  8:09 ` Péter Ujfalusi
2022-01-22  8:47   ` 刘永志

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.