[v3,11/30] dma/dpaa2: change the DMA copy return value

Message ID 20240722163930.2171568-12-g.singh@nxp.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series NXP DMA driver fixes and Enhancements |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Gagandeep Singh July 22, 2024, 4:39 p.m. UTC
From: Jun Yang <jun.yang@nxp.com>

The return value of DMA copy/sg copy should be index of
descriptor copied in success.

Signed-off-by: Jun Yang <jun.yang@nxp.com>
---
 drivers/dma/dpaa2/dpaa2_qdma.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/dma/dpaa2/dpaa2_qdma.c b/drivers/dma/dpaa2/dpaa2_qdma.c
index d1358b686c..b70750fede 100644
--- a/drivers/dma/dpaa2/dpaa2_qdma.c
+++ b/drivers/dma/dpaa2/dpaa2_qdma.c
@@ -605,6 +605,11 @@  dpaa2_qdma_copy_sg(void *dev_private,
 		return -ENOTSUP;
 	}
 
+	if (unlikely(!nb_src)) {
+		DPAA2_QDMA_ERR("No SG entry specified");
+		return -EINVAL;
+	}
+
 	if (unlikely(nb_src > RTE_DPAA2_QDMA_JOB_SUBMIT_MAX)) {
 		DPAA2_QDMA_ERR("SG entry number(%d) > MAX(%d)",
 			nb_src, RTE_DPAA2_QDMA_JOB_SUBMIT_MAX);
@@ -681,10 +686,13 @@  dpaa2_qdma_copy_sg(void *dev_private,
 	if (flags & RTE_DMA_OP_FLAG_SUBMIT) {
 		expected = qdma_vq->fd_idx;
 		ret = dpaa2_qdma_multi_eq(qdma_vq);
-		if (likely(ret == expected))
-			return 0;
+		if (likely(ret == expected)) {
+			qdma_vq->copy_num += nb_src;
+			return (qdma_vq->copy_num - 1) & UINT16_MAX;
+		}
 	} else {
-		return 0;
+		qdma_vq->copy_num += nb_src;
+		return (qdma_vq->copy_num - 1) & UINT16_MAX;
 	}
 
 	return ret;