Skip to content

Commit e3aad74

Browse files
shavitmichaelwilldeacon
authored andcommitted
iommu/arm-smmu-v3: Encapsulate ctx_desc_cfg init in alloc_cd_tables
This is slighlty cleaner: arm_smmu_ctx_desc_cfg is initialized in a single function instead of having pieces set ahead-of time by its caller. Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Michael Shavit <mshavit@google.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Link: https://lore.kernel.org/r/20230915211705.v8.3.I875254464d044a8ce8b3a2ad6beb655a4a006456@changeid Signed-off-by: Will Deacon <will@kernel.org>
1 parent 1f85888 commit e3aad74

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,14 +1132,16 @@ int arm_smmu_write_ctx_desc(struct arm_smmu_domain *smmu_domain, int ssid,
11321132
return 0;
11331133
}
11341134

1135-
static int arm_smmu_alloc_cd_tables(struct arm_smmu_domain *smmu_domain)
1135+
static int arm_smmu_alloc_cd_tables(struct arm_smmu_domain *smmu_domain,
1136+
struct arm_smmu_master *master)
11361137
{
11371138
int ret;
11381139
size_t l1size;
11391140
size_t max_contexts;
11401141
struct arm_smmu_device *smmu = smmu_domain->smmu;
11411142
struct arm_smmu_ctx_desc_cfg *cdcfg = &smmu_domain->cd_table;
11421143

1144+
cdcfg->s1cdmax = master->ssid_bits;
11431145
max_contexts = 1 << cdcfg->s1cdmax;
11441146

11451147
if (!(smmu->features & ARM_SMMU_FEAT_2_LVL_CDTAB) ||
@@ -2092,7 +2094,6 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain,
20922094
int ret;
20932095
u32 asid;
20942096
struct arm_smmu_device *smmu = smmu_domain->smmu;
2095-
struct arm_smmu_ctx_desc_cfg *cd_table = &smmu_domain->cd_table;
20962097
struct arm_smmu_ctx_desc *cd = &smmu_domain->cd;
20972098
typeof(&pgtbl_cfg->arm_lpae_s1_cfg.tcr) tcr = &pgtbl_cfg->arm_lpae_s1_cfg.tcr;
20982099

@@ -2105,11 +2106,9 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain,
21052106
if (ret)
21062107
goto out_unlock;
21072108

2108-
cd_table->s1cdmax = master->ssid_bits;
2109-
21102109
smmu_domain->stall_enabled = master->stall_enabled;
21112110

2112-
ret = arm_smmu_alloc_cd_tables(smmu_domain);
2111+
ret = arm_smmu_alloc_cd_tables(smmu_domain, master);
21132112
if (ret)
21142113
goto out_free_asid;
21152114

0 commit comments

Comments
 (0)