[7/7] net/iavf: fix port close

Message ID 20200811062917.7007-8-stevex.yang@intel.com (mailing list archive)
State Superseded, archived
Headers
Series Bugs Porting from I40evf For IAVF Feature |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed

Commit Message

Steve Yang Aug. 11, 2020, 6:29 a.m. UTC
  From: "Zhang, RobinX" <robinx.zhang@intel.com>

Port reset will call iavf_dev_uninit() to release resources. It wants
to call iavf_dev_close() to release resources. So there will be a
call conflict if calling iavf_dev_reset() and iavf_dev_close() at the
same time.

This patch added adapter->closed flag in iavf_dev_close()
to control the status of close.

Fixes: 83fe5e80692a ("net/iavf: move device state flag")

Signed-off-by: SteveX Yang <stevex.yang@intel.com>
---
 drivers/net/iavf/iavf.h        | 1 +
 drivers/net/iavf/iavf_ethdev.c | 6 ++++++
 2 files changed, 7 insertions(+)
  

Patch

diff --git a/drivers/net/iavf/iavf.h b/drivers/net/iavf/iavf.h
index 9be8a2381..06cbe6089 100644
--- a/drivers/net/iavf/iavf.h
+++ b/drivers/net/iavf/iavf.h
@@ -161,6 +161,7 @@  struct iavf_adapter {
 	bool tx_vec_allowed;
 	const uint32_t *ptype_tbl;
 	bool stopped;
+	bool closed;
 	uint16_t fdir_ref_cnt;
 };
 
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index f16aff531..b58e57b07 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -1367,6 +1367,7 @@  iavf_dev_init(struct rte_eth_dev *eth_dev)
 	hw->back = IAVF_DEV_PRIVATE_TO_ADAPTER(eth_dev->data->dev_private);
 	adapter->eth_dev = eth_dev;
 	adapter->stopped = 1;
+	adapter->closed = 0;
 
 	if (iavf_init_vf(eth_dev) != 0) {
 		PMD_INIT_LOG(ERR, "Init vf failed");
@@ -1423,6 +1424,9 @@  iavf_dev_close(struct rte_eth_dev *dev)
 	struct iavf_adapter *adapter =
 		IAVF_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
 
+	if (adapter->closed == 1)
+		return;
+
 	iavf_dev_stop(dev);
 	iavf_flow_flush(dev, NULL);
 	iavf_flow_uninit(adapter);
@@ -1434,6 +1438,8 @@  iavf_dev_close(struct rte_eth_dev *dev)
 	rte_intr_callback_unregister(intr_handle,
 				     iavf_dev_interrupt_handler, dev);
 	iavf_disable_irq0(hw);
+
+	adapter->closed = 1;
 }
 
 static int