Re: [PATCH v8 5/6] dmaengine: dw: calculate residue in the status getter

From: Andy Shevchenko

Date: Mon Nov 16 2026 - 11:14:56 EST


On Mon, Nov 16, 2026 at 03:52:33AM -0700, James Hilliard wrote:

> Calculate hardware-LLP residue while looking up the requested cookie under
> the channel lock. The descriptor scanner updates cached residue only when
> no transfer-complete event is pending. If a status query completes the
> current transaction and starts the next one, that new transaction's cached
> residue has not been initialized and a query for its cookie reports zero.
>
> Have dwc_get_hard_llp_desc_residue() return a local residue value from a
> fresh LLP snapshot. Keep the persistent residue field for software-LLP
> block accounting, subtracting the current block's progress when reporting
> status. The descriptor scanner continues to advance software-LLP blocks
> and complete cookies from RAW.XFER, including for polled transfers.

...

> desc = dwc_find_desc(dwc, cookie);
> if (desc) {
> if (desc == dwc->desc) {
> - residue = desc->residue;
> - if (test_bit(DW_DMA_IS_SOFT_LLP, &dwc->flags) && residue)
> + if (test_bit(DW_DMA_IS_SOFT_LLP, &dwc->flags)) {
> + residue = desc->residue;
> residue -= dwc_get_sent(dwc);
> + } else {
> + residue = dwc_get_hard_llp_desc_residue(dwc, desc);
> + }

It can be written in a shorter form

if (test_bit(DW_DMA_IS_SOFT_LLP, &dwc->flags))
residue = desc->residue - dwc_get_sent(dwc);
else
residue = dwc_get_hard_llp_desc_residue(dwc, desc);

> if (test_bit(DW_DMA_IS_PAUSED, &dwc->flags))
> *status = DMA_PAUSED;
> } else {

--
With Best Regards,
Andy Shevchenko