]> git.droids-corp.org - dpdk.git/commitdiff
dma/skeleton: fix index returned when no memcpy completed
authorChengwen Feng <fengchengwen@huawei.com>
Wed, 8 Jun 2022 08:50:05 +0000 (16:50 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 15 Jun 2022 14:15:07 +0000 (16:15 +0200)
If no memcopy request is completed, the ring_idx of the last completed
operation need returned by last_idx parameter. This patch fixes it.

Fixes: 05d5fc66a269 ("dma/skeleton: introduce skeleton driver")
Cc: stable@dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
drivers/dma/skeleton/skeleton_dmadev.c
drivers/dma/skeleton/skeleton_dmadev.h

index 81cbdd286ecef621934b9d33c14b472132c762f3..6b0bb14e2cd1303302d99bac672e9761283c9c37 100644 (file)
@@ -118,6 +118,7 @@ skeldma_start(struct rte_dma_dev *dev)
        fflush_ring(hw, hw->desc_running);
        fflush_ring(hw, hw->desc_completed);
        hw->ridx = 0;
+       hw->last_ridx = hw->ridx - 1;
        hw->submitted_count = 0;
        hw->zero_req_count = 0;
        hw->completed_count = 0;
@@ -322,9 +323,11 @@ skeldma_dump(const struct rte_dma_dev *dev, FILE *f)
                GET_RING_COUNT(hw->desc_completed));
        (void)fprintf(f,
                "    next_ring_idx: %u\n"
+               "    last_ring_idx: %u\n"
                "    submitted_count: %" PRIu64 "\n"
                "    completed_count: %" PRIu64 "\n",
-               hw->ridx, hw->submitted_count, hw->completed_count);
+               hw->ridx, hw->last_ridx,
+               hw->submitted_count, hw->completed_count);
 
        return 0;
 }
@@ -398,11 +401,15 @@ skeldma_completed(void *dev_private,
        count = RTE_MIN(nb_cpls, rte_ring_count(hw->desc_completed));
        while (index < count) {
                (void)rte_ring_dequeue(hw->desc_completed, (void **)&desc);
-               if (index == count - 1)
+               if (index == count - 1) {
+                       hw->last_ridx = desc->ridx;
                        *last_idx = desc->ridx;
+               }
                index++;
                (void)rte_ring_enqueue(hw->desc_empty, (void *)desc);
        }
+       if (unlikely(count == 0))
+               *last_idx = hw->last_ridx;
 
        return count;
 }
@@ -422,11 +429,15 @@ skeldma_completed_status(void *dev_private,
        count = RTE_MIN(nb_cpls, rte_ring_count(hw->desc_completed));
        while (index < count) {
                (void)rte_ring_dequeue(hw->desc_completed, (void **)&desc);
-               if (index == count - 1)
+               if (index == count - 1) {
+                       hw->last_ridx = desc->ridx;
                        *last_idx = desc->ridx;
+               }
                status[index++] = RTE_DMA_STATUS_SUCCESSFUL;
                (void)rte_ring_enqueue(hw->desc_empty, (void *)desc);
        }
+       if (unlikely(count == 0))
+               *last_idx = hw->last_ridx;
 
        return count;
 }
index 91eb5460fce5388f95f8fd90b658f7add17a86cd..6f894004809b25c46fe4feabb644ab5bd49f8281 100644 (file)
@@ -50,6 +50,7 @@ struct skeldma_hw {
        /* Cache delimiter for dataplane API's operation data */
        char cache1 __rte_cache_aligned;
        uint16_t ridx;  /* ring idx */
+       uint16_t last_ridx;
        uint64_t submitted_count;
 
        /* Cache delimiter for cpucopy thread's operation data */