From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH] ethdev: fix rte_eth_dev_owner_unset Date: Fri, 24 Aug 2018 07:42:36 -0700 Message-ID: <20180824074236.7f979884@xeon-e3> References: <20180814001926.19630-1-stephen@networkplumber.org> <20180814095521.492e575a@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Matan Azrad , "dev@dpdk.org" To: Ferruh Yigit Return-path: Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id E3C315B3E for ; Fri, 24 Aug 2018 16:42:43 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id x6-v6so1189474plv.10 for ; Fri, 24 Aug 2018 07:42:43 -0700 (PDT) In-Reply-To: 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 Fri, 24 Aug 2018 14:55:56 +0100 Ferruh Yigit wrote: > 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. > The issue was the incorrect log message, addressed in later patches.