Skip to contentSkip to conversation

dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend

PATCH Applied Xiangwu Lai 4 participants 5 messages Nov 2 – Nov 20

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

PATCH 1/1 dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend

stm32_mdma_pm_suspend() increments the runtime PM usage counter with pm_runtime_resume_and_get(), but when a channel is still enabled it returns -EBUSY directly without dropping the reference. The matching pm_runtime_put_sync() only runs on the success path.

Each failed suspend attempt therefore leaks one runtime PM reference, so the device can never runtime suspend afterwards. Drop the reference before returning -EBUSY.

Fixes 7cb819c856d9 ("dmaengine: stm32-mdma: add suspend/resume power management support")
---
 drivers/dma/stm32/stm32-mdma.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/stm32/stm32-mdma.c +1 -0
index e3bbdc9ee..fe1ff4a00 100644
@@ -1785,6 +1785,7 @@ static int stm32_mdma_pm_suspend(struct device *dev)
 		ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(id));
 		if (ccr & STM32_MDMA_CCR_EN) {
 			dev_warn(dev, "Suspend is prevented by Chan %i\n", id);
+			pm_runtime_put_sync(dev);
 			return -EBUSY;
 		}
 	}
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Xiangwu Lai

stm32_mdma_pm_suspend() increments the runtime PM usage counter with pm_runtime_resume_and_get(), but when a channel is still enabled it returns -EBUSY directly without dropping the reference. The matching pm_runtime_put_sync() only runs on the success path.

Each failed suspend attempt therefore leaks one runtime PM reference, so the device can never runtime suspend afterwards. Drop the reference before returning -EBUSY.

Fixes 7cb819c856d9 ("dmaengine: stm32-mdma: add suspend/resume power management support")

Thanks for your patch,

Quoted 19 lines
---
  drivers/dma/stm32/stm32-mdma.c | 1 +
  1 file changed, 1 insertion(+)
drivers/dma/stm32/stm32-mdma.c +1 -0
index e3bbdc9ee..fe1ff4a00 100644
@@ -1785,6 +1785,7 @@ static int stm32_mdma_pm_suspend(struct device *dev)
  		ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(id));
  		if (ccr & STM32_MDMA_CCR_EN) {
  			dev_warn(dev, "Suspend is prevented by Chan %i\n", id);
+			pm_runtime_put_sync(dev);
  			return -EBUSY;
  		}
  	}
Reviewed-by on v1 1/1
#2 lore raw
In reply to Xiangwu Lai
Quoted 7 lines · Xiangwu Lai

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

stm32_mdma_pm_suspend() increments the runtime PM usage counter with pm_runtime_resume_and_get(), but when a channel is still enabled it returns -EBUSY directly without dropping the reference. The matching pm_runtime_put_sync() only runs on the success path.

Quoted 6 lines

Each failed suspend attempt therefore leaks one runtime PM reference, so the device can never runtime suspend afterwards. Drop the reference before returning -EBUSY.

Fixes 7cb819c856d9 ("dmaengine: stm32-mdma: add suspend/resume power management support")
Quoted 19 lines
---
 drivers/dma/stm32/stm32-mdma.c | 1 +
 1 file changed, 1 insertion(+)
drivers/dma/stm32/stm32-mdma.c +1 -0
index e3bbdc9ee..fe1ff4a00 100644
@@ -1785,6 +1785,7 @@ static int stm32_mdma_pm_suspend(struct device *dev)
                ccr = stm32_mdma_read(dmadev, STM32_MDMA_CCR(id));
                if (ccr & STM32_MDMA_CCR_EN) {
                        dev_warn(dev, "Suspend is prevented by Chan %i\n", id);
+                       pm_runtime_put_sync(dev);
                        return -EBUSY;
                }
        }
author Reviewed-by Amelie Delaunay Reviewed-by Frank Li on v1 1/1
#3 lore raw

Re: [PATCH] dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend()

In reply to Xiangwu Lai

Hi Vinod,

gentle ping on this patch:

[PATCH] dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend()
https://lore.kernel.org/r/[email protected]

stm32_mdma_pm_suspend() takes a runtime PM reference with pm_runtime_resume_and_get() and returns -EBUSY without dropping it when a channel is still enabled, so each aborted suspend leaks one reference. The patch adds the missing pm_runtime_put_sync() on the -EBUSY path.

The patch carries both Reviewed-by tags since early November:

The sibling fix for stm32-dma is pending on the same topic as well (Reviewed-by: Amelie Delaunay and Frank Li):

[PATCH] dmaengine: stm32-dma: Fix runtime PM reference leak in pm_suspend()
https://lore.kernel.org/r/[email protected]

Could these two be queued for the next merge window?

Thanks,
Xiangwu Lai

maintainer Applied
#4 lore raw
In reply to Xiangwu Lai
Quoted 10 lines · Xiangwu Lai

stm32_mdma_pm_suspend() increments the runtime PM usage counter with pm_runtime_resume_and_get(), but when a channel is still enabled it returns -EBUSY directly without dropping the reference. The matching pm_runtime_put_sync() only runs on the success path.

Each failed suspend attempt therefore leaks one runtime PM reference, so the device can never runtime suspend afterwards. Drop the reference before returning -EBUSY.

[...]

Applied, thanks!

[1/1] dmaengine: stm32-mdma: Fix runtime PM reference leak in pm_suspend

      commit: 34c8c2ea213aab7b452df93e5b7547f4459a49e9

Best regards,

Signature · 1 line
~Vinod