Skip to content

Commit 4a20ce0

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu: Add a capability for flush queue support
Passing a special type to domain_alloc to indirectly query whether flush queues are a worthwhile optimisation with the given driver is a bit clunky, and looking increasingly anachronistic. Let's put that into an explicit capability instead. Signed-off-by: Robin Murphy <robin.murphy@arm.com> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.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/f0086a93dbccb92622e1ace775846d81c1c4b174.1683233867.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 5d62bac commit 4a20ce0

5 files changed

Lines changed: 10 additions & 0 deletions

File tree

drivers/iommu/amd/iommu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2293,6 +2293,8 @@ static bool amd_iommu_capable(struct device *dev, enum iommu_cap cap)
22932293
return amdr_ivrs_remap_support;
22942294
case IOMMU_CAP_ENFORCE_CACHE_COHERENCY:
22952295
return true;
2296+
case IOMMU_CAP_DEFERRED_FLUSH:
2297+
return true;
22962298
default:
22972299
break;
22982300
}

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,7 @@ static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap)
20082008
/* Assume that a coherent TCU implies coherent TBUs */
20092009
return master->smmu->features & ARM_SMMU_FEAT_COHERENCY;
20102010
case IOMMU_CAP_NOEXEC:
2011+
case IOMMU_CAP_DEFERRED_FLUSH:
20112012
return true;
20122013
default:
20132014
return false;

drivers/iommu/arm/arm-smmu/arm-smmu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,7 @@ static bool arm_smmu_capable(struct device *dev, enum iommu_cap cap)
13251325
return cfg->smmu->features & ARM_SMMU_FEAT_COHERENT_WALK ||
13261326
device_get_dma_attr(dev) == DEV_DMA_COHERENT;
13271327
case IOMMU_CAP_NOEXEC:
1328+
case IOMMU_CAP_DEFERRED_FLUSH:
13281329
return true;
13291330
default:
13301331
return false;

drivers/iommu/intel/iommu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4369,6 +4369,7 @@ static bool intel_iommu_capable(struct device *dev, enum iommu_cap cap)
43694369

43704370
switch (cap) {
43714371
case IOMMU_CAP_CACHE_COHERENCY:
4372+
case IOMMU_CAP_DEFERRED_FLUSH:
43724373
return true;
43734374
case IOMMU_CAP_PRE_BOOT_PROTECTION:
43744375
return dmar_platform_optin();

include/linux/iommu.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ enum iommu_cap {
127127
* this device.
128128
*/
129129
IOMMU_CAP_ENFORCE_CACHE_COHERENCY,
130+
/*
131+
* IOMMU driver does not issue TLB maintenance during .unmap, so can
132+
* usefully support the non-strict DMA flush queue.
133+
*/
134+
IOMMU_CAP_DEFERRED_FLUSH,
130135
};
131136

132137
/* These are the possible reserved region types */

0 commit comments

Comments
 (0)