From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by dpdk.org (Postfix) with ESMTP id CB9258D8A for ; Tue, 27 Oct 2015 03:34:49 +0100 (CET) Received: by pabla5 with SMTP id la5so13291567pab.0 for ; Mon, 26 Oct 2015 19:34:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=yuuwzTFiyOyayR+2tMA3K8CXu6P9yMfAd+KX4vUXaqw=; b=Hb+HT0bAPoEee31RXAzTPY+zM33p33jb7uakpRpbXJvt8XxkRkmh9d/k2m+ZN82xLk MUqf9w2NaEleQB74XZt/oS7M28yLL9oP2Tt4c2mbEkaT+1tNZLmWk6v4kBThNg3CPVqt x1NImbzd2YAQL+JaZuglVNXXetKHqHGCtK2k3DAU0JqIvLLHKBwlXz2Ge0dWsG6Xch6o pGYtGYzXlhpvPKmjFdgkgeqAHlFOzMaYP44MVeAUTHdMxkZ6J1L+eew5zXyVPuw3xZRM njScB/plTJaULB6EUiaF1hXe3KMuxEZ9ku0gDpT4rm+ya9LBWzTN/pAoPJNycstlyKnK hpWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=yuuwzTFiyOyayR+2tMA3K8CXu6P9yMfAd+KX4vUXaqw=; b=b5JlAvNCevZVa4fvd3dXrw594vc9kJJ6mYQEYnNopOonup0uylYUt9feteqfzMFKSD 2Y4AwWthsHkizCqC/4NE4wk3ShpZ4JMwBj+T5n/2PrNGZk77OiJlU2jwmJE3//pP5RGP Hwqj8AtqjZANVj/nj8peQioz3p8dwNcdqaFTA7BHVJ6Je80rrCzFfs87TtphHSO6Ub9F J90/TzCgtXEr/aZz3uWqzXPTE+Mt34sc1dxtWh3+ettYdh1d0jhFm9S/oY9h6Chg5a0Y 0jcW3fNNI2aKAzl1V6lybtRS6IpXxs0lyCvpftMCCPkKWPuhZpzkZqEmhJVYbTVoN/8X 2c7Q== X-Gm-Message-State: ALoCoQlkhOio8G94REjz3yk0mWePzkUXs+xj1ywXE6F8d8VDSFXX9M8vcuR4R/1e8FomQ2wYqSE9 X-Received: by 10.68.103.161 with SMTP id fx1mr25465792pbb.42.1445913289142; Mon, 26 Oct 2015 19:34:49 -0700 (PDT) Received: from localhost.localdomain ([58.123.138.250]) by smtp.gmail.com with ESMTPSA id c4sm36579762pat.46.2015.10.26.19.34.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Oct 2015 19:34:48 -0700 (PDT) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: dev@dpdk.org Date: Tue, 27 Oct 2015 11:34:28 +0900 Message-Id: <1445913268-26457-1-git-send-email-shemming@brocade.com> X-Mailer: git-send-email 2.1.4 Cc: alex.williamson@redhat.com Subject: [dpdk-dev] [PATCH] vfio: support iommu group zero 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: Tue, 27 Oct 2015 02:34:50 -0000 From: Stephen Hemminger The implementation of VFIO is broken on some platforms and if using the proposed VFIO without IOMMU patch. IOMMU group zero is a valid value. Change code to split the return value from the group value. Signed-off-by: Stephen Hemminger --- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c index 0e6c48a..74f91ba 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c @@ -499,14 +499,15 @@ pci_vfio_get_group_fd(int iommu_group_no) } /* parse IOMMU group number for a PCI device - * returns -1 for errors, 0 for non-existent group */ + * returns 1 on success, -1 for errors, 0 for non-existent group + */ static int -pci_vfio_get_group_no(const char *pci_addr) +pci_vfio_get_group_no(const char *pci_addr, int *iommu_group_no) { char linkname[PATH_MAX]; char filename[PATH_MAX]; char *tok[16], *group_tok, *end; - int ret, iommu_group_no; + int ret; memset(linkname, 0, sizeof(linkname)); memset(filename, 0, sizeof(filename)); @@ -533,13 +534,13 @@ pci_vfio_get_group_no(const char *pci_addr) errno = 0; group_tok = tok[ret - 1]; end = group_tok; - iommu_group_no = strtol(group_tok, &end, 10); + *iommu_group_no = strtol(group_tok, &end, 10); if ((end != group_tok && *end != '\0') || errno != 0) { RTE_LOG(ERR, EAL, " %s error parsing IOMMU number!\n", pci_addr); return -1; } - return iommu_group_no; + return 1; } static void @@ -581,16 +582,15 @@ pci_vfio_map_resource(struct rte_pci_device *dev) loc->domain, loc->bus, loc->devid, loc->function); /* get group number */ - iommu_group_no = pci_vfio_get_group_no(pci_addr); - - /* if 0, group doesn't exist */ - if (iommu_group_no == 0) { + ret = pci_vfio_get_group_no(pci_addr, &iommu_group_no); + if (ret == 0) { RTE_LOG(WARNING, EAL, " %s not managed by VFIO driver, skipping\n", - pci_addr); + pci_addr); return 1; } + /* if negative, something failed */ - else if (iommu_group_no < 0) + if (ret < 0) return -1; /* get the actual group fd */ -- 2.1.4