From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by dpdk.org (Postfix) with ESMTP id 6034E11F5 for ; Wed, 9 Dec 2015 18:55:50 +0100 (CET) Received: by pacdm15 with SMTP id dm15so33248859pac.3 for ; Wed, 09 Dec 2015 09:55:49 -0800 (PST) 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=96TvDsEviPtygT7vkUrofGdeNAtgR7ijiarkw8Kl2AY=; b=SWzCv9mqd59QlD8KfD88x3YFTw9ZxtXtGWSdHo57qjSTXOf8L6VY3NRPvpEDLfa3jO Ch1DycdHh1/N1o8X1X0MaJVMUNCtRVbznscs0wCGUTGtTghahoRoFvnFJfCQvgBU87iZ 4/loUJNArXVWWGr00n/UGmjCZwYaUuOxD/hD3lcFfYhnPsgNhUvIVVFI9JieWZW5tRg3 6ys28fMi6kcBnK11T+XWpRAonFskWLGmIqLwZniBsCu8AfCD7ZJ7YttLpPlX97BtpjFZ I5qYxs4Mgz8QsgIohLi1bhfgedwGTzzQiGOvH9tzl84oQ90RgHfHnTrJUkGcECtFyTDI UYJg== 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=96TvDsEviPtygT7vkUrofGdeNAtgR7ijiarkw8Kl2AY=; b=N3+6opQrF1TT5+0mTPkOnbLwB6whdqX7FcUZwHtPnbXJnASTX4UJpdA9OULRU41eNc dZ6mZJWlXfa2YdMb3wdbUygtQOACa3HXkENQUCpUiHBjjNwG72/JMSe77sXyCnQfQQA9 P0hsAsWT563CmkSaQRrTHESLQS2uYnFMNycfHC861lW1jsuP+C81n+dQaOUt+x5MwmEA I+ucr9oy1eSJxq9U4QsYsYdkfc9CrlfsQE3Vpdn3Ae1IZIFybF0akyQStEUdqwdiM47i dLvHy0tSVo6EwMoP64rc/PeJ+TJdpnpNq8MyDwVmGgDb9j9n1HINTO7VImlt7eU4lhTg 2Z6Q== X-Gm-Message-State: ALoCoQnAIL4W+ndrWXaC1kFEtpSQFkf2OWaa2qgCz+ZivxEsjtQ9FjqILErWA5zHq70IqR6mhE7sS1bsXyXFE/QKuwQedpkMEw== X-Received: by 10.66.142.168 with SMTP id rx8mr9813831pab.16.1449683749718; Wed, 09 Dec 2015 09:55:49 -0800 (PST) Received: from xeon-e3.home.lan (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id s10sm7988688par.45.2015.12.09.09.55.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Dec 2015 09:55:48 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Date: Wed, 9 Dec 2015 09:55:56 -0800 Message-Id: <1449683756-13381-1-git-send-email-stephen@networkplumber.org> X-Mailer: git-send-email 2.1.4 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: Wed, 09 Dec 2015 17:55:50 -0000 The current implementation of VFIO will not with the new no-IOMMU mode in 4.4 kernel. The original code assumed that IOMMU group zero would never be used. Group numbers are assigned starting at zero, and up until now the group numbers came from the hardware which is likely to use group 0 for system devices that are not used with DPDK. The fix is to allow 0 as a valid group and rearrange code to split the return value from the group value. Signed-off-by: Stephen Hemminger --- Why was this ignored? It was originally sent on 26 Oct 15 back when IOMMU discussion was lively. 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