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 E8AA5A0C43; Wed, 20 Oct 2021 15:15:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E2944118F; Wed, 20 Oct 2021 15:15:49 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id DC09740142; Wed, 20 Oct 2021 15:15:47 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 6B69B7F6C1; Wed, 20 Oct 2021 16:15:47 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id BF6EA7F530; Wed, 20 Oct 2021 16:15:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru BF6EA7F530 Authentication-Results: shelob.oktetlabs.ru/BF6EA7F530; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: Thomas Monjalon , Ferruh Yigit , Tetsuya Mukawa Cc: dev@dpdk.org, Maxime Coquelin , Chenbo Xia , stable@dpdk.org Date: Wed, 20 Oct 2021 16:15:40 +0300 Message-Id: <20211020131540.2957180-1-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211020104715.2526074-1-andrew.rybchenko@oktetlabs.ru> References: <20211020104715.2526074-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] ethdev: do not allow to close started device X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Ethernet device must be stopped first before close in accordance with the documentation. Fixes: 980995f8cc56 ("ethdev: improve API comments of close and detach functions") Cc: stable@dpdk.org Signed-off-by: Andrew Rybchenko --- In fact the patch is required to fix segfault in the case of net/virtio on close without stop after Rx interrupts enabled. lib/ethdev/rte_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 3b8ef9ef22..f981e0226a 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -1893,6 +1893,12 @@ rte_eth_dev_close(uint16_t port_id) RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); dev = &rte_eth_devices[port_id]; + if (dev->data->dev_started) { + RTE_ETHDEV_LOG(ERR, "Cannot close started device (port %u)\n", + port_id); + return -EINVAL; + } + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_close, -ENOTSUP); *lasterr = (*dev->dev_ops->dev_close)(dev); if (*lasterr != 0) -- 2.30.2