[dpdk-dev] [PATCH v2 08/12] eal/pci: Collapse loops in rte_pci_get_iommu_class

Ben Walker benjamin.walker at intel.com
Thu May 30 23:29:55 CEST 2019


The three loops can now be easily combined into one.

This is slightly less efficient than before because it
doesn't break out early. But that can be addressed
later.

Signed-off-by: Ben Walker <benjamin.walker at intel.com>
---
 drivers/bus/pci/linux/pci.c | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index 549d61e74..765c473e8 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -604,15 +604,7 @@ rte_pci_get_iommu_class(void)
 		if (dev->kdrv != RTE_KDRV_UNKNOWN &&
 		    dev->kdrv != RTE_KDRV_NONE) {
 			is_bound = true;
-			break;
 		}
-	}
-	if (!is_bound)
-		return RTE_IOVA_DC;
-
-	FOREACH_DEVICE_ON_PCIBUS(dev) {
-		if (pci_ignore_device(dev))
-			continue;
 
 		if (dev->kdrv == RTE_KDRV_VFIO) {
 			FOREACH_DRIVER_ON_PCIBUS(drv) {
@@ -630,15 +622,7 @@ rte_pci_get_iommu_class(void)
 					break;
 				}
 			}
-
-			if (has_iova_va)
-				break;
 		}
-	}
-
-	FOREACH_DEVICE_ON_PCIBUS(dev) {
-		if (pci_ignore_device(dev))
-			continue;
 
 		if (dev->kdrv == RTE_KDRV_IGB_UIO ||
 		   dev->kdrv == RTE_KDRV_UIO_GENERIC) {
@@ -646,6 +630,9 @@ rte_pci_get_iommu_class(void)
 		}
 	}
 
+	if (!is_bound)
+		return RTE_IOVA_DC;
+
 #ifdef VFIO_PRESENT
 	is_vfio_noiommu_enabled = rte_vfio_noiommu_is_enabled() == true ?
 					true : false;
-- 
2.20.1



More information about the dev mailing list