Skip to content

Commit 1228cc5

Browse files
shavitmichaelwilldeacon
authored andcommitted
iommu/arm-smmu-v3: move stall_enabled to the cd table
A domain can be attached to multiple masters with different master->stall_enabled values. The stall bit of a CD entry should follow master->stall_enabled and has an inverse relationship with the STE.S1STALLD bit. The stall_enabled bit does not depend on any property of the domain, so move it out of the arm_smmu_domain struct. Move it to the CD table struct so that it can fully describe how CD entries should be written to it. 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.4.I5aa89c849228794a64146cfe86df21fb71629384@changeid Signed-off-by: Will Deacon <will@kernel.org>
1 parent e3aad74 commit 1228cc5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ int arm_smmu_write_ctx_desc(struct arm_smmu_domain *smmu_domain, int ssid,
11141114
FIELD_PREP(CTXDESC_CD_0_ASID, cd->asid) |
11151115
CTXDESC_CD_0_V;
11161116

1117-
if (smmu_domain->stall_enabled)
1117+
if (smmu_domain->cd_table.stall_enabled)
11181118
val |= CTXDESC_CD_0_S;
11191119
}
11201120

@@ -1141,6 +1141,7 @@ static int arm_smmu_alloc_cd_tables(struct arm_smmu_domain *smmu_domain,
11411141
struct arm_smmu_device *smmu = smmu_domain->smmu;
11421142
struct arm_smmu_ctx_desc_cfg *cdcfg = &smmu_domain->cd_table;
11431143

1144+
cdcfg->stall_enabled = master->stall_enabled;
11441145
cdcfg->s1cdmax = master->ssid_bits;
11451146
max_contexts = 1 << cdcfg->s1cdmax;
11461147

@@ -2106,8 +2107,6 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain,
21062107
if (ret)
21072108
goto out_unlock;
21082109

2109-
smmu_domain->stall_enabled = master->stall_enabled;
2110-
21112110
ret = arm_smmu_alloc_cd_tables(smmu_domain, master);
21122111
if (ret)
21132112
goto out_free_asid;
@@ -2448,7 +2447,8 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
24482447
ret = -EINVAL;
24492448
goto out_unlock;
24502449
} else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 &&
2451-
smmu_domain->stall_enabled != master->stall_enabled) {
2450+
smmu_domain->cd_table.stall_enabled !=
2451+
master->stall_enabled) {
24522452
ret = -EINVAL;
24532453
goto out_unlock;
24542454
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,8 @@ struct arm_smmu_ctx_desc_cfg {
598598
u8 s1fmt;
599599
/* log2 of the maximum number of CDs supported by this table */
600600
u8 s1cdmax;
601+
/* Whether CD entries in this table have the stall bit set. */
602+
u8 stall_enabled:1;
601603
};
602604

603605
struct arm_smmu_s2_cfg {
@@ -715,7 +717,6 @@ struct arm_smmu_domain {
715717
struct mutex init_mutex; /* Protects smmu pointer */
716718

717719
struct io_pgtable_ops *pgtbl_ops;
718-
bool stall_enabled;
719720
atomic_t nr_ats_masters;
720721

721722
enum arm_smmu_domain_stage stage;

0 commit comments

Comments
 (0)