Skip to contentSkip to conversation

engine: stm32-dma: call pm_runtime_put if pm_runtime_get_sync fails

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 engine: stm32-dma: call pm_runtime_put if pm_runtime_get_sync fails

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.

---
 drivers/dma/stm32-dma.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/dma/stm32-dma.c +6 -2
index 0ddbaa4b4f0b..0aab86bd97fe 100644
@@ -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));
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 3 lines · 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.

pls fix subsystem name as dmaengine: ...

Quoted 23 lines
---
 drivers/dma/stm32-dma.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/dma/stm32-dma.c +3 -1
index 0ddbaa4b4f0b..0aab86bd97fe 100644
@@ -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)

drivers/dma/stm32-dma.c static int stm32_dma_suspend(struct device *dev) · line 1445

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

Quoted 7 lines
drivers/dma/stm32-dma.c +1 -0
 		return ret;
+	}
 
 	for (id = 0; id < STM32_DMA_MAX_CHANNELS; id++) {
 		scr = stm32_dma_read(dmadev, STM32_DMA_SCR(id));
Signature · 1 line
2.17.1
Signature · 1 line
~Vinod
#2 lore raw

Hi,

Quoted 32 lines · Vinod Koul
Quoted 3 lines · 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.

pls fix subsystem name as dmaengine: ...

Quoted 25 lines
---
 drivers/dma/stm32-dma.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/dma/stm32-dma.c +3 -1
index 0ddbaa4b4f0b..0aab86bd97fe 100644
@@ -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;
 
Quoted 6 lines

drivers/dma/stm32-dma.c static int stm32_dma_suspend(struct device *dev) · line 1445

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

Quoted 10 lines
Quoted 7 lines
drivers/dma/stm32-dma.c +1 -1
              return ret;
+     }
 
      for (id = 0; id < STM32_DMA_MAX_CHANNELS; id++) {
              scr = stm32_dma_read(dmadev, STM32_DMA_SCR(id));
--

2.17.1

--
~Vinod

Signature · 1 line
Navid.