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 09E48A0C43; Wed, 20 Oct 2021 15:06:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A687A4118F; Wed, 20 Oct 2021 15:06:27 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 5AF4B40142 for ; Wed, 20 Oct 2021 15:06:26 +0200 (CEST) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id E9EAB7F519; Wed, 20 Oct 2021 16:06:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru E9EAB7F519 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1634735186; bh=Y6+eKc2byOQZ5VjNF3FKgyAuxLUZ3enFf6HmYgJuVD4=; h=Subject:From:To:Cc:References:Date:In-Reply-To; b=ovbjQd6W7W+dDTLZQ4qaCqHa8Hlgk6ZfC+XYsiNEnfU+NpiGs1VHDzayK628dS0ZV j2/pTaYWnXr+MD5g248a1jPZJOkf81RN++XpUnUo+1V2Kbm6QsEP0dOvvc9P17EMCY kxjLG5bb2ZWZGQ4+FQ70/JYxMcb0F3jQan9KMR3s= From: Andrew Rybchenko To: Thomas Monjalon , Ivan Ilchenko Cc: Ferruh Yigit , dev@dpdk.org, Maxime Coquelin , Chenbo Xia References: <20211020104715.2526074-1-andrew.rybchenko@oktetlabs.ru> <2158870.PWGGICSfzm@thomas> <31d69964-1b54-ce9e-b917-9ab6f86571b7@oktetlabs.ru> Organization: OKTET Labs Message-ID: <6e907ce3-5897-d024-f7b3-05728ba1cda6@oktetlabs.ru> Date: Wed, 20 Oct 2021 16:06:25 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <31d69964-1b54-ce9e-b917-9ab6f86571b7@oktetlabs.ru> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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" On 10/20/21 3:24 PM, Andrew Rybchenko wrote: > On 10/20/21 3:17 PM, Thomas Monjalon wrote: >> 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. > > Isn't returning an error a change of API behaviour? After looking at rte_eth_dev_close() description I agreethat we should return an error. Yes, it is a behaviour change, but a change in accordance with the documentation. I'll submit v2 which checks that port is stopped and return error. > > This way we change behaviour less since some PMDs allow > to close in started state and do stop itself. > >> >>> @@ -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; >> >>