Skip to contentSkip to conversation

dmaengine: dw: Move check for paused channel to dwc_get_residue()

PATCH Applied Andy Shevchenko 2 participants 2 messages Jan 30, 2023 – Feb 10, 2023

Subsystems (2)
lore
Share & tools
lore

Andy Shevchenko

author reviewer
#0 lore raw

PATCH 1/1 dmaengine: dw: Move check for paused channel to dwc_get_residue()

Move check for paused channel to dwc_get_residue() and rename the latter to dwc_get_residue_and_status().

This improves data integrity as residue and DMA channel status are set in the same function under the same conditions.

---
 drivers/dma/dw/core.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/dma/dw/core.c +5 -6
index 97ba3bfc10b1..5f7d690e3dba 100644
@@ -889,7 +889,8 @@ static struct dw_desc *dwc_find_desc(struct dw_dma_chan *dwc, dma_cookie_t c)
 	return NULL;
 }
 
-static u32 dwc_get_residue(struct dw_dma_chan *dwc, dma_cookie_t cookie)
+static u32 dwc_get_residue_and_status(struct dw_dma_chan *dwc, dma_cookie_t cookie,
+				      enum dma_status *status)
 {
 	struct dw_desc *desc;
 	unsigned long flags;
@@ -903,6 +904,8 @@ static u32 dwc_get_residue(struct dw_dma_chan *dwc, dma_cookie_t cookie)
 			residue = desc->residue;
 			if (test_bit(DW_DMA_IS_SOFT_LLP, &dwc->flags) && residue)
 				residue -= dwc_get_sent(dwc);
+			if (test_bit(DW_DMA_IS_PAUSED, &dwc->flags))
+				*status = DMA_PAUSED;
 		} else {
 			residue = desc->total_len;
 		}
@@ -932,11 +935,7 @@ dwc_tx_status(struct dma_chan *chan,
 	if (ret == DMA_COMPLETE)
 		return ret;
 
-	dma_set_residue(txstate, dwc_get_residue(dwc, cookie));
-
-	if (test_bit(DW_DMA_IS_PAUSED, &dwc->flags) && ret == DMA_IN_PROGRESS)
-		return DMA_PAUSED;
-
+	dma_set_residue(txstate, dwc_get_residue_and_status(dwc, cookie, &ret));
 	return ret;
 }
 
Signature · 1 line
2.39.0
maintainer Applied
#1 lore raw
Quoted 5 lines · Andy Shevchenko

Move check for paused channel to dwc_get_residue() and rename the latter to dwc_get_residue_and_status().

This improves data integrity as residue and DMA channel status are set in the same function under the same conditions.

Applied, thanks

Signature · 1 line
~Vinod