Skip to contentSkip to conversation

dmaengine: stm32-dmamux: fix pm_runtime_get_sync fialure cases

PATCH In review Navid Emamdoost 2 participants 3 messages Jun 3, 2020 – Jun 24, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: stm32-dmamux: fix pm_runtime_get_sync fialure cases

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.

---
 drivers/dma/stm32-dmamux.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/stm32-dmamux.c +4 -1
index 12f7637e13a1..ab250d7eed29 100644
@@ -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,
Signature · 1 line
2.17.1
maintainer
#1 lore raw

On 03-06-20, 14:36, Navid Emamdoost wrote:

s/fialure/failure

Quoted 14 lines

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.

---
 drivers/dma/stm32-dmamux.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/stm32-dmamux.c +0 -0
index 12f7637e13a1..ab250d7eed29 100644

drivers/dma/stm32-dmamux.c static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, · line 143

Quoted 4 lines
drivers/dma/stm32-dmamux.c +1 -0
@@ -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()

drivers/dma/stm32-dmamux.c static int stm32_dmamux_suspend(struct device *dev) · line 345

Quoted 10 lines
drivers/dma/stm32-dmamux.c +2 -1
 		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

Quoted 7 lines
drivers/dma/stm32-dmamux.c +1 -0
 		return ret;
+	}
 
 	for (i = 0; i < stm32_dmamux->dma_requests; i++)
 		stm32_dmamux->ccr[i] = stm32_dmamux_read(stm32_dmamux->iomem,
Signature · 1 line
2.17.1
Signature · 1 line
~Vinod
#2 lore raw
Quoted 32 lines · Vinod Koul

On 03-06-20, 14:36, Navid Emamdoost wrote:

s/fialure/failure

Quoted 14 lines

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.

---
 drivers/dma/stm32-dmamux.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/stm32-dmamux.c +0 -0
index 12f7637e13a1..ab250d7eed29 100644

drivers/dma/stm32-dmamux.c static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, · line 143

Quoted 4 lines
drivers/dma/stm32-dmamux.c +1 -0
@@ -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()

Quoted 6 lines
drivers/dma/stm32-dmamux.c +0 -0
              goto error;
      }
      spin_unlock_irqrestore(&dmamux->lock, flags);
@@ -340,8 +341,10 @@ static int stm32_dmamux_suspend(struct device *dev)
      int i, ret;
 
Quoted 6 lines

drivers/dma/stm32-dmamux.c static int stm32_dmamux_suspend(struct device *dev) · line 345

Quoted 4 lines
drivers/dma/stm32-dmamux.c +2 -1
      ret = pm_runtime_get_sync(dev);
-     if (ret < 0)
+     if (ret < 0) {
+             pm_runtime_put_sync(dev);

here too

Is put_noidle() better?

Quoted 11 lines
Quoted 8 lines
drivers/dma/stm32-dmamux.c +1 -1
              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

Signature · 1 line
Navid.