From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 2474DA0544;
	Thu, 13 Feb 2020 20:43:28 +0100 (CET)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 5F7351BE94;
	Thu, 13 Feb 2020 20:43:26 +0100 (CET)
Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com
 [64.147.123.24]) by dpdk.org (Postfix) with ESMTP id 2904C1BE90
 for <dev@dpdk.org>; Thu, 13 Feb 2020 20:43:24 +0100 (CET)
Received: from compute1.internal (compute1.nyi.internal [10.202.2.41])
 by mailout.west.internal (Postfix) with ESMTP id 0B58293E;
 Thu, 13 Feb 2020 14:43:20 -0500 (EST)
Received: from mailfrontend2 ([10.202.2.163])
 by compute1.internal (MEProxy); Thu, 13 Feb 2020 14:43:21 -0500
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=mesmtp;
 bh=TVvO3/q6PMoGqzS++ETDrYqum0rPhkWV2/h9oboyADw=; b=n4lT8Puy+yhq
 LGoFvy9afT0Bf/hvhTOWzeVfH1t5XZF/k1fo6r8mvLibLw6VtVzwnf15S4mK53gq
 +6wyNt2bD7zjCDoHAPRMumN/OMn30yiAzLcMNU+JfiJFZSeLx7kbjuW75xmK4NZl
 Tc1OnmvpWLONO4UkziIZfmrIkdvIakU=
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=fm2; bh=TVvO3/q6PMoGqzS++ETDrYqum0rPhkWV2/h9oboyA
 Dw=; b=cQKQaJGNuLxVJqw8PzLuuaL4aV4WR/Xo/2KqPLuY7SViykdLMIYnW9cFq
 nNO6lRp35nbFIZMVuf+t6ZFepF2wUUGPUeK6scsDHPyf/lf4tUarDV4b0QbNlb44
 Tzw1bLP2fXgYEtge5JXERh+xo7YQxF8hExHsDtLVmO5Wo+bTZ3x4RKfWgpdGIyQM
 uZOm8i/KytJR9LSHQ0iG60cT8ibic9BUKli1gOvarEnZZzZYTUVw6bo1iu9F9Azf
 MvA1wg9WySDNrWuAh+F6kZgxlb3yUqBQORPfsZBAJb/3/U1VgPPRou/231Bxevvc
 zPfedED7JqO5ei0i/IVqoW5nEIGQg==
X-ME-Sender: <xms:2KZFXi49Y3-kitKMLUJbnUca4vkU0SQF9wxO0GI8dCy7dWktZTa8Pg>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrieekgddufedtucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne
 cujfgurhephffvufffkfgjfhgggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgr
 shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecukf
 hppeejjedrudefgedrvddtfedrudekgeenucevlhhushhtvghrufhiiigvpedtnecurfgr
 rhgrmhepmhgrihhlfhhrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght
X-ME-Proxy: <xmx:2KZFXluoCyT3R9Cee0RIrJmBWtQ9F1RTHcpOOBN8yrAZGje66Ui19g>
 <xmx:2KZFXgRcxfUnn48Q-z7gyEyMTfNxSuuD-ra7jrZEumCk0CYt7bO8sg>
 <xmx:2KZFXqjvyN-Drcq_fxRUsAa8avyv3w21h4d0DsrBT0NdzIphnnvoRg>
 <xmx:2KZFXituhm91cTXV8Cz0yfiv8mqtx1yDV06d1m361MxA7ocqXCXMHw>
Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184])
 by mail.messagingengine.com (Postfix) with ESMTPA id D9A5930600DC;
 Thu, 13 Feb 2020 14:43:19 -0500 (EST)
From: Thomas Monjalon <thomas@monjalon.net>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: dev@dpdk.org, Andrew Rybchenko <arybchenko@solarflare.com>
Date: Thu, 13 Feb 2020 20:43:17 +0100
Message-ID: <1913442.o4kTbAZ4gJ@xps>
In-Reply-To: <f269433e-92e0-78ed-5380-a9394f73a812@intel.com>
References: <20200213143312.1021487-1-thomas@monjalon.net>
 <2855847.M6yMPqc0BA@xps> <f269433e-92e0-78ed-5380-a9394f73a812@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
Subject: Re: [dpdk-dev] [PATCH 20.05] ethdev: clear struct on releasing port
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

13/02/2020 17:05, Ferruh Yigit:
> On 2/13/2020 3:27 PM, Thomas Monjalon wrote:
> > 13/02/2020 16:16, Ferruh Yigit:
> >> On 2/13/2020 2:33 PM, Thomas Monjalon wrote:
> >>> The function rte_eth_dev_release_port() is called by drivers
> >>> when closing or removing a device.
> >>> Its main usage should be via rte_eth_dev_close() by up-to-date
> >>> drivers which are compliant with RTE_ETH_DEV_CLOSE_REMOVE flag.
> >>>
> >>> When a port is released, the data (rte_eth_dev_data) are cleared,
> >>> but the pointers in rte_eth_dev were not cleared.
> >>> It may cause issues with code paths trying to use dangling pointers
> >>> (e.g. the .device pointer which may reference a removed rte_device).
> >>> Everything is now cleared to 0 when releasing.
> >>> The state is explicitly set to RTE_ETH_DEV_UNUSED which is 0 anyway.
> >>>
> >>> Using this patch may reveal bugs in some code paths:
> >>> 	- device pointer must be saved before closing a port if needed
> >>
> >> Is this saving should be done in application code or will be done by ethdev?
> > 
> > by the application
> > From ethdev point of view, when a port is closed, there is nothing more to do next.
> > 
> 
> That sound reasonable from ethdev perspective, but it will push dealing with
> rte_device level details to the application.
> 
> Like this change will be forcing each application to store the rte_device
> pointer before close(), in case device can be detached later.

Yes
I think PMDs could release rte_device when closing the last port of the device.
I am not sure what is the benefit of explicit detach.
That's something we should discuss, agree and write in the API doc.