linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] dmaengine: zynqmp_dma: Add shutdown operation support
@ 2025-07-22  7:02 Abin Joseph
  2025-08-13  6:51 ` Pandey, Radhey Shyam
  2025-08-20 17:42 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Abin Joseph @ 2025-07-22  7:02 UTC (permalink / raw)
  To: vkoul, michal.simek, yanzhen, radhey.shyam.pandey, palmer,
	u.kleine-koenig
  Cc: git, abin.joseph, dmaengine, linux-arm-kernel, linux-kernel

Add shutdown callback to ensure that DMA operations are properly stopped
and resources are released during system shutdown or kexec operations.
Fix incorrect PM state handling in the remove function that was causing
clock disable warnings during the shutdown operations, which was not
implemented earlier. The original logic used pm_runtime_enabled() check
after calling the pm_runtime_disable(), would always evaluate to true
after the disable call, which leads to unconditionally calling the
runtime_suspend regardless of the device's actual power state.

During shutdown, the device may already be suspended with clock disabled
from the autosuspend timer, causing the clock framework to warn about
the double-disable attempt. The pm_runtime_active() function checks the
actual device power state rather than the PM subsystem's enabled/disabled
status. ensuring the runtime_suspend is only called when the device is in
active power state. This prevents clock warnings during shutdown while
maintaining proper cleanup during normal remove operations.

Signed-off-by: Abin Joseph <abin.joseph@amd.com>
---

Changes in v3:
Update the commit description
Update to call remove directly from shutdown hook.

Changes in v2:
Update the shutdown to perform same operations as remove.

---
 drivers/dma/xilinx/zynqmp_dma.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
index d05fc5fcc77d..f7e584de4335 100644
--- a/drivers/dma/xilinx/zynqmp_dma.c
+++ b/drivers/dma/xilinx/zynqmp_dma.c
@@ -1173,9 +1173,9 @@ static void zynqmp_dma_remove(struct platform_device *pdev)
 	dma_async_device_unregister(&zdev->common);
 
 	zynqmp_dma_chan_remove(zdev->chan);
-	pm_runtime_disable(zdev->dev);
-	if (!pm_runtime_enabled(zdev->dev))
+	if (pm_runtime_active(zdev->dev))
 		zynqmp_dma_runtime_suspend(zdev->dev);
+	pm_runtime_disable(zdev->dev);
 }
 
 static const struct of_device_id zynqmp_dma_of_match[] = {
@@ -1193,6 +1193,7 @@ static struct platform_driver zynqmp_dma_driver = {
 	},
 	.probe = zynqmp_dma_probe,
 	.remove = zynqmp_dma_remove,
+	.shutdown = zynqmp_dma_remove,
 };
 
 module_platform_driver(zynqmp_dma_driver);
-- 
2.43.0


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

* RE: [PATCH v3] dmaengine: zynqmp_dma: Add shutdown operation support
  2025-07-22  7:02 [PATCH v3] dmaengine: zynqmp_dma: Add shutdown operation support Abin Joseph
@ 2025-08-13  6:51 ` Pandey, Radhey Shyam
  2025-08-20 17:42 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Pandey, Radhey Shyam @ 2025-08-13  6:51 UTC (permalink / raw)
  To: Joseph, Abin, vkoul@kernel.org, Simek, Michal, yanzhen@vivo.com,
	palmer@rivosinc.com, u.kleine-koenig@baylibre.com
  Cc: git (AMD-Xilinx), Joseph, Abin, dmaengine@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org

[Public]

> -----Original Message-----
> From: Abin Joseph <abin.joseph@amd.com>
> Sent: Tuesday, July 22, 2025 12:33 PM
> To: vkoul@kernel.org; Simek, Michal <michal.simek@amd.com>;
> yanzhen@vivo.com; Pandey, Radhey Shyam <radhey.shyam.pandey@amd.com>;
> palmer@rivosinc.com; u.kleine-koenig@baylibre.com
> Cc: git (AMD-Xilinx) <git@amd.com>; Joseph, Abin <Abin.Joseph@amd.com>;
> dmaengine@vger.kernel.org; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org
> Subject: [PATCH v3] dmaengine: zynqmp_dma: Add shutdown operation support
>
> Add shutdown callback to ensure that DMA operations are properly stopped
> and resources are released during system shutdown or kexec operations.
> Fix incorrect PM state handling in the remove function that was causing
> clock disable warnings during the shutdown operations, which was not
> implemented earlier. The original logic used pm_runtime_enabled() check
> after calling the pm_runtime_disable(), would always evaluate to true
> after the disable call, which leads to unconditionally calling the
> runtime_suspend regardless of the device's actual power state.
>
> During shutdown, the device may already be suspended with clock disabled
> from the autosuspend timer, causing the clock framework to warn about
> the double-disable attempt. The pm_runtime_active() function checks the
> actual device power state rather than the PM subsystem's enabled/disabled
> status. ensuring the runtime_suspend is only called when the device is in
> active power state. This prevents clock warnings during shutdown while
> maintaining proper cleanup during normal remove operations.
>
> Signed-off-by: Abin Joseph <abin.joseph@amd.com>

Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
Thanks!
> ---
>
> Changes in v3:
> Update the commit description
> Update to call remove directly from shutdown hook.
>
> Changes in v2:
> Update the shutdown to perform same operations as remove.
>
> ---
>  drivers/dma/xilinx/zynqmp_dma.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
> index d05fc5fcc77d..f7e584de4335 100644
> --- a/drivers/dma/xilinx/zynqmp_dma.c
> +++ b/drivers/dma/xilinx/zynqmp_dma.c
> @@ -1173,9 +1173,9 @@ static void zynqmp_dma_remove(struct platform_device
> *pdev)
>       dma_async_device_unregister(&zdev->common);
>
>       zynqmp_dma_chan_remove(zdev->chan);
> -     pm_runtime_disable(zdev->dev);
> -     if (!pm_runtime_enabled(zdev->dev))
> +     if (pm_runtime_active(zdev->dev))
>               zynqmp_dma_runtime_suspend(zdev->dev);
> +     pm_runtime_disable(zdev->dev);
>  }
>
>  static const struct of_device_id zynqmp_dma_of_match[] = {
> @@ -1193,6 +1193,7 @@ static struct platform_driver zynqmp_dma_driver = {
>       },
>       .probe = zynqmp_dma_probe,
>       .remove = zynqmp_dma_remove,
> +     .shutdown = zynqmp_dma_remove,
>  };
>
>  module_platform_driver(zynqmp_dma_driver);
> --
> 2.43.0


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

* Re: [PATCH v3] dmaengine: zynqmp_dma: Add shutdown operation support
  2025-07-22  7:02 [PATCH v3] dmaengine: zynqmp_dma: Add shutdown operation support Abin Joseph
  2025-08-13  6:51 ` Pandey, Radhey Shyam
@ 2025-08-20 17:42 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2025-08-20 17:42 UTC (permalink / raw)
  To: michal.simek, yanzhen, radhey.shyam.pandey, palmer,
	u.kleine-koenig, Abin Joseph
  Cc: git, dmaengine, linux-arm-kernel, linux-kernel


On Tue, 22 Jul 2025 12:32:55 +0530, Abin Joseph wrote:
> Add shutdown callback to ensure that DMA operations are properly stopped
> and resources are released during system shutdown or kexec operations.
> Fix incorrect PM state handling in the remove function that was causing
> clock disable warnings during the shutdown operations, which was not
> implemented earlier. The original logic used pm_runtime_enabled() check
> after calling the pm_runtime_disable(), would always evaluate to true
> after the disable call, which leads to unconditionally calling the
> runtime_suspend regardless of the device's actual power state.
> 
> [...]

Applied, thanks!

[1/1] dmaengine: zynqmp_dma: Add shutdown operation support
      commit: 72dd8b2914b5db1dccf902971c2ea6b541711b28

Best regards,
-- 
~Vinod



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

end of thread, other threads:[~2025-08-20 17:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22  7:02 [PATCH v3] dmaengine: zynqmp_dma: Add shutdown operation support Abin Joseph
2025-08-13  6:51 ` Pandey, Radhey Shyam
2025-08-20 17:42 ` 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).