From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rugang Chen Subject: [PATCH] pci: don't insert an unbound device to pci_device_list in pci_scan_one Date: Sat, 25 Jun 2016 03:30:00 -0700 Message-ID: <1466850600-1483-1-git-send-email-rugangchen2011@gmail.com> References: <1466815528-27163-1-git-send-email-rugangchen2011@gmail.com> Cc: Rugang Chen To: dev@dpdk.org Return-path: Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by dpdk.org (Postfix) with ESMTP id 777D4C410 for ; Sat, 25 Jun 2016 12:30:15 +0200 (CEST) Received: by mail-pf0-f194.google.com with SMTP id c74so11446431pfb.0 for ; Sat, 25 Jun 2016 03:30:15 -0700 (PDT) In-Reply-To: <1466815528-27163-1-git-send-email-rugangchen2011@gmail.com> 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" If a device isn't bound by any uio driver (vfio-pci, igb_uio, uio_pci_generic) and is expected to owned by a kernel space driver, here it's still inserted to pci_device_list. This may cause application based on dpdk fetch the device by accident and then the device is hanlded by dpdk. For safe, skip it from pci_device_list as if it's unbound, dpdk won't want to use it. --- lib/librte_eal/linuxapp/eal/eal_pci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index f63febc..432d2e8 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -392,8 +392,12 @@ pci_scan_one(const char *dirname, uint16_t domain, uint8_t bus, * fetch it from pci_device_list by accident and then dpdk handles it. Kernel * space driver maybe wants to own it. */ - if (dev->kdrv == RTE_KDRV_NONE) + if (dev->kdrv == RTE_KDRV_NONE) { + RTE_LOG(WARNING, EAL, "Skip ubound device\n"); + free(dev); return 0; + } + /* device is valid, add in list (sorted) */ if (TAILQ_EMPTY(&pci_device_list)) { TAILQ_INSERT_TAIL(&pci_device_list, dev, next); -- 2.1.4