[4/5] app/testpmd: stop and close dmadevs at exit

Message ID 20220408141504.1319913-5-kevin.laatz@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Fix IDXD PCI device close |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Kevin Laatz April 8, 2022, 2:15 p.m. UTC
  DMA devices are created during PCI probe in EAL init. In order to
perform cleanup for those devices, they need to be stopped and closed.
This patch adds the necessary cleanup to ensure clean exit.

Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
---
 app/test-pmd/testpmd.c | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Comments

Bruce Richardson April 12, 2022, 1:36 p.m. UTC | #1
On Fri, Apr 08, 2022 at 03:15:03PM +0100, Kevin Laatz wrote:
> DMA devices are created during PCI probe in EAL init. In order to
> perform cleanup for those devices, they need to be stopped and closed.
> This patch adds the necessary cleanup to ensure clean exit.
> 
> Signed-off-by: Kevin Laatz <kevin.laatz@intel.com>
> ---
>  app/test-pmd/testpmd.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> index fe2ce19f99..438749c5b8 100644
> --- a/app/test-pmd/testpmd.c
> +++ b/app/test-pmd/testpmd.c
> @@ -45,6 +45,7 @@
>  #include <rte_pci.h>
>  #include <rte_ether.h>
>  #include <rte_ethdev.h>
> +#include <rte_dmadev.h>

This addition triggers a build error for me, as the header is not found.
Does dmadev need to be added as a testpmd dependency in this case?
  

Patch

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index fe2ce19f99..438749c5b8 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -45,6 +45,7 @@ 
 #include <rte_pci.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
+#include <rte_dmadev.h>
 #include <rte_dev.h>
 #include <rte_string_fns.h>
 #ifdef RTE_NET_IXGBE
@@ -3402,6 +3403,14 @@  pmd_test_exit(void)
 		}
 	}
 
+	/* stop and close all dmadevs */
+	RTE_DMA_FOREACH_DEV(i) {
+		printf("\nStopping and closing dmadev %d...\n", i);
+		fflush(stdout);
+		rte_dma_stop(i);
+		rte_dma_close(i);
+	}
+
 	if (hot_plug) {
 		ret = rte_dev_event_monitor_stop();
 		if (ret) {