linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: sprd: move pm_runtime_disable to err_rpm
@ 2021-12-06 11:34 Dongliang Mu
  2021-12-07  1:39 ` Baolin Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Dongliang Mu @ 2021-12-06 11:34 UTC (permalink / raw)
  To: Vinod Koul, Orson Zhai, Baolin Wang, Chunyan Zhang
  Cc: Dongliang Mu, Baolin Wang, dmaengine, linux-kernel

When pm_runtime_get_sync fails, it forgets to invoke pm_runtime_disable
in the label err_rpm.

Fix this by moving pm_runtime_disable to label err_rpm.

Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
 drivers/dma/sprd-dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index 4357d2395e6b..ae8b2cfebfee 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -1226,8 +1226,8 @@ static int sprd_dma_probe(struct platform_device *pdev)
 	dma_async_device_unregister(&sdev->dma_dev);
 err_register:
 	pm_runtime_put_noidle(&pdev->dev);
-	pm_runtime_disable(&pdev->dev);
 err_rpm:
+	pm_runtime_disable(&pdev->dev);
 	sprd_dma_disable(sdev);
 	return ret;
 }
-- 
2.25.1


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

* Re: [PATCH] dmaengine: sprd: move pm_runtime_disable to err_rpm
  2021-12-06 11:34 [PATCH] dmaengine: sprd: move pm_runtime_disable to err_rpm Dongliang Mu
@ 2021-12-07  1:39 ` Baolin Wang
  2021-12-07  2:06   ` Dongliang Mu
  0 siblings, 1 reply; 3+ messages in thread
From: Baolin Wang @ 2021-12-07  1:39 UTC (permalink / raw)
  To: Dongliang Mu
  Cc: Vinod Koul, Orson Zhai, Chunyan Zhang, Baolin Wang, dmaengine, LKML

Hi Dongliang,

On Mon, Dec 6, 2021 at 7:34 PM Dongliang Mu <mudongliangabcd@gmail.com> wrote:
>
> When pm_runtime_get_sync fails, it forgets to invoke pm_runtime_disable
> in the label err_rpm.
>
> Fix this by moving pm_runtime_disable to label err_rpm.
>
> Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> ---

Thanks for your patch, but looking at the code in detail, I think we
also should decrease the rpm counter when failing to call the
pm_runtime_get_sync().

--- 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;
 }

-- 
Baolin Wang

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

* Re: [PATCH] dmaengine: sprd: move pm_runtime_disable to err_rpm
  2021-12-07  1:39 ` Baolin Wang
@ 2021-12-07  2:06   ` Dongliang Mu
  0 siblings, 0 replies; 3+ messages in thread
From: Dongliang Mu @ 2021-12-07  2:06 UTC (permalink / raw)
  To: Baolin Wang
  Cc: Vinod Koul, Orson Zhai, Chunyan Zhang, Baolin Wang, dmaengine, LKML

On Tue, Dec 7, 2021 at 9:38 AM Baolin Wang <baolin.wang7@gmail.com> wrote:
>
> Hi Dongliang,
>
> On Mon, Dec 6, 2021 at 7:34 PM Dongliang Mu <mudongliangabcd@gmail.com> wrote:
> >
> > When pm_runtime_get_sync fails, it forgets to invoke pm_runtime_disable
> > in the label err_rpm.
> >
> > Fix this by moving pm_runtime_disable to label err_rpm.
> >
> > Fixes: 9b3b8171f7f4 ("dmaengine: sprd: Add Spreadtrum DMA driver")
> > Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> > ---
>
> Thanks for your patch, but looking at the code in detail, I think we
> also should decrease the rpm counter when failing to call the
> pm_runtime_get_sync().

Thanks for your reply. There are many different pm_runtime_* API.
After I double check the usage of pm_runtime_get_sync, there are two
kinds of error handling code:

1. When pm_runtime_get_sync fails, call pm_runtime_put_sync and
pm_runtime_disable [1]

2. When pm_runtime_get_sync fails, only call pm_runtime_disable [2]

[1] https://elixir.bootlin.com/linux/latest/source/drivers/dma/ti/edma.c#L2402
[2] https://elixir.bootlin.com/linux/latest/source/drivers/dma/ti/cppi41.c#L1098

BTW, is there any standard error handling code of pm runtime API? Or
the majority wins?

>
> --- 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;
>  }
>
> --
> Baolin Wang

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

end of thread, other threads:[~2021-12-07  2:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06 11:34 [PATCH] dmaengine: sprd: move pm_runtime_disable to err_rpm Dongliang Mu
2021-12-07  1:39 ` Baolin Wang
2021-12-07  2:06   ` Dongliang Mu

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).