Re: [PATCH v7 3/7] dmaengine: dw-edma: Factor out descriptor completion

From: Frank Li

Date: Wed Nov 04 2026 - 12:52:55 EST


On Thu, Nov 05, 2026 at 01:12:23AM +0900, Koichiro Den wrote:
> Completing a descriptor takes three steps: record the callback result,
> unlink it from the issued list and hand it to virt-dma.
>
> Factor them into dw_edma_complete_vdesc() to avoid sprinkling
> vchan_cookie_complete() calls throughout the driver.
>
> No functional change.
>
> Suggested-by: Frank Li <Frank.Li@xxxxxxx>
> Signed-off-by: Koichiro Den <den@xxxxxxxxxxxxx>
> ---

Reviewed-by: Frank Li <Frank.Li@xxxxxxx>

> Changes from v6:
> - New patch, per Frank's comment here:
> https://lore.kernel.org/r/auTL2mHwCt20uhII@SMW015318/
> "let vchan_cookie_complete() at one place only".
>
> drivers/dma/dw-edma/dw-edma-core.c | 17 +++++++++++------
> 1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
> index fb38d51037c5..e2f7af5969c6 100644
> --- a/drivers/dma/dw-edma/dw-edma-core.c
> +++ b/drivers/dma/dw-edma/dw-edma-core.c
> @@ -107,6 +107,15 @@ static void dw_hdma_set_callback_result(struct virt_dma_desc *vd,
> res->residue = residue;
> }
>
> +/* Must be called with vc.lock held. */
> +static void dw_edma_complete_vdesc(struct virt_dma_desc *vd,
> + enum dmaengine_tx_result result)
> +{
> + dw_hdma_set_callback_result(vd, result);
> + list_del(&vd->node);
> + vchan_cookie_complete(vd);
> +}
> +
> static void dw_edma_core_reset_ll(struct dw_edma_chan *chan)
> {
> u32 i;
> @@ -788,9 +797,7 @@ static void dw_edma_done_interrupt_locked(struct dw_edma_chan *chan)
>
> desc = vd2dw_edma_desc(vd);
> if (desc->start_burst >= desc->nburst) {
> - dw_hdma_set_callback_result(vd, DMA_TRANS_NOERROR);
> - list_del(&vd->node);
> - vchan_cookie_complete(vd);
> + dw_edma_complete_vdesc(vd, DMA_TRANS_NOERROR);
> if (!chan->non_ll)
> chan->ll_done = chan->ll_head;
> }
> @@ -838,9 +845,7 @@ static void dw_edma_abort_interrupt(struct dw_edma_chan *chan)
> if (vd && chan->request == EDMA_REQ_STOP) {
> dw_edma_terminate_all_descs(chan);
> } else if (vd) {
> - dw_hdma_set_callback_result(vd, DMA_TRANS_ABORTED);
> - list_del(&vd->node);
> - vchan_cookie_complete(vd);
> + dw_edma_complete_vdesc(vd, DMA_TRANS_ABORTED);
> }
> if (!chan->non_ll)
> dw_edma_core_reset_ll(chan);
> --
> 2.54.0
>