dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: sprd: Fix runtime PM imbalance on error
@ 2020-05-22  6:52 Dinghao Liu
  2020-05-22 12:33 ` Baolin Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Dinghao Liu @ 2020-05-22  6:52 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Dan Williams, Vinod Koul, Orson Zhai, Baolin Wang, Chunyan Zhang,
	dmaengine, linux-kernel

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

Also, call pm_runtime_disable() when pm_runtime_get_sync() returns
an error code.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/dma/sprd-dma.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index 0ef5ca81ba4d..275d83768d0d 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -1210,7 +1210,7 @@ static int sprd_dma_probe(struct platform_device *pdev)
 	ret = dma_async_device_register(&sdev->dma_dev);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "register dma device failed:%d\n", ret);
-		goto err_register;
+		goto err_rpm;
 	}
 
 	sprd_dma_info.dma_cap = sdev->dma_dev.cap_mask;
@@ -1224,10 +1224,9 @@ static int sprd_dma_probe(struct platform_device *pdev)
 
 err_of_register:
 	dma_async_device_unregister(&sdev->dma_dev);
-err_register:
+err_rpm:
 	pm_runtime_put_noidle(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-err_rpm:
 	sprd_dma_disable(sdev);
 	return ret;
 }
-- 
2.17.1


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

* Re: [PATCH] dmaengine: sprd: Fix runtime PM imbalance on error
  2020-05-22  6:52 [PATCH] dmaengine: sprd: Fix runtime PM imbalance on error Dinghao Liu
@ 2020-05-22 12:33 ` Baolin Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Baolin Wang @ 2020-05-22 12:33 UTC (permalink / raw)
  To: Dinghao Liu
  Cc: kjlu, Dan Williams, Vinod Koul, Orson Zhai, Chunyan Zhang,
	dmaengine, LKML

On Fri, May 22, 2020 at 2:53 PM Dinghao Liu <dinghao.liu@zju.edu.cn> wrote:
>
> pm_runtime_get_sync() increments the runtime PM usage counter even
> when it returns an error code. Thus a pairing decrement is needed on
> the error handling path to keep the counter balanced.
>
> Also, call pm_runtime_disable() when pm_runtime_get_sync() returns
> an error code.

Good catch. Thanks.
Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>

>
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>  drivers/dma/sprd-dma.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
> index 0ef5ca81ba4d..275d83768d0d 100644
> --- a/drivers/dma/sprd-dma.c
> +++ b/drivers/dma/sprd-dma.c
> @@ -1210,7 +1210,7 @@ static int sprd_dma_probe(struct platform_device *pdev)
>         ret = dma_async_device_register(&sdev->dma_dev);
>         if (ret < 0) {
>                 dev_err(&pdev->dev, "register dma device failed:%d\n", ret);
> -               goto err_register;
> +               goto err_rpm;
>         }
>
>         sprd_dma_info.dma_cap = sdev->dma_dev.cap_mask;
> @@ -1224,10 +1224,9 @@ static int sprd_dma_probe(struct platform_device *pdev)
>
>  err_of_register:
>         dma_async_device_unregister(&sdev->dma_dev);
> -err_register:
> +err_rpm:
>         pm_runtime_put_noidle(&pdev->dev);
>         pm_runtime_disable(&pdev->dev);
> -err_rpm:
>         sprd_dma_disable(sdev);
>         return ret;
>  }
> --
> 2.17.1
>


-- 
Baolin Wang

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

end of thread, other threads:[~2020-05-22 12:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22  6:52 [PATCH] dmaengine: sprd: Fix runtime PM imbalance on error Dinghao Liu
2020-05-22 12:33 ` Baolin Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).