From: Jun Yang <jun.y...@nxp.com>

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

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

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;
-- 
2.25.1

Reply via email to