Skip to content

Commit ff0f802

Browse files
jgunthorpewilldeacon
authored andcommitted
iommu/arm-smmu: Reorganize arm_smmu_domain_add_master()
Make arm_smmu_domain_add_master() not use the smmu_domain to detect the s2cr configuration, instead pass it in as a parameter. It always returns zero so make it return void. Since it no longer really does anything to do with a domain call it arm_smmu_master_install_s2crs(). This is done to make the next two patches able to re-use this code without forcing the creation of a struct arm_smmu_domain. Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Link: https://lore.kernel.org/r/1-v2-c86cc8c2230e+160bb-smmu_newapi_jgg@nvidia.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 9fde008 commit ff0f802

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,21 +1081,14 @@ static void arm_smmu_master_free_smes(struct arm_smmu_master_cfg *cfg,
10811081
mutex_unlock(&smmu->stream_map_mutex);
10821082
}
10831083

1084-
static int arm_smmu_domain_add_master(struct arm_smmu_domain *smmu_domain,
1085-
struct arm_smmu_master_cfg *cfg,
1086-
struct iommu_fwspec *fwspec)
1084+
static void arm_smmu_master_install_s2crs(struct arm_smmu_master_cfg *cfg,
1085+
enum arm_smmu_s2cr_type type,
1086+
u8 cbndx, struct iommu_fwspec *fwspec)
10871087
{
1088-
struct arm_smmu_device *smmu = smmu_domain->smmu;
1088+
struct arm_smmu_device *smmu = cfg->smmu;
10891089
struct arm_smmu_s2cr *s2cr = smmu->s2crs;
1090-
u8 cbndx = smmu_domain->cfg.cbndx;
1091-
enum arm_smmu_s2cr_type type;
10921090
int i, idx;
10931091

1094-
if (smmu_domain->stage == ARM_SMMU_DOMAIN_BYPASS)
1095-
type = S2CR_TYPE_BYPASS;
1096-
else
1097-
type = S2CR_TYPE_TRANS;
1098-
10991092
for_each_cfg_sme(cfg, fwspec, i, idx) {
11001093
if (type == s2cr[idx].type && cbndx == s2cr[idx].cbndx)
11011094
continue;
@@ -1105,7 +1098,6 @@ static int arm_smmu_domain_add_master(struct arm_smmu_domain *smmu_domain,
11051098
s2cr[idx].cbndx = cbndx;
11061099
arm_smmu_write_s2cr(smmu, idx);
11071100
}
1108-
return 0;
11091101
}
11101102

11111103
static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
@@ -1153,7 +1145,12 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
11531145
}
11541146

11551147
/* Looks ok, so add the device to the domain */
1156-
ret = arm_smmu_domain_add_master(smmu_domain, cfg, fwspec);
1148+
arm_smmu_master_install_s2crs(cfg,
1149+
smmu_domain->stage ==
1150+
ARM_SMMU_DOMAIN_BYPASS ?
1151+
S2CR_TYPE_BYPASS :
1152+
S2CR_TYPE_TRANS,
1153+
smmu_domain->cfg.cbndx, fwspec);
11571154

11581155
/*
11591156
* Setup an autosuspend delay to avoid bouncing runpm state.

0 commit comments

Comments
 (0)