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 17503A00C4; Mon, 30 May 2022 10:28:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F07FE42B75; Mon, 30 May 2022 10:28:11 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by mails.dpdk.org (Postfix) with ESMTP id 9D8D140A8A; Mon, 30 May 2022 10:28:10 +0200 (CEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 540995C019B; Mon, 30 May 2022 04:28:08 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 30 May 2022 04:28:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1653899288; x= 1653985688; bh=ad2mX9HUme3/rYzvNbf1Nd+6cD6TIRScENU5ZobUih4=; b=t 7Mnt8+/KU4JlR87k9/gRiAmxq85+hFz/6qKdgFk9BDMux5V6wdf9lZRj5RgZ/CzJ bwi2tcRRoFVr+o3Gr1rP4T0tykZmmKSCLjN25Mkes1zyytkDKzUW80gOZejHPYLy nL+POUz541l9aZLiMNMrG3vt6dP0YBddY/XDqoCpD2MoZoTH7SCCFy80xrlEjA5z ZxKLvRUJ3++GGF1dSVwU72yjRC1ne77/dD3fCR8HR+a+Q1RvZ6nwYv9u86bmAt4V KFQLjmKTDtcjmzWGuVysWVlwA2SO+P9gEQVZudZOLJGlzFPu2tHJqXAiV9oEwyvk lUsgeCLYtJ013+pVPbaLA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1653899288; x= 1653985688; bh=ad2mX9HUme3/rYzvNbf1Nd+6cD6TIRScENU5ZobUih4=; b=S vdMRhEbkk/hGGhYjvUjuEgFQ5Ri7BbAs6U5ud4pv9bk9aVLi3LGjEt3tSsJBaSEm yk2Ah3wNs/8zVl3gjMTxd7mjjzCLL4ueFbFOLk1ZewKIdCILIWAWPYWU6QN6rQCv 9I7c2t7tbI1o69OwecgYM/htDtvi9bV202DFZtCUw26q2fvfRoV7/EuP5+IdulAy UFHOpcYCF9QZmidb+cXxfLMVQHbKxQgeSr6ClCdtAsMeys842lUeA9V3cqNHWvrK dUuW7GiTEVBSyw5AGPso3XvT22KxLTfp7C2hcHCvcsy8RxQYmd6JYD7tsAgmp+PS rLmj3o5t4ehFqbpWZxpxg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrkeeigddtfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvfevufffkfgjfhgggfgtsehtqhertddttdejnecuhfhrohhmpefvhhhomhgr shcuofhonhhjrghlohhnuceothhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecugg ftrfgrthhtvghrnhepgedttdeljeejgeffkeekkedtjeevtdehvedtkeeivdeuuedviedu vdelveejueejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvth X-ME-Proxy: Feedback-ID: i47234305:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 30 May 2022 04:28:05 -0400 (EDT) From: Thomas Monjalon To: "Min Hu (Connor)" , Ferruh Yigit , Andrew Rybchenko , David Marchand , "lihuisong (C)" Cc: dev , dpdk stable , Bruce Richardson Subject: Re: [PATCH] ethdev: fix push new event Date: Mon, 30 May 2022 10:28:03 +0200 Message-ID: <11986117.O9o76ZdvQC@thomas> In-Reply-To: <3a28b653-b83a-6cb5-bf5a-a04c144ba497@huawei.com> References: <20220521065549.33451-1-humin29@huawei.com> <2199956.o7ts2hSHzF@thomas> <3a28b653-b83a-6cb5-bf5a-a04c144ba497@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" 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 28/05/2022 10:53, lihuisong (C): >=20 > =E5=9C=A8 2022/5/23 22:36, Thomas Monjalon =E5=86=99=E9=81=93: > > 23/05/2022 11:51, David Marchand: > >> On Sat, May 21, 2022 at 8:57 AM Min Hu (Connor) w= rote: > >>> From: Huisong Li > >>> > >>> The 'state' in struct rte_eth_dev may be used to update some informat= ion > >>> when app receive these events. For example, when app receives a new e= vent, > >>> app may get the socket id of this port by calling rte_eth_dev_socket_= id to > >>> setup the attached port. The 'state' is used in rte_eth_dev_socket_id. > >>> > >>> If the state isn't modified to RTE_ETH_DEV_ATTACHED before pushing th= e new > >>> event, app will get the socket id failed. So this patch moves pushing= event > >>> operation after the state updated. > >>> > >>> Fixes: 99a2dd955fba ("lib: remove librte_ prefix from directory names= ") > >> A patch moving code is unlikely to be at fault. > >> > >> > >> Looking at the patch which moved those notifications in this point of > >> the code, the state update was pushed after the notification on > >> purpose. > >> See be8cd210379a ("ethdev: fix port probing notification") > >> > >> ethdev: fix port probing notification > >> > >> The new device was notified as soon as it was allocated. > >> It leads to use a device which is not yet initialized. > >> > >> The notification must be published after the initialization is do= ne > >> by the PMD, but before the state is changed, in order to let > >> notified entities taking ownership before general availability. > >> > >> > >> Do we need an intermediate state during probing? > > Possibly. Currently we have only 3 states: > > RTE_ETH_DEV_UNUSED > > RTE_ETH_DEV_ATTACHED > > RTE_ETH_DEV_REMOVED > > > > We may add RTE_ETH_DEV_ALLOCATED just before calling > > rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_NEW, NULL); > > Then we would need to check against RTE_ETH_DEV_ALLOCATED > > in some ethdev functions. > > > Hi, Thomas, >=20 > Do you mean that we need to modify some funcions like following? >=20 > int rte_eth_dev_is_valid_port(uint16_t port_id) > { > if (port_id >=3D RTE_MAX_ETHPORTS || > (rte_eth_devices[port_id].state !=3D *RTE_ETH_DEV_ALLOCATED*)) > return 0; > else > return 1; > } >=20 > uint16_t rte_eth_find_next(uint16_t port_id) > { > while (port_id < RTE_MAX_ETHPORTS && > rte_eth_devices[port_id].state !=3D *RTE_ETH_DEV_ALLOCATED*) > port_id++; >=20 > if (port_id >=3D RTE_MAX_ETHPORTS) > return RTE_MAX_ETHPORTS; >=20 > return port_id; > } Yes this is what I mean.