From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0085.outbound.protection.outlook.com [104.47.0.85]) by dpdk.org (Postfix) with ESMTP id E79B27D43; Thu, 17 Aug 2017 08:04:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=9nmtA8b8EbZ8DNiKboPGekKkifl3TijdP47/oZkVOwI=; b=cMI1nkTswshWzC9WJULuQmbhaToVWEQm+KvJkVIa06+/KscNSTtvCn+Mj5S/seYnKWCHrivGzntsOu765vEzzYaaALRQcZOE/g5zbgu2Lxi9QyJNziHQZ61AsB5j0vcSWwquOLibd8rBueYQlJ7HX7gFpZc0GsPUQatFOu1H3SQ= Received: from VI1PR05MB3149.eurprd05.prod.outlook.com (10.170.237.142) by VI1PR05MB3149.eurprd05.prod.outlook.com (10.170.237.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1341.21; Thu, 17 Aug 2017 06:04:27 +0000 Received: from VI1PR05MB3149.eurprd05.prod.outlook.com ([fe80::8450:1a86:2dd0:82c2]) by VI1PR05MB3149.eurprd05.prod.outlook.com ([fe80::8450:1a86:2dd0:82c2%13]) with mapi id 15.01.1341.024; Thu, 17 Aug 2017 06:04:27 +0000 From: Shahaf Shuler To: =?iso-8859-1?Q?Ga=EBtan_Rivet?= CC: Thomas Monjalon , "dev@dpdk.org" , "stable@dpdk.org" Thread-Topic: [PATCH] ethdev: fix device state on close Thread-Index: AQHTFo0Eom7jHIBJrESDD1xInahTyKKHBDHAgAAWqoCAAOp7YA== Date: Thu, 17 Aug 2017 06:04:27 +0000 Message-ID: References: <20170816114308.165850-1-shahafs@mellanox.com> <20170816124130.GL8124@bidouze.vm.6wind.com> <20170816152607.GO8124@bidouze.vm.6wind.com> In-Reply-To: <20170816152607.GO8124@bidouze.vm.6wind.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR05MB3149; 6:H5wfCsh6hyJb7zkOCpKRZz5K8ksdZB7n6bhN4oBJK3R4ON9sanIA2mK2qGey+bUpO4zplxJoP1cZJijrMJkOuJ9+YZtW9fZweJ8Bx7ENCSr5xUJYTo9c34ZLV1bPyNJpLo/4PBFVUmfCikU3u/uRZ1IYbr8wT7xFXYeUQ1zL4E1ewHcv2aFuEf8gjT4acKXYyiDZwfYXjzl2JFjjtHL2MVxd3HcNiPJpoBSH01gcpoTpbc/hDIkdnicRnrHK27923m0/AvOcv2ZPe9MMjIFZaQ4DYwOLRkZMIToBKm+LxwU63J0aT6eJL/qskadEktyIlw/neVEZcZ/cJfU9Tlwy4w==; 5:vTddkfXZ7/CwH8NzzjL/Vx5SICj041lJvnuYqS76JhkKHv3E2JxxvkwV9IJp9R8Ze9/0lfy2Ex1wBBlN+NfHjKUDBMG2GP2ZauQqdBebPiXGmkQ5r7z9tXqE0ZEfi15uSGIgxdugOvi8EbaiN1bw6g==; 24:R8SCQJR5GQvb0NG11Dc63ebkSAcrqUYscMIKp/SodFELr2G+iglpHWfzeEFPQB4dqLKN9tgr3WOF112YWg0cqhrZJ4P/bKzWFBmz9DM2sqE=; 7:YxhPuFo19ya7SWjYdACmg/+pLkGOoJRMTioxRIkEhbtz8JPQdBRUVGmA04yvo7wGGvb2fKDluqFlwvWAVpr+KnazIGmYhyJ4zkZAutfVFAZTviplVYlVJhphgFVPZ6TqWZRnWFyUhU5bCF3IhX+iCe3NGFf3rtJn1colnv4yBhbfq9MrFgaDnBW4bIw3awlH88pcUcd9L3RlxO/3n+7n2IiV0NU9qMGR9J7xB/gbazQ= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ld-processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr x-ms-office365-filtering-correlation-id: d39edef7-5903-4981-46e8-08d4e535d193 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:VI1PR05MB3149; x-ms-traffictypediagnostic: VI1PR05MB3149: x-exchange-antispam-report-test: UriScan:(278428928389397)(17755550239193); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(6055026)(6041248)(20161123558100)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR05MB3149; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR05MB3149; x-forefront-prvs: 0402872DA1 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(189002)(199003)(377454003)(105586002)(6436002)(106356001)(229853002)(33656002)(6506006)(6916009)(2950100002)(2900100001)(305945005)(7736002)(25786009)(4326008)(74316002)(8676002)(81166006)(8936002)(7696004)(81156014)(5660300001)(14454004)(5250100002)(5890100001)(93886005)(97736004)(478600001)(3846002)(6116002)(102836003)(68736007)(189998001)(66066001)(53936002)(54906002)(55016002)(9686003)(99286003)(6246003)(2906002)(110136004)(3280700002)(3660700001)(76176999)(54356999)(86362001)(50986999)(101416001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB3149; H:VI1PR05MB3149.eurprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Aug 2017 06:04:27.4605 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB3149 Subject: Re: [dpdk-stable] [PATCH] ethdev: fix device state on close X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Aug 2017 06:04:29 -0000 Wednesday, August 16, 2017 6:26 PM, Ga=EBtan Rivet: > > Even though it is reasonable for driver to call the > rte_eth_dev_port_release, I still think the ethdev layer should protect f= rom > such bad behavior from the application side. > > It is more robust than counting on the different PMD to implement such > release. > > >=20 > The ethdev layer does so in the rte_eth_dev_detach function, which is > currently the only way to detach a device from the ethdev level. >=20 > `rte_eth_dev_detach` setting the device state seems to me to be a crutch > against badly implemented drivers. If I was nitpicky I would actually rem= ove it > and ideally everyone should enforce the call of rte_eth_dev_release_port > from device removal functions when reviewing PMD implementations. >=20 > The hotplug API is available to applications and the only way to have > consistent devices states after calling rte_eal_hotplug_remove is to have > drivers using a hook in the ethdev layer allowing to clean-up resources u= pon > release. While it is trivial in its current state, such entry-point in th= e ethdev > layer will be useful and should be kept and enforced IMO. >=20 > I'm thinking about the 16-bit portid scheduled for v17.11, which implies = an > arbitrary number of port available. This would imply a dynamic allocation= of > rte_eth_devices, which would *need* such release hook to be available. > Well the API should not be designed from conjectures or speculations of > course, but I think it should be useful and there is no reason to remove = it. >=20 > Going further, I find it dangerous to have two points where the port is > semantically released (device state set to UNUSED). If the API of the por= t > release changes, we now have two points where we need to enforce the > changes. While trivial concerning an enum, it could become more complex / > dangerous if this veered toward memory management. Those are valid concerns, and you convinced me the RTE_ETH_DEV_UNUSED canno= t be set after device close. I still think the ethdev layer missing protection against driver calls (oth= er than detach) following a device close. The API not allows, but the ethde= v should enforce it. Considering some driver memset to 0 their control structs after device clos= e, with no protection such bad calls might lead to segfault, which is not w= hat we want even under bad behavior.=20 One could suggest to protect it inside the driver by replacing the vtable o= f the driver ops, however it will introduce a lot of duplicated code which = can easily be avoided if ethdev would not pass such Calls after device close. So, how about adding another state which will indicate the device is closed= , cannot be used, yet still attached?=20