]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
iommu: Use flush queue capability
authorRobin Murphy <robin.murphy@arm.com>
Thu, 4 May 2023 21:10:56 +0000 (22:10 +0100)
committerJoerg Roedel <jroedel@suse.de>
Mon, 22 May 2023 15:38:45 +0000 (17:38 +0200)
It remains really handy to have distinct DMA domain types within core
code for the sake of default domain policy selection, but we can now
hide that detail from drivers by using the new capability instead.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Tested-by: Jerry Snitselaar <jsnitsel@redhat.com> # amd, intel, smmu-v3
Reviewed-by: Jerry Snitselaar <jsnitsel@redhat.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/1c552d99e8ba452bdac48209fa74c0bdd52fd9d9.1683233867.git.robin.murphy@arm.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
drivers/iommu/arm/arm-smmu/arm-smmu.c
drivers/iommu/dma-iommu.c
drivers/iommu/intel/iommu.c
drivers/iommu/iommu.c
include/linux/iommu.h

index 6d65a7e81df46011a27c6b36eb757d55e7f347e2..1ed9c4ed5db971d83f15876a7c2cd8119116e85b 100644 (file)
@@ -2024,7 +2024,6 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
 
        if (type != IOMMU_DOMAIN_UNMANAGED &&
            type != IOMMU_DOMAIN_DMA &&
-           type != IOMMU_DOMAIN_DMA_FQ &&
            type != IOMMU_DOMAIN_IDENTITY)
                return NULL;
 
index 7f4ee365912cf1350ad4a692991d327de7815fdd..a86acd76c1dfb43b3475a11d632011feedadfac4 100644 (file)
@@ -856,8 +856,7 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
        struct arm_smmu_domain *smmu_domain;
 
        if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_IDENTITY) {
-               if (using_legacy_binding ||
-                   (type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_DMA_FQ))
+               if (using_legacy_binding || type != IOMMU_DOMAIN_DMA)
                        return NULL;
        }
        /*
index 7a9f0b0bddbda6175ed11ec92edf4eded7877872..c4bdd2587daf34e5d51310ca169f2189188987f4 100644 (file)
@@ -586,7 +586,8 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base,
                goto done_unlock;
 
        /* If the FQ fails we can simply fall back to strict mode */
-       if (domain->type == IOMMU_DOMAIN_DMA_FQ && iommu_dma_init_fq(domain))
+       if (domain->type == IOMMU_DOMAIN_DMA_FQ &&
+           (!device_iommu_capable(dev, IOMMU_CAP_DEFERRED_FLUSH) || iommu_dma_init_fq(domain)))
                domain->type = IOMMU_DOMAIN_DMA;
 
        ret = iova_reserve_iommu_regions(dev, domain);
index ff923298f8edd2870cf85741e90d2c9459399921..8096273b034c3a8e714e26aa996afff90b526a41 100644 (file)
@@ -4064,7 +4064,6 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type)
        case IOMMU_DOMAIN_BLOCKED:
                return &blocking_domain;
        case IOMMU_DOMAIN_DMA:
-       case IOMMU_DOMAIN_DMA_FQ:
        case IOMMU_DOMAIN_UNMANAGED:
                dmar_domain = alloc_domain(type);
                if (!dmar_domain) {
index f1dcfa3f1a1b48ab8a48bb6976f524e3dc4c29e0..7078bf4a8ec8b6fa66dea53683d03335568d61c2 100644 (file)
@@ -1980,11 +1980,12 @@ static struct iommu_domain *__iommu_domain_alloc(const struct bus_type *bus,
                                                 unsigned type)
 {
        struct iommu_domain *domain;
+       unsigned int alloc_type = type & IOMMU_DOMAIN_ALLOC_FLAGS;
 
        if (bus == NULL || bus->iommu_ops == NULL)
                return NULL;
 
-       domain = bus->iommu_ops->domain_alloc(type);
+       domain = bus->iommu_ops->domain_alloc(alloc_type);
        if (!domain)
                return NULL;
 
index 1b7180d6edae3584c8735ff479da1f0975be2729..d3164259667599679673cf45226f82b25b4018ad 100644 (file)
@@ -65,6 +65,7 @@ struct iommu_domain_geometry {
 
 #define __IOMMU_DOMAIN_SVA     (1U << 4)  /* Shared process address space */
 
+#define IOMMU_DOMAIN_ALLOC_FLAGS ~__IOMMU_DOMAIN_DMA_FQ
 /*
  * This are the possible domain-types
  *