The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 0/2] dmaengine: dw-axi-dmac: clean up DMAC enable and PM
@ 2026-05-25  7:10 tze.yee.ng
  2026-05-25  7:10 ` [PATCH v2 1/2] dmaengine: dw-axi-dmac: drop redundant DMAC enable in block start tze.yee.ng
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: tze.yee.ng @ 2026-05-25  7:10 UTC (permalink / raw)
  To: Eugeniy Paltsev, Vinod Koul, Frank Li, dmaengine, linux-kernel
  Cc: Tze Yee Ng, Adrian Ng Ho Yin, Nazim Amirul

From: Tze Yee Ng <tze.yee.ng@altera.com>

The DesignWare AXI DMAC driver enables the controller in axi_dma_resume(),
which is invoked from the runtime PM resume path and from probe. Calling
axi_dma_enable() again at the start of every block transfer is redundant
on the normal path.

That extra call had also masked a gap in system-sleep power management:
with only runtime PM callbacks registered, a channel could remain allocated
across suspend/resume while the runtime usage count stayed non-zero and
axi_dma_runtime_resume() was not run, leaving DMAC_CFG and clocks out of
sync with software state. Removing the per-transfer enable without fixing
PM would make that scenario more visible.

This series drops the redundant enable and adds the missing system-sleep
and channel-allocation PM handling called out during review.

Patch 1 removes axi_dma_enable() from axi_chan_block_xfer_start().

Patch 2 (follow-up to review feedback from Sashiko Watanabe):

 - Add SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
   pm_runtime_force_resume) so system suspend/resume reuses the existing
   axi_dma_suspend() and axi_dma_resume() paths even when the runtime
   usage count is non-zero.

 - Replace pm_runtime_get() with pm_runtime_resume_and_get() in
   dma_chan_alloc_chan_resources(), with pm_runtime_put() on error paths,
   so clocks are enabled before a client can submit a transfer immediately
   after allocation.

Changes in v2:
- Add Patch 2 as a follow-up to review feedback from Sashiko Watanabe.
- No changes to Patch 1.

Niravkumar L Rabara (1):
  dmaengine: dw-axi-dmac: drop redundant DMAC enable in block start

Tze Yee Ng (1):
  dmaengine: dw-axi-dmac: fix PM for system sleep and channel alloc

 drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

-- 
2.43.7


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

* [PATCH v2 1/2] dmaengine: dw-axi-dmac: drop redundant DMAC enable in block start
  2026-05-25  7:10 [PATCH v2 0/2] dmaengine: dw-axi-dmac: clean up DMAC enable and PM tze.yee.ng
@ 2026-05-25  7:10 ` tze.yee.ng
  2026-05-25  7:10 ` [PATCH v2 2/2] dmaengine: dw-axi-dmac: fix PM for system sleep and channel alloc tze.yee.ng
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: tze.yee.ng @ 2026-05-25  7:10 UTC (permalink / raw)
  To: Eugeniy Paltsev, Vinod Koul, Frank Li, dmaengine, linux-kernel
  Cc: Tze Yee Ng, Adrian Ng Ho Yin, Nazim Amirul

From: Niravkumar L Rabara <niravkumarlaxmidas.rabara@altera.com>

axi_chan_block_xfer_start() runs after the controller is already enabled,
so calling axi_dma_enable() again is unnecessary. Remove the redundant
enable call to keep the transfer start path clean and avoid repeated no-op
programming.

Signed-off-by: Niravkumar L Rabara <niravkumarlaxmidas.rabara@altera.com>
Signed-off-by: Tze Yee Ng <tze.yee.ng@altera.com>
---
 drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index 4d53f077e9d2..f7a50f470461 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -437,8 +437,6 @@ static void axi_chan_block_xfer_start(struct axi_dma_chan *chan,
 		return;
 	}
 
-	axi_dma_enable(chan->chip);
-
 	config.dst_multblk_type = DWAXIDMAC_MBLK_TYPE_LL;
 	config.src_multblk_type = DWAXIDMAC_MBLK_TYPE_LL;
 	config.tt_fc = DWAXIDMAC_TT_FC_MEM_TO_MEM_DMAC;
-- 
2.43.7


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

* [PATCH v2 2/2] dmaengine: dw-axi-dmac: fix PM for system sleep and channel alloc
  2026-05-25  7:10 [PATCH v2 0/2] dmaengine: dw-axi-dmac: clean up DMAC enable and PM tze.yee.ng
  2026-05-25  7:10 ` [PATCH v2 1/2] dmaengine: dw-axi-dmac: drop redundant DMAC enable in block start tze.yee.ng
@ 2026-05-25  7:10 ` tze.yee.ng
  2026-06-11  2:13 ` [PATCH v2 0/2] dmaengine: dw-axi-dmac: clean up DMAC enable and PM NG, TZE YEE
  2026-06-11  5:51 ` Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: tze.yee.ng @ 2026-05-25  7:10 UTC (permalink / raw)
  To: Eugeniy Paltsev, Vinod Koul, Frank Li, dmaengine, linux-kernel
  Cc: Tze Yee Ng, Adrian Ng Ho Yin, Nazim Amirul

From: Tze Yee Ng <tze.yee.ng@altera.com>

The driver only had runtime PM callbacks. If a channel stayed allocated
across system suspend/resume, the runtime usage count could remain
non-zero while hardware state (DMAC_CFG, clocks) was lost, and
axi_dma_runtime_resume() would not run to restore it.

Add system-sleep PM ops that use pm_runtime_force_suspend() and
pm_runtime_force_resume() so suspend/resume reuses the existing
axi_dma_suspend() and axi_dma_resume() paths.

Replace pm_runtime_get() with pm_runtime_resume_and_get() in
dma_chan_alloc_chan_resources() so clocks are enabled before a client
can immediately submit a transfer and touch MMIO.

Signed-off-by: Tze Yee Ng <tze.yee.ng@altera.com>
---
 drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index f7a50f470461..bcefaff03b5c 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -516,11 +516,17 @@ static void dw_axi_dma_synchronize(struct dma_chan *dchan)
 static int dma_chan_alloc_chan_resources(struct dma_chan *dchan)
 {
 	struct axi_dma_chan *chan = dchan_to_axi_dma_chan(dchan);
+	int ret;
+
+	ret = pm_runtime_resume_and_get(chan->chip->dev);
+	if (ret < 0)
+		return ret;
 
 	/* ASSERT: channel is idle */
 	if (axi_chan_is_hw_enable(chan)) {
 		dev_err(chan2dev(chan), "%s is non-idle!\n",
 			axi_chan_name(chan));
+		pm_runtime_put(chan->chip->dev);
 		return -EBUSY;
 	}
 
@@ -531,12 +537,11 @@ static int dma_chan_alloc_chan_resources(struct dma_chan *dchan)
 					  64, 0);
 	if (!chan->desc_pool) {
 		dev_err(chan2dev(chan), "No memory for descriptors\n");
+		pm_runtime_put(chan->chip->dev);
 		return -ENOMEM;
 	}
 	dev_vdbg(dchan2dev(dchan), "%s: allocating\n", axi_chan_name(chan));
 
-	pm_runtime_get(chan->chip->dev);
-
 	return 0;
 }
 
@@ -1663,6 +1668,8 @@ static void dw_remove(struct platform_device *pdev)
 }
 
 static const struct dev_pm_ops dw_axi_dma_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
+				pm_runtime_force_resume)
 	SET_RUNTIME_PM_OPS(axi_dma_runtime_suspend, axi_dma_runtime_resume, NULL)
 };
 
-- 
2.43.7


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

* Re: [PATCH v2 0/2] dmaengine: dw-axi-dmac: clean up DMAC enable and PM
  2026-05-25  7:10 [PATCH v2 0/2] dmaengine: dw-axi-dmac: clean up DMAC enable and PM tze.yee.ng
  2026-05-25  7:10 ` [PATCH v2 1/2] dmaengine: dw-axi-dmac: drop redundant DMAC enable in block start tze.yee.ng
  2026-05-25  7:10 ` [PATCH v2 2/2] dmaengine: dw-axi-dmac: fix PM for system sleep and channel alloc tze.yee.ng
@ 2026-06-11  2:13 ` NG, TZE YEE
  2026-06-11  5:51 ` Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: NG, TZE YEE @ 2026-06-11  2:13 UTC (permalink / raw)
  To: Eugeniy Paltsev, Vinod Koul, Frank Li, dmaengine@vger.kernel.org,
	linux-kernel@vger.kernel.org
  Cc: NG, ADRIAN HO YIN, Nazle Asmade, Muhammad Nazim Amirul

On 25/5/2026 3:10 pm, NG, TZE YEE wrote:
> From: Tze Yee Ng <tze.yee.ng@altera.com>
> 
> The DesignWare AXI DMAC driver enables the controller in axi_dma_resume(),
> which is invoked from the runtime PM resume path and from probe. Calling
> axi_dma_enable() again at the start of every block transfer is redundant
> on the normal path.
> 
> That extra call had also masked a gap in system-sleep power management:
> with only runtime PM callbacks registered, a channel could remain allocated
> across suspend/resume while the runtime usage count stayed non-zero and
> axi_dma_runtime_resume() was not run, leaving DMAC_CFG and clocks out of
> sync with software state. Removing the per-transfer enable without fixing
> PM would make that scenario more visible.
> 
> This series drops the redundant enable and adds the missing system-sleep
> and channel-allocation PM handling called out during review.
> 
> Patch 1 removes axi_dma_enable() from axi_chan_block_xfer_start().
> 
> Patch 2 (follow-up to review feedback from Sashiko Watanabe):
> 
>   - Add SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
>     pm_runtime_force_resume) so system suspend/resume reuses the existing
>     axi_dma_suspend() and axi_dma_resume() paths even when the runtime
>     usage count is non-zero.
> 
>   - Replace pm_runtime_get() with pm_runtime_resume_and_get() in
>     dma_chan_alloc_chan_resources(), with pm_runtime_put() on error paths,
>     so clocks are enabled before a client can submit a transfer immediately
>     after allocation.
> 
> Changes in v2:
> - Add Patch 2 as a follow-up to review feedback from Sashiko Watanabe.
> - No changes to Patch 1.
> 
> Niravkumar L Rabara (1):
>    dmaengine: dw-axi-dmac: drop redundant DMAC enable in block start
> 
> Tze Yee Ng (1):
>    dmaengine: dw-axi-dmac: fix PM for system sleep and channel alloc
> 
>   drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 13 +++++++++----
>   1 file changed, 9 insertions(+), 4 deletions(-)
> 

Hi,

Gentle follow-up on v2 of this dw-axi-dmac series (25 May), which adds
system-sleep PM and channel-allocation fixes per Sashiko's review.

Please let me know if anything else is needed before this can move forward.

Thanks,
Tze Yee

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

* Re: [PATCH v2 0/2] dmaengine: dw-axi-dmac: clean up DMAC enable and PM
  2026-05-25  7:10 [PATCH v2 0/2] dmaengine: dw-axi-dmac: clean up DMAC enable and PM tze.yee.ng
                   ` (2 preceding siblings ...)
  2026-06-11  2:13 ` [PATCH v2 0/2] dmaengine: dw-axi-dmac: clean up DMAC enable and PM NG, TZE YEE
@ 2026-06-11  5:51 ` Vinod Koul
  3 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2026-06-11  5:51 UTC (permalink / raw)
  To: Eugeniy Paltsev, Frank Li, dmaengine, linux-kernel, tze.yee.ng
  Cc: Adrian Ng Ho Yin, Nazim Amirul


On Mon, 25 May 2026 00:10:20 -0700, tze.yee.ng@altera.com wrote:
> The DesignWare AXI DMAC driver enables the controller in axi_dma_resume(),
> which is invoked from the runtime PM resume path and from probe. Calling
> axi_dma_enable() again at the start of every block transfer is redundant
> on the normal path.
> 
> That extra call had also masked a gap in system-sleep power management:
> with only runtime PM callbacks registered, a channel could remain allocated
> across suspend/resume while the runtime usage count stayed non-zero and
> axi_dma_runtime_resume() was not run, leaving DMAC_CFG and clocks out of
> sync with software state. Removing the per-transfer enable without fixing
> PM would make that scenario more visible.
> 
> [...]

Applied, thanks!

[1/2] dmaengine: dw-axi-dmac: drop redundant DMAC enable in block start
      commit: dc6d681e1571c89cd38145926fb2513d70a633e1
[2/2] dmaengine: dw-axi-dmac: fix PM for system sleep and channel alloc
      commit: df0c2dc68770cf43f15df40b184df030b850ea05

Best regards,
-- 
~Vinod



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

end of thread, other threads:[~2026-06-11  5:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-25  7:10 [PATCH v2 0/2] dmaengine: dw-axi-dmac: clean up DMAC enable and PM tze.yee.ng
2026-05-25  7:10 ` [PATCH v2 1/2] dmaengine: dw-axi-dmac: drop redundant DMAC enable in block start tze.yee.ng
2026-05-25  7:10 ` [PATCH v2 2/2] dmaengine: dw-axi-dmac: fix PM for system sleep and channel alloc tze.yee.ng
2026-06-11  2:13 ` [PATCH v2 0/2] dmaengine: dw-axi-dmac: clean up DMAC enable and PM NG, TZE YEE
2026-06-11  5:51 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox