Skip to content

Commit 5e742de

Browse files
xdev0x01vinodkoul
authored andcommitted
dmaengine: dw-edma: Set status for callback_result
DMA Engine has support for the callback_result which provides the status of the request and the residue. This helps in determining the correct status of the request and in efficient resource management of the request. The 'callback_result' method is preferred over the deprecated 'callback' method. Signed-off-by: Devendra K Verma <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent a33e3b6 commit 5e742de

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/dma/dw-edma/dw-edma-core.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,25 @@ dw_edma_device_prep_interleaved_dma(struct dma_chan *dchan,
584584
return dw_edma_device_transfer(&xfer);
585585
}
586586

587+
static void dw_hdma_set_callback_result(struct virt_dma_desc *vd,
588+
enum dmaengine_tx_result result)
589+
{
590+
u32 residue = 0;
591+
struct dw_edma_desc *desc;
592+
struct dmaengine_result *res;
593+
594+
if (!vd->tx.callback_result)
595+
return;
596+
597+
desc = vd2dw_edma_desc(vd);
598+
if (desc)
599+
residue = desc->alloc_sz - desc->xfer_sz;
600+
601+
res = &vd->tx_result;
602+
res->result = result;
603+
res->residue = residue;
604+
}
605+
587606
static void dw_edma_done_interrupt(struct dw_edma_chan *chan)
588607
{
589608
struct dw_edma_desc *desc;
@@ -597,6 +616,8 @@ static void dw_edma_done_interrupt(struct dw_edma_chan *chan)
597616
case EDMA_REQ_NONE:
598617
desc = vd2dw_edma_desc(vd);
599618
if (!desc->chunks_alloc) {
619+
dw_hdma_set_callback_result(vd,
620+
DMA_TRANS_NOERROR);
600621
list_del(&vd->node);
601622
vchan_cookie_complete(vd);
602623
}
@@ -633,6 +654,7 @@ static void dw_edma_abort_interrupt(struct dw_edma_chan *chan)
633654
spin_lock_irqsave(&chan->vc.lock, flags);
634655
vd = vchan_next_desc(&chan->vc);
635656
if (vd) {
657+
dw_hdma_set_callback_result(vd, DMA_TRANS_ABORTED);
636658
list_del(&vd->node);
637659
vchan_cookie_complete(vd);
638660
}

0 commit comments

Comments
 (0)