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 6FACCA0C43; Wed, 20 Oct 2021 14:24:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 31BC340687; Wed, 20 Oct 2021 14:24:09 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id BDB1040142 for ; Wed, 20 Oct 2021 14:24:07 +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 6500D7F56B; Wed, 20 Oct 2021 15:24:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 6500D7F56B DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1634732647; bh=j5I+tlT91lp6HyB8XlgCbj+/tmeaXNC2C4m7xD8uwWE=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=fTVYOwEn7P0SUZs5i6pV84BdLr6pH8DpQ7Z5UnXokVoP1EF8zSmZcQNlRVGCPP1b8 6H93edJSUTqFu/LCL8VrYMSGF34CvlYn4l2sWG+fwR8l4ZL6jwHE6U/zOG0/OFDUCU jOEW1m8lc0Yh3WwiF8SGXK/0MRzVN65TJwZLWPtQ= 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> From: Andrew Rybchenko Organization: OKTET Labs Message-ID: <31d69964-1b54-ce9e-b917-9ab6f86571b7@oktetlabs.ru> Date: Wed, 20 Oct 2021 15:24:07 +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: <2158870.PWGGICSfzm@thomas> 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: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? 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; > >