[PATCH 2/3] dmaengine: ti: k3-udma: Ensure a minimum polling delay
From: Miquel Raynal
Date: Thu Jul 31 2025 - 12:42:22 EST
ktime_to_us() returns 0 if the time (ktime_t stores nanoseconds) is too
small, leading to a while loop without sleeps, kind of conflicting with
the initial aim of this function at observing a small delay and then
guessing the amount of time needed to finish draining the descriptor.
Make sure we always sleep for (abitrarily) at least 1us to reduce
pressure on the CPU, while not waiting too much either.
Fixes: 25dcb5dd7b7c ("dmaengine: ti: New driver for K3 UDMA")
Cc: stable@xxxxxxxxxxxxxxx # 5.7
Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
---
drivers/dma/ti/k3-udma.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index b2059baed1b2ffc81c10feca797c763e2a04a357..11232b306475edd5e1ed75d938bbf49ed9c2aabd 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -1125,6 +1125,8 @@ static void udma_check_tx_completion(struct work_struct *work)
if (residue_diff) {
delay = (time_diff / residue_diff) *
uc->tx_drain.residue;
+ if (delay < 1000)
+ delay = 1000;
} else {
delay = 100000;
}
--
2.50.1