From patchwork Thu Jul 7 22:26:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yong Wang X-Patchwork-Id: 14657 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 [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id C661A2C13; Fri, 8 Jul 2016 00:43:04 +0200 (CEST) Received: from smtp-outbound-1.vmware.com (smtp-outbound-1.vmware.com [208.91.2.12]) by dpdk.org (Postfix) with ESMTP id 2B1B3137D for ; Fri, 8 Jul 2016 00:43:03 +0200 (CEST) Received: from sc9-mailhost3.vmware.com (sc9-mailhost3.vmware.com [10.113.161.73]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 6FCB99868B; Thu, 7 Jul 2016 15:43:00 -0700 (PDT) Received: from prmh-edge-ivybridge-01.eng.vmware.com (unknown [10.24.235.72]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 5B75B40415; Thu, 7 Jul 2016 15:43:01 -0700 (PDT) From: Yong Wang To: anatoly.burakov@intel.com Cc: dev@dpdk.org, Yong Wang , Ronghua Zhang Date: Thu, 7 Jul 2016 15:26:36 -0700 Message-Id: <1467930397-39777-1-git-send-email-yongwang@vmware.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH 1/2] vfio: fix pci_vfio_map_resource 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The offset of the 2nd mmap when mapping the region after msix_bar needs to take region address into consideration. This is exposed when using vfio-pci to manage vmxnet3 pmd. Fixes: 90a1633b2347 ("eal/linux: allow to map BARs with MSI-X tables") Signed-off-by: Yong Wang Signed-off-by: Ronghua Zhang --- lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c index f91b924..3729c35 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c @@ -896,7 +896,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev) } else { memreg[0].offset = reg.offset; memreg[0].size = table_start; - memreg[1].offset = table_end; + memreg[1].offset = reg.offset + table_end; memreg[1].size = reg.size - table_end; RTE_LOG(DEBUG, EAL, @@ -939,7 +939,8 @@ pci_vfio_map_resource(struct rte_pci_device *dev) /* if there's a second part, try to map it */ if (map_addr != MAP_FAILED && memreg[1].offset && memreg[1].size) { - void *second_addr = RTE_PTR_ADD(bar_addr, memreg[1].offset); + void *second_addr = RTE_PTR_ADD(bar_addr, + memreg[1].offset - memreg[0].offset); map_addr = pci_map_resource(second_addr, vfio_dev_fd, memreg[1].offset, memreg[1].size,