Re: [PATCH v3 i-g-t 7/7] tests/intel/xe_sriov_flr: Skip xe-vfio-pci load/bind when IOMMU is off

Laguna, Lukasz
2026-02-11T06:43:24Z

On 2/10/2026 12:23, Bernatowicz, Marcin wrote:
>
> On 2/9/2026 11:42 AM, Laguna, Lukasz wrote:
>>
>> On 2/4/2026 17:32, Marcin Bernatowicz wrote:
>>> When the IOMMU is disabled VFs typically lack an iommu_group, and
>>> xe-vfio-pci binding may fail. Skip load/bind in that case.
>>
>> I'm not sure if checking for IOMMU groups is enough.
>> I think it's possible that the device has the IOMMU group and
>> vfio-pci still fail to bind if e.g. CONFIG_VFIO_IOMMU_TYPE1 is disabled.
>>
>> We have a control on the environment where test is executed, so I'm
>> not sure if this patch is needed. We prefer to use the approach with
>> xe-vfio-pci, so if it fails because of the system configuration than
>> I think it would be better to fix the configuration.
>
>
> Maybe it's good time to add xe_sriov_vfio test with some basic checks:
>
> igt@xe_sriov_vfio@load-xe-vfio-pci
> igt@xe_sriov_vfio@unload-xe-vfio-pci
> igt@xe_sriov_vfio@bind-unbind-vf
> igt@xe_sriov_vfio@open-basic
>
> ?
>

Sounds good to me

>>> Signed-off-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
>>> Cc: Jakub Kolakowski <jakub1.kolakowski@intel.com>
>>> Cc: Lukasz Laguna <lukasz.laguna@intel.com>
>>> Cc: Michał Winiarski <michal.winiarski@intel.com>
>>> Cc: Piotr Piórkowski <piotr.piorkowski@intel.com>
>>> ---
>>>   tests/intel/xe_sriov_flr.c | 43
>>> +++++++++++++++++++++++++++++++++++---
>>>   1 file changed, 40 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/tests/intel/xe_sriov_flr.c b/tests/intel/xe_sriov_flr.c
>>> index b73727787..3fc84bbf9 100644
>>> --- a/tests/intel/xe_sriov_flr.c
>>> +++ b/tests/intel/xe_sriov_flr.c
>>> @@ -13,6 +13,7 @@
>>>   #include "igt_kmod.h"
>>>   #include "igt_pci.h"
>>>   #include "igt_sriov_device.h"
>>> +#include "igt_sysfs.h"
>>>   #include "intel_chipset.h"
>>>   #include "intel_vram.h"
>>>   #include "linux_scaffold.h"
>>> @@ -325,6 +326,44 @@ static void vf_unbind_driver_override(int
>>> pf_fd, unsigned int vf_id)
>>>       free(slot);
>>>   }
>>>   +static bool vf_has_iommu_group(int pf_fd, unsigned int vf_id)
>>> +{
>>> +    int sysfs;
>>> +    bool present;
>>> +
>>> +    sysfs = igt_sriov_device_sysfs_open(pf_fd, vf_id);
>>> +    if (sysfs < 0)
>>> +        return false;
>>> +
>>> +    present = igt_sysfs_has_attr(sysfs, "iommu_group");
>>> +    close(sysfs);
>>> +
>>> +    return present;
>>> +}
>>> +
>>> +static bool vfs_have_iommu_groups(int pf_fd, int num_vfs)
>>> +{
>>> +    for (int vf_id = 1; vf_id <= num_vfs; vf_id++)
>>> +        if (!vf_has_iommu_group(pf_fd, vf_id))
>>> +            return false;
>>> +
>>> +    return true;
>>> +}
>>> +
>>> +static bool try_load_xe_vfio_pci(int pf_fd, int num_vfs)
>>> +{
>>> +    if (!g_use_xe_vfio_pci)
>>> +        return false;
>>> +
>>> +    if (!vfs_have_iommu_groups(pf_fd, num_vfs)) {
>>> +        igt_info("Disabling xe-vfio-pci binding: missing VF IOMMU
>>> group(s) (IOMMU off?)\n");
>>> +        g_use_xe_vfio_pci = false;
>>> +        return false;
>>> +    }
>>> +
>>> +    return igt_kmod_load("xe_vfio_pci", NULL) >= 0;
>>> +}
>>> +
>>>   /**
>>>    * flr_exec_strategy - Function pointer for FLR execution strategy
>>>    * @pf_fd: File descriptor for the Physical Function (PF).
>>> @@ -386,9 +425,7 @@ static void verify_flr(int pf_fd, int num_vfs,
>>> struct subcheck *checks,
>>>       if (igt_warn_on(igt_pci_system_reinit()))
>>>           goto disable_vfs;
>>>   -    xe_vfio_loaded = false;
>>> -    if (g_use_xe_vfio_pci)
>>> -        xe_vfio_loaded = igt_kmod_load("xe_vfio_pci", NULL) >= 0;
>>> +    xe_vfio_loaded = try_load_xe_vfio_pci(pf_fd, num_vfs);
>>>       if (xe_vfio_loaded) {
>>>           vf_bound = calloc(num_vfs + 1, sizeof(*vf_bound));
>>>           igt_assert(vf_bound);