[PATCH v1 1/2] at_hdmac: check and return DMA_PAUSED status when suitable

Andy Shevchenko andriy.shevchenko at linux.intel.com
Mon Nov 7 23:49:37 PST 2022


device_tx_status() may return DMA_PAUSED status when driver supports it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
---
 drivers/dma/at_hdmac.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 8858470246e1..a9d8dd990d6e 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -1669,9 +1669,19 @@ atc_tx_status(struct dma_chan *chan,
 	int ret;
 
 	dma_status = dma_cookie_status(chan, cookie, txstate);
-	if (dma_status == DMA_COMPLETE || !txstate)
+	if (dma_status == DMA_COMPLETE)
 		return dma_status;
 
+	/*
+	 * There's no point in calculating the residue if there's
+	 * no txstate to store the value.
+	 */
+	if (!txstate) {
+		if (test_bit(ATC_IS_PAUSED, &atchan->status))
+			return DMA_PAUSED;
+		return DMA_ERROR;
+	}
+
 	spin_lock_irqsave(&atchan->vc.lock, flags);
 	/*  Get number of bytes left in the active transactions */
 	ret = atc_get_residue(chan, cookie, &residue);
@@ -1684,6 +1694,9 @@ atc_tx_status(struct dma_chan *chan,
 		dma_set_residue(txstate, residue);
 	}
 
+	if (test_bit(ATC_IS_PAUSED, &atchan->status))
+		dma_status = DMA_PAUSED;
+
 	dev_vdbg(chan2dev(chan), "tx_status %d: cookie = %d residue = %u\n",
 		 dma_status, cookie, residue);
 
-- 
2.35.1




More information about the linux-arm-kernel mailing list