From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 70C164F98 for ; Tue, 14 Aug 2018 18:55:24 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id p12-v6so9517487pfh.2 for ; Tue, 14 Aug 2018 09:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WwBXZ44fT2NEqTG8DfyJRaOe+mWShocYl5YxWZ9eeE4=; b=G1T1jS4cY26Wl9wA9bk3ncPZ8WQC82vjg3DYhlsFWlBUIB9OSbzNlmLsaCXsuU7bbk rzhJ+f0yX0VlTvYD3qEk7DCjl33J1dCgSnKjqVH9xVc99zlwPwA1seXMD+Zram8W+NVw 2ryoY9n9ABmcHL0wpaIGw9xWot/krk2mneRENyc+mH65YXvaOlGxe2PjhZWZbvcQOk2C JGB/vYU7vfKh5I2NZxHk69ea2naiODLZsIBqDeVBqQoBIn7uMOAQalfW7VYgp4Y6nFxW wfjbd6Wcz7AHrM8E5xmD4DWdsA0tn1SZHJAd8h1QIm0v9Ow02VOyeOACbE7nrGJQs74w BPMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WwBXZ44fT2NEqTG8DfyJRaOe+mWShocYl5YxWZ9eeE4=; b=imblFJQgyuwERx0LK2lAzWGU/0G+6KIGeddjoduXwuma4oRMo4Ne+KuXNSudcma34N by6YX/UgX0STc8qR/aSLiLQpvyq38PYLUTdx86uFCRVaFXIhJ4Miwi3ZgVZIQgPt0V1l RcZPryLsblVGUb2SIoPrlwlaZ+6bjMe3TIBthpIPGn0R8Djdkl4w4OMiDdHG+4CgZkB0 6UKSGGn2Efk+pk5U61EdnO6zeCkJVfDKTxSwAzD8SuM0H4InMKKVKAwbyS6azkKQvKcx FKeRQV7ErbkPdHLZsU7jNzsHaUwVrOdnTrn31kr+E7u7+37GVjst1I5lZVV/aMgQ68LQ RbTQ== X-Gm-Message-State: AOUpUlFQYjLuKjGrX6zIAbUPxb9UKr4l6j4ZPpSJmVOn2U+5aEUh4ina x9cMWWnNQSV1jlS9lxFfwHblXw== X-Google-Smtp-Source: AA+uWPwbkTCmxmXTBIrW3iuFEI+izJI9xA1TxidoWrto5EZ+DMbWWV5j7ouBbEQzhZte6HQPRVlILQ== X-Received: by 2002:a63:2359:: with SMTP id u25-v6mr22091839pgm.220.1534265723636; Tue, 14 Aug 2018 09:55:23 -0700 (PDT) Received: from xeon-e3 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id f6-v6sm34140832pgf.52.2018.08.14.09.55.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Aug 2018 09:55:23 -0700 (PDT) Date: Tue, 14 Aug 2018 09:55:21 -0700 From: Stephen Hemminger To: Matan Azrad Cc: "dev@dpdk.org" Message-ID: <20180814095521.492e575a@xeon-e3> In-Reply-To: References: <20180814001926.19630-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] ethdev: fix rte_eth_dev_owner_unset X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Aug 2018 16:55:24 -0000 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; The failsafe driver never checks the return value, and therefore doesn't see that it never clears ownership.