iommu: Redefine IOMMU_CAP_CACHE_COHERENCY as the cap flag for IOMMU_CACHE
authorJason Gunthorpe <jgg@nvidia.com>
Mon, 11 Apr 2022 15:16:07 +0000 (12:16 -0300)
committerJoerg Roedel <jroedel@suse.de>
Thu, 28 Apr 2022 15:24:57 +0000 (17:24 +0200)
While the comment was correct that this flag was intended to convey the
block no-snoop support in the IOMMU, it has become widely implemented and
used to mean the IOMMU supports IOMMU_CACHE as a map flag. Only the Intel
driver was different.

Now that the Intel driver is using enforce_cache_coherency() update the
comment to make it clear that IOMMU_CAP_CACHE_COHERENCY is only about
IOMMU_CACHE.  Fix the Intel driver to return true since IOMMU_CACHE always
works.

The two places that test this flag, usnic and vdpa, are both assigning
userspace pages to a driver controlled iommu_domain and require
IOMMU_CACHE behavior as they offer no way for userspace to synchronize
caches.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Acked-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/3-v3-2cf356649677+a32-intel_no_snoop_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel/iommu.c
include/linux/iommu.h

index 38441cb06c8c474591d53330ca409c75f3066dcd..efcecfa5952aee54b9602eca251221ab517a8da4 100644 (file)
@@ -4556,7 +4556,7 @@ static bool intel_iommu_enforce_cache_coherency(struct iommu_domain *domain)
 static bool intel_iommu_capable(enum iommu_cap cap)
 {
        if (cap == IOMMU_CAP_CACHE_COHERENCY)
-               return domain_update_iommu_snooping(NULL);
+               return true;
        if (cap == IOMMU_CAP_INTR_REMAP)
                return irq_remapping_enabled == 1;
        if (cap == IOMMU_CAP_PRE_BOOT_PROTECTION)
index c7ad6b10e2616e306248f2f1749dff63cb9b5892..575ab27ede5ba2c84c6d81eb8c087ca5aca7b726 100644 (file)
@@ -103,8 +103,7 @@ static inline bool iommu_is_dma_domain(struct iommu_domain *domain)
 }
 
 enum iommu_cap {
-       IOMMU_CAP_CACHE_COHERENCY,      /* IOMMU can enforce cache coherent DMA
-                                          transactions */
+       IOMMU_CAP_CACHE_COHERENCY,      /* IOMMU_CACHE is supported */
        IOMMU_CAP_INTR_REMAP,           /* IOMMU supports interrupt isolation */
        IOMMU_CAP_NOEXEC,               /* IOMMU_NOEXEC flag */
        IOMMU_CAP_PRE_BOOT_PROTECTION,  /* Firmware says it used the IOMMU for