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 DB98E431D5 for ; Sun, 22 Oct 2023 16:30:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D435A40EDB; Sun, 22 Oct 2023 16:30:48 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2075.outbound.protection.outlook.com [40.107.92.75]) by mails.dpdk.org (Postfix) with ESMTP id 058AB4027E for ; Sun, 22 Oct 2023 16:30:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JdB4QY3vPag/8M/5C27m6PFl6PzjH0oNnYsxzxZgxRbO22uvuQNh4Fcg28fw3NCjeOSazjXckUqtPs9Aoyy4iXQ8FS5qddE7febZObiQwL9zMbOCn1Hxbc7CF7Lhk3SgslUi+Zo/iopfEarRg/HQNLIy3m/p5z8cq8Sg1RzVH9iLGtVYq5LfzFLX/Swf0GDMxbWNyc0LV/1U9MWoFowCik9Um51chr1KImmlp7OkDT6sBrbYKpJqt0Ja85kAaL7PV/WCcXWLwKor9OaOyu390YAv7v8gc81VGUl/ctEMED05AwlLHqXZmdFJ64O2mrCEHyvwHUUNduj77emSk490eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+vEtXbOMjsECEYzBgoUz6OdS1PrAuqKdq/CzAWucFCs=; b=iBLPd+23HXGQ+clc3cX/6oeNWyl3HOjn7zwrAh2ll49p+t28lNFSMoaam9wVYM44y7VoyRbGpnhdSfMJtOGiw2TGWX8G9G0qBWXssqrCu6tGYQJqLcoWwaGgWBjG5GLwoNs0IcQ/Q5F3rN6GJuOXUvUKIIbaBWTj8zIwPaO2NgHHPgqXTSKDM472+cjxMlrhB+MR2rw8gXxyLOAeBEQSNcMBZKyAjxGH2z8nyyBWsZQo3J07ScZeagmj0GN06olLO665d4S4IRUcLbitDRhYlYGaKPG+qJy3heatFtrIR+kGuAqxII7b6rD4UmbeJJfzeEm6eEHmXFowZCK46iK73Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=arista.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+vEtXbOMjsECEYzBgoUz6OdS1PrAuqKdq/CzAWucFCs=; b=hzM/HRcOZ9oL4u7cRYSA5kynHPnR8s8B1Pa0Ww3kLPYfxfgHtw+KdLDkMRuwgLWetQh3/hv5acbJpZya1NFq7J/blJyDd+RY2qYDUHEL0g1CCYs5clxyG3aycQ1oE1c5wSNvVSpxKb6/78r0tcbmMCeJykd979J1WF0OZ6dXq7Xc3mKQhyDnx4BECRk+8Nn10usivKPYHvlqNC1sHdD9I5fGNGVEN47af7cKMLdROee3gAQ4C2pSPJ7evlq8YjAXqOgLNWtaCZIL66/GUlbekbmO4SYyFTVewdTCieuOsiks4SWYPnWkllzX9AaDwi22XiicEp+ur4IXjyX7hjbzRg== Received: from DS7PR05CA0061.namprd05.prod.outlook.com (2603:10b6:8:57::15) by SJ0PR12MB7065.namprd12.prod.outlook.com (2603:10b6:a03:4ae::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Sun, 22 Oct 2023 14:30:44 +0000 Received: from DS1PEPF0001708F.namprd03.prod.outlook.com (2603:10b6:8:57:cafe::64) by DS7PR05CA0061.outlook.office365.com (2603:10b6:8:57::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.15 via Frontend Transport; Sun, 22 Oct 2023 14:30:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS1PEPF0001708F.mail.protection.outlook.com (10.167.17.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.15 via Frontend Transport; Sun, 22 Oct 2023 14:30:44 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Sun, 22 Oct 2023 07:30:35 -0700 Received: from nvidia.com (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Sun, 22 Oct 2023 07:30:33 -0700 From: Xueming Li To: Saurabh Singhal CC: Qi Zhang , dpdk stable Subject: patch 'net/iavf: unregister interrupt handler before FD close' has been queued to stable release 22.11.4 Date: Sun, 22 Oct 2023 22:21:57 +0800 Message-ID: <20231022142250.10324-89-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231022142250.10324-1-xuemingl@nvidia.com> References: <20231022142250.10324-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail201.nvidia.com (10.129.68.8) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0001708F:EE_|SJ0PR12MB7065:EE_ X-MS-Office365-Filtering-Correlation-Id: e551fce1-708d-4bb2-ab2c-08dbd30b79ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VpC4rHEnM3W2nqwZ98RqZ0F/VKe7qiV6eK3i/6ogWxvf6SElQ6Ar8S36aR0kXwQvTGw6E/J2rWX6flyw5hg3/XfoJU4o1BPxQvTp2mAdMSwjF1lYQG3bE1rDitaMLYKSE+9wtqv7jwwWei9HADOHbRY0lVSaf8rtja3qSXsEc859Pqrdkrz1nMhOF4fudBr2Slyz+OF8J0BiBzNcSKZ88fOH2+U8xDoZYBnZXZ6YErbMOnLaH9dWgqCiz+BwzCrMVt9VpwVDf597bUB4XJH31itZOfA1IrEnOsvgYiaWYtGD48hBErQaL+CtHdHjqbru7hb/VPdak0l/nu38FCiW1vsM0YUFBIujw55e/Yyx3LA9lyXMzs8mk5JXLyMg91ml5UqmgUpDv9uFsgWYXiynDcbOQXZiV57xnSqy0GSyOybbCBUmkLjfeRyx8qt7Z61PR7sKr5RUS6WAlgkTgkjyL7NILsDDDEh6NAaaEQIZuwWcICWTFl0ZYJWdQJZKrSziBBqfsMRRZ2ZD5XXa5F4rOBG2+coJ0f2fbMP5psWe2gGfpRYZz2uvrJ5PufF3m/Ci8gcESpInIKUws8WYSPEg5tTPmsCI7Q3plM2awp1jwWHFywVspvuIAyBcrWn0dOcEXHI1V5gH21kKfv/U5k3xaWhD0I5j5DIG58S7OPcaVZ1r0ausEvVOUkMPSI00aQ0/hlxmylUIZjy9PrhUXyiwuoB+AtlFBtU1g11H5PJdgInzmxpLFvPaaMd5SrFdiA++qnsLVFj+eWtQk2tzfmLbaAbnVuJkgNjJKudcz6qLEuE= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(136003)(39860400002)(346002)(396003)(376002)(230922051799003)(451199024)(64100799003)(82310400011)(186009)(1800799009)(46966006)(40470700004)(36840700001)(40460700003)(55016003)(6286002)(336012)(16526019)(7696005)(6666004)(36860700001)(53546011)(4001150100001)(426003)(2616005)(83380400001)(47076005)(8676002)(41300700001)(8936002)(4326008)(5660300002)(2906002)(478600001)(966005)(70586007)(70206006)(54906003)(316002)(1076003)(6916009)(356005)(7636003)(82740400003)(86362001)(40480700001)(40140700001)(36756003)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2023 14:30:44.5018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e551fce1-708d-4bb2-ab2c-08dbd30b79ea X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0001708F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB7065 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 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 --- >From efdea6d6f43f02f533617471a72e7bc184cfe367 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 Cc: Xueming Li [ 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 d3c05941d5..83b960753a 100644 --- a/.mailmap +++ b/.mailmap @@ -1193,6 +1193,7 @@ Satananda Burla Satha Rao Satheesh Paul Sathesh Edara +Saurabh Singhal Savinay Dharmappa Scott Branden Scott Daniels 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 + +[ upstream commit e35a5737a7469423880a0946afffd2568f6156dd ] @@ -55 +57,0 @@ -Cc: stable@dpdk.org @@ -65 +67 @@ -index 013ad8cbca..d35257d6eb 100644 +index d3c05941d5..83b960753a 100644 @@ -68 +70 @@ -@@ -1235,6 +1235,7 @@ Satananda Burla +@@ -1193,6 +1193,7 @@ Satananda Burla @@ -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)