From: Rahul Sharma <r-sharma3@ti.com>
To: <peter.ujfalusi@gmail.com>, <vkoul@kernel.org>,
<Frank.Li@kernel.org>, <nm@ti.com>, <kristo@kernel.org>,
<ssantosh@kernel.org>, <tglx@kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
<dmaengine@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] dma: ti: k3-udma: enable runtime PM support
Date: Wed, 29 Apr 2026 23:19:03 +0530 [thread overview]
Message-ID: <20260429174904.4049243-2-r-sharma3@ti.com> (raw)
In-Reply-To: <20260429174904.4049243-1-r-sharma3@ti.com>
Rename udma_pm_suspend/resume to udma_runtime_suspend/resume and
register them as runtime PM callbacks via SET_RUNTIME_PM_OPS. Enable
runtime PM in probe via devm_pm_runtime_enable().
System sleep is handled by reusing the same callbacks via
pm_runtime_force_suspend/resume as late/early sleep ops, keeping the
PM runtime state machine consistent across system sleep transitions.
Hold a runtime PM reference for the lifetime of each allocated channel
(acquired in alloc_chan_resources, released in free_chan_resources) to
ensure the device stays powered while DMA is in use.
Signed-off-by: Rahul Sharma <r-sharma3@ti.com>
---
drivers/dma/ti/k3-udma.c | 46 +++++++++++++++++++++++++++++++---------
1 file changed, 36 insertions(+), 10 deletions(-)
diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index c964ebfcf3b6..47a4d45f4c09 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -28,6 +28,7 @@
#include <linux/soc/ti/ti_sci_inta_msi.h>
#include <linux/dma/k3-event-router.h>
#include <linux/dma/ti-cppi5.h>
+#include <linux/pm_runtime.h>
#include "../virt-dma.h"
#include "k3-udma.h"
@@ -2189,6 +2190,10 @@ static int udma_alloc_chan_resources(struct dma_chan *chan)
u32 irq_udma_idx;
int ret;
+ ret = pm_runtime_resume_and_get(ud->dev);
+ if (ret)
+ return ret;
+
uc->dma_dev = ud->dev;
if (uc->config.pkt_mode || uc->config.dir == DMA_MEM_TO_MEM) {
@@ -2382,6 +2387,7 @@ static int udma_alloc_chan_resources(struct dma_chan *chan)
uc->use_dma_pool = false;
}
+ pm_runtime_put(ud->dev);
return ret;
}
@@ -2393,6 +2399,10 @@ static int bcdma_alloc_chan_resources(struct dma_chan *chan)
u32 irq_udma_idx, irq_ring_idx;
int ret;
+ ret = pm_runtime_resume_and_get(ud->dev);
+ if (ret)
+ return ret;
+
/* Only TR mode is supported */
uc->config.pkt_mode = false;
@@ -2412,7 +2422,7 @@ static int bcdma_alloc_chan_resources(struct dma_chan *chan)
ret = bcdma_alloc_bchan_resources(uc);
if (ret)
- return ret;
+ goto err_res_free;
irq_ring_idx = uc->bchan->id + oes->bcdma_bchan_ring;
irq_udma_idx = uc->bchan->id + oes->bcdma_bchan_data;
@@ -2427,7 +2437,7 @@ static int bcdma_alloc_chan_resources(struct dma_chan *chan)
ret = udma_alloc_tx_resources(uc);
if (ret) {
uc->config.remote_thread_id = -1;
- return ret;
+ goto err_res_free;
}
uc->config.src_thread = ud->psil_base + uc->tchan->id;
@@ -2447,7 +2457,7 @@ static int bcdma_alloc_chan_resources(struct dma_chan *chan)
ret = udma_alloc_rx_resources(uc);
if (ret) {
uc->config.remote_thread_id = -1;
- return ret;
+ goto err_res_free;
}
uc->config.src_thread = uc->config.remote_thread_id;
@@ -2463,7 +2473,8 @@ static int bcdma_alloc_chan_resources(struct dma_chan *chan)
/* Can not happen */
dev_err(uc->ud->dev, "%s: chan%d invalid direction (%u)\n",
__func__, uc->id, uc->config.dir);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_res_free;
}
/* check if the channel configuration was successful */
@@ -2576,6 +2587,7 @@ static int bcdma_alloc_chan_resources(struct dma_chan *chan)
uc->use_dma_pool = false;
}
+ pm_runtime_put(ud->dev);
return ret;
}
@@ -2605,6 +2617,10 @@ static int pktdma_alloc_chan_resources(struct dma_chan *chan)
u32 irq_ring_idx;
int ret;
+ ret = pm_runtime_resume_and_get(ud->dev);
+ if (ret)
+ return ret;
+
/*
* Make sure that the completion is in a known state:
* No teardown, the channel is idle
@@ -2622,7 +2638,7 @@ static int pktdma_alloc_chan_resources(struct dma_chan *chan)
ret = udma_alloc_tx_resources(uc);
if (ret) {
uc->config.remote_thread_id = -1;
- return ret;
+ goto err_res_free;
}
uc->config.src_thread = ud->psil_base + uc->tchan->id;
@@ -2641,7 +2657,7 @@ static int pktdma_alloc_chan_resources(struct dma_chan *chan)
ret = udma_alloc_rx_resources(uc);
if (ret) {
uc->config.remote_thread_id = -1;
- return ret;
+ goto err_res_free;
}
uc->config.src_thread = uc->config.remote_thread_id;
@@ -2656,7 +2672,8 @@ static int pktdma_alloc_chan_resources(struct dma_chan *chan)
/* Can not happen */
dev_err(uc->ud->dev, "%s: chan%d invalid direction (%u)\n",
__func__, uc->id, uc->config.dir);
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_res_free;
}
/* check if the channel configuration was successful */
@@ -2745,6 +2762,7 @@ static int pktdma_alloc_chan_resources(struct dma_chan *chan)
dma_pool_destroy(uc->hdesc_pool);
uc->use_dma_pool = false;
+ pm_runtime_put(ud->dev);
return ret;
}
@@ -4123,6 +4141,8 @@ static void udma_free_chan_resources(struct dma_chan *chan)
dma_pool_destroy(uc->hdesc_pool);
uc->use_dma_pool = false;
}
+
+ pm_runtime_put(ud->dev);
}
static struct platform_driver udma_driver;
@@ -5644,6 +5664,11 @@ static int udma_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, ud);
+ /* Enable runtime PM */
+ ret = devm_pm_runtime_enable(dev);
+ if (ret)
+ return ret;
+
ret = of_dma_controller_register(dev->of_node, udma_of_xlate, ud);
if (ret) {
dev_err(dev, "failed to register of_dma controller\n");
@@ -5653,7 +5678,7 @@ static int udma_probe(struct platform_device *pdev)
return ret;
}
-static int __maybe_unused udma_pm_suspend(struct device *dev)
+static int udma_runtime_suspend(struct device *dev)
{
struct udma_dev *ud = dev_get_drvdata(dev);
struct dma_device *dma_dev = &ud->ddev;
@@ -5675,7 +5700,7 @@ static int __maybe_unused udma_pm_suspend(struct device *dev)
return 0;
}
-static int __maybe_unused udma_pm_resume(struct device *dev)
+static int udma_runtime_resume(struct device *dev)
{
struct udma_dev *ud = dev_get_drvdata(dev);
struct dma_device *dma_dev = &ud->ddev;
@@ -5701,7 +5726,8 @@ static int __maybe_unused udma_pm_resume(struct device *dev)
}
static const struct dev_pm_ops udma_pm_ops = {
- SET_LATE_SYSTEM_SLEEP_PM_OPS(udma_pm_suspend, udma_pm_resume)
+ SET_LATE_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+ SET_RUNTIME_PM_OPS(udma_runtime_suspend, udma_runtime_resume, NULL)
};
static struct platform_driver udma_driver = {
--
2.34.1
next prev parent reply other threads:[~2026-04-29 17:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-29 17:49 [PATCH 0/2] Add runtime PM support to K3 UDMA and K3 INTA Rahul Sharma
2026-04-29 17:49 ` Rahul Sharma [this message]
2026-04-29 17:49 ` [PATCH 2/2] irqchip: ti-sci-inta: add runtime PM and system sleep support Rahul Sharma
2026-05-05 19:33 ` Thomas Gleixner
2026-04-30 6:11 ` [PATCH 0/2] Add runtime PM support to K3 UDMA and K3 INTA Rahul Sharma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260429174904.4049243-2-r-sharma3@ti.com \
--to=r-sharma3@ti.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=kristo@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nm@ti.com \
--cc=peter.ujfalusi@gmail.com \
--cc=ssantosh@kernel.org \
--cc=tglx@kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox