[v4,3/4] raw/ifpga/base: cleanup ifpga raw devices when process quit
diff mbox series

Message ID 1600846213-18093-4-git-send-email-tianfei.zhang@intel.com
State Superseded
Delegated to: Qi Zhang
Headers show
Series
  • raw/ifpga/base: An inprovement for multi-process
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Zhang, Tianfei Sept. 23, 2020, 7:30 a.m. UTC
From: Wei Huang <wei.huang@intel.com>

Add function ifpga_rawdev_cleanup() to cleanup all ifpga
raw devices and register it as RTE_FINI function to make
it called after main().

Signed-off-by: Wei Huang <wei.huang@intel.com>
Signed-off-by: Tianfei zhang <tianfei.zhang@intel.com>
---
 drivers/raw/ifpga/ifpga_rawdev.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

Patch
diff mbox series

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index 98b02b5fa..1bc500a2a 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -1609,6 +1609,26 @@  RTE_PMD_REGISTER_PCI_TABLE(ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd);
 RTE_PMD_REGISTER_KMOD_DEP(ifpga_rawdev_pci_driver, "* igb_uio | uio_pci_generic | vfio-pci");
 RTE_LOG_REGISTER(ifpga_rawdev_logtype, driver.raw.init, NOTICE);
 
+RTE_FINI(ifpga_rawdev_cleanup)
+{
+	struct ifpga_rawdev *dev;
+	struct opae_adapter *adapter;
+	unsigned int i;
+
+	for (i = 0; i < IFPGA_RAWDEV_NUM; i++) {
+		dev = &ifpga_rawdevices[i];
+		if (dev->rawdev) {
+			adapter = ifpga_rawdev_get_priv(dev->rawdev);
+			if (adapter) {
+				opae_adapter_destroy(adapter);
+				opae_adapter_data_free(adapter->data);
+			}
+			rte_rawdev_pmd_release(dev->rawdev);
+			dev->rawdev = NULL;
+		}
+	}
+}
+
 static const char * const valid_args[] = {
 #define IFPGA_ARG_NAME         "ifpga"
 	IFPGA_ARG_NAME,