Skip to content

Commit 255ccd8

Browse files
andy-shevvinodkoul
authored andcommitted
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. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 9284699 commit 255ccd8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/dma/dw/core.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,8 @@ static struct dw_desc *dwc_find_desc(struct dw_dma_chan *dwc, dma_cookie_t c)
889889
return NULL;
890890
}
891891

892-
static u32 dwc_get_residue(struct dw_dma_chan *dwc, dma_cookie_t cookie)
892+
static u32 dwc_get_residue_and_status(struct dw_dma_chan *dwc, dma_cookie_t cookie,
893+
enum dma_status *status)
893894
{
894895
struct dw_desc *desc;
895896
unsigned long flags;
@@ -903,6 +904,8 @@ static u32 dwc_get_residue(struct dw_dma_chan *dwc, dma_cookie_t cookie)
903904
residue = desc->residue;
904905
if (test_bit(DW_DMA_IS_SOFT_LLP, &dwc->flags) && residue)
905906
residue -= dwc_get_sent(dwc);
907+
if (test_bit(DW_DMA_IS_PAUSED, &dwc->flags))
908+
*status = DMA_PAUSED;
906909
} else {
907910
residue = desc->total_len;
908911
}
@@ -932,11 +935,7 @@ dwc_tx_status(struct dma_chan *chan,
932935
if (ret == DMA_COMPLETE)
933936
return ret;
934937

935-
dma_set_residue(txstate, dwc_get_residue(dwc, cookie));
936-
937-
if (test_bit(DW_DMA_IS_PAUSED, &dwc->flags) && ret == DMA_IN_PROGRESS)
938-
return DMA_PAUSED;
939-
938+
dma_set_residue(txstate, dwc_get_residue_and_status(dwc, cookie, &ret));
940939
return ret;
941940
}
942941

0 commit comments

Comments
 (0)