Skip to content

Commit a4fdd97

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu: Use flush queue capability
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 <[email protected]> Tested-by: Jerry Snitselaar <[email protected]> # amd, intel, smmu-v3 Reviewed-by: Jerry Snitselaar <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/1c552d99e8ba452bdac48209fa74c0bdd52fd9d9.1683233867.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel <[email protected]>
1 parent 4a20ce0 commit a4fdd97

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,6 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
20242024

20252025
if (type != IOMMU_DOMAIN_UNMANAGED &&
20262026
type != IOMMU_DOMAIN_DMA &&
2027-
type != IOMMU_DOMAIN_DMA_FQ &&
20282027
type != IOMMU_DOMAIN_IDENTITY)
20292028
return NULL;
20302029

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,7 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
856856
struct arm_smmu_domain *smmu_domain;
857857

858858
if (type != IOMMU_DOMAIN_UNMANAGED && type != IOMMU_DOMAIN_IDENTITY) {
859-
if (using_legacy_binding ||
860-
(type != IOMMU_DOMAIN_DMA && type != IOMMU_DOMAIN_DMA_FQ))
859+
if (using_legacy_binding || type != IOMMU_DOMAIN_DMA)
861860
return NULL;
862861
}
863862
/*

drivers/iommu/dma-iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,8 @@ static int iommu_dma_init_domain(struct iommu_domain *domain, dma_addr_t base,
586586
goto done_unlock;
587587

588588
/* If the FQ fails we can simply fall back to strict mode */
589-
if (domain->type == IOMMU_DOMAIN_DMA_FQ && iommu_dma_init_fq(domain))
589+
if (domain->type == IOMMU_DOMAIN_DMA_FQ &&
590+
(!device_iommu_capable(dev, IOMMU_CAP_DEFERRED_FLUSH) || iommu_dma_init_fq(domain)))
590591
domain->type = IOMMU_DOMAIN_DMA;
591592

592593
ret = iova_reserve_iommu_regions(dev, domain);

drivers/iommu/intel/iommu.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4064,7 +4064,6 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type)
40644064
case IOMMU_DOMAIN_BLOCKED:
40654065
return &blocking_domain;
40664066
case IOMMU_DOMAIN_DMA:
4067-
case IOMMU_DOMAIN_DMA_FQ:
40684067
case IOMMU_DOMAIN_UNMANAGED:
40694068
dmar_domain = alloc_domain(type);
40704069
if (!dmar_domain) {

drivers/iommu/iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1980,11 +1980,12 @@ static struct iommu_domain *__iommu_domain_alloc(const struct bus_type *bus,
19801980
unsigned type)
19811981
{
19821982
struct iommu_domain *domain;
1983+
unsigned int alloc_type = type & IOMMU_DOMAIN_ALLOC_FLAGS;
19831984

19841985
if (bus == NULL || bus->iommu_ops == NULL)
19851986
return NULL;
19861987

1987-
domain = bus->iommu_ops->domain_alloc(type);
1988+
domain = bus->iommu_ops->domain_alloc(alloc_type);
19881989
if (!domain)
19891990
return NULL;
19901991

include/linux/iommu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct iommu_domain_geometry {
6565

6666
#define __IOMMU_DOMAIN_SVA (1U << 4) /* Shared process address space */
6767

68+
#define IOMMU_DOMAIN_ALLOC_FLAGS ~__IOMMU_DOMAIN_DMA_FQ
6869
/*
6970
* This are the possible domain-types
7071
*

0 commit comments

Comments
 (0)