* [PATCH] engine: stm32-dma: call pm_runtime_put if pm_runtime_get_sync fails
@ 2020-06-03 18:34 Navid Emamdoost
2020-06-24 7:39 ` Vinod Koul
0 siblings, 1 reply; 3+ messages in thread
From: Navid Emamdoost @ 2020-06-03 18:34 UTC (permalink / raw)
To: Dan Williams, Vinod Koul, 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 if
pm_runtime_get_sync fails.
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
drivers/dma/stm32-dma.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 0ddbaa4b4f0b..0aab86bd97fe 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -1169,8 +1169,10 @@ static int stm32_dma_alloc_chan_resources(struct dma_chan *c)
chan->config_init = false;
ret = pm_runtime_get_sync(dmadev->ddev.dev);
- if (ret < 0)
+ if (ret < 0) {
+ pm_runtime_put(dmadev->ddev.dev);
return ret;
+ }
ret = stm32_dma_disable_chan(chan);
if (ret < 0)
@@ -1439,8 +1441,10 @@ static int stm32_dma_suspend(struct device *dev)
int id, ret, scr;
ret = pm_runtime_get_sync(dev);
- if (ret < 0)
+ if (ret < 0) {
+ pm_runtime_put_sync(dev);
return ret;
+ }
for (id = 0; id < STM32_DMA_MAX_CHANNELS; id++) {
scr = stm32_dma_read(dmadev, STM32_DMA_SCR(id));
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] engine: stm32-dma: call pm_runtime_put if pm_runtime_get_sync fails
2020-06-03 18:34 [PATCH] engine: stm32-dma: call pm_runtime_put if pm_runtime_get_sync fails Navid Emamdoost
@ 2020-06-24 7:39 ` Vinod Koul
2020-06-24 7:48 ` Navid Emamdoost
0 siblings, 1 reply; 3+ messages in thread
From: Vinod Koul @ 2020-06-24 7:39 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, 13:34, Navid Emamdoost wrote:
> Calling pm_runtime_get_sync increments the counter even in case of
> failure, causing incorrect ref count. Call pm_runtime_put if
> pm_runtime_get_sync fails.
pls fix subsystem name as dmaengine: ...
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> drivers/dma/stm32-dma.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
> index 0ddbaa4b4f0b..0aab86bd97fe 100644
> --- a/drivers/dma/stm32-dma.c
> +++ b/drivers/dma/stm32-dma.c
> @@ -1169,8 +1169,10 @@ static int stm32_dma_alloc_chan_resources(struct dma_chan *c)
> chan->config_init = false;
>
> ret = pm_runtime_get_sync(dmadev->ddev.dev);
> - if (ret < 0)
> + if (ret < 0) {
> + pm_runtime_put(dmadev->ddev.dev);
> return ret;
> + }
>
> ret = stm32_dma_disable_chan(chan);
> if (ret < 0)
> @@ -1439,8 +1441,10 @@ static int stm32_dma_suspend(struct device *dev)
> int id, ret, scr;
>
> ret = pm_runtime_get_sync(dev);
> - if (ret < 0)
> + if (ret < 0) {
> + pm_runtime_put_sync(dev);
why put_sync()
> return ret;
> + }
>
> for (id = 0; id < STM32_DMA_MAX_CHANNELS; id++) {
> scr = stm32_dma_read(dmadev, STM32_DMA_SCR(id));
> --
> 2.17.1
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] engine: stm32-dma: call pm_runtime_put if pm_runtime_get_sync fails
2020-06-24 7:39 ` Vinod Koul
@ 2020-06-24 7:48 ` Navid Emamdoost
0 siblings, 0 replies; 3+ messages in thread
From: Navid Emamdoost @ 2020-06-24 7:48 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
Hi,
On Wed, Jun 24, 2020 at 2:39 AM Vinod Koul <vkoul@kernel.org> wrote:
>
> On 03-06-20, 13:34, Navid Emamdoost wrote:
> > Calling pm_runtime_get_sync increments the counter even in case of
> > failure, causing incorrect ref count. Call pm_runtime_put if
> > pm_runtime_get_sync fails.
>
> pls fix subsystem name as dmaengine: ...
> >
> > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> > ---
> > drivers/dma/stm32-dma.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
> > index 0ddbaa4b4f0b..0aab86bd97fe 100644
> > --- a/drivers/dma/stm32-dma.c
> > +++ b/drivers/dma/stm32-dma.c
> > @@ -1169,8 +1169,10 @@ static int stm32_dma_alloc_chan_resources(struct dma_chan *c)
> > chan->config_init = false;
> >
> > ret = pm_runtime_get_sync(dmadev->ddev.dev);
> > - if (ret < 0)
> > + if (ret < 0) {
> > + pm_runtime_put(dmadev->ddev.dev);
> > return ret;
> > + }
> >
> > ret = stm32_dma_disable_chan(chan);
> > if (ret < 0)
> > @@ -1439,8 +1441,10 @@ static int stm32_dma_suspend(struct device *dev)
> > int id, ret, scr;
> >
> > ret = pm_runtime_get_sync(dev);
> > - if (ret < 0)
> > + if (ret < 0) {
> > + pm_runtime_put_sync(dev);
>
> why put_sync()
My bad! I will fix it.
> > return ret;
> > + }
> >
> > for (id = 0; id < STM32_DMA_MAX_CHANNELS; id++) {
> > scr = stm32_dma_read(dmadev, STM32_DMA_SCR(id));
> > --
> > 2.17.1
>
> --
> ~Vinod
--
Navid.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-24 7:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 18:34 [PATCH] engine: stm32-dma: call pm_runtime_put if pm_runtime_get_sync fails Navid Emamdoost
2020-06-24 7:39 ` Vinod Koul
2020-06-24 7:48 ` 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).