From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3chas3@gmail.com> Received: from mail-qt0-f195.google.com (mail-qt0-f195.google.com [209.85.216.195]) by dpdk.org (Postfix) with ESMTP id CFC1B201 for ; Sat, 25 Nov 2017 00:57:25 +0100 (CET) Received: by mail-qt0-f195.google.com with SMTP id r39so33017391qtr.13 for ; Fri, 24 Nov 2017 15:57:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=dC5ndccFNEjV9POscEuZDLs/rPfPZfs/nXEKSqHeLwY=; b=nHoCXFqJPtDYI1ZJEz2yWSEdLPYr/7pL3dnqk7psS/R9lHyxzdkyQsfURyOdGPs/EW Q49y0UH+se8yoFXUW4zQw/XHtdqjGCUCoyo2HYvcL8id8YdF2LUcl/k+QaRipX+4eXxl HuC39cvMQBKbUR74h0M0LPeLOXHHsIsXjZ9UznNvpYXAG/ZOFv1ELHJGTOyTxWXCEr14 ujKyDU6768aWK+3PCUhNQNqBSyxR0hzgh2sZfiaScTlefLplTXOrgP9JhD3BpLJhLWxa OV5Naj2vpJ9giA3lk/pOTtHKStgywnCaHQ6yrWBLn/cNmnj96O3+0SN+qtfdYf2M0kDn Gn4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=dC5ndccFNEjV9POscEuZDLs/rPfPZfs/nXEKSqHeLwY=; b=lmHsEmb5KMCPTumpdgvBFWJefM8wPBa4uJg8Lg7XnO3sbWUPESUlrusR1lqKgjhmoK OkZQfiC2E98M1F44ByHW+JsbQhHjz1qydF8Ou648aMEnNy+7GMagn9js/TaXtF+aB6lh sxZRyA3F9IR7MWd/W5XSgR+vH2GCxr5v6l1Np96tZgAPNb6C8BghujE49OJKitqwHNXX DPi/Sqi4ZziXLnHyAMwQZp8I9WxFF2g+wLep0DdNIaNtAPhBhx1QpMmO5BwxmPvkGAct LoXOMyRvJh3ciXSKV5LuUVBN5yU+F+pjjv2fl+o46fWSrDwZ4NRXenD7EF2zHvMT+gvL zbpQ== X-Gm-Message-State: AJaThX7FpGgCEc7XUjrsQqLE98Wgtu3mfO3MSCLhlJ/0GMZaqaHOJzIc Q8nkyZm0haJm62yP14HjV7xT8w== X-Google-Smtp-Source: AGs4zMZRmh5TtLf3anlnNS4Khzq5zyH3mrF1QVk8zIgnr8CrFlxJtykVLzQKrjN5N7WPwA05Savklw== X-Received: by 10.200.34.239 with SMTP id g44mr49179231qta.11.1511567844804; Fri, 24 Nov 2017 15:57:24 -0800 (PST) Received: from monolith.home (pool-173-79-224-159.washdc.fios.verizon.net. [173.79.224.159]) by smtp.gmail.com with ESMTPSA id v21sm15754928qtv.21.2017.11.24.15.57.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Nov 2017 15:57:24 -0800 (PST) From: Chas Williams <3chas3@gmail.com> To: dev@dpdk.org Cc: skhare@vmware.com, Chas Williams <3chas3@gmail.com>, Chas Williams Date: Fri, 24 Nov 2017 18:57:18 -0500 Message-Id: <20171124235718.6064-1-3chas3@gmail.com> X-Mailer: git-send-email 2.9.5 Subject: [dpdk-dev] [PATCH] vfio: try physical address if virtual address fails 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: , X-List-Received-Date: Fri, 24 Nov 2017 23:57:26 -0000 Some machines appear to have buggy DMAR mappings. A typical mapping error looks like: DMAR: intel_iommu_map: iommu width (39) is not sufficient for the mapped address (7fc4fa800000) DMAR: intel_iommu_map: iommu width (39) is not sufficient for the mapped address (7fc4fa800000) DMAR: intel_iommu_map: iommu width (39) is not sufficient for the mapped address (7fc4fa800000) DMAR: intel_iommu_map: iommu width (39) is not sufficient for the mapped address (7fc4fa800000) To work around this, attempt to do a physical address mapping if the virtual address mapping fails. Fixes: e85a919286d2 ("vfio: honor IOVA mode before mapping") Signed-off-by: Chas Williams --- lib/librte_eal/linuxapp/eal/eal_vfio.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c index 58f0123..6250676 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -702,6 +703,7 @@ vfio_type1_dma_map(int vfio_container_fd) /* map all DPDK segments for DMA. use 1:1 PA to IOVA mapping */ for (i = 0; i < RTE_MAX_MEMSEG; i++) { struct vfio_iommu_type1_dma_map dma_map; + int retried = false; if (ms[i].addr == NULL) break; @@ -716,9 +718,15 @@ vfio_type1_dma_map(int vfio_container_fd) dma_map.iova = ms[i].iova; dma_map.flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE; +retry: ret = ioctl(vfio_container_fd, VFIO_IOMMU_MAP_DMA, &dma_map); if (ret) { + if (!retried && rte_eal_iova_mode() == RTE_IOVA_VA) { + dma_map.iova = ms[i].iova; + retried = true; + goto retry; + } RTE_LOG(ERR, EAL, " cannot set up DMA remapping, " "error %i (%s)\n", errno, strerror(errno)); -- 2.9.5