From patchwork Tue Jul 3 12:09:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Lucero X-Patchwork-Id: 42152 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9E75B1BF00; Tue, 3 Jul 2018 14:10:08 +0200 (CEST) Received: from netronome.com (host-79-78-33-110.static.as9105.net [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id 102BA1BE3A; Tue, 3 Jul 2018 14:09:57 +0200 (CEST) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id w63C9raO033394; Tue, 3 Jul 2018 13:09:53 +0100 Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id w63C9rhm033393; Tue, 3 Jul 2018 13:09:53 +0100 From: Alejandro Lucero To: dev@dpdk.org Cc: stable@dpdk.org, anatoly.burakov@intel.com, maxime.coquelin@redhat.com Date: Tue, 3 Jul 2018 13:09:46 +0100 Message-Id: <1530619789-33337-4-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1530619789-33337-1-git-send-email-alejandro.lucero@netronome.com> References: <1530619789-33337-1-git-send-email-alejandro.lucero@netronome.com> Subject: [dpdk-dev] [PATCH v2 3/6] bus/pci: use IOVAs check when setting IOVA mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Although VT-d emulation currently only supports 39 bits, it could be iovas being within that supported range. This patch allows IOVA mode in such a case. Indeed, memory initialization code can be modified for using lower virtual addresses than those used by the kernel for 64 bits processes by default, and therefore memsegs iovas can use 39 bits or less for most system. And this is likely 100% true for VMs. Signed-off-by: Alejandro Lucero --- drivers/bus/pci/linux/pci.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index 74deef3..792c819 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "eal_private.h" #include "eal_filesystem.h" @@ -613,10 +614,12 @@ fclose(fp); mgaw = ((vtd_cap_reg & VTD_CAP_MGAW_MASK) >> VTD_CAP_MGAW_SHIFT) + 1; - if (mgaw < X86_VA_WIDTH) + + if (!rte_eal_check_dma_mask(mgaw)) + return true; + else return false; - return true; } #elif defined(RTE_ARCH_PPC_64) static bool @@ -640,13 +643,17 @@ { struct rte_pci_device *dev = NULL; struct rte_pci_driver *drv = NULL; + int iommu_dma_mask_check_done = 0; FOREACH_DRIVER_ON_PCIBUS(drv) { FOREACH_DEVICE_ON_PCIBUS(dev) { if (!rte_pci_match(drv, dev)) continue; - if (!pci_one_device_iommu_support_va(dev)) - return false; + if (!iommu_dma_mask_check_done) { + if (pci_one_device_iommu_support_va(dev) < 0) + return false; + iommu_dma_mask_check_done = 1; + } } } return true;