patch 'net/iavf: unregister interrupt handler before FD close' has been queued to stable release 22.11.4

Xueming Li xuemingl at nvidia.com
Sun Oct 22 16:21:57 CEST 2023


Hi,

FYI, your patch has been queued to stable release 22.11.4

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 11/15/23. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=efdea6d6f43f02f533617471a72e7bc184cfe367

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From efdea6d6f43f02f533617471a72e7bc184cfe367 Mon Sep 17 00:00:00 2001
From: Saurabh Singhal <saurabhs at arista.com>
Date: Wed, 6 Sep 2023 20:15:29 -0700
Subject: [PATCH] net/iavf: unregister interrupt handler before FD close
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit e35a5737a7469423880a0946afffd2568f6156dd ]

Unregister VFIO interrupt handler before the interrupt fd gets closed in
case iavf_dev_init() returns an error.

dpdk creates a standalone thread named eal-intr-thread for processing
interrupts for the PCI devices. The interrupt handler callbacks are
registered by the VF driver(iavf, in this case).

When we do a PCI probe of the network interfaces, we register an
interrupt handler, open a vfio-device fd using ioctl, and an eventfd in
dpdk. These interrupt sources are registered in a global linked list
that the eal-intr-thread keeps iterating over for handling the
interrupts. In our internal testing, we see eal-intr-thread crash in
these two ways:

Error adding fd 660 epoll_ctl, Operation not permitted

or

Error adding fd 660 epoll_ctl, Bad file descriptor

epoll_ctl() returns EPERM if the target fd does not support poll.
It returns EBADF when the epoll fd itself is closed or the target fd is
closed.

When the first type of crash happens, we see that the fd 660 is
anon_inode:[vfio-device] which does not support poll.

When the second type of crash happens, we could see from the fd map of
the crashing process that the fd 660 was already closed.

This means the said fd has been closed and in certain cases may have
been reassigned to a different device by the operating system but the
eal-intr-thread does not know about it.

We observed that these crashes were always accompanied by an error in
iavf_dev_init() after rte_intr_callback_register() and
iavf_enable_irq0() have already happened. In the error path, the
intr_handle_fd was being closed but the interrupt handler wasn't being
unregistered.

The fix is to unregister the interrupt handle in the
iavf_dev_init() error path.

Ensure proper cleanup if iavf_security_init() or
iavf_security_ctx_create() fail. Earlier, we were leaking memory by
simply returning from iavf_dev_init().

Fixes: 22b123a36d07 ("net/avf: initialize PMD")
Fixes: 6bc987ecb860 ("net/iavf: support IPsec inline crypto")

Signed-off-by: Saurabh Singhal <saurabhs at arista.com>
Acked-by: Qi Zhang <qi.z.zhang at intel.com>
---
 .mailmap                       |  1 +
 drivers/net/iavf/iavf_ethdev.c | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/.mailmap b/.mailmap
index d3c05941d5..83b960753a 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1193,6 +1193,7 @@ Satananda Burla <sburla at marvell.com>
 Satha Rao <skoteshwar at marvell.com> <skoteshwar at caviumnetworks.com>
 Satheesh Paul <psatheesh at marvell.com>
 Sathesh Edara <sedara at marvell.com>
+Saurabh Singhal <saurabhs at arista.com>
 Savinay Dharmappa <savinay.dharmappa at intel.com>
 Scott Branden <scott.branden at broadcom.com>
 Scott Daniels <daniels at research.att.com>
diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index fb2c9364cd..fce56d33cc 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -131,6 +131,8 @@ static int iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
 					uint16_t queue_id);
 static int iavf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev,
 					 uint16_t queue_id);
+static void iavf_dev_interrupt_handler(void *param);
+static void iavf_disable_irq0(struct iavf_hw *hw);
 static int iavf_dev_flow_ops_get(struct rte_eth_dev *dev,
 				 const struct rte_flow_ops **ops);
 static int iavf_set_mc_addr_list(struct rte_eth_dev *dev,
@@ -2689,13 +2691,13 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
 		ret = iavf_security_ctx_create(adapter);
 		if (ret) {
 			PMD_INIT_LOG(ERR, "failed to create ipsec crypto security instance");
-			return ret;
+			goto flow_init_err;
 		}

 		ret = iavf_security_init(adapter);
 		if (ret) {
 			PMD_INIT_LOG(ERR, "failed to initialized ipsec crypto resources");
-			return ret;
+			goto security_init_err;
 		}
 	}

@@ -2709,7 +2711,23 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)

 	return 0;

+security_init_err:
+	iavf_security_ctx_destroy(adapter);
+
 flow_init_err:
+	iavf_disable_irq0(hw);
+
+	if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) {
+		/* disable uio intr before callback unregiser */
+		rte_intr_disable(pci_dev->intr_handle);
+
+		/* unregister callback func from eal lib */
+		rte_intr_callback_unregister(pci_dev->intr_handle,
+					     iavf_dev_interrupt_handler, eth_dev);
+	} else {
+		rte_eal_alarm_cancel(iavf_dev_alarm_handler, eth_dev);
+	}
+
 	rte_free(eth_dev->data->mac_addrs);
 	eth_dev->data->mac_addrs = NULL;

--
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-10-22 22:17:37.576185500 +0800
+++ 0088-net-iavf-unregister-interrupt-handler-before-FD-clos.patch	2023-10-22 22:17:34.336723700 +0800
@@ -1 +1 @@
-From e35a5737a7469423880a0946afffd2568f6156dd Mon Sep 17 00:00:00 2001
+From efdea6d6f43f02f533617471a72e7bc184cfe367 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit e35a5737a7469423880a0946afffd2568f6156dd ]
@@ -55 +57,0 @@
-Cc: stable at dpdk.org
@@ -65 +67 @@
-index 013ad8cbca..d35257d6eb 100644
+index d3c05941d5..83b960753a 100644
@@ -68 +70 @@
-@@ -1235,6 +1235,7 @@ Satananda Burla <sburla at marvell.com>
+@@ -1193,6 +1193,7 @@ Satananda Burla <sburla at marvell.com>
@@ -77 +79 @@
-index 27a6a7b80f..97390237ba 100644
+index fb2c9364cd..fce56d33cc 100644
@@ -80 +82 @@
-@@ -133,6 +133,8 @@ static int iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
+@@ -131,6 +131,8 @@ static int iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev,
@@ -89 +91 @@
-@@ -2736,13 +2738,13 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
+@@ -2689,13 +2691,13 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
@@ -105 +107 @@
-@@ -2756,7 +2758,23 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)
+@@ -2709,7 +2711,23 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)


More information about the stable mailing list