From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B29144326F for ; Thu, 2 Nov 2023 14:14:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F3D8A42E13; Thu, 2 Nov 2023 14:14:33 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 4AF7042DDB for ; Thu, 2 Nov 2023 14:14:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698930871; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Btt68zONvMmsfdMr3Ie98UsK+00XAbwctx1kO75Tj+w=; b=F5XmSSF9OLYyqXPlGoAXYn9TDPaXenZoPiMv4d8LMBnroyQGEgMXV+1We/YG9uwrsBGS2F GA+eGOgsGLeeYfk/KpyzROGGfqYdbM2IqqpcPwZVWjBH3+OGVEagO+qxk+KmifqdMBt4c1 /OjPs6vp2nX1VHQpNwzsvzI+kLVNVGY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-318-lV9VhC2fNq6vsK3Ur_P81A-1; Thu, 02 Nov 2023 09:14:29 -0400 X-MC-Unique: lV9VhC2fNq6vsK3Ur_P81A-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E65CE82BA82; Thu, 2 Nov 2023 13:14:28 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 038EB474FA0; Thu, 2 Nov 2023 13:14:27 +0000 (UTC) From: Kevin Traynor To: Saurabh Singhal Cc: Qi Zhang , dpdk stable Subject: patch 'net/iavf: unregister interrupt handler before FD close' has been queued to stable release 21.11.6 Date: Thu, 2 Nov 2023 13:12:06 +0000 Message-ID: <20231102131254.315947-60-ktraynor@redhat.com> In-Reply-To: <20231102131254.315947-1-ktraynor@redhat.com> References: <20231102131254.315947-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.6 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/08/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://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/77aff6a04619079eb4fc934ba5c8859be5288b28 Thanks. Kevin --- >From 77aff6a04619079eb4fc934ba5c8859be5288b28 Mon Sep 17 00:00:00 2001 From: Saurabh Singhal Date: Wed, 6 Sep 2023 20:15:29 -0700 Subject: [PATCH] net/iavf: unregister interrupt handler before FD close [ 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 Acked-by: Qi Zhang --- .mailmap | 1 + drivers/net/iavf/iavf_ethdev.c | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.mailmap b/.mailmap index 743366389a..f0aac43189 100644 --- a/.mailmap +++ b/.mailmap @@ -1194,4 +1194,5 @@ Satha Rao Satheesh Paul Sathesh Edara +Saurabh Singhal Savinay Dharmappa Scott Branden diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index f9eef7233d..2214ba9545 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -126,4 +126,6 @@ static int iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, 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); @@ -2614,5 +2616,5 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) if (ret) { PMD_INIT_LOG(ERR, "failed to create ipsec crypto security instance"); - return ret; + goto flow_init_err; } @@ -2620,5 +2622,5 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) if (ret) { PMD_INIT_LOG(ERR, "failed to initialized ipsec crypto resources"); - return ret; + goto security_init_err; } } @@ -2634,5 +2636,21 @@ 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.41.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-11-02 13:09:42.283195979 +0000 +++ 0060-net-iavf-unregister-interrupt-handler-before-FD-clos.patch 2023-11-02 13:09:40.870163518 +0000 @@ -1 +1 @@ -From e35a5737a7469423880a0946afffd2568f6156dd Mon Sep 17 00:00:00 2001 +From 77aff6a04619079eb4fc934ba5c8859be5288b28 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit e35a5737a7469423880a0946afffd2568f6156dd ] + @@ -55 +56,0 @@ -Cc: stable@dpdk.org @@ -65 +66 @@ -index 013ad8cbca..d35257d6eb 100644 +index 743366389a..f0aac43189 100644 @@ -68 +69 @@ -@@ -1236,4 +1236,5 @@ Satha Rao +@@ -1194,4 +1194,5 @@ Satha Rao @@ -75 +76 @@ -index 27a6a7b80f..97390237ba 100644 +index f9eef7233d..2214ba9545 100644 @@ -78 +79 @@ -@@ -134,4 +134,6 @@ static int iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, +@@ -126,4 +126,6 @@ static int iavf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, @@ -85 +86 @@ -@@ -2737,5 +2739,5 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) +@@ -2614,5 +2616,5 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) @@ -92 +93 @@ -@@ -2743,5 +2745,5 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) +@@ -2620,5 +2622,5 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) @@ -99 +100 @@ -@@ -2757,5 +2759,21 @@ iavf_dev_init(struct rte_eth_dev *eth_dev) +@@ -2634,5 +2636,21 @@ iavf_dev_init(struct rte_eth_dev *eth_dev)