[3/5] app/test: close dma devices during cleanup

Message ID 20220408141504.1319913-4-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 of EAL init. These devices
need to be closed in order to perform necessary cleanup for those
devices. This patch adds the call to close() for all DMA devices.

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

Comments

Bruce Richardson April 8, 2022, 2:55 p.m. UTC | #1
On Fri, Apr 08, 2022 at 03:15:02PM +0100, Kevin Laatz wrote:
> DMA devices are created during PCI probe of EAL init. These devices need
> to be closed in order to perform necessary cleanup for those devices.
> This patch adds the call to close() for all DMA devices.
> 
> Signed-off-by: Kevin Laatz <kevin.laatz@intel.com> --- app/test/test.c |
> 6 ++++++ 1 file changed, 6 insertions(+)
> 
Just to clarify the situation here - on EAL init, all buses are probed and
all devices initialized. On eal_cleanup/rte_exit the inverse does not
happen, then, i.e. all probed devices on all buses are not closed, right?
This would seem a better option than requiring each application to manually
close all devices even if it never used them. However, it is probably a
bigger and more complex change.

/Bruce
  
Kevin Laatz April 19, 2022, 4:18 p.m. UTC | #2
On 08/04/2022 15:55, Bruce Richardson wrote:
> On Fri, Apr 08, 2022 at 03:15:02PM +0100, Kevin Laatz wrote:
>> DMA devices are created during PCI probe of EAL init. These devices need
>> to be closed in order to perform necessary cleanup for those devices.
>> This patch adds the call to close() for all DMA devices.
>>
>> Signed-off-by: Kevin Laatz <kevin.laatz@intel.com> --- app/test/test.c |
>> 6 ++++++ 1 file changed, 6 insertions(+)
>>
> Just to clarify the situation here - on EAL init, all buses are probed and
> all devices initialized. On eal_cleanup/rte_exit the inverse does not
> happen, then, i.e. all probed devices on all buses are not closed, right?
> This would seem a better option than requiring each application to manually
> close all devices even if it never used them. However, it is probably a
> bigger and more complex change.

+1, precisely.

I've prepared an RFC to explore option of adding bus cleanup to 
eal_cleanup() to start a discussion on that option.

https://patches.dpdk.org/project/dpdk/patch/20220419161438.1837860-1-kevin.laatz@intel.com/

BR,
Kevin
  

Patch

diff --git a/app/test/test.c b/app/test/test.c
index e69cae3eea..cc986e5cc9 100644
--- a/app/test/test.c
+++ b/app/test/test.c
@@ -24,6 +24,7 @@  extern cmdline_parse_ctx_t main_ctx[];
 #include <rte_cycles.h>
 #include <rte_log.h>
 #include <rte_string_fns.h>
+#include <rte_dmadev.h>
 #ifdef RTE_LIB_TIMER
 #include <rte_timer.h>
 #endif
@@ -244,6 +245,11 @@  main(int argc, char **argv)
 #ifdef RTE_LIB_TIMER
 	rte_timer_subsystem_finalize();
 #endif
+
+	/* close all dmadevs */
+	RTE_DMA_FOREACH_DEV(i)
+		rte_dma_close(i);
+
 	rte_eal_cleanup();
 	return ret;
 }