]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dmaengine: dw-edma: Set status for callback_result
authorDevendra K Verma <devverma@amd.com>
Thu, 21 Aug 2025 12:15:05 +0000 (17:45 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Dec 2025 11:45:11 +0000 (12:45 +0100)
[ Upstream commit 5e742de97c806a4048418237ef1283e7d71eaf4b ]

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 <devverma@amd.com>
Link: https://lore.kernel.org/r/20250821121505.318179-1-devverma@amd.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/dma/dw-edma/dw-edma-core.c

index 25d65f64cd50775aa2f93b44fc43ba1a7485fbcb..6cbb018c215adbea0337c5eb728af6c6a6530673 100644 (file)
@@ -474,6 +474,25 @@ dw_edma_device_prep_dma_cyclic(struct dma_chan *dchan, dma_addr_t paddr,
        return dw_edma_device_transfer(&xfer);
 }
 
+static void dw_hdma_set_callback_result(struct virt_dma_desc *vd,
+                                       enum dmaengine_tx_result result)
+{
+       u32 residue = 0;
+       struct dw_edma_desc *desc;
+       struct dmaengine_result *res;
+
+       if (!vd->tx.callback_result)
+               return;
+
+       desc = vd2dw_edma_desc(vd);
+       if (desc)
+               residue = desc->alloc_sz - desc->xfer_sz;
+
+       res = &vd->tx_result;
+       res->result = result;
+       res->residue = residue;
+}
+
 static void dw_edma_done_interrupt(struct dw_edma_chan *chan)
 {
        struct dw_edma_desc *desc;
@@ -489,6 +508,8 @@ static void dw_edma_done_interrupt(struct dw_edma_chan *chan)
                case EDMA_REQ_NONE:
                        desc = vd2dw_edma_desc(vd);
                        if (!desc->chunks_alloc) {
+                               dw_hdma_set_callback_result(vd,
+                                                           DMA_TRANS_NOERROR);
                                list_del(&vd->node);
                                vchan_cookie_complete(vd);
                        }
@@ -527,6 +548,7 @@ static void dw_edma_abort_interrupt(struct dw_edma_chan *chan)
        spin_lock_irqsave(&chan->vc.lock, flags);
        vd = vchan_next_desc(&chan->vc);
        if (vd) {
+               dw_hdma_set_callback_result(vd, DMA_TRANS_ABORTED);
                list_del(&vd->node);
                vchan_cookie_complete(vd);
        }