]> git.droids-corp.org - dpdk.git/commitdiff
bus/pci: always check IOMMU capabilities
authorDavid Marchand <david.marchand@redhat.com>
Mon, 5 Aug 2019 06:23:26 +0000 (08:23 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 5 Aug 2019 10:08:15 +0000 (12:08 +0200)
IOMMU capabilities won't change and must be checked even if no PCI device
seem to be supported yet when EAL initialised.

This is to accommodate with SPDK that registers its drivers after
rte_eal_init(), especially on PPC platform where the IOMMU does not
support VA.

Fixes: 703458e19c16 ("bus/pci: consider only usable devices for IOVA mode")
Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: David Christensen <drc@linux.vnet.ibm.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
Tested-by: Jerin Jacob <jerinj@marvell.com>
Tested-by: Takeshi Yoshimura <tyos@jp.ibm.com>
drivers/bus/pci/bsd/pci.c
drivers/bus/pci/linux/pci.c
drivers/bus/pci/pci_common.c
drivers/bus/pci/private.h

index a2de709107c6764c858b5b10e3d5116a6d43e4ed..8f07ed94baf8822692d4ea8a94a05a1e86e922b2 100644 (file)
@@ -376,6 +376,12 @@ error:
        return -1;
 }
 
+bool
+pci_device_iommu_support_va(__rte_unused const struct rte_pci_device *dev)
+{
+       return false;
+}
+
 enum rte_iova_mode
 pci_device_iova_mode(const struct rte_pci_driver *pdrv __rte_unused,
                     const struct rte_pci_device *pdev)
index f4fb7427b592c8b13e67a8a9607d657ec85e27a2..43debaa25114e906f54abf9860d94ebf8f5ecdfe 100644 (file)
@@ -498,8 +498,8 @@ error:
 }
 
 #if defined(RTE_ARCH_X86)
-static bool
-pci_one_device_iommu_support_va(const struct rte_pci_device *dev)
+bool
+pci_device_iommu_support_va(const struct rte_pci_device *dev)
 {
 #define VTD_CAP_MGAW_SHIFT     16
 #define VTD_CAP_MGAW_MASK      (0x3fULL << VTD_CAP_MGAW_SHIFT)
@@ -546,14 +546,14 @@ pci_one_device_iommu_support_va(const struct rte_pci_device *dev)
        return true;
 }
 #elif defined(RTE_ARCH_PPC_64)
-static bool
-pci_one_device_iommu_support_va(__rte_unused const struct rte_pci_device *dev)
+bool
+pci_device_iommu_support_va(__rte_unused const struct rte_pci_device *dev)
 {
        return false;
 }
 #else
-static bool
-pci_one_device_iommu_support_va(__rte_unused const struct rte_pci_device *dev)
+bool
+pci_device_iommu_support_va(__rte_unused const struct rte_pci_device *dev)
 {
        return true;
 }
@@ -564,7 +564,6 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv,
                     const struct rte_pci_device *pdev)
 {
        enum rte_iova_mode iova_mode = RTE_IOVA_DC;
-       static int iommu_no_va = -1;
 
        switch (pdev->kdrv) {
        case RTE_KDRV_VFIO: {
@@ -595,18 +594,6 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv,
                        iova_mode = RTE_IOVA_VA;
                break;
        }
-
-       if (iova_mode != RTE_IOVA_PA) {
-               /*
-                * We can check this only once, because the IOMMU hardware is
-                * the same for all of them.
-                */
-               if (iommu_no_va == -1)
-                       iommu_no_va = pci_one_device_iommu_support_va(pdev)
-                                       ? 0 : 1;
-               if (iommu_no_va != 0)
-                       iova_mode = RTE_IOVA_PA;
-       }
        return iova_mode;
 }
 
index 9794552fd8d62b030422dcef5471d9081ea93ac7..6b46b4f07004a186b1351e39058499aefb626e0a 100644 (file)
@@ -616,8 +616,16 @@ rte_pci_get_iommu_class(void)
        const struct rte_pci_driver *drv;
        bool devices_want_va = false;
        bool devices_want_pa = false;
+       int iommu_no_va = -1;
 
        FOREACH_DEVICE_ON_PCIBUS(dev) {
+               /*
+                * We can check this only once, because the IOMMU hardware is
+                * the same for all of them.
+                */
+               if (iommu_no_va == -1)
+                       iommu_no_va = pci_device_iommu_support_va(dev)
+                                       ? 0 : 1;
                if (pci_ignore_device(dev))
                        continue;
                if (dev->kdrv == RTE_KDRV_UNKNOWN ||
@@ -643,7 +651,13 @@ rte_pci_get_iommu_class(void)
                                devices_want_va = true;
                }
        }
-       if (devices_want_va && !devices_want_pa) {
+       if (iommu_no_va == 1) {
+               iova_mode = RTE_IOVA_PA;
+               if (devices_want_va) {
+                       RTE_LOG(WARNING, EAL, "Some devices want 'VA' but IOMMU does not support 'VA'.\n");
+                       RTE_LOG(WARNING, EAL, "The devices that want 'VA' won't initialize.\n");
+               }
+       } else if (devices_want_va && !devices_want_pa) {
                iova_mode = RTE_IOVA_VA;
        } else if (devices_want_pa && !devices_want_va) {
                iova_mode = RTE_IOVA_PA;
index 8a5524052bcc2ad065e43036b9f990be92dca57f..a205d4d9f0af726bf8574dedfb1536aef8ffb35d 100644 (file)
@@ -173,9 +173,12 @@ rte_pci_match(const struct rte_pci_driver *pci_drv,
              const struct rte_pci_device *pci_dev);
 
 /**
- * OS specific callback for rte_pci_get_iommu_class
+ * OS specific callbacks for rte_pci_get_iommu_class
  *
  */
+bool
+pci_device_iommu_support_va(const struct rte_pci_device *dev);
+
 enum rte_iova_mode
 pci_device_iova_mode(const struct rte_pci_driver *pci_drv,
                     const struct rte_pci_device *pci_dev);