@@ -268,6 +268,25 @@ config_dmadevs(struct test_configure *cfg)
268268 return 0 ;
269269}
270270
271+ static void
272+ stop_dmadev (struct test_configure * cfg , bool * stopped )
273+ {
274+ struct lcore_dma_map_t * lcore_dma_map ;
275+ uint32_t i ;
276+
277+ if (* stopped )
278+ return ;
279+
280+ if (cfg -> test_type == TEST_TYPE_DMA_MEM_COPY ) {
281+ for (i = 0 ; i < cfg -> num_worker ; i ++ ) {
282+ lcore_dma_map = & cfg -> dma_config [i ].lcore_dma_map ;
283+ printf ("Stopping dmadev %d\n" , lcore_dma_map -> dma_id );
284+ rte_dma_stop (lcore_dma_map -> dma_id );
285+ }
286+ }
287+ * stopped = true;
288+ }
289+
271290static void
272291error_exit (int dev_id )
273292{
@@ -880,6 +899,7 @@ mem_copy_benchmark(struct test_configure *cfg)
880899 float bandwidth , bandwidth_total ;
881900 unsigned int lcore_id = 0 ;
882901 uint32_t avg_cycles_total ;
902+ bool dev_stopped = false;
883903 uint32_t avg_cycles = 0 ;
884904 float mops , mops_total ;
885905 float memory = 0 ;
@@ -943,7 +963,7 @@ mem_copy_benchmark(struct test_configure *cfg)
943963 vchan_dev -> tdir == RTE_DMA_DIR_MEM_TO_DEV ) {
944964 if (attach_ext_buffer (vchan_dev , lcores [i ], cfg -> is_sg ,
945965 (nr_sgsrc /nb_workers ), (nr_sgdst /nb_workers )) < 0 )
946- goto out ;
966+ goto stop_dmadev ;
947967 }
948968
949969 if (cfg -> is_sg && cfg -> use_ops ) {
@@ -997,6 +1017,8 @@ mem_copy_benchmark(struct test_configure *cfg)
9971017
9981018 rte_eal_mp_wait_lcore ();
9991019
1020+ stop_dmadev (cfg , & dev_stopped );
1021+
10001022 ret = verify_data (cfg , srcs , dsts , nr_buf );
10011023 if (ret != 0 )
10021024 goto out ;
@@ -1022,8 +1044,10 @@ mem_copy_benchmark(struct test_configure *cfg)
10221044 output_csv (CSV_TOTAL_LINE_FMT , cfg -> scenario_id , nr_buf , memory * nb_workers ,
10231045 (avg_cycles_total * (float ) 1.0 ) / nb_workers , bandwidth_total , mops_total );
10241046
1025- out :
1047+ stop_dmadev :
1048+ stop_dmadev (cfg , & dev_stopped );
10261049
1050+ out :
10271051 for (k = 0 ; k < nb_workers ; k ++ ) {
10281052 struct rte_mbuf * * sbuf = NULL , * * dbuf = NULL ;
10291053 vchan_dev = & cfg -> dma_config [k ].vchan_dev ;
@@ -1077,13 +1101,5 @@ mem_copy_benchmark(struct test_configure *cfg)
10771101 lcores [i ] = NULL ;
10781102 }
10791103
1080- if (cfg -> test_type == TEST_TYPE_DMA_MEM_COPY ) {
1081- for (i = 0 ; i < nb_workers ; i ++ ) {
1082- lcore_dma_map = & cfg -> dma_config [i ].lcore_dma_map ;
1083- printf ("Stopping dmadev %d\n" , lcore_dma_map -> dma_id );
1084- rte_dma_stop (lcore_dma_map -> dma_id );
1085- }
1086- }
1087-
10881104 return ret ;
10891105}
0 commit comments