ixgbevf_dev_close() unregisters its interrupt callback
only once.
If the callback is running at that time,
rte_intr_callback_unregister() returns -EAGAIN and the
callback stays registered: its allocation is leaked,
it keeps a pointer to the closed device, and a reset
registers a second one.
The PF close already retries in that case.
Wait for the running callback to complete before
unregistering.
When close is called from the callback itself,
e.g. by an application resetting or closing the
port on RTE_ETH_EVENT_INTR_RESET, waiting would
never end, so defer the removal until the
callback returns instead.
Fixes: 77234603fba0 ("net/ixgbe: support VF mailbox interrupt for link up/down")
Cc: [email protected]
Signed-off-by: Anurag Mandal <[email protected]>
---
drivers/net/intel/ixgbe/ixgbe_ethdev.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/net/intel/ixgbe/ixgbe_ethdev.c
b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
index 003fe32891..231319d02f 100644
--- a/drivers/net/intel/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/intel/ixgbe/ixgbe_ethdev.c
@@ -5648,8 +5648,16 @@ ixgbevf_dev_close(struct rte_eth_dev *dev)
ixgbevf_remove_mac_addr(dev, 0);
rte_intr_disable(intr_handle);
- rte_intr_callback_unregister(intr_handle,
- ixgbevf_dev_interrupt_handler, dev);
+ if (rte_intr_callback_unregister(intr_handle,
+ ixgbevf_dev_interrupt_handler, dev) == -EAGAIN) {
+ /* the handler may be our caller and cannot be waited for */
+ if (rte_thread_is_intr())
+ rte_intr_callback_unregister_pending(intr_handle,
+ ixgbevf_dev_interrupt_handler, dev,
NULL);
+ else
+ rte_intr_callback_unregister_sync(intr_handle,
+ ixgbevf_dev_interrupt_handler, dev);
+ }
return ret;
}
--
2.25.1