Skip to content

Commit 48e7b8e

Browse files
jgunthorpewilldeacon
authored andcommitted
iommu/arm-smmu-v3: Remove arm_smmu_domain_finalise() during attach
Domains are now always finalized during allocation because the core code no longer permits a NULL dev argument to domain_alloc_paging/_flags(). Remove the late finalize during attach that supported domains that were not fully initialized. Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 6e19221 commit 48e7b8e

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

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

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,6 @@ struct arm_smmu_domain *arm_smmu_domain_alloc(void)
24602460
if (!smmu_domain)
24612461
return ERR_PTR(-ENOMEM);
24622462

2463-
mutex_init(&smmu_domain->init_mutex);
24642463
INIT_LIST_HEAD(&smmu_domain->devices);
24652464
spin_lock_init(&smmu_domain->devices_lock);
24662465

@@ -2469,7 +2468,9 @@ struct arm_smmu_domain *arm_smmu_domain_alloc(void)
24692468

24702469
static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev)
24712470
{
2471+
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
24722472
struct arm_smmu_domain *smmu_domain;
2473+
int ret;
24732474

24742475
/*
24752476
* Allocate the domain and initialise some of its data structures.
@@ -2480,15 +2481,10 @@ static struct iommu_domain *arm_smmu_domain_alloc_paging(struct device *dev)
24802481
if (IS_ERR(smmu_domain))
24812482
return ERR_CAST(smmu_domain);
24822483

2483-
if (dev) {
2484-
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
2485-
int ret;
2486-
2487-
ret = arm_smmu_domain_finalise(smmu_domain, master->smmu, 0);
2488-
if (ret) {
2489-
kfree(smmu_domain);
2490-
return ERR_PTR(ret);
2491-
}
2484+
ret = arm_smmu_domain_finalise(smmu_domain, master->smmu, 0);
2485+
if (ret) {
2486+
kfree(smmu_domain);
2487+
return ERR_PTR(ret);
24922488
}
24932489
return &smmu_domain->domain;
24942490
}
@@ -2965,15 +2961,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
29652961
state.master = master = dev_iommu_priv_get(dev);
29662962
smmu = master->smmu;
29672963

2968-
mutex_lock(&smmu_domain->init_mutex);
2969-
2970-
if (!smmu_domain->smmu) {
2971-
ret = arm_smmu_domain_finalise(smmu_domain, smmu, 0);
2972-
} else if (smmu_domain->smmu != smmu)
2973-
ret = -EINVAL;
2974-
2975-
mutex_unlock(&smmu_domain->init_mutex);
2976-
if (ret)
2964+
if (smmu_domain->smmu != smmu)
29772965
return ret;
29782966

29792967
if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1) {
@@ -3030,16 +3018,9 @@ static int arm_smmu_s1_set_dev_pasid(struct iommu_domain *domain,
30303018
struct arm_smmu_master *master = dev_iommu_priv_get(dev);
30313019
struct arm_smmu_device *smmu = master->smmu;
30323020
struct arm_smmu_cd target_cd;
3033-
int ret = 0;
30343021

3035-
mutex_lock(&smmu_domain->init_mutex);
3036-
if (!smmu_domain->smmu)
3037-
ret = arm_smmu_domain_finalise(smmu_domain, smmu, 0);
3038-
else if (smmu_domain->smmu != smmu)
3039-
ret = -EINVAL;
3040-
mutex_unlock(&smmu_domain->init_mutex);
3041-
if (ret)
3042-
return ret;
3022+
if (smmu_domain->smmu != smmu)
3023+
return -EINVAL;
30433024

30443025
if (smmu_domain->stage != ARM_SMMU_DOMAIN_S1)
30453026
return -EINVAL;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,6 @@ enum arm_smmu_domain_stage {
843843

844844
struct arm_smmu_domain {
845845
struct arm_smmu_device *smmu;
846-
struct mutex init_mutex; /* Protects smmu pointer */
847846

848847
struct io_pgtable_ops *pgtbl_ops;
849848
atomic_t nr_ats_masters;

0 commit comments

Comments
 (0)