From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ferruh Yigit Subject: Re: rte_eth_dev_attach returns 0, although device is not attached Date: Thu, 4 Aug 2016 12:33:40 +0100 Message-ID: <57A32814.1000404@intel.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Cc: David Marchand To: Igor Ryzhov , dev@dpdk.org Return-path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id AFE3F3794 for ; Thu, 4 Aug 2016 13:33:43 +0200 (CEST) In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Igor, On 8/3/2016 5:58 PM, Igor Ryzhov wrote: > Hello. > > Function rte_eth_dev_attach can return false positive result. > It happens because rte_eal_pci_probe_one returns zero if no driver is found for the device: > ret = pci_probe_all_drivers(dev); > if (ret < 0) > goto err_return; > return 0; > (pci_probe_all_drivers returns 1 in that case) > > For example, it can be easily reproduced by trying to attach virtio device, managed by kernel driver. You are right, and I did able to reproduce this issue with virtio as you suggest. But I wonder why rte_eth_dev_get_port_by_addr() is not catching this. Perhaps a dev->attached check needs to be added into this function. > > I think it should be: > ret = pci_probe_all_drivers(dev); > if (ret) > goto err_return; > return 0; Your proposal looks good to me. Will you send a patch? > Best regards, > Igor >