dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Peter Ujfalusi <peter.ujfalusi@gmail.com>,
	 Vinod Koul <vkoul@kernel.org>,
	Grygorii Strashko <grygorii.strashko@ti.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	 Peter Ujfalusi <peter.ujfalusi@ti.com>,
	dmaengine@vger.kernel.org,  linux-kernel@vger.kernel.org,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	 stable@vger.kernel.org
Subject: [PATCH 2/3] dmaengine: ti: k3-udma: Ensure a minimum polling delay
Date: Thu, 31 Jul 2025 18:41:30 +0200	[thread overview]
Message-ID: <20250731-ti-dma-timeout-v1-2-33321d2b7406@bootlin.com> (raw)
In-Reply-To: <20250731-ti-dma-timeout-v1-0-33321d2b7406@bootlin.com>

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@vger.kernel.org # 5.7
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 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


  parent reply	other threads:[~2025-07-31 16:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-31 16:41 [PATCH 0/3] dmaengine: ti: k3-udma: Fix/improve the completion helper Miquel Raynal
2025-07-31 16:41 ` [PATCH 1/3] dmaengine: ti: k3-udma: Reduce completion polling delay Miquel Raynal
2025-07-31 16:41 ` Miquel Raynal [this message]
2025-07-31 16:41 ` [PATCH 3/3] dmaengine: ti: k3-udma: Simplify the completion worker Miquel Raynal

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=20250731-ti-dma-timeout-v1-2-33321d2b7406@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=grygorii.strashko@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.ujfalusi@gmail.com \
    --cc=peter.ujfalusi@ti.com \
    --cc=stable@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --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;
as well as URLs for NNTP newsgroup(s).