From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f67.google.com (mail-lf0-f67.google.com [209.85.215.67]) by dpdk.org (Postfix) with ESMTP id 0E9A42142 for ; Thu, 4 Aug 2016 16:54:12 +0200 (CEST) Received: by mail-lf0-f67.google.com with SMTP id 33so15368407lfw.3 for ; Thu, 04 Aug 2016 07:54:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nfware-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc:message-id:references :to; bh=rHxUZGTHkBeH40O5J780Mx1McuKPEH+bCY0gV7VxLqA=; b=sALn2MyH5tLY5STd33W/CQ7FBbXCkQRoC+7wVwwaof8C2KiB7rpalo63K1GInBaBRZ 8V1mm0OP8oWGwSg7MaIj9mu/fA/y5Dtkgk3dFF02LXZv2xhacANOb1nj4w1O+z8q7ygc XUCR+C03nQ5irRg1oL8U44y7HEN+S0U3FlhIycJbDSRhIggWvc6aTajTIpCzbDakJkY6 geeUyUs/mmjhMy2WA9wMNyQrVcOrR7GhejzGNXoNT21r8MsCdTkZN4qnqiBlfkuJYQNe N4TDUcO9Q1uS6DQ0POaGAWAjNb0IqvrzNmFylzUOEJZjfp+6AMfVTfjSFEHS8hWDwlCj z8zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=rHxUZGTHkBeH40O5J780Mx1McuKPEH+bCY0gV7VxLqA=; b=Vr8e7X5RGoAgCgoS7kJ2HvUn9VA0Bz3/KqmWyCHx0WoCPxb7+KA1yvomCOekRWPigR OTtnumSLHwGvPGWLKtAnmw0wrtn5/1VaX99xGOFcxe0+J3i/KZl2moG9gUePwmqgaDJf 6EmoemxttdKXhEwg7do+Q+D7V58EWc3qIVXL284BIiLydDPNW2ORII0aGCx6hW3fye1g Q+2KCxZ+K5R78gTs1EAzt9f74K0B5EQ9Sucnvmwm4sNGR9U/v2TrEEmH7SNLlVZja3+T UkUq+ynRUMuidOIOMDvL3chSmP3zmwCx/69lDz8BeTI78NqeUP9MtRgpZZgKrxsMzYnx WfmQ== X-Gm-Message-State: AEkooutHl/fT9rGwMhA/leWA8ruGepnD28me3BdS1faBLl54lRSvAKPB7PAHNmmKtkERoQ== X-Received: by 10.25.20.226 with SMTP id 95mr20320185lfu.194.1470322451463; Thu, 04 Aug 2016 07:54:11 -0700 (PDT) Received: from [172.20.100.10] (vpn.arccn.ru. [95.182.74.2]) by smtp.gmail.com with ESMTPSA id f64sm2493617lfi.36.2016.08.04.07.54.10 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Aug 2016 07:54:10 -0700 (PDT) Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) From: Igor Ryzhov In-Reply-To: <57A34175.1040204@intel.com> Date: Thu, 4 Aug 2016 17:54:09 +0300 Cc: dev@dpdk.org, David Marchand , "Liu, Yuanhan" Message-Id: <9C1AE4BF-9530-4596-BCF6-09E9AF7E55F3@nfware.com> References: <57A32814.1000404@intel.com> <0AB336DF-9C66-4826-BA17-EDE1F8D6A2EA@nfware.com> <57A34175.1040204@intel.com> To: Ferruh Yigit X-Mailer: Apple Mail (2.3124) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] rte_eth_dev_attach returns 0, although device is not attached X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Aug 2016 14:54:12 -0000 > 4 =D0=B0=D0=B2=D0=B3. 2016 =D0=B3., =D0=B2 16:21, Ferruh Yigit = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0= ): >=20 > On 8/4/2016 12:51 PM, Igor Ryzhov wrote: >> Hello Ferruh, >>=20 >>> 4 =D0=B0=D0=B2=D0=B3. 2016 =D0=B3., =D0=B2 14:33, Ferruh Yigit = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0= ): >>>=20 >>> Hi Igor, >>>=20 >>> On 8/3/2016 5:58 PM, Igor Ryzhov wrote: >>>> Hello. >>>>=20 >>>> 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 =3D pci_probe_all_drivers(dev); >>>> if (ret < 0) >>>> goto err_return; >>>> return 0; >>>> (pci_probe_all_drivers returns 1 in that case) >>>>=20 >>>> For example, it can be easily reproduced by trying to attach virtio = device, managed by kernel driver. >>>=20 >>> You are right, and I did able to reproduce this issue with virtio as = you >>> suggest. >>>=20 >>> 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. >=20 > With a second check, rte_eth_dev_get_port_by_addr() catches it if the > driver is missing. >=20 > But for virtio case, problem is not missing driver. > Problem is eth_virtio_dev_init() is returning a positive value on = fail. >=20 > Call stack is: > rte_eal_pci_probe_one > pci_probe_all_drivers > rte_eal_pci_probe_one_driver > rte_eth_dev_init > eth_virtio_dev_init >=20 > So rte_eal_pci_probe_one_driver() also returns positive value, as no > driver found, and rte_eth_dev_get_port_by_addr() returns a valid > port_id, since rte_eth_dev_init() allocated an eth_dev. >=20 > Briefly, this can be fixed in virtio pmd, instead of eal pci. >=20 >>>=20 >>>>=20 >>>> I think it should be: >>>> ret =3D pci_probe_all_drivers(dev); >>>> if (ret) >>>> goto err_return; >>>> return 0; >>>=20 >>> Your proposal looks good to me. Will you send a patch? >>=20 >=20 > Original code silently ignores the if driver is missing for that dev, > although it is still questionable, I think we can keep this as it is. >=20 >> Patch sent. >=20 > Sorry for this, but can you please test with following modification in > virtio: > index 07d6449..c74eeee 100644 > --- a/drivers/net/virtio/virtio_ethdev.c > +++ b/drivers/net/virtio/virtio_ethdev.c > @@ -1156,7 +1156,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) > if (pci_dev) { > ret =3D vtpci_init(pci_dev, hw, &dev_flags); > if (ret) > - return ret; > + return -1; > } >=20 > /* Reset the device although not necessary at startup */ I think it's not a good change, because it will break the idea of this = patch - http://dpdk.org/browse/dpdk/commit/?id=3Dac5e1d83 = Also, with your patch the application will not start, because = rte_eal_pci_probe will fail: if (ret < 0) rte_exit(EXIT_FAILURE, "Requested device " PCI_PRI_FMT " cannot be used\n", dev->addr.domain, = dev->addr.bus, dev->addr.devid, dev->addr.function); And now I think that maybe we should change the way rte_eal_pci_probe = works. I think we shouldn't stop the application if just one of PCI devices is = not probed successfully. >=20 >=20 >>=20 >>>=20 >>>> Best regards, >>>> Igor