Skip to content

Commit

Permalink
vfio: use contiguous mapping for IOVA as VA mode
Browse files Browse the repository at this point in the history
[ upstream commit 78a6d7e ]

When using IOVA as VA mode, there is no need to map segments
page by page. This normally isn't a problem, but it becomes one
when attempting to use DPDK in no-huge mode, where VFIO subsystem
simply runs out of space to store mappings.

Fix this for x86 by triggering different callbacks based on whether
IOVA as VA mode is enabled.

Fixes: 73a6390 ("vfio: allow to map other memory regions")

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Tested-by: Andrius Sirvys <andrius.sirvys@intel.com>
  • Loading branch information
anatolyburakov authored and kevintraynor committed Sep 4, 2019
1 parent 4551d9c commit f61b77c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/librte_eal/linuxapp/eal/eal_vfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,19 @@ rte_vfio_get_group_num(const char *sysfs_base,
return 1;
}

static int
type1_map_contig(const struct rte_memseg_list *msl, const struct rte_memseg *ms,
size_t len, void *arg)
{
int *vfio_container_fd = arg;

if (msl->external)
return 0;

return vfio_type1_dma_mem_map(*vfio_container_fd, ms->addr_64, ms->iova,
len, 1);
}

static int
type1_map(const struct rte_memseg_list *msl, const struct rte_memseg *ms,
void *arg)
Expand Down Expand Up @@ -1289,6 +1302,13 @@ vfio_type1_dma_mem_map(int vfio_container_fd, uint64_t vaddr, uint64_t iova,
static int
vfio_type1_dma_map(int vfio_container_fd)
{
if (rte_eal_iova_mode() == RTE_IOVA_VA) {
/* with IOVA as VA mode, we can get away with mapping contiguous
* chunks rather than going page-by-page.
*/
return rte_memseg_contig_walk(type1_map_contig,
&vfio_container_fd);
}
return rte_memseg_walk(type1_map, &vfio_container_fd);
}

Expand Down

0 comments on commit f61b77c

Please sign in to comment.