]> Gentwo Git Trees - linux/.git/commitdiff
dmaengine: zynqmp_dma: Add shutdown operation support
authorAbin Joseph <abin.joseph@amd.com>
Tue, 22 Jul 2025 07:02:55 +0000 (12:32 +0530)
committerVinod Koul <vkoul@kernel.org>
Wed, 20 Aug 2025 17:27:20 +0000 (22:57 +0530)
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>
Link: https://lore.kernel.org/r/20250722070255.28944-1-abin.joseph@amd.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/dma/xilinx/zynqmp_dma.c

index d05fc5fcc77dcedd32cc23c99d084504647c31aa..f7e584de4335e2ad89964c141a6e6ad89201f52b 100644 (file)
@@ -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);