DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vfio: try physical address if virtual address fails
@ 2017-11-24 23:57 Chas Williams
  2017-11-27  9:30 ` Zhang, Qi Z
  0 siblings, 1 reply; 4+ messages in thread
From: Chas Williams @ 2017-11-24 23:57 UTC (permalink / raw)
  To: dev; +Cc: skhare, Chas Williams, Chas Williams

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 <chas3@att.com>
---
 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 <fcntl.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
+#include <stdbool.h>
 
 #include <rte_log.h>
 #include <rte_memory.h>
@@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-30  2:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-24 23:57 [dpdk-dev] [PATCH] vfio: try physical address if virtual address fails Chas Williams
2017-11-27  9:30 ` Zhang, Qi Z
2017-11-27 12:58   ` Chas Williams
2017-11-30  2:03     ` Chas Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).