Skip to content

Commit 9b3febc

Browse files
jgunthorpewilldeacon
authored andcommitted
iommu/arm-smmu: Convert to domain_alloc_paging()
Now that the BLOCKED and IDENTITY behaviors are managed with their own domains change to the domain_alloc_paging() op. The check for using_legacy_binding is now redundant, arm_smmu_def_domain_type() always returns IOMMU_DOMAIN_IDENTITY for this mode, so the core code will never attempt to create a DMA domain in the first place. Since commit a4fdd97 ("iommu: Use flush queue capability") the core code only passes in IDENTITY/BLOCKED/UNMANAGED/DMA domain types. It will not pass in IDENTITY or BLOCKED if the global statics exist, so the test for DMA is also redundant now too. Call arm_smmu_init_domain_context() early if a dev is available. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/5-v2-c86cc8c2230e+160bb-smmu_newapi_jgg@nvidia.com [will: Simplify arm_smmu_domain_alloc_paging() since 'cfg' cannot be NULL] Signed-off-by: Will Deacon <will@kernel.org>
1 parent e097633 commit 9b3febc

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -859,14 +859,10 @@ static void arm_smmu_destroy_domain_context(struct arm_smmu_domain *smmu_domain)
859859
arm_smmu_rpm_put(smmu);
860860
}
861861

862-
static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
862+
static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev)
863863
{
864864
struct arm_smmu_domain *smmu_domain;
865865

866-
if (type != IOMMU_DOMAIN_UNMANAGED) {
867-
if (using_legacy_binding || type != IOMMU_DOMAIN_DMA)
868-
return NULL;
869-
}
870866
/*
871867
* Allocate the domain and initialise some of its data structures.
872868
* We can't really do anything meaningful until we've added a
@@ -879,6 +875,15 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
879875
mutex_init(&smmu_domain->init_mutex);
880876
spin_lock_init(&smmu_domain->cb_lock);
881877

878+
if (dev) {
879+
struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev);
880+
881+
if (arm_smmu_init_domain_context(smmu_domain, cfg->smmu, dev)) {
882+
kfree(smmu_domain);
883+
return NULL;
884+
}
885+
}
886+
882887
return &smmu_domain->domain;
883888
}
884889

@@ -1603,7 +1608,7 @@ static struct iommu_ops arm_smmu_ops = {
16031608
.identity_domain = &arm_smmu_identity_domain,
16041609
.blocked_domain = &arm_smmu_blocked_domain,
16051610
.capable = arm_smmu_capable,
1606-
.domain_alloc = arm_smmu_domain_alloc,
1611+
.domain_alloc_paging = arm_smmu_domain_alloc_paging,
16071612
.probe_device = arm_smmu_probe_device,
16081613
.release_device = arm_smmu_release_device,
16091614
.probe_finalize = arm_smmu_probe_finalize,

0 commit comments

Comments
 (0)