diff mbox series

[1/4] dma/hisilicon: fix return last-idx when no DMA completed

Message ID 20220527034055.33271-2-fengchengwen@huawei.com (mailing list archive)
State Accepted
Delegated to: Thomas Monjalon
Headers show
Series bugfix and feature for Hisilicon DMA PMD | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

fengchengwen May 27, 2022, 3:40 a.m. UTC
If no DMA request is completed, the ring_idx of the last completed
operation need returned by last_idx parameter. This patch fixes it.

Fixes: 2db4f0b82360 ("dma/hisilicon: add data path")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
 drivers/dma/hisilicon/hisi_dmadev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/dma/hisilicon/hisi_dmadev.c b/drivers/dma/hisilicon/hisi_dmadev.c
index 9cef2cbfbe..f5c3cd914d 100644
--- a/drivers/dma/hisilicon/hisi_dmadev.c
+++ b/drivers/dma/hisilicon/hisi_dmadev.c
@@ -702,12 +702,12 @@  hisi_dma_completed(void *dev_private,
 		}
 		sq_head = (sq_head + 1) & hw->sq_depth_mask;
 	}
+	*last_idx = hw->cridx + i - 1;
 	if (i > 0) {
 		hw->cridx += i;
-		*last_idx = hw->cridx - 1;
 		hw->sq_head = sq_head;
+		hw->completed += i;
 	}
-	hw->completed += i;
 
 	return i;
 }
@@ -761,12 +761,12 @@  hisi_dma_completed_status(void *dev_private,
 		hw->status[sq_head] = HISI_DMA_STATUS_SUCCESS;
 		sq_head = (sq_head + 1) & hw->sq_depth_mask;
 	}
+	*last_idx = hw->cridx + cpl_num - 1;
 	if (likely(cpl_num > 0)) {
 		hw->cridx += cpl_num;
-		*last_idx = hw->cridx - 1;
 		hw->sq_head = sq_head;
+		hw->completed += cpl_num;
 	}
-	hw->completed += cpl_num;
 
 	return cpl_num;
 }