From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ferruh Yigit Subject: Re: [PATCH] ethdev: fix rte_eth_dev_owner_unset Date: Fri, 24 Aug 2018 14:55:56 +0100 Message-ID: References: <20180814001926.19630-1-stephen@networkplumber.org> <20180814095521.492e575a@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "dev@dpdk.org" To: Matan Azrad , Stephen Hemminger Return-path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 42E314CE4 for ; Fri, 24 Aug 2018 15:55:59 +0200 (CEST) In-Reply-To: Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 8/14/2018 8:46 PM, Matan Azrad wrote: > Hi Stephen > > From: Stephen Hemminger >> On Tue, 14 Aug 2018 05:52:20 +0000 >> Matan Azrad wrote: >> >>> Hi Stephen >>> >>> From: Stephen Hemminger >>>> The rte_eth_dev_owner_unset function is unusable because it always >>>> returns -EINVAL. This is because the magic (unowned) value is >>>> flagged as not valid. >>>> >>> >>> It's OK to raise an error when you do unset for unowned device. >>> It means that unset owner should be called for owned device. >>> >> >> Original code was broken. The following would always fail. >> >> rte_eth_dev_owner_new(&owner.id); >> sprintf(owner.name, "example"); >> rte_eth_dev_owner_set(port_id, &owner); >> rte_eth_dev_owner_unset(port_id, owner.id); >> >> That is because of: >> rte_eth_dev_owner_unset(port_id, owner_id) >> _rte_eth_dev_owner_set(port_id, owner_id, &new_owner) >> << new_owner.id == RTE_ETH_DEV_NO_OWNER (0) >> >> >> if (!rte_eth_is_valid_owner_id(new_owner->id) && << >> new_owner->id == RTE_ETH_DEV_NO_OWNER (which is flagged as invalid) >> !rte_eth_is_valid_owner_id(old_owner_id)) >> return -EINVAL; >> > > But both should be invalid the new owner and the old owner(&&) to raise an EINVAL error. > > In the aforementioned check above the old owner should be valid. It looks rte_eth_dev_owner_unset() works, updating patch as rejected.