Re: [PATCH v4 6/8] iommu/arm-smmu-v3: Move CD table to arm_smmu_master

From: Jason Gunthorpe
Date: Fri Aug 04 2023 - 18:46:32 EST


On Fri, Aug 04, 2023 at 03:25:43PM -0700, Nicolin Chen wrote:
> > @@ -2436,22 +2419,14 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
> > if (!smmu_domain->smmu) {
> > smmu_domain->smmu = smmu;
> > ret = arm_smmu_domain_finalise(domain, master);
> > - if (ret) {
> > + if (ret)
> > smmu_domain->smmu = NULL;
> > - goto out_unlock;
> > - }
> > - } else if (smmu_domain->smmu != smmu) {
> > + } else if (smmu_domain->smmu != smmu)
> > ret = -EINVAL;
> > - goto out_unlock;
> > - } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 &&
> > - master->ssid_bits != smmu_domain->cd_table.max_cds_bits) {
> > - ret = -EINVAL;
> > - goto out_unlock;
> > - } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 &&
> > - smmu_domain->cd_table.stall_enabled != master->stall_enabled) {
> > - ret = -EINVAL;
> > - goto out_unlock;
> > - }
>
> ... then we remove this stall_enabled sanity also.
>
> This means a shared domain (holding a shared CD) being inserted
> to two CD tables from two masters would have two different CDTE
> configurations at the stall bit.

I looked through the spec for a while and I thought this was fine..

Stall is basically a master specific behavior on how to operate page
faulting. It makes sense that it follows the master and the IOPTEs in
the domain can be used with both the faulting and non-faulting page
faulting path.

I would expect the page faulting path to figure out what to (if there
is anything special to do) do based on the master that triggered the
fault, not based on the domain that received it.

Jason