[PATCH 24.11 3/3] [PATCH 24.11] app/dma-perf: fix stopping device
Chengwen Feng
fengchengwen at huawei.com
Tue Nov 25 02:51:30 CET 2025
[ upstream commit cca4c3bc3feb16226480ea9b3c1dc5e7f0116fee ]
The benchmark do stop-dmadev at last, it has two problem:
1. it still invoke stop-dmadev when something wrong before
config-dmadev.
2. the dmadev may working but the memory are freed.
Fixes: 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")
Cc: stable at dpdk.org
Signed-off-by: Chengwen Feng <fengchengwen at huawei.com>
---
app/test-dma-perf/benchmark.c | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/app/test-dma-perf/benchmark.c b/app/test-dma-perf/benchmark.c
index fc583725c4..537cc7618c 100644
--- a/app/test-dma-perf/benchmark.c
+++ b/app/test-dma-perf/benchmark.c
@@ -257,6 +257,25 @@ config_dmadevs(struct test_configure *cfg)
return 0;
}
+static void
+stop_dmadev(struct test_configure *cfg, bool *stopped)
+{
+ struct lcore_dma_map_t *lcore_dma_map;
+ uint32_t i;
+
+ if (*stopped)
+ return;
+
+ if (cfg->is_dma) {
+ for (i = 0; i < cfg->num_worker; i++) {
+ lcore_dma_map = &cfg->dma_config[i].lcore_dma_map;
+ printf("Stopping dmadev %d\n", lcore_dma_map->dma_id);
+ rte_dma_stop(lcore_dma_map->dma_id);
+ }
+ }
+ *stopped = true;
+}
+
static void
error_exit(int dev_id)
{
@@ -709,6 +728,7 @@ mem_copy_benchmark(struct test_configure *cfg)
float memory = 0;
uint32_t avg_cycles = 0;
uint32_t avg_cycles_total;
+ bool dev_stopped = false;
float mops, mops_total;
float bandwidth, bandwidth_total;
uint32_t nr_sgsrc = 0, nr_sgdst = 0;
@@ -770,7 +790,7 @@ mem_copy_benchmark(struct test_configure *cfg)
vchan_dev->tdir == RTE_DMA_DIR_MEM_TO_DEV) {
if (attach_ext_buffer(vchan_dev, lcores[i], cfg->is_sg,
(nr_sgsrc/nb_workers), (nr_sgdst/nb_workers)) < 0)
- goto out;
+ goto stop_dmadev;
}
rte_eal_remote_launch(get_work_function(cfg), (void *)(lcores[i]), lcore_id);
@@ -805,6 +825,8 @@ mem_copy_benchmark(struct test_configure *cfg)
rte_eal_mp_wait_lcore();
+ stop_dmadev(cfg, &dev_stopped);
+
for (k = 0; k < nb_workers; k++) {
struct rte_mbuf **src_buf = NULL, **dst_buf = NULL;
uint32_t nr_buf_pt = nr_buf / nb_workers;
@@ -889,6 +911,8 @@ mem_copy_benchmark(struct test_configure *cfg)
cfg->scenario_id, nr_buf, memory * nb_workers,
(avg_cycles_total * (float) 1.0) / nb_workers, bandwidth_total, mops_total);
+stop_dmadev:
+ stop_dmadev(cfg, &dev_stopped);
out:
for (k = 0; k < nb_workers; k++) {
@@ -944,13 +968,5 @@ mem_copy_benchmark(struct test_configure *cfg)
lcores[i] = NULL;
}
- if (cfg->is_dma) {
- for (i = 0; i < nb_workers; i++) {
- lcore_dma_map = &cfg->dma_config[i].lcore_dma_map;
- printf("Stopping dmadev %d\n", lcore_dma_map->dma_id);
- rte_dma_stop(lcore_dma_map->dma_id);
- }
- }
-
return ret;
}
--
2.17.1
More information about the stable
mailing list