Commit 1228cc50 authored by Michael Shavit's avatar Michael Shavit Committed by Will Deacon

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: default avatarJason Gunthorpe <jgg@nvidia.com>
Reviewed-by: default avatarNicolin Chen <nicolinc@nvidia.com>
Signed-off-by: default avatarMichael Shavit <mshavit@google.com>
Tested-by: default avatarNicolin Chen <nicolinc@nvidia.com>
Link: https://lore.kernel.org/r/20230915211705.v8.4.I5aa89c849228794a64146cfe86df21fb71629384@changeidSigned-off-by: default avatarWill Deacon <will@kernel.org>
parent e3aad74c
...@@ -1114,7 +1114,7 @@ int arm_smmu_write_ctx_desc(struct arm_smmu_domain *smmu_domain, int ssid, ...@@ -1114,7 +1114,7 @@ int arm_smmu_write_ctx_desc(struct arm_smmu_domain *smmu_domain, int ssid,
FIELD_PREP(CTXDESC_CD_0_ASID, cd->asid) | FIELD_PREP(CTXDESC_CD_0_ASID, cd->asid) |
CTXDESC_CD_0_V; CTXDESC_CD_0_V;
if (smmu_domain->stall_enabled) if (smmu_domain->cd_table.stall_enabled)
val |= CTXDESC_CD_0_S; val |= CTXDESC_CD_0_S;
} }
...@@ -1141,6 +1141,7 @@ static int arm_smmu_alloc_cd_tables(struct arm_smmu_domain *smmu_domain, ...@@ -1141,6 +1141,7 @@ static int arm_smmu_alloc_cd_tables(struct arm_smmu_domain *smmu_domain,
struct arm_smmu_device *smmu = smmu_domain->smmu; struct arm_smmu_device *smmu = smmu_domain->smmu;
struct arm_smmu_ctx_desc_cfg *cdcfg = &smmu_domain->cd_table; struct arm_smmu_ctx_desc_cfg *cdcfg = &smmu_domain->cd_table;
cdcfg->stall_enabled = master->stall_enabled;
cdcfg->s1cdmax = master->ssid_bits; cdcfg->s1cdmax = master->ssid_bits;
max_contexts = 1 << cdcfg->s1cdmax; max_contexts = 1 << cdcfg->s1cdmax;
...@@ -2106,8 +2107,6 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain, ...@@ -2106,8 +2107,6 @@ static int arm_smmu_domain_finalise_s1(struct arm_smmu_domain *smmu_domain,
if (ret) if (ret)
goto out_unlock; goto out_unlock;
smmu_domain->stall_enabled = master->stall_enabled;
ret = arm_smmu_alloc_cd_tables(smmu_domain, master); ret = arm_smmu_alloc_cd_tables(smmu_domain, master);
if (ret) if (ret)
goto out_free_asid; goto out_free_asid;
...@@ -2448,7 +2447,8 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) ...@@ -2448,7 +2447,8 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
ret = -EINVAL; ret = -EINVAL;
goto out_unlock; goto out_unlock;
} else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 && } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 &&
smmu_domain->stall_enabled != master->stall_enabled) { smmu_domain->cd_table.stall_enabled !=
master->stall_enabled) {
ret = -EINVAL; ret = -EINVAL;
goto out_unlock; goto out_unlock;
} }
......
...@@ -598,6 +598,8 @@ struct arm_smmu_ctx_desc_cfg { ...@@ -598,6 +598,8 @@ struct arm_smmu_ctx_desc_cfg {
u8 s1fmt; u8 s1fmt;
/* log2 of the maximum number of CDs supported by this table */ /* log2 of the maximum number of CDs supported by this table */
u8 s1cdmax; u8 s1cdmax;
/* Whether CD entries in this table have the stall bit set. */
u8 stall_enabled:1;
}; };
struct arm_smmu_s2_cfg { struct arm_smmu_s2_cfg {
...@@ -715,7 +717,6 @@ struct arm_smmu_domain { ...@@ -715,7 +717,6 @@ struct arm_smmu_domain {
struct mutex init_mutex; /* Protects smmu pointer */ struct mutex init_mutex; /* Protects smmu pointer */
struct io_pgtable_ops *pgtbl_ops; struct io_pgtable_ops *pgtbl_ops;
bool stall_enabled;
atomic_t nr_ats_masters; atomic_t nr_ats_masters;
enum arm_smmu_domain_stage stage; enum arm_smmu_domain_stage stage;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment