* [PATCH] dmaengine: stm32-dmamux: fix pm_runtime_get_sync fialure cases
@ 2020-06-03 19:36 Navid Emamdoost
2020-06-24 7:40 ` Vinod Koul
0 siblings, 1 reply; 3+ messages in thread
From: Navid Emamdoost @ 2020-06-03 19:36 UTC (permalink / raw)
To: Vinod Koul, Dan Williams, Maxime Coquelin, Alexandre Torgue,
dmaengine, linux-stm32, linux-arm-kernel, linux-kernel
Cc: emamd001, wu000273, kjlu, smccaman, Navid Emamdoost
Calling pm_runtime_get_sync increments the counter even in case of
failure, causing incorrect ref count. Call pm_runtime_put_sync if
pm_runtime_get_sync fails.
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
drivers/dma/stm32-dmamux.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c
index 12f7637e13a1..ab250d7eed29 100644
--- a/drivers/dma/stm32-dmamux.c
+++ b/drivers/dma/stm32-dmamux.c
@@ -140,6 +140,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
ret = pm_runtime_get_sync(&pdev->dev);
if (ret < 0) {
spin_unlock_irqrestore(&dmamux->lock, flags);
+ pm_runtime_put_sync(&pdev->dev);
goto error;
}
spin_unlock_irqrestore(&dmamux->lock, flags);
@@ -340,8 +341,10 @@ static int stm32_dmamux_suspend(struct device *dev)
int i, ret;
ret = pm_runtime_get_sync(dev);
- if (ret < 0)
+ if (ret < 0) {
+ pm_runtime_put_sync(dev);
return ret;
+ }
for (i = 0; i < stm32_dmamux->dma_requests; i++)
stm32_dmamux->ccr[i] = stm32_dmamux_read(stm32_dmamux->iomem,
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: stm32-dmamux: fix pm_runtime_get_sync fialure cases
2020-06-03 19:36 [PATCH] dmaengine: stm32-dmamux: fix pm_runtime_get_sync fialure cases Navid Emamdoost
@ 2020-06-24 7:40 ` Vinod Koul
2020-06-24 7:56 ` Navid Emamdoost
0 siblings, 1 reply; 3+ messages in thread
From: Vinod Koul @ 2020-06-24 7:40 UTC (permalink / raw)
To: Navid Emamdoost
Cc: Dan Williams, Maxime Coquelin, Alexandre Torgue, dmaengine,
linux-stm32, linux-arm-kernel, linux-kernel, emamd001, wu000273,
kjlu, smccaman
On 03-06-20, 14:36, Navid Emamdoost wrote:
s/fialure/failure
> Calling pm_runtime_get_sync increments the counter even in case of
> failure, causing incorrect ref count. Call pm_runtime_put_sync if
> pm_runtime_get_sync fails.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> drivers/dma/stm32-dmamux.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c
> index 12f7637e13a1..ab250d7eed29 100644
> --- a/drivers/dma/stm32-dmamux.c
> +++ b/drivers/dma/stm32-dmamux.c
> @@ -140,6 +140,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
> ret = pm_runtime_get_sync(&pdev->dev);
> if (ret < 0) {
> spin_unlock_irqrestore(&dmamux->lock, flags);
> + pm_runtime_put_sync(&pdev->dev);
why put_sync()
> goto error;
> }
> spin_unlock_irqrestore(&dmamux->lock, flags);
> @@ -340,8 +341,10 @@ static int stm32_dmamux_suspend(struct device *dev)
> int i, ret;
>
> ret = pm_runtime_get_sync(dev);
> - if (ret < 0)
> + if (ret < 0) {
> + pm_runtime_put_sync(dev);
here too
> return ret;
> + }
>
> for (i = 0; i < stm32_dmamux->dma_requests; i++)
> stm32_dmamux->ccr[i] = stm32_dmamux_read(stm32_dmamux->iomem,
> --
> 2.17.1
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dmaengine: stm32-dmamux: fix pm_runtime_get_sync fialure cases
2020-06-24 7:40 ` Vinod Koul
@ 2020-06-24 7:56 ` Navid Emamdoost
0 siblings, 0 replies; 3+ messages in thread
From: Navid Emamdoost @ 2020-06-24 7:56 UTC (permalink / raw)
To: Vinod Koul
Cc: Dan Williams, Maxime Coquelin, Alexandre Torgue, dmaengine,
linux-stm32, linux-arm-kernel, LKML, Navid Emamdoost, Qiushi Wu,
Kangjie Lu, Stephen McCamant
On Wed, Jun 24, 2020 at 2:40 AM Vinod Koul <vkoul@kernel.org> wrote:
>
> On 03-06-20, 14:36, Navid Emamdoost wrote:
>
> s/fialure/failure
>
> > Calling pm_runtime_get_sync increments the counter even in case of
> > failure, causing incorrect ref count. Call pm_runtime_put_sync if
> > pm_runtime_get_sync fails.
> >
> > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> > ---
> > drivers/dma/stm32-dmamux.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c
> > index 12f7637e13a1..ab250d7eed29 100644
> > --- a/drivers/dma/stm32-dmamux.c
> > +++ b/drivers/dma/stm32-dmamux.c
> > @@ -140,6 +140,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
> > ret = pm_runtime_get_sync(&pdev->dev);
> > if (ret < 0) {
> > spin_unlock_irqrestore(&dmamux->lock, flags);
> > + pm_runtime_put_sync(&pdev->dev);
>
> why put_sync()
>
> > goto error;
> > }
> > spin_unlock_irqrestore(&dmamux->lock, flags);
> > @@ -340,8 +341,10 @@ static int stm32_dmamux_suspend(struct device *dev)
> > int i, ret;
> >
> > ret = pm_runtime_get_sync(dev);
> > - if (ret < 0)
> > + if (ret < 0) {
> > + pm_runtime_put_sync(dev);
>
> here too
Is put_noidle() better?
>
> > return ret;
> > + }
> >
> > for (i = 0; i < stm32_dmamux->dma_requests; i++)
> > stm32_dmamux->ccr[i] = stm32_dmamux_read(stm32_dmamux->iomem,
> > --
> > 2.17.1
>
> --
> ~Vinod
--
Navid.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-24 7:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 19:36 [PATCH] dmaengine: stm32-dmamux: fix pm_runtime_get_sync fialure cases Navid Emamdoost
2020-06-24 7:40 ` Vinod Koul
2020-06-24 7:56 ` Navid Emamdoost
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).