DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC] vfio: only map regions VFIO supports
@ 2015-07-08 22:38 Stephen Hemminger
  2015-07-10  7:54 ` Qiu, Michael
  0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2015-07-08 22:38 UTC (permalink / raw)
  To: dev

The FM10K driver has 3 BARS numbered 0, 4, and 8. But the kernel
VFIO driver only allows mapping 0-5 anything bigger than that will
return -EINVAL (see kernel source vfio_pci.c:vfio_pci_mmap).

The workaround is to limit the DPDK EAL VFIO support only map
the regions that will work. The FM10K driver is not using BAR8
in current code anyway.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 6 ++++--
 1 file changed, 4 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 426953a..e269e75 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -549,7 +549,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 	int iommu_group_no;
 	char pci_addr[PATH_MAX] = {0};
 	struct rte_pci_addr *loc = &dev->addr;
-	int i, ret, msix_bar;
+	int i, ret, msix_bar, nmaps;
 	struct mapped_pci_resource *vfio_res = NULL;
 	struct mapped_pci_res_list *vfio_res_list = RTE_TAILQ_CAST(rte_vfio_tailq.head, mapped_pci_res_list);
 
@@ -724,7 +724,9 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 	/* map BARs */
 	maps = vfio_res->maps;
 
-	for (i = 0; i < (int) vfio_res->nb_maps; i++) {
+	/* VFIO supports limited (0-5) maps */
+	nmaps = RTE_MIN(vfio_res->nb_maps, VFIO_PCI_ROM_REGION_INDEX - 1);
+	for (i = 0; i < nmaps; i++) {
 		struct vfio_region_info reg = { .argsz = sizeof(reg) };
 		void *bar_addr;
 		struct memreg {
-- 
2.1.4

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

end of thread, other threads:[~2015-07-14 11:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-08 22:38 [dpdk-dev] [RFC] vfio: only map regions VFIO supports Stephen Hemminger
2015-07-10  7:54 ` Qiu, Michael
2015-07-10 17:24   ` Stephen Hemminger
2015-07-14 10:45     ` Qiu, Michael
2015-07-14 11:03     ` Qiu, Michael

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).