Commit c6e7958e authored by Alexey Kardashevskiy's avatar Alexey Kardashevskiy Committed by Alex Williamson
Browse files

vfio/spapr: Allow fallback to SPAPR TCE IOMMU v1



The vfio_iommu_spapr_tce driver advertises kernel's support for
v1 and v2 IOMMU support, however it is not always possible to use
the requested IOMMU type. For example, a pseries host platform does not
support dynamic DMA windows so v2 cannot initialize and QEMU fails to
start.

This adds a fallback to the v1 IOMMU if v2 cannot be used.

Fixes: 318f67ce ("vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU v2)")
Signed-off-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent f7f9c7b2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1042,6 +1042,11 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
        container->iommu_type =
            v2 ? VFIO_SPAPR_TCE_v2_IOMMU : VFIO_SPAPR_TCE_IOMMU;
        ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
        if (ret) {
            container->iommu_type = VFIO_SPAPR_TCE_IOMMU;
            v2 = false;
            ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
        }
        if (ret) {
            error_setg_errno(errp, errno, "failed to set iommu for container");
            ret = -errno;