[PATCH v12 15/20] bus/pci: use the new VFIO mode API
From: Anatoly Burakov <hidden>
Date: 2026-08-25 13:23:13
Subsystem:
library code, the rest · Maintainers:
Andrew Morton, Linus Torvalds
Use the new VFIO mode API to query no-IOMMU status. This requires moving the VFIO init earlier in the init sequence, as now checking no-IOMMU mode is not a sysfs check but instead relies on full VFIO subsystem to be initialized and available. Signed-off-by: Anatoly Burakov <redacted> --- drivers/bus/pci/linux/pci.c | 2 +- lib/eal/linux/eal.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index 9aae0a5d14..a1575b84e2 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c@@ -596,7 +596,7 @@ pci_device_iova_mode(const struct rte_pci_driver *pdrv, static int is_vfio_noiommu_enabled = -1; if (is_vfio_noiommu_enabled == -1) { - if (rte_vfio_noiommu_is_enabled() == 1) + if (rte_vfio_get_mode() == RTE_VFIO_MODE_NOIOMMU) is_vfio_noiommu_enabled = 1; else is_vfio_noiommu_enabled = 0;
diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c
index fc2e9b8c0e..5bc095bd61 100644
--- a/lib/eal/linux/eal.c
+++ b/lib/eal/linux/eal.c@@ -677,6 +677,16 @@ rte_eal_init(int argc, char **argv) } } + /* + * VFIO must be initialized before bus scan because buses need to know + * about no-IOMMU mode status. + */ + if (rte_vfio_enable("vfio")) { + rte_eal_init_alert("Cannot init VFIO"); + rte_errno = EAGAIN; + goto err_out; + } + if (rte_bus_scan()) { rte_eal_init_alert("Cannot scan the buses for devices"); rte_errno = ENODEV;
@@ -772,11 +782,6 @@ rte_eal_init(int argc, char **argv) #endif } - if (rte_vfio_enable("vfio")) { - rte_eal_init_alert("Cannot init VFIO"); - rte_errno = EAGAIN; - goto err_out; - } /* in secondary processes, memory init may allocate additional fbarrays * not present in primary processes, so to avoid any potential issues, * initialize memzones first.
--
2.52.0