From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id 4CFB85F4A for ; Thu, 18 Oct 2018 10:34:29 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us3.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id ED6F298009C; Thu, 18 Oct 2018 08:34:27 +0000 (UTC) Received: from [192.168.38.17] (91.220.146.112) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 18 Oct 2018 09:34:21 +0100 To: Thomas Monjalon , CC: , , , References: <20180907233929.21950-1-thomas@monjalon.net> <20181018012402.1240-1-thomas@monjalon.net> <20181018012402.1240-7-thomas@monjalon.net> From: Andrew Rybchenko Message-ID: <97e9f9fa-067e-57bf-6ade-3745cd65c703@solarflare.com> Date: Thu, 18 Oct 2018 11:33:40 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20181018012402.1240-7-thomas@monjalon.net> Content-Language: en-GB X-Originating-IP: [91.220.146.112] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24162.003 X-TM-AS-Result: No-8.465500-8.000000-10 X-TMASE-MatchedRID: UuaOI1zLN1gOwH4pD14DsPHkpkyUphL9wuIWIvQEbW6vPoND+wakFlPK Q4g0ENBTz0kHebusWqG/OcTZGXKzdinPugGsN3p5bc297PAGtWbhKQh1LCmGBhqB+wKK9uZexUD TxL3vuSD2AACUM2O1MOYlJ9L2w/CHX/LM4Em7bYL1RUeLAvHT8krvvQQRSWAPnp9KgXcu34zizc UyXZxJLOC1MNhQ4YIV8fS1SD8lfIiUTHcBIlpNjS2XcOg2J9fLfMhjt3b5PP0Cdb5O7YWLhlHXx CnNdK1OL0FRNMjhhaWKgWXlQrdwn9J24xzpGcj5PlujdkswUwcH519/vRZuOUIjuk0uJKN9xTPN 0i7ijGH3aCtTBCBhl436uZ2JD8HYGAdnzrnkM485f9Xw/xqKXVkMvWAuahr8+gD2vYtOFhjLbB1 Y6YQ17UUOheg9Br8m9pVNCAenpGgsd7ewZPMQcdnDAHx4e0Mw9MYTQX2lvSpIXdze2jUQdgOwBm cheL2dsvcAfLbHaKKEG2OQ8Hvc/HAtzuwHRD2m8B2y8yeL5f15v/GoTjcjNWUJ4oH3BHMiHQukz uoEEd96bhm/I1scLhxjyevZr4dB9vrF4BjJ4hPAnQ90Lm+58Q== X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--8.465500-8.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24162.003 X-MDID: 1539851668-ohkEA9-OREI3 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v5 6/6] ethdev: complete closing of port X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Oct 2018 08:34:29 -0000 On 10/18/18 4:24 AM, Thomas Monjalon wrote: > After closing a port, it cannot be restarted. > So there is no reason to not free all associated resources. > > The last step was done with rte_eth_dev_detach() which is deprecated. > Instead of blindly removing the associated rte_device, the driver should > check if no more port (ethdev, cryptodev, etc) is open for the device. > > The last ethdev freeing which were done by rte_eth_dev_detach(), > are now done at the end of rte_eth_dev_close(). > > Some drivers does not allocate MAC addresses dynamically or separately. > In those cases, the pointer is set to NULL, in order to avoid wrongly > freeing them in rte_eth_dev_release_port(). > > A closed port will have the state RTE_ETH_DEV_UNUSED which is > considered as invalid by rte_eth_dev_is_valid_port(). > So validity is not checked anymore for closed ports in testpmd. > > If the driver is trying to free the port again, the function > rte_eth_dev_release_port() will abort with -ENODEV error. > > Signed-off-by: Thomas Monjalon I've tested the patch series together with [1]. As I expected it makes problems and resource leaks if rte_eth_dev_close() is used. Everything is OK if I do port stop and detach (with net/sfc patch which does close from uninit). If I do port stop, close and detach, the last one returns error since the device already released and net/sfc uninit is never called. Basically it should be one function which is called in both cases: dev_close or pci_device remove. Similar changes should be done in many PCI drivers. If I drop the patch, everything seems to be work fine from the first sight. May be it should be removed from the patchset and considered separately. [1] http://patches.dpdk.org/project/dpdk/list/?series=1966