Skip to contentSkip to conversation

vfio: make container open error non-fatal

PATCH In review Bruce Richardson 3 participants 7 messages Jun 16, 2014 – Jun 17, 2014 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio: make container open error non-fatal

When setting up an app to run using the uio driver, errors caused by VFIO failures should not abruptly cause the app to fail.

Example: on a board with 8 ports bound to igb_uio module, and no VFIO configuration, a testpmd run currently fails with:

EAL:   cannot open VFIO container!
EAL:   0000:04:00.0 cannot open VFIO container!
EAL: Error - exiting with code: 1

Cause: Requested device 0000:04:00.0 cannot be used

With this patch applied, the problem with VFIO is ignored and testpmd successfully starts up - with ignored errors with vfio - as below:

EAL: PCI device 0000:04:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1521 rte_igb_pmd
EAL:   unknown IOMMU driver!
EAL:   0000:04:00.0 cannot open VFIO container!
EAL:   0000:04:00.0 not managed by UIO driver, skipping
<...scan results for other ports skipped...>
EAL: PCI device 0000:8e:00.0 on NUMA socket 1
EAL:   probe driver: 8086:154a rte_ixgbe_pmd
EAL:   unknown IOMMU driver!
EAL:   0000:8e:00.0 cannot open VFIO container!
EAL:   PCI memory mapped at 0x7ff4ff5fa000
EAL:   PCI memory mapped at 0x7ff4ff5f6000
EAL: PCI device 0000:8e:00.1 on NUMA socket 1
EAL:   probe driver: 8086:154a rte_ixgbe_pmd
EAL:   unknown IOMMU driver!
EAL:   0000:8e:00.1 cannot open VFIO container!
EAL:   PCI memory mapped at 0x7ff4ff4f6000
EAL:   PCI memory mapped at 0x7ff4ff4f2000

Interactive-mode selected
Configuring Port 0 (socket 0)
<...other 7 ports ...>
Checking link statuses...
Port 0 Link Up - speed 10000 Mbps - full-duplex
Port 1 Link Down
Port 2 Link Up - speed 10000 Mbps - full-duplex
Port 3 Link Down
Port 4 Link Up - speed 10000 Mbps - full-duplex
Port 5 Link Down
Port 6 Link Up - speed 10000 Mbps - full-duplex
Port 7 Link Down
Done
testpmd>

This issue is introduced by the VFIO patch set addition, specifically commit ff0b67d1.

---
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -1
index 4de6061..4af38f6 100644
@@ -528,7 +528,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 		int vfio_container_fd = pci_vfio_get_container_fd();
 		if (vfio_container_fd < 0) {
 			RTE_LOG(ERR, EAL, "  %s cannot open VFIO container!\n", pci_addr);
-			return -1;
+			return 1;
 		}
 
 		vfio_cfg.vfio_container_fd = vfio_container_fd;
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1402957745-31967-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw

The below patch is the quickest fix I found to make my applications work again, but I'm not sure it's the best solution. Can anyone else offer other suggestions to improve this?

Quoted 79 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Monday, June 16, 2014 3:29 PM
To: [email protected]
Cc: Richardson, Bruce
Subject: [PATCH] vfio: make container open error non-fatal

When setting up an app to run using the uio driver, errors caused by VFIO failures should not abruptly cause the app to fail.

Example: on a board with 8 ports bound to igb_uio module, and no VFIO configuration, a testpmd run currently fails with:

EAL:   cannot open VFIO container!
EAL:   0000:04:00.0 cannot open VFIO container!
EAL: Error - exiting with code: 1

Cause: Requested device 0000:04:00.0 cannot be used

With this patch applied, the problem with VFIO is ignored and testpmd successfully starts up - with ignored errors with vfio - as below:

EAL: PCI device 0000:04:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1521 rte_igb_pmd
EAL:   unknown IOMMU driver!
EAL:   0000:04:00.0 cannot open VFIO container!
EAL:   0000:04:00.0 not managed by UIO driver, skipping
<...scan results for other ports skipped...>
EAL: PCI device 0000:8e:00.0 on NUMA socket 1
EAL:   probe driver: 8086:154a rte_ixgbe_pmd
EAL:   unknown IOMMU driver!
EAL:   0000:8e:00.0 cannot open VFIO container!
EAL:   PCI memory mapped at 0x7ff4ff5fa000
EAL:   PCI memory mapped at 0x7ff4ff5f6000
EAL: PCI device 0000:8e:00.1 on NUMA socket 1
EAL:   probe driver: 8086:154a rte_ixgbe_pmd
EAL:   unknown IOMMU driver!
EAL:   0000:8e:00.1 cannot open VFIO container!
EAL:   PCI memory mapped at 0x7ff4ff4f6000
EAL:   PCI memory mapped at 0x7ff4ff4f2000

Interactive-mode selected
Configuring Port 0 (socket 0)
<...other 7 ports ...>
Checking link statuses...
Port 0 Link Up - speed 10000 Mbps - full-duplex
Port 1 Link Down
Port 2 Link Up - speed 10000 Mbps - full-duplex
Port 3 Link Down
Port 4 Link Up - speed 10000 Mbps - full-duplex
Port 5 Link Down
Port 6 Link Up - speed 10000 Mbps - full-duplex
Port 7 Link Down
Done
testpmd>

This issue is introduced by the VFIO patch set addition, specifically commit ff0b67d1.

---
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -1
index 4de6061..4af38f6 100644
@@ -528,7 +528,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 		int vfio_container_fd = pci_vfio_get_container_fd();
 		if (vfio_container_fd < 0) {
 			RTE_LOG(ERR, EAL, "  %s cannot open VFIO
 container!\n", pci_addr);
-			return -1;
+			return 1;
 		}
 

vfio_cfg.vfio_container_fd = vfio_container_fd;
--
1.9.3

A message that is not in the archive (sent off-list or not yet received): 59AF69C657FD0841A61C55336867B5B01AA36B94-kPTMFJFq+rELt2AQoY/[email protected]

#4 lore raw

Hi Bruce,

Quoted 3 lines

The below patch is the quickest fix I found to make my applications work again, but I'm not sure it's the best solution. Can anyone else offer other suggestions to improve this?

Are you running things as root? If not, I suggest to try and use the setup.sh script to correct permissions on the VFIO container and see if it works.

The inability of opening a container is likely a problem with permissions on the container, and thus should be considered fatal as far as VFIO is concerned. However, given that we try to use VFIO unconditionally, I think your suggestion is a good solution to the problem, however I would also close the group fd's that were already opened before returning 1.

Best regards,
Anatoly Burakov
DPDK SW Engineer

A message that is not in the archive (sent off-list or not yet received): C6ECDF3AB251BE4894318F4E451236976CC9C63B-kPTMFJFq+rF9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org

#6 lore raw
Quoted 8 lines

-----Original Message-----
From: Burakov, Anatoly
Sent: Tuesday, June 17, 2014 1:52 AM
To: Richardson, Bruce; [email protected]
Subject: RE: [PATCH] vfio: make container open error non-fatal

Quoted 9 lines

Hi Bruce,

Quoted 3 lines

The below patch is the quickest fix I found to make my applications work again, but I'm not sure it's the best solution. Can anyone else offer other suggestions to improve this?

Are you running things as root? If not, I suggest to try and use the setup.sh script to correct permissions on the VFIO container and see if it works.

Same error running with or without sudo. I'm not trying to get vfio to work, I'm trying to find out how to make dpdk ignore vfio since I didn't do any setting up of vfio. :-)

#7 lore raw
In reply to a message not in the archive
Quoted 78 lines · Bruce

The below patch is the quickest fix I found to make my applications work again, but I'm not sure it's the best solution. Can anyone else offer other suggestions to improve this?

Quoted 76 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Monday, June 16, 2014 3:29 PM
To: [email protected]
Cc: Richardson, Bruce
Subject: [PATCH] vfio: make container open error non-fatal

When setting up an app to run using the uio driver, errors caused by VFIO failures should not abruptly cause the app to fail.

Example: on a board with 8 ports bound to igb_uio module, and no VFIO configuration, a testpmd run currently fails with:

EAL:   cannot open VFIO container!
EAL:   0000:04:00.0 cannot open VFIO container!
EAL: Error - exiting with code: 1

Cause: Requested device 0000:04:00.0 cannot be used

With this patch applied, the problem with VFIO is ignored and testpmd successfully starts up - with ignored errors with vfio - as below:

EAL: PCI device 0000:04:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1521 rte_igb_pmd
EAL:   unknown IOMMU driver!
EAL:   0000:04:00.0 cannot open VFIO container!
EAL:   0000:04:00.0 not managed by UIO driver, skipping
<...scan results for other ports skipped...>
EAL: PCI device 0000:8e:00.0 on NUMA socket 1
EAL:   probe driver: 8086:154a rte_ixgbe_pmd
EAL:   unknown IOMMU driver!
EAL:   0000:8e:00.0 cannot open VFIO container!
EAL:   PCI memory mapped at 0x7ff4ff5fa000
EAL:   PCI memory mapped at 0x7ff4ff5f6000
EAL: PCI device 0000:8e:00.1 on NUMA socket 1
EAL:   probe driver: 8086:154a rte_ixgbe_pmd
EAL:   unknown IOMMU driver!
EAL:   0000:8e:00.1 cannot open VFIO container!
EAL:   PCI memory mapped at 0x7ff4ff4f6000
EAL:   PCI memory mapped at 0x7ff4ff4f2000

Interactive-mode selected
Configuring Port 0 (socket 0)
<...other 7 ports ...>
Checking link statuses...
Port 0 Link Up - speed 10000 Mbps - full-duplex
Port 1 Link Down
Port 2 Link Up - speed 10000 Mbps - full-duplex
Port 3 Link Down
Port 4 Link Up - speed 10000 Mbps - full-duplex
Port 5 Link Down
Port 6 Link Up - speed 10000 Mbps - full-duplex
Port 7 Link Down
Done
testpmd>

This issue is introduced by the VFIO patch set addition, specifically commit ff0b67d1.

---
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -1
index 4de6061..4af38f6 100644
@@ -528,7 +528,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 		int vfio_container_fd = pci_vfio_get_container_fd();
 		if (vfio_container_fd < 0) {
 			RTE_LOG(ERR, EAL, "  %s cannot open VFIO
 container!\n", pci_addr);
-			return -1;
+			return 1;
 		}
 
Quoted 5 lines
Quoted 3 lines

vfio_cfg.vfio_container_fd = vfio_container_fd;
--
1.9.3

I think it would be preferable to convert the pci_vfio_get_container_fd function to return not -1, but some -ERRNO value, so that the caller can differentiate between fatal and non-fatal errors (for instance, not having any vfio container seems non-fatal, but having one with an incompatible api version may be unworkable.

Neil

#8 lore raw
In reply to Richardson, Bruce

Hi Bruce,

Quoted 6 lines

Hi Bruce,

Quoted 3 lines

The below patch is the quickest fix I found to make my applications work again, but I'm not sure it's the best solution. Can anyone else offer other suggestions to improve this?

Quoted 8 lines

Are you running things as root? If not, I suggest to try and use the setup.sh script to correct permissions on the VFIO container and see if it works.

The inability of opening a container is likely a problem with permissions on the container, and thus should be considered fatal as far as VFIO is concerned. However, given that we try to use VFIO unconditionally, I think your suggestion is a good solution to the problem, however I would also close the group fd's that were already opened before returning 1.

On a second thought, I think this may be better solved by checking access() on the container. Right now I think PCI init checks for access on /dev/vfio (the VFIO dir) but not /dev/vfio/vfio (the container). I will prepare a patch shortly, so I would appreciate if you self-NAKed yours :-)

Best regards,
Anatoly Burakov
DPDK SW Engineer

#9 lore raw
In reply to a message not in the archive
Quoted 56 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Monday, June 16, 2014 3:29 PM
To: [email protected]
Cc: Richardson, Bruce
Subject: [PATCH] vfio: make container open error non-fatal

When setting up an app to run using the uio driver, errors caused by VFIO failures should not abruptly cause the app to fail.

Example: on a board with 8 ports bound to igb_uio module, and no VFIO configuration, a testpmd run currently fails with:

EAL:   cannot open VFIO container!
EAL:   0000:04:00.0 cannot open VFIO container!
EAL: Error - exiting with code: 1

Cause: Requested device 0000:04:00.0 cannot be used

With this patch applied, the problem with VFIO is ignored and testpmd successfully starts up - with ignored errors with vfio - as below:

EAL: PCI device 0000:04:00.0 on NUMA socket 0
EAL:   probe driver: 8086:1521 rte_igb_pmd
EAL:   unknown IOMMU driver!
EAL:   0000:04:00.0 cannot open VFIO container!
EAL:   0000:04:00.0 not managed by UIO driver, skipping
<...scan results for other ports skipped...>
EAL: PCI device 0000:8e:00.0 on NUMA socket 1
EAL:   probe driver: 8086:154a rte_ixgbe_pmd
EAL:   unknown IOMMU driver!
EAL:   0000:8e:00.0 cannot open VFIO container!
EAL:   PCI memory mapped at 0x7ff4ff5fa000
EAL:   PCI memory mapped at 0x7ff4ff5f6000
EAL: PCI device 0000:8e:00.1 on NUMA socket 1
EAL:   probe driver: 8086:154a rte_ixgbe_pmd
EAL:   unknown IOMMU driver!
EAL:   0000:8e:00.1 cannot open VFIO container!
EAL:   PCI memory mapped at 0x7ff4ff4f6000
EAL:   PCI memory mapped at 0x7ff4ff4f2000

Interactive-mode selected
Configuring Port 0 (socket 0)
<...other 7 ports ...>
Checking link statuses...
Port 0 Link Up - speed 10000 Mbps - full-duplex
Port 1 Link Down
Port 2 Link Up - speed 10000 Mbps - full-duplex
Port 3 Link Down
Port 4 Link Up - speed 10000 Mbps - full-duplex
Port 5 Link Down
Port 6 Link Up - speed 10000 Mbps - full-duplex
Port 7 Link Down
Done
testpmd>

Quoted 5 lines

This issue is introduced by the VFIO patch set addition, specifically commit ff0b67d1.

---

Self-NAK. Anatoly's patch is a better fix.