All of lore.kernel.org
 help / color / mirror / Atom feed
From: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
To: vkoul@kernel.org, dan.j.williams@intel.com,
	michal.simek@xilinx.com, nick.graumann@gmail.com,
	andrea.merello@gmail.com, appana.durga.rao@xilinx.com,
	mcgrof@kernel.org
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Subject: [PATCH v2 -next 5/7] dmaengine: xilinx_dma: Add callback_result support
Date: Tue, 15 Oct 2019 20:18:22 +0530	[thread overview]
Message-ID: <1571150904-3988-6-git-send-email-radhey.shyam.pandey@xilinx.com> (raw)
In-Reply-To: <1571150904-3988-1-git-send-email-radhey.shyam.pandey@xilinx.com>

From: Nicholas Graumann <nick.graumann@gmail.com>

Take advantage of dmaengine_desc_get_callback_invoke which allows either
a callback or callback_result to be specified. This can be useful when
using the AXI DMA transfer unknown quantities of data where the residue
contained in the result can be used to calculate the number of bytes
transferred.

Signed-off-by: Nicholas Graumann <nick.graumann@gmail.com>
Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
---
Changes for v2:
Invoke xilinx_dma_get_residue only for valid combination.
---
 drivers/dma/xilinx/xilinx_dma.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index 8c10686..932407a 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -303,12 +303,16 @@ struct xilinx_cdma_tx_segment {
  * @segments: TX segments list
  * @node: Node in the channel descriptors list
  * @cyclic: Check for cyclic transfers.
+ * @err: Whether the descriptor has an error.
+ * @residue: Residue of the completed descriptor
  */
 struct xilinx_dma_tx_descriptor {
 	struct dma_async_tx_descriptor async_tx;
 	struct list_head segments;
 	struct list_head node;
 	bool cyclic;
+	bool err;
+	u32 residue;
 };
 
 /**
@@ -859,6 +863,8 @@ static void xilinx_dma_chan_desc_cleanup(struct xilinx_dma_chan *chan)
 	spin_lock_irqsave(&chan->lock, flags);
 
 	list_for_each_entry_safe(desc, next, &chan->done_list, node) {
+		struct dmaengine_result result;
+
 		if (desc->cyclic) {
 			xilinx_dma_chan_handle_cyclic(chan, desc, &flags);
 			break;
@@ -867,9 +873,20 @@ static void xilinx_dma_chan_desc_cleanup(struct xilinx_dma_chan *chan)
 		/* Remove from the list of running transactions */
 		list_del(&desc->node);
 
+		if (unlikely(desc->err)) {
+			if (chan->direction == DMA_DEV_TO_MEM)
+				result.result = DMA_TRANS_READ_FAILED;
+			else
+				result.result = DMA_TRANS_WRITE_FAILED;
+		} else {
+			result.result = DMA_TRANS_NOERROR;
+		}
+
+		result.residue = desc->residue;
+
 		/* Run the link descriptor callback function */
 		spin_unlock_irqrestore(&chan->lock, flags);
-		dmaengine_desc_get_callback_invoke(&desc->async_tx, NULL);
+		dmaengine_desc_get_callback_invoke(&desc->async_tx, &result);
 		spin_lock_irqsave(&chan->lock, flags);
 
 		/* Run any dependencies, then free the descriptor */
@@ -1425,6 +1442,13 @@ static void xilinx_dma_complete_descriptor(struct xilinx_dma_chan *chan)
 		return;
 
 	list_for_each_entry_safe(desc, next, &chan->active_list, node) {
+		if (chan->has_sg && chan->xdev->dma_config->dmatype !=
+		    XDMA_TYPE_VDMA)
+			desc->residue = xilinx_dma_get_residue(chan, desc);
+		else
+			desc->residue = 0;
+		desc->err = chan->err;
+
 		list_del(&desc->node);
 		if (!desc->cyclic)
 			dma_cookie_complete(&desc->async_tx);
-- 
2.7.4


  parent reply	other threads:[~2019-10-15 14:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15 14:48 [PATCH v2 -next 0/7] dmaengine: xilinx_dma: AXI DMA driver improvements Radhey Shyam Pandey
2019-10-15 14:48 ` [PATCH v2 -next 1/7] dmaengine: xilinx_dma: Remove desc_callback_valid check Radhey Shyam Pandey
2019-10-15 14:48 ` [PATCH v2 -next 2/7] dmaengine: xilinx_dma: Merge get_callback and _invoke Radhey Shyam Pandey
2019-10-15 14:48 ` [PATCH v2 -next 3/7] dmaengine: xilinx_dma: Remove residue from channel data Radhey Shyam Pandey
2019-10-15 14:48 ` [PATCH v2 -next 4/7] dmaengine: xilinx_dma: Introduce xilinx_dma_get_residue Radhey Shyam Pandey
2019-10-15 14:48 ` Radhey Shyam Pandey [this message]
2019-10-15 14:48 ` [PATCH v2 -next 6/7] dmaengine: xilinx_dma: Print debug message when no free tx segments Radhey Shyam Pandey
2019-10-15 14:48 ` [PATCH v2 -next 7/7] dmaengine: xilinx_dma: Clear desc_pendingcount in xilinx_dma_reset Radhey Shyam Pandey
2019-10-20 14:05 ` [PATCH v2 -next 0/7] dmaengine: xilinx_dma: AXI DMA driver improvements Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1571150904-3988-6-git-send-email-radhey.shyam.pandey@xilinx.com \
    --to=radhey.shyam.pandey@xilinx.com \
    --cc=andrea.merello@gmail.com \
    --cc=appana.durga.rao@xilinx.com \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=nick.graumann@gmail.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.