Skip to content

Commit 1c18a12

Browse files
jgunthorpejoergroedel
authored andcommitted
iommu/dma: Always allow DMA-FQ when iommupt provides the iommu_domain
iommupt always supports the semantics required for DMA-FQ, when drivers are converted to use it they automatically get support. Detect iommpt directly instead of using IOMMU_CAP_DEFERRED_FLUSH and remove IOMMU_CAP_DEFERRED_FLUSH from converted drivers. This will also enable DMA-FQ on RISC-V. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
1 parent a11661a commit 1c18a12

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

drivers/iommu/amd/iommu.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,8 +2978,6 @@ static bool amd_iommu_capable(struct device *dev, enum iommu_cap cap)
29782978
return amdr_ivrs_remap_support;
29792979
case IOMMU_CAP_ENFORCE_CACHE_COHERENCY:
29802980
return true;
2981-
case IOMMU_CAP_DEFERRED_FLUSH:
2982-
return true;
29832981
case IOMMU_CAP_DIRTY_TRACKING: {
29842982
struct amd_iommu *iommu = get_amd_iommu_from_dev(dev);
29852983

drivers/iommu/dma-iommu.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/device.h>
1515
#include <linux/dma-direct.h>
1616
#include <linux/dma-map-ops.h>
17+
#include <linux/generic_pt/iommu.h>
1718
#include <linux/gfp.h>
1819
#include <linux/huge_mm.h>
1920
#include <linux/iommu.h>
@@ -648,6 +649,15 @@ static void iommu_dma_init_options(struct iommu_dma_options *options,
648649
}
649650
}
650651

652+
static bool iommu_domain_supports_fq(struct device *dev,
653+
struct iommu_domain *domain)
654+
{
655+
/* iommupt always supports DMA-FQ */
656+
if (iommupt_from_domain(domain))
657+
return true;
658+
return device_iommu_capable(dev, IOMMU_CAP_DEFERRED_FLUSH);
659+
}
660+
651661
/**
652662
* iommu_dma_init_domain - Initialise a DMA mapping domain
653663
* @domain: IOMMU domain previously prepared by iommu_get_dma_cookie()
@@ -706,7 +716,8 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, struct device *dev
706716

707717
/* If the FQ fails we can simply fall back to strict mode */
708718
if (domain->type == IOMMU_DOMAIN_DMA_FQ &&
709-
(!device_iommu_capable(dev, IOMMU_CAP_DEFERRED_FLUSH) || iommu_dma_init_fq(domain)))
719+
(!iommu_domain_supports_fq(dev, domain) ||
720+
iommu_dma_init_fq(domain)))
710721
domain->type = IOMMU_DOMAIN_DMA;
711722

712723
return iova_reserve_iommu_regions(dev, domain);

drivers/iommu/intel/iommu.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,8 +3212,6 @@ static bool intel_iommu_capable(struct device *dev, enum iommu_cap cap)
32123212

32133213
switch (cap) {
32143214
case IOMMU_CAP_CACHE_COHERENCY:
3215-
case IOMMU_CAP_DEFERRED_FLUSH:
3216-
return true;
32173215
case IOMMU_CAP_PRE_BOOT_PROTECTION:
32183216
return dmar_platform_optin();
32193217
case IOMMU_CAP_ENFORCE_CACHE_COHERENCY:

0 commit comments

Comments
 (0)