]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
iommu/virtio: Enable x86 support
authorJean-Philippe Brucker <jean-philippe@linaro.org>
Fri, 18 Jun 2021 15:21:00 +0000 (17:21 +0200)
committerJoerg Roedel <jroedel@suse.de>
Fri, 25 Jun 2021 13:02:43 +0000 (15:02 +0200)
With the VIOT support in place, x86 platforms can now use the
virtio-iommu.

Because the other x86 IOMMU drivers aren't yet ready to use the
acpi_dma_setup() path, x86 doesn't implement arch_setup_dma_ops() at the
moment. Similarly to Vt-d and AMD IOMMU, clear the DMA ops and call
iommu_setup_dma_ops() from probe_finalize().

Acked-by: Joerg Roedel <jroedel@suse.de>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Link: https://lore.kernel.org/r/20210618152059.1194210-6-jean-philippe@linaro.org
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/Kconfig
drivers/iommu/dma-iommu.c
drivers/iommu/virtio-iommu.c

index aff8a4830dd1947d4ac2fc135af957276fc30d60..07b7c25cbed8a1cc6cf6c91ff8402ea63f9d5074 100644 (file)
@@ -400,8 +400,9 @@ config HYPERV_IOMMU
 config VIRTIO_IOMMU
        tristate "Virtio IOMMU driver"
        depends on VIRTIO
-       depends on ARM64
+       depends on (ARM64 || X86)
        select IOMMU_API
+       select IOMMU_DMA
        select INTERVAL_TREE
        select ACPI_VIOT if ACPI
        help
index c62e19bed302ffe8d483cbaa8cb242838cb114f1..9dbbc95c8189f996eecc5650d642a1d3bfd695d9 100644 (file)
@@ -1330,6 +1330,7 @@ out_err:
         pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n",
                 dev_name(dev));
 }
+EXPORT_SYMBOL_GPL(iommu_setup_dma_ops);
 
 static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev,
                phys_addr_t msi_addr, struct iommu_domain *domain)
index c6e5ee4d9cef83e81b0896d0811c673d3be09b89..fe581f0c9b3a5a1f1f46184ba32cca151d513346 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/amba/bus.h>
 #include <linux/delay.h>
 #include <linux/dma-iommu.h>
+#include <linux/dma-map-ops.h>
 #include <linux/freezer.h>
 #include <linux/interval_tree.h>
 #include <linux/iommu.h>
@@ -904,6 +905,15 @@ err_free_dev:
        return ERR_PTR(ret);
 }
 
+static void viommu_probe_finalize(struct device *dev)
+{
+#ifndef CONFIG_ARCH_HAS_SETUP_DMA_OPS
+       /* First clear the DMA ops in case we're switching from a DMA domain */
+       set_dma_ops(dev, NULL);
+       iommu_setup_dma_ops(dev, 0, U64_MAX);
+#endif
+}
+
 static void viommu_release_device(struct device *dev)
 {
        struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev);
@@ -940,6 +950,7 @@ static struct iommu_ops viommu_ops = {
        .iova_to_phys           = viommu_iova_to_phys,
        .iotlb_sync             = viommu_iotlb_sync,
        .probe_device           = viommu_probe_device,
+       .probe_finalize         = viommu_probe_finalize,
        .release_device         = viommu_release_device,
        .device_group           = viommu_device_group,
        .get_resv_regions       = viommu_get_resv_regions,