linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/3] Fix PM usage counter imblance and clear code
@ 2021-06-07  6:46 Zhang Qilong
  2021-06-07  6:46 ` [PATCH -next 1/3] dmaengine: stm32-dma: Fix PM usage counter imbalance in stm32 dma ops Zhang Qilong
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Zhang Qilong @ 2021-06-07  6:46 UTC (permalink / raw)
  To: vkoul, mcoquelin.stm32, alexandre.torgue, pierre-yves.mordret
  Cc: amelie.delaunay, dmaengine, linux-stm32, linux-arm-kernel

The first two patches fix PM disable depth imbalance and
the last clear pm_runtime_get_sync calls.

Zhang Qilong (3):
  dmaengine: stm32-dma: Fix PM usage counter imbalance in stm32 dma ops
  dmaengine: stm32-dmamux: Fix PM usage counter unbalance in stm32
    dmamux ops
  dmaengine: tegra210-adma: Using pm_runtime_resume_and_get to replace
    open coding

 drivers/dma/stm32-dma.c     | 4 ++--
 drivers/dma/stm32-dmamux.c  | 6 +++---
 drivers/dma/tegra210-adma.c | 7 ++-----
 3 files changed, 7 insertions(+), 10 deletions(-)

-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH -next 1/3] dmaengine: stm32-dma: Fix PM usage counter imbalance in stm32 dma ops
  2021-06-07  6:46 [PATCH -next 0/3] Fix PM usage counter imblance and clear code Zhang Qilong
@ 2021-06-07  6:46 ` Zhang Qilong
  2021-06-07  6:46 ` [PATCH -next 2/3] dmaengine: stm32-dmamux: Fix PM usage counter unbalance in stm32 dmamux ops Zhang Qilong
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Zhang Qilong @ 2021-06-07  6:46 UTC (permalink / raw)
  To: vkoul, mcoquelin.stm32, alexandre.torgue, pierre-yves.mordret
  Cc: amelie.delaunay, dmaengine, linux-stm32, linux-arm-kernel

pm_runtime_get_sync will increment pm usage counter
even it failed. Forgetting to putting operation will
result in reference leak here. We fix it by replacing
it with pm_runtime_resume_and_get to keep usage counter
balanced.

Fixes: 48bc73ba14bcd ("dmaengine: stm32-dma: Add PM Runtime support")
Fixes: 05f8740a0e6fc ("dmaengine: stm32-dma: add suspend/resume power management support")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/dma/stm32-dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index f54ecb123a52..7dd1d3d0bf06 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -1200,7 +1200,7 @@ static int stm32_dma_alloc_chan_resources(struct dma_chan *c)
 
 	chan->config_init = false;
 
-	ret = pm_runtime_get_sync(dmadev->ddev.dev);
+	ret = pm_runtime_resume_and_get(dmadev->ddev.dev);
 	if (ret < 0)
 		return ret;
 
@@ -1470,7 +1470,7 @@ static int stm32_dma_suspend(struct device *dev)
 	struct stm32_dma_device *dmadev = dev_get_drvdata(dev);
 	int id, ret, scr;
 
-	ret = pm_runtime_get_sync(dev);
+	ret = pm_runtime_resume_and_get(dev);
 	if (ret < 0)
 		return ret;
 
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH -next 2/3] dmaengine: stm32-dmamux: Fix PM usage counter unbalance in stm32 dmamux ops
  2021-06-07  6:46 [PATCH -next 0/3] Fix PM usage counter imblance and clear code Zhang Qilong
  2021-06-07  6:46 ` [PATCH -next 1/3] dmaengine: stm32-dma: Fix PM usage counter imbalance in stm32 dma ops Zhang Qilong
@ 2021-06-07  6:46 ` Zhang Qilong
  2021-06-07  6:46 ` [PATCH -next 3/3] dmaengine: tegra210-adma: Using pm_runtime_resume_and_get to replace open coding Zhang Qilong
  2021-07-28  6:34 ` [PATCH -next 0/3] Fix PM usage counter imblance and clear code Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Zhang Qilong @ 2021-06-07  6:46 UTC (permalink / raw)
  To: vkoul, mcoquelin.stm32, alexandre.torgue, pierre-yves.mordret
  Cc: amelie.delaunay, dmaengine, linux-stm32, linux-arm-kernel

pm_runtime_get_sync will increment pm usage counter
even it failed. Forgetting to putting operation will
result in reference leak here. We fix it by replacing
it with pm_runtime_resume_and_get to keep usage counter
balanced.

Fixes: 4f3ceca254e0f ("dmaengine: stm32-dmamux: Add PM Runtime support")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/dma/stm32-dmamux.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c
index ef0d0555103d..a42164389ebc 100644
--- a/drivers/dma/stm32-dmamux.c
+++ b/drivers/dma/stm32-dmamux.c
@@ -137,7 +137,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
 
 	/* Set dma request */
 	spin_lock_irqsave(&dmamux->lock, flags);
-	ret = pm_runtime_get_sync(&pdev->dev);
+	ret = pm_runtime_resume_and_get(&pdev->dev);
 	if (ret < 0) {
 		spin_unlock_irqrestore(&dmamux->lock, flags);
 		goto error;
@@ -336,7 +336,7 @@ static int stm32_dmamux_suspend(struct device *dev)
 	struct stm32_dmamux_data *stm32_dmamux = platform_get_drvdata(pdev);
 	int i, ret;
 
-	ret = pm_runtime_get_sync(dev);
+	ret = pm_runtime_resume_and_get(dev);
 	if (ret < 0)
 		return ret;
 
@@ -361,7 +361,7 @@ static int stm32_dmamux_resume(struct device *dev)
 	if (ret < 0)
 		return ret;
 
-	ret = pm_runtime_get_sync(dev);
+	ret = pm_runtime_resume_and_get(dev);
 	if (ret < 0)
 		return ret;
 
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH -next 3/3] dmaengine: tegra210-adma: Using pm_runtime_resume_and_get to replace open coding
  2021-06-07  6:46 [PATCH -next 0/3] Fix PM usage counter imblance and clear code Zhang Qilong
  2021-06-07  6:46 ` [PATCH -next 1/3] dmaengine: stm32-dma: Fix PM usage counter imbalance in stm32 dma ops Zhang Qilong
  2021-06-07  6:46 ` [PATCH -next 2/3] dmaengine: stm32-dmamux: Fix PM usage counter unbalance in stm32 dmamux ops Zhang Qilong
@ 2021-06-07  6:46 ` Zhang Qilong
  2021-07-28  6:34 ` [PATCH -next 0/3] Fix PM usage counter imblance and clear code Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Zhang Qilong @ 2021-06-07  6:46 UTC (permalink / raw)
  To: vkoul, mcoquelin.stm32, alexandre.torgue, pierre-yves.mordret
  Cc: amelie.delaunay, dmaengine, linux-stm32, linux-arm-kernel

use pm_runtime_resume_and_get() to replace pm_runtime_get_sync and
pm_runtime_put_noidle. this change is just to simplify the code,
there is no actual functional change.

Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
---
 drivers/dma/tegra210-adma.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
index 4735742e826d..b1115a6d1935 100644
--- a/drivers/dma/tegra210-adma.c
+++ b/drivers/dma/tegra210-adma.c
@@ -655,9 +655,8 @@ static int tegra_adma_alloc_chan_resources(struct dma_chan *dc)
 		return ret;
 	}
 
-	ret = pm_runtime_get_sync(tdc2dev(tdc));
+	ret = pm_runtime_resume_and_get(tdc2dev(tdc));
 	if (ret < 0) {
-		pm_runtime_put_noidle(tdc2dev(tdc));
 		free_irq(tdc->irq, tdc);
 		return ret;
 	}
@@ -869,10 +868,8 @@ static int tegra_adma_probe(struct platform_device *pdev)
 	pm_runtime_enable(&pdev->dev);
 
 	ret = pm_runtime_get_sync(&pdev->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(&pdev->dev);
+	if (ret < 0)
 		goto rpm_disable;
-	}
 
 	ret = tegra_adma_init(tdma);
 	if (ret)
-- 
2.31.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH -next 0/3] Fix PM usage counter imblance and clear code
  2021-06-07  6:46 [PATCH -next 0/3] Fix PM usage counter imblance and clear code Zhang Qilong
                   ` (2 preceding siblings ...)
  2021-06-07  6:46 ` [PATCH -next 3/3] dmaengine: tegra210-adma: Using pm_runtime_resume_and_get to replace open coding Zhang Qilong
@ 2021-07-28  6:34 ` Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2021-07-28  6:34 UTC (permalink / raw)
  To: Zhang Qilong
  Cc: mcoquelin.stm32, alexandre.torgue, pierre-yves.mordret,
	amelie.delaunay, dmaengine, linux-stm32, linux-arm-kernel

On 07-06-21, 14:46, Zhang Qilong wrote:
> The first two patches fix PM disable depth imbalance and
> the last clear pm_runtime_get_sync calls.

Applied, thanks

-- 
~Vinod

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-07-28  6:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07  6:46 [PATCH -next 0/3] Fix PM usage counter imblance and clear code Zhang Qilong
2021-06-07  6:46 ` [PATCH -next 1/3] dmaengine: stm32-dma: Fix PM usage counter imbalance in stm32 dma ops Zhang Qilong
2021-06-07  6:46 ` [PATCH -next 2/3] dmaengine: stm32-dmamux: Fix PM usage counter unbalance in stm32 dmamux ops Zhang Qilong
2021-06-07  6:46 ` [PATCH -next 3/3] dmaengine: tegra210-adma: Using pm_runtime_resume_and_get to replace open coding Zhang Qilong
2021-07-28  6:34 ` [PATCH -next 0/3] Fix PM usage counter imblance and clear code Vinod Koul

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