From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 036541041 for ; Mon, 10 Sep 2018 10:04:12 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us4.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id 90324BC005E; Mon, 10 Sep 2018 08:04:11 +0000 (UTC) Received: from [192.168.38.17] (91.220.146.112) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 10 Sep 2018 01:04:08 -0700 To: Thomas Monjalon , CC: References: <20180907233929.21950-1-thomas@monjalon.net> From: Andrew Rybchenko Message-ID: <47678eef-0260-302a-b46b-2cdf861322a6@solarflare.com> Date: Mon, 10 Sep 2018 11:03:39 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180907233929.21950-1-thomas@monjalon.net> Content-Language: en-US X-Originating-IP: [91.220.146.112] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ocex03.SolarFlarecom.com (10.20.40.36) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24084.005 X-TM-AS-Result: No-17.840600-4.000000-10 X-TMASE-MatchedRID: vEvJ7Rh1lGgOwH4pD14DsPHkpkyUphL9wuIWIvQEbW6vPoND+wakFlPK Q4g0ENBTz0kHebusWqG/OcTZGXKzdinPugGsN3p5bc297PAGtWbhKQh1LCmGBk+nXRcya9Nvq4N L3KtjQyb2gpsjdbRHZ+kFggkz1/z6iwjsyrTVNP71RUeLAvHT8iGi0ftsSkQyBlt4RZwvTdVweO CJM432Mvd++qp3fg8+B68sndztqwJPDIOIbXrV2IlD2T5imTkJ6Pzo2DwBrIoHiwiF9OOogUqyU ztVRoTBdvgGbsWpCcvPX7sUkKqkssgNYoWONkdvL4+sB3yBsckIUQiRW/XLrHlQgJBy8EXjyumv aRKwzjs1Nxz4Ua0cvWC2mpXkc+jb31upjFk7WXTkGAR1SqoA1H0tCKdnhB58vqq8s2MNhPCy5/t FZu9S3GNgbF0oRDZ0zYfCUsTvTZzrJZC+zEeyXZdPRzDa+TtQs6OxVNqVCoH8rWWqY4zykXCHqL 5kE+zNj6VGmjtqkG3yxVUiJpMAU5uO0zJ8cIYFuqy7mgT409o= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--17.840600-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24084.005 X-MDID: 1536566652-zCNneHS0MaO3 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] [RFC] ethdev: complete closing to free all resources 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: Mon, 10 Sep 2018 08:04:13 -0000 On 09/08/2018 02:39 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 removing the associated rte_device, the driver should check > if no more port (ethdev, cryptodev, etc) is still open for the device. > Then the device resources can be freed by the driver inside the > dev_close() driver callback operation. > > The last ethdev freeing (dev_private and final release), which were done > by rte_eth_dev_detach(), are now done at the end of rte_eth_dev_close(). For me, it sounds more logical to kill dev_close and keep detach. IMHO, dev_close is artificial and hardly useful. detach is a local pair to attach. Anyway it requires update of all drivers as I understand. > Signed-off-by: Thomas Monjalon > --- > This patch contains only the change in the close function as RFC. > > This idea was presented at Dublin during the "hotplug talk". > --- > lib/librte_ethdev/rte_ethdev.c | 5 +++++ > lib/librte_ethdev/rte_ethdev.h | 5 +++-- > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c > index 4c3202505..071fcbd23 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -1358,6 +1358,7 @@ void > rte_eth_dev_close(uint16_t port_id) > { > struct rte_eth_dev *dev; > + struct rte_bus *bus; > > RTE_ETH_VALID_PORTID_OR_RET(port_id); > dev = &rte_eth_devices[port_id]; > @@ -1372,6 +1373,10 @@ rte_eth_dev_close(uint16_t port_id) > dev->data->nb_tx_queues = 0; > rte_free(dev->data->tx_queues); > dev->data->tx_queues = NULL; > + > + rte_free(dev->data->dev_private); > + > + rte_eth_dev_release_port(dev); > } > > int > diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h > index 7070e9ab4..37a757a7a 100644 > --- a/lib/librte_ethdev/rte_ethdev.h > +++ b/lib/librte_ethdev/rte_ethdev.h > @@ -1797,8 +1797,9 @@ int rte_eth_dev_set_link_down(uint16_t port_id); > > /** > * Close a stopped Ethernet device. The device cannot be restarted! > - * The function frees all resources except for needed by the > - * closed state. To free these resources, call rte_eth_dev_detach(). > + * The function frees all port resources. > + * If there is no more port associated with the underlying device, > + * the driver should free the device resources. > * > * @param port_id > * The port identifier of the Ethernet device.