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 133B5A0C43; Wed, 20 Oct 2021 14:17:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A8C040687; Wed, 20 Oct 2021 14:17:29 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by mails.dpdk.org (Postfix) with ESMTP id 053F140142 for ; Wed, 20 Oct 2021 14:17:27 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 8FFF132005BC; Wed, 20 Oct 2021 08:17:26 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 20 Oct 2021 08:17:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm2; bh= v4ImU0jL/ait+YhyC5EtKR+imwQQ1IyDbbipehIB/ng=; b=h0nmUqt6xd/3YNYM yvfQLbiymvNMj6bOc9CbTxHL5ub6mnLOdV/zi72MxyqBIxUK0efNF9MaamfY5LJn d7IzWMq6EWYL85KhYdE7z8CdygTD0bH6z4TQlu3kkYrWVnHad9m55nnp/Bq7JNZk i46N4HZ6MciydpH2VFuchBqVcwrT36+bdDv7ejpscHoM5ZAqgG8FCvvMexF8wU6R Wfz5FsFdkRdQPKV2X8EQL+uXcsgBBzKJGE1EM9gVC/2m5CPPIsZfxzjVeRBUtJ6k VvHs8YLQK1u4QJs88JQfylcTWxYjDXAtBCZACcOi4zx5rhstgIoSmja4nnHQ4xID khRvXA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=v4ImU0jL/ait+YhyC5EtKR+imwQQ1IyDbbipehIB/ ng=; b=GxzHTw3PDVMCKxF+9y4zQK2l9bIhhQuJxt66ZZ9ncSVkECo9jaGBsRhxi RYDBO7WPWSbSnLIHJiXraJ2N81Vl9Dh3EdzqD6tEiJKWDXSEZm5ZEXEm5WFNiucP 2Prs5YvHEPv8kzT5VIcc5Igp1TWOHyJh9tTkHgndGQCXoL9PoZqDwvs6BKRDs77E EQVxK1ynz4WBfyky8vtk5SVNu0a1RH9adeds7QCjI+Km+U1ySfP/yOm0Ine7H8F8 D6MEMe2UmPB2YVVRxDni8uJW+H0RZZ94VYuleYzUm54WQ+UvV3DynLR2deWHsqjr XLYy36hL0jFvZq+TvjtLZsMzCWhQw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvgedggeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkfgjfhgggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepudeggfdvfeduffdtfeeglefghfeukefgfffhueejtdetuedtjeeu ieeivdffgeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 20 Oct 2021 08:17:25 -0400 (EDT) From: Thomas Monjalon To: Andrew Rybchenko , Ivan Ilchenko Cc: Ferruh Yigit , dev@dpdk.org, Maxime Coquelin , Chenbo Xia Date: Wed, 20 Oct 2021 14:17:23 +0200 Message-ID: <2158870.PWGGICSfzm@thomas> 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: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH] ethdev: stop the device before close 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" 20/10/2021 12:47, Andrew Rybchenko: > From: Ivan Ilchenko > > In drivers important cleanup could happen on the device stop. > Do stop in the rte_eth_dev_close() function for robustness and > to simplify drivers code. > > Signed-off-by: Ivan Ilchenko > 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. > > I believe that the right way to address the problem is automated > stop from close, but I guess it cannot not be backported and > may be fix in a different way required in stable branches. It is possible to do this addition. But the right fix (not changing API behaviour) should be to return early if the port is not stopped. > @@ -1894,6 +1894,17 @@ rte_eth_dev_close(uint16_t port_id) > dev = &rte_eth_devices[port_id]; > > RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_close, -ENOTSUP); > + > + if (dev->data->dev_started) { > + *lasterr = rte_eth_dev_stop(port_id); > + if (*lasterr != 0) { > + RTE_ETHDEV_LOG(ERR, > + "Failed to stop device (port %u) before close: %s - ignore\n", > + port_id, rte_strerror(-*lasterr)); > + lasterr = &binerr; > + } > + } > + > *lasterr = (*dev->dev_ops->dev_close)(dev); > if (*lasterr != 0) > lasterr = &binerr;